@openfin/remote-adapter 39.83.21 → 40.82.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 +1691 -1857
  2. package/package.json +2 -2
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var require$$0 = require('lodash/cloneDeep');
4
- var require$$3 = require('lodash/isEqual');
5
- var require$$0$1 = require('events');
3
+ var require$$3 = require('lodash');
4
+ var require$$0 = require('events');
6
5
  var bridge = require('./bridge-ef11968f.js');
7
6
  var crypto = require('crypto');
8
7
  var backchannel = require('./backchannel.js');
@@ -526,32 +525,9 @@ var utils$2 = {};
526
525
 
527
526
  var PrivateChannelClient$1 = {};
528
527
 
529
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
530
- if (k2 === undefined) k2 = k;
531
- var desc = Object.getOwnPropertyDescriptor(m, k);
532
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
533
- desc = { enumerable: true, get: function() { return m[k]; } };
534
- }
535
- Object.defineProperty(o, k2, desc);
536
- }) : (function(o, m, k, k2) {
537
- if (k2 === undefined) k2 = k;
538
- o[k2] = m[k];
539
- }));
540
- var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
541
- Object.defineProperty(o, "default", { enumerable: true, value: v });
542
- }) : function(o, v) {
543
- o["default"] = v;
544
- });
545
- var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
546
- if (mod && mod.__esModule) return mod;
547
- var result = {};
548
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
549
- __setModuleDefault(result, mod);
550
- return result;
551
- };
552
528
  Object.defineProperty(PrivateChannelClient$1, "__esModule", { value: true });
553
529
  PrivateChannelClient$1.PrivateChannelClient = void 0;
554
- const utils$1 = __importStar(utils$3);
530
+ const utils$1 = utils$3;
555
531
  class PrivateChannelClient {
556
532
  constructor(client, id) {
557
533
  this.id = id;
@@ -640,14 +616,11 @@ class PrivateChannelClient {
640
616
  PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
641
617
 
642
618
  (function (exports) {
643
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
644
- return (mod && mod.__esModule) ? mod : { "default": mod };
645
- };
646
619
  Object.defineProperty(exports, "__esModule", { value: true });
647
620
  exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
648
621
  const utils_1 = utils$3;
649
622
  const PrivateChannelClient_1 = PrivateChannelClient$1;
650
- const isEqual_1 = __importDefault(require$$3);
623
+ const lodash_1 = require$$3;
651
624
  const getUnsupportedChannelApis = (channelType) => {
652
625
  return {
653
626
  addContextListener: () => {
@@ -775,7 +748,7 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
775
748
  const wrappedHandler = (context, contextMetadata) => {
776
749
  if (first) {
777
750
  first = false;
778
- if ((0, isEqual_1.default)(currentContext, context)) {
751
+ if ((0, lodash_1.isEqual)(currentContext, context)) {
779
752
  return;
780
753
  }
781
754
  }
@@ -897,16 +870,13 @@ function requireFdc3Common () {
897
870
  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");
898
871
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
899
872
  };
900
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
901
- return (mod && mod.__esModule) ? mod : { "default": mod };
902
- };
903
873
  var _FDC3ModuleBase_producer;
904
874
  Object.defineProperty(fdc3Common, "__esModule", { value: true });
905
875
  fdc3Common.FDC3ModuleBase = void 0;
906
876
  const utils_1 = utils$2;
907
877
  const utils_2 = utils$3;
908
878
  const InteropClient_1 = requireInteropClient();
909
- const isEqual_1 = __importDefault(require$$3);
879
+ const lodash_1 = require$$3;
910
880
  class FDC3ModuleBase {
911
881
  get client() {
912
882
  return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
@@ -1095,7 +1065,7 @@ function requireFdc3Common () {
1095
1065
  const wrappedHandler = (context, contextMetadata) => {
1096
1066
  if (first) {
1097
1067
  first = false;
1098
- if ((0, isEqual_1.default)(currentContext, context)) {
1068
+ if ((0, lodash_1.isEqual)(currentContext, context)) {
1099
1069
  return;
1100
1070
  }
1101
1071
  }
@@ -1708,14 +1678,11 @@ function requireInteropClient () {
1708
1678
  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");
1709
1679
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1710
1680
  };
1711
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1712
- return (mod && mod.__esModule) ? mod : { "default": mod };
1713
- };
1714
1681
  var _InteropClient_clientPromise, _InteropClient_sessionContextGroups;
1715
1682
  Object.defineProperty(InteropClient, "__esModule", { value: true });
1716
1683
  InteropClient.InteropClient = void 0;
1717
1684
  const base_1 = base;
1718
- const SessionContextGroupClient_1 = __importDefault(SessionContextGroupClient$1);
1685
+ const SessionContextGroupClient_1 = SessionContextGroupClient$1;
1719
1686
  const fdc3_1_2_1 = requireFdc31_2();
1720
1687
  const fdc3_2_0_1 = requireFdc32_0();
1721
1688
  const utils_1 = utils$3;
@@ -2333,12 +2300,9 @@ var hasRequiredFactory$3;
2333
2300
  function requireFactory$3 () {
2334
2301
  if (hasRequiredFactory$3) return Factory$8;
2335
2302
  hasRequiredFactory$3 = 1;
2336
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2337
- return (mod && mod.__esModule) ? mod : { "default": mod };
2338
- };
2339
2303
  Object.defineProperty(Factory$8, "__esModule", { value: true });
2340
2304
  Factory$8.InteropModule = void 0;
2341
- const cloneDeep_1 = __importDefault(require$$0);
2305
+ const lodash_1 = require$$3;
2342
2306
  const inaccessibleObject_1 = inaccessibleObject;
2343
2307
  const base_1 = base;
2344
2308
  const InteropBroker_1 = requireInteropBroker();
@@ -2375,7 +2339,7 @@ function requireFactory$3 () {
2375
2339
  // Allows for manifest-level configuration, without having to override. (e.g. specifying custom context groups)
2376
2340
  const options = await this.wire.environment.getInteropInfo(this.wire.getFin());
2377
2341
  const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
2378
- const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, cloneDeep_1.default)(options));
2342
+ const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, lodash_1.cloneDeep)(options));
2379
2343
  const getProvider = () => {
2380
2344
  return this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
2381
2345
  };
@@ -2941,16 +2905,13 @@ function requireInteropBroker () {
2941
2905
  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");
2942
2906
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2943
2907
  };
2944
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2945
- return (mod && mod.__esModule) ? mod : { "default": mod };
2946
- };
2947
2908
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
2948
2909
  Object.defineProperty(InteropBroker, "__esModule", { value: true });
2949
2910
  InteropBroker.InteropBroker = void 0;
2950
2911
  const base_1 = base;
2951
- const SessionContextGroupBroker_1 = __importDefault(requireSessionContextGroupBroker());
2912
+ const SessionContextGroupBroker_1 = requireSessionContextGroupBroker();
2952
2913
  const utils_1 = utils$3;
2953
- const isEqual_1 = __importDefault(require$$3);
2914
+ const lodash_1 = require$$3;
2954
2915
  const PrivateChannelProvider_1 = requirePrivateChannelProvider();
2955
2916
  const lazy_1 = lazy;
2956
2917
  const defaultContextGroups = [
@@ -3148,7 +3109,7 @@ function requireInteropBroker () {
3148
3109
  constructor(...unused) {
3149
3110
  if (unused.length) {
3150
3111
  const [_ignore1, ignore2, opts] = unused;
3151
- if (opts && typeof opts === 'object' && !(0, isEqual_1.default)(opts, args[2])) {
3112
+ if (opts && typeof opts === 'object' && !(0, lodash_1.isEqual)(opts, args[2])) {
3152
3113
  // eslint-disable-next-line no-console
3153
3114
  console.warn('You have modified the parameters of the InteropOverride constructor. This behavior is deprecated and will be removed in a future version. You can modify these options in your manifest. Please consult our Interop docs for guidance on migrating to the new override scheme.');
3154
3115
  super(args[0], args[1], opts);
@@ -4273,10 +4234,6 @@ Object.defineProperty(baseEnv, "__esModule", { value: true });
4273
4234
  baseEnv.BaseEnvironment = void 0;
4274
4235
  const overrideCheck_1 = requireOverrideCheck();
4275
4236
  class BaseEnvironment {
4276
- async getViewWindowIdentity(fin, viewIdentity) {
4277
- const { identity } = await fin.View.wrapSync(viewIdentity).getCurrentWindow();
4278
- return identity;
4279
- }
4280
4237
  async getInteropInfo(fin) {
4281
4238
  const appInfo = await fin.Application.getCurrentSync()
4282
4239
  .getInfo()
@@ -4507,7 +4464,7 @@ var emitterMap = {};
4507
4464
 
4508
4465
  Object.defineProperty(emitterMap, "__esModule", { value: true });
4509
4466
  emitterMap.EmitterMap = void 0;
4510
- const events_1$6 = require$$0$1;
4467
+ const events_1$6 = require$$0;
4511
4468
  class EmitterMap {
4512
4469
  constructor() {
4513
4470
  this.storage = new Map();
@@ -4684,9 +4641,7 @@ function requireFactory$2 () {
4684
4641
  * @experimental
4685
4642
  */
4686
4643
  async wrap(identity) {
4687
- this.wire.sendAction('view-wrap').catch((e) => {
4688
- // we do not want to expose this error, just continue if this analytics-only call fails
4689
- });
4644
+ this.wire.sendAction('view-wrap');
4690
4645
  const errorMsg = (0, validate_1.validateIdentity)(identity);
4691
4646
  if (errorMsg) {
4692
4647
  throw new Error(errorMsg);
@@ -4767,937 +4722,1601 @@ function requireFactory$2 () {
4767
4722
 
4768
4723
  var Instance$7 = {};
4769
4724
 
4770
- var main = {};
4725
+ var layoutEntities = {};
4771
4726
 
4772
- Object.defineProperty(main, "__esModule", { value: true });
4773
- main.WebContents = void 0;
4774
- const base_1$i = base;
4775
- class WebContents extends base_1$i.EmitterBase {
4776
- /**
4777
- * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
4778
- * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
4779
- */
4780
- constructor(wire, identity, entityType) {
4781
- super(wire, entityType, identity.uuid, identity.name);
4782
- this.identity = identity;
4783
- this.entityType = entityType;
4727
+ var apiExposer$1 = {};
4728
+
4729
+ var apiConsumer = {};
4730
+
4731
+ Object.defineProperty(apiConsumer, "__esModule", { value: true });
4732
+ apiConsumer.ApiConsumer = void 0;
4733
+ /**
4734
+ * Consumer for apis exposed with {@see ApiExposer}.
4735
+ *
4736
+ * A strategy that matches the strategy used to expose a target API must be provided.
4737
+ */
4738
+ class ApiConsumer {
4739
+ // eslint-disable-next-line
4740
+ constructor(strategy) {
4741
+ this.strategy = strategy;
4742
+ /**
4743
+ * Consumes an api exposed using a given transport strategy, and generates a client
4744
+ * for easy, type safe consumption of that client.
4745
+ * @param options Strategy specific consumption options.
4746
+ * @returns An api client matching the given type.
4747
+ */
4748
+ this.consume = async (options) => {
4749
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
4750
+ return exposedProperties.reduce((client, prop) => ({
4751
+ ...client,
4752
+ [prop.key]: this.strategy.createFunction(prop, options)
4753
+ }), {});
4754
+ };
4784
4755
  }
4756
+ }
4757
+ apiConsumer.ApiConsumer = ApiConsumer;
4758
+
4759
+ var apiExposer = {};
4760
+
4761
+ var decorators = {};
4762
+
4763
+ Object.defineProperty(decorators, "__esModule", { value: true });
4764
+ decorators.expose = decorators.getExposedProperties = void 0;
4765
+ const exposedProperties = Symbol('exposedProperties');
4766
+ const getExposedProperties = (target) => {
4767
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
4768
+ };
4769
+ decorators.getExposedProperties = getExposedProperties;
4770
+ /**
4771
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
4772
+ * @param options Options specific to the strategy used in {@link ApiExposer}
4773
+ */
4774
+ // Returns any as decorator typing is weird.
4775
+ const expose = (options) => (target, key, descriptor) => {
4776
+ target[exposedProperties] = target[exposedProperties] || [];
4777
+ target[exposedProperties].push({ key, descriptor, options });
4778
+ };
4779
+ decorators.expose = expose;
4780
+
4781
+ Object.defineProperty(apiExposer, "__esModule", { value: true });
4782
+ apiExposer.ApiExposer = void 0;
4783
+ const decorators_1 = decorators;
4784
+ /**
4785
+ * Exposes api services on the transport of choice.
4786
+ */
4787
+ class ApiExposer {
4785
4788
  /**
4786
- * Gets a base64 encoded image of all or part of the WebContents.
4787
- * @param options Options for the capturePage call.
4788
- *
4789
- * @example
4790
- *
4791
- * View:
4792
- * ```js
4793
- * const view = fin.View.getCurrentSync();
4794
- *
4795
- * // PNG image of a full visible View
4796
- * console.log(await view.capturePage());
4797
- *
4798
- * // Low-quality JPEG image of a defined visible area of the view
4799
- * const options = {
4800
- * area: {
4801
- * height: 100,
4802
- * width: 100,
4803
- * x: 10,
4804
- * y: 10,
4805
- * },
4806
- * format: 'jpg',
4807
- * quality: 20
4808
- * }
4809
- * console.log(await view.capturePage(options));
4810
- * ```
4811
- *
4812
- * Window:
4813
- * ```js
4814
- * const wnd = await fin.Window.getCurrent();
4815
- *
4816
- * // PNG image of a full visible window
4817
- * console.log(await wnd.capturePage());
4818
- *
4819
- * // Low-quality JPEG image of a defined visible area of the window
4820
- * const options = {
4821
- * area: {
4822
- * height: 100,
4823
- * width: 100,
4824
- * x: 10,
4825
- * y: 10,
4826
- * },
4827
- * format: 'jpg',
4828
- * quality: 20
4829
- * }
4830
- * console.log(await wnd.capturePage(options));
4831
- * ```
4832
- *
4833
- * @remarks
4834
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
4835
- * We do not expose an explicit superclass for this functionality, but it does have its own
4836
- * {@link OpenFin.WebContentsEvents event namespace}.
4789
+ * @param strategy The expose strategy to use to expose instances.
4837
4790
  */
4838
- capturePage(options) {
4839
- return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
4791
+ // eslint-disable-next-line
4792
+ constructor(strategy) {
4793
+ this.strategy = strategy;
4794
+ /**
4795
+ * Exposes an instance of a given api on
4796
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
4797
+ * @param instanceOptions Transport strategy specific options to use when exposing.
4798
+ */
4799
+ this.exposeInstance = async (instance, instanceOptions) => {
4800
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
4801
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
4802
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
4803
+ key,
4804
+ options,
4805
+ meta: instanceOptions
4806
+ });
4807
+ return {
4808
+ key,
4809
+ options: customConsumptionOptions
4810
+ };
4811
+ }));
4812
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
4813
+ };
4840
4814
  }
4841
- /**
4842
- * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
4843
- * applications you have created.
4844
- * @param code JavaScript code to be executed on the view.
4845
- *
4846
- * @example
4847
- * View:
4848
- * ```js
4849
- * async function executeJavaScript(code) {
4850
- * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
4851
- * return await view.executeJavaScript(code);
4852
- * }
4853
- *
4854
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
4855
- * ```
4856
- *
4857
- * Window:
4858
- * ```js
4859
- * async function executeJavaScript(code) {
4860
- * const app = await fin.Application.start({
4861
- * name: 'myApp',
4862
- * uuid: 'app-1',
4863
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
4864
- * autoShow: true
4865
- * });
4866
- * const win = await app.getWindow();
4867
- * return await win.executeJavaScript(code);
4868
- * }
4869
- *
4870
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
4871
- * ```
4872
- * @remarks
4873
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
4874
- * We do not expose an explicit superclass for this functionality, but it does have its own
4875
- * {@link OpenFin.WebContentsEvents event namespace}.
4876
- */
4877
- executeJavaScript(code) {
4878
- return this.wire
4879
- .sendAction('execute-javascript-in-window', { ...this.identity, code })
4880
- .then(({ payload }) => payload.data);
4815
+ ;
4816
+ }
4817
+ apiExposer.ApiExposer = ApiExposer;
4818
+
4819
+ var strategies = {};
4820
+
4821
+ var openfinChannels = {};
4822
+
4823
+ var channelsConsumer = {};
4824
+
4825
+ Object.defineProperty(channelsConsumer, "__esModule", { value: true });
4826
+ channelsConsumer.ChannelsConsumer = void 0;
4827
+ class ChannelsConsumer {
4828
+ // eslint-disable-next-line
4829
+ constructor(channel) {
4830
+ this.channel = channel;
4831
+ this.getExposedFunctions = async (options) => {
4832
+ const { id } = options;
4833
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
4834
+ return props;
4835
+ };
4836
+ this.createFunction = (prop) => (...args) => {
4837
+ const { action } = prop.options;
4838
+ return this.channel.dispatch(action, { args });
4839
+ };
4881
4840
  }
4882
- /**
4883
- * Returns the zoom level of the WebContents.
4884
- *
4885
- * @example
4886
- * View:
4887
- * ```js
4888
- * async function getZoomLevel() {
4889
- * const view = await fin.View.getCurrent();
4890
- * return await view.getZoomLevel();
4891
- * }
4892
- *
4893
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
4894
- * ```
4895
- *
4896
- * Window:
4897
- * ```js
4898
- * async function createWin() {
4899
- * const app = await fin.Application.start({
4900
- * name: 'myApp',
4901
- * uuid: 'app-1',
4902
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
4903
- * autoShow: true
4904
- * });
4905
- * return await app.getWindow();
4906
- * }
4907
- *
4908
- * async function getZoomLevel() {
4909
- * const win = await createWin();
4910
- * return await win.getZoomLevel();
4911
- * }
4912
- *
4913
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
4914
- * ```
4915
- * @remarks
4916
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
4917
- * We do not expose an explicit superclass for this functionality, but it does have its own
4918
- * {@link OpenFin.WebContentsEvents event namespace}.
4919
- */
4920
- getZoomLevel() {
4921
- return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
4841
+ ;
4842
+ }
4843
+ channelsConsumer.ChannelsConsumer = ChannelsConsumer;
4844
+
4845
+ var channelsExposer = {};
4846
+
4847
+ Object.defineProperty(channelsExposer, "__esModule", { value: true });
4848
+ channelsExposer.ChannelsExposer = void 0;
4849
+ class ChannelsExposer {
4850
+ // eslint-disable-next-line
4851
+ constructor(channelProviderOrClient) {
4852
+ this.channelProviderOrClient = channelProviderOrClient;
4853
+ this.exposeFunction = async (target, config) => {
4854
+ const { key, options, meta } = config;
4855
+ const { id } = meta;
4856
+ const action = `${id}.${options?.action || key}`;
4857
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
4858
+ return target(...args);
4859
+ });
4860
+ return { action };
4861
+ };
4862
+ this.exposeMeta = async ({ id }, props) => {
4863
+ const action = `api-meta:${id}`;
4864
+ await this.channelProviderOrClient.register(action, () => ({ props }));
4865
+ };
4922
4866
  }
4923
- /**
4924
- * Sets the zoom level of the WebContents.
4925
- * @param level The zoom level
4926
- *
4927
- * @example
4928
- * View:
4929
- * ```js
4930
- * async function setZoomLevel(number) {
4931
- * const view = await fin.View.getCurrent();
4932
- * return await view.setZoomLevel(number);
4933
- * }
4934
- *
4935
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
4936
- * ```
4937
- *
4938
- * Window:
4939
- * ```js
4940
- * async function createWin() {
4941
- * const app = await fin.Application.start({
4942
- * name: 'myApp',
4943
- * uuid: 'app-1',
4944
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
4945
- * autoShow: true
4946
- * });
4947
- * return await app.getWindow();
4948
- * }
4949
- *
4950
- * async function setZoomLevel(number) {
4951
- * const win = await createWin();
4952
- * return await win.setZoomLevel(number);
4953
- * }
4954
- *
4955
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
4956
- * ```
4957
- * @remarks
4958
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
4959
- * We do not expose an explicit superclass for this functionality, but it does have its own
4960
- * {@link OpenFin.WebContentsEvents event namespace}.
4961
- */
4962
- setZoomLevel(level) {
4963
- return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
4867
+ }
4868
+ channelsExposer.ChannelsExposer = ChannelsExposer;
4869
+
4870
+ (function (exports) {
4871
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4872
+ if (k2 === undefined) k2 = k;
4873
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4874
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4875
+ desc = { enumerable: true, get: function() { return m[k]; } };
4876
+ }
4877
+ Object.defineProperty(o, k2, desc);
4878
+ }) : (function(o, m, k, k2) {
4879
+ if (k2 === undefined) k2 = k;
4880
+ o[k2] = m[k];
4881
+ }));
4882
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
4883
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4884
+ };
4885
+ Object.defineProperty(exports, "__esModule", { value: true });
4886
+ __exportStar(channelsConsumer, exports);
4887
+ __exportStar(channelsExposer, exports);
4888
+ } (openfinChannels));
4889
+
4890
+ (function (exports) {
4891
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4892
+ if (k2 === undefined) k2 = k;
4893
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4894
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4895
+ desc = { enumerable: true, get: function() { return m[k]; } };
4896
+ }
4897
+ Object.defineProperty(o, k2, desc);
4898
+ }) : (function(o, m, k, k2) {
4899
+ if (k2 === undefined) k2 = k;
4900
+ o[k2] = m[k];
4901
+ }));
4902
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
4903
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4904
+ };
4905
+ Object.defineProperty(exports, "__esModule", { value: true });
4906
+ __exportStar(openfinChannels, exports);
4907
+ } (strategies));
4908
+
4909
+ (function (exports) {
4910
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4911
+ if (k2 === undefined) k2 = k;
4912
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4913
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4914
+ desc = { enumerable: true, get: function() { return m[k]; } };
4915
+ }
4916
+ Object.defineProperty(o, k2, desc);
4917
+ }) : (function(o, m, k, k2) {
4918
+ if (k2 === undefined) k2 = k;
4919
+ o[k2] = m[k];
4920
+ }));
4921
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
4922
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4923
+ };
4924
+ Object.defineProperty(exports, "__esModule", { value: true });
4925
+ __exportStar(apiConsumer, exports);
4926
+ __exportStar(apiExposer, exports);
4927
+ __exportStar(strategies, exports);
4928
+ __exportStar(decorators, exports);
4929
+ } (apiExposer$1));
4930
+
4931
+ var channelApiRelay = {};
4932
+
4933
+ Object.defineProperty(channelApiRelay, "__esModule", { value: true });
4934
+ channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
4935
+ const EXPECTED_ERRORS = [
4936
+ 'no longer connected',
4937
+ 'RTCDataChannel closed unexpectedly',
4938
+ 'The client you are trying to dispatch from is disconnected from the target provider',
4939
+ ];
4940
+ // Checks possible error messages that we want to trap, client error message can originate
4941
+ // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
4942
+ const isDisconnectedError = (errorMsg) => {
4943
+ return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
4944
+ };
4945
+ /**
4946
+ * @internal
4947
+ * Create a channel relay for a given channel exposition, allowing a single provider to route
4948
+ * actions to the designated clients.
4949
+ *
4950
+ * Designed to be used in conjunction with @expose
4951
+ *
4952
+ * @param channelProvider The channel provider to relay the actions on.
4953
+ * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
4954
+ */
4955
+ const relayChannelClientApi = async (channelProvider, relayId) => {
4956
+ channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
4957
+ return channelProvider.dispatch(target, action, payload);
4958
+ });
4959
+ await Promise.resolve();
4960
+ };
4961
+ channelApiRelay.relayChannelClientApi = relayChannelClientApi;
4962
+ const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
4963
+ try {
4964
+ return await client.dispatch(`relay:${relayId}`, {
4965
+ action,
4966
+ payload,
4967
+ target
4968
+ });
4964
4969
  }
4965
- /**
4966
- * Navigates the WebContents to a specified URL.
4967
- *
4968
- * Note: The url must contain the protocol prefix such as http:// or https://.
4969
- * @param url - The URL to navigate the WebContents to.
4970
- *
4971
- * @example
4972
- * View:
4973
- * ```js
4974
- * async function createView() {
4975
- * const me = await fin.Window.getCurrent();
4976
- * return fin.View.create({
4977
- * name: 'viewName',
4978
- * target: me.identity,
4979
- * bounds: {top: 10, left: 10, width: 200, height: 200}
4980
- * });
4981
- * }
4982
- *
4983
- * createView()
4984
- * .then(view => view.navigate('https://example.com'))
4985
- * .then(() => console.log('navigation complete'))
4986
- * .catch(err => console.log(err));
4987
- * ```
4988
- *
4989
- * Window:
4990
- * ```js
4991
- * async function navigate() {
4992
- * const win = await fin.Window.getCurrent();
4993
- * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
4994
- * }
4995
- * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
4996
- * ```
4997
- * @experimental
4998
- * @remarks
4999
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5000
- * We do not expose an explicit superclass for this functionality, but it does have its own
5001
- * {@link OpenFin.WebContentsEvents event namespace}.
5002
- */
5003
- navigate(url) {
5004
- return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
4970
+ catch (e) {
4971
+ if (isDisconnectedError(e.message) && relayErrorMsg) {
4972
+ throw new Error(relayErrorMsg);
4973
+ }
4974
+ throw e;
5005
4975
  }
4976
+ };
4977
+ channelApiRelay.createRelayedDispatch = createRelayedDispatch;
4978
+
4979
+ var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4980
+ if (kind === "m") throw new TypeError("Private method is not writable");
4981
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4982
+ 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");
4983
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4984
+ };
4985
+ var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
4986
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4987
+ 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");
4988
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4989
+ };
4990
+ var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
4991
+ Object.defineProperty(layoutEntities, "__esModule", { value: true });
4992
+ layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
4993
+ const api_exposer_1 = apiExposer$1;
4994
+ const channel_api_relay_1 = channelApiRelay;
4995
+ /*
4996
+ This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
4997
+ intertwined, and share members via parent abstract class LayoutNode. To prevent circular
4998
+ refs, we define and export all the classes here.
4999
+ */
5000
+ /**
5001
+ * @ignore
5002
+ * @internal
5003
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
5004
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
5005
+ */
5006
+ class LayoutNode {
5006
5007
  /**
5007
- * Navigates the WebContents back one page.
5008
- *
5009
- * @example
5010
- * View:
5011
- * ```js
5012
- * async function navigateBack() {
5013
- * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
5014
- * await view.navigate('https://www.google.com');
5015
- * return await view.navigateBack();
5016
- * }
5017
- * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
5018
- * ```
5019
- *
5020
- * Window:
5021
- * ```js
5022
- * async function navigateBack() {
5023
- * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
5024
- * await win.navigate('https://www.google.com');
5025
- * return await win.navigateBack();
5026
- * }
5027
- * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
5028
- * ```
5029
- * @remarks
5030
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5031
- * We do not expose an explicit superclass for this functionality, but it does have its own
5032
- * {@link OpenFin.WebContentsEvents event namespace}.
5008
+ * @internal
5009
+ * @ignore
5033
5010
  */
5034
- navigateBack() {
5035
- return this.wire.sendAction('navigate-window-back', { ...this.identity }).then(() => undefined);
5011
+ constructor(client, entityId) {
5012
+ /**
5013
+ * @ignore
5014
+ * @internal
5015
+ * ApiClient for {@link LayoutEntitiesController}
5016
+ */
5017
+ _LayoutNode_client.set(this, void 0);
5018
+ /**
5019
+ * Checks if the TabStack or ColumnOrRow is the root content item
5020
+ *
5021
+ * @example
5022
+ * ```js
5023
+ * if (!fin.me.isView) {
5024
+ * throw new Error('Not running in a platform View.');
5025
+ * }
5026
+ *
5027
+ * const stack = await fin.me.getCurrentStack();
5028
+ * const isRoot = await stack.isRoot();
5029
+ * // The TabStack is root: false
5030
+ * console.log(`The TabStack is root: ${isRoot}`);
5031
+ *
5032
+ * // Retrieves the parent ColumnOrRow
5033
+ * const parent = await stack.getParent();
5034
+ * const parentIsRoot = await parent.isRoot();
5035
+ * // The parent ColumnOrRow is root: true
5036
+ * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
5037
+ * ```
5038
+ */
5039
+ this.isRoot = () => __classPrivateFieldGet$c(this, _LayoutNode_client, "f").isRoot(this.entityId);
5040
+ /**
5041
+ * Checks if the TabStack or ColumnOrRow exists
5042
+ *
5043
+ * @example
5044
+ * ```js
5045
+ * if (!fin.me.isView) {
5046
+ * throw new Error('Not running in a platform View.');
5047
+ * }
5048
+ *
5049
+ * const stack = await fin.me.getCurrentStack();
5050
+ * // Retrieves the parent ColumnOrRow
5051
+ * const columnOrRow = await stack.getParent();
5052
+ * let exists = await stack.exists();
5053
+ * // or
5054
+ * let exists = await columnOrRow.exists();
5055
+ * // The entity exists: true
5056
+ * console.log(`The entity exists: ${exists}`);
5057
+ * ```
5058
+ */
5059
+ this.exists = () => __classPrivateFieldGet$c(this, _LayoutNode_client, "f").exists(this.entityId);
5060
+ /**
5061
+ * Retrieves the parent of the TabStack or ColumnOrRow
5062
+ *
5063
+ * @example
5064
+ * ```js
5065
+ * if (!fin.me.isView) {
5066
+ * throw new Error('Not running in a platform View.');
5067
+ * }
5068
+ *
5069
+ * const stack = await fin.me.getCurrentStack();
5070
+ * // Retrieves the parent ColumnOrRow
5071
+ * const columnOrRow = await stack.getParent();
5072
+ *
5073
+ * // undefined if entity is the root item
5074
+ * let parent = await columnOrRow.getParent();
5075
+ * // or
5076
+ * let parent = await stack.getParent();
5077
+ * ```
5078
+ */
5079
+ this.getParent = async () => {
5080
+ const parent = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").getParent(this.entityId);
5081
+ if (!parent) {
5082
+ return undefined;
5083
+ }
5084
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet$c(this, _LayoutNode_client, "f"));
5085
+ };
5086
+ /**
5087
+ * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
5088
+ *
5089
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
5090
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
5091
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
5092
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
5093
+ *
5094
+ * @param views The views that will populate the new TabStack.
5095
+ * @param options Additional options that control new TabStack creation.
5096
+ * @returns The newly-created TabStack.
5097
+ *
5098
+ * @example
5099
+ * ```js
5100
+ * if (!fin.me.isView) {
5101
+ * throw new Error('Not running in a platform View.');
5102
+ * }
5103
+ *
5104
+ * const stack = await fin.me.getCurrentStack();
5105
+ * const columnOrRow = await stack.getParent();
5106
+ *
5107
+ * // Create view references by supplying a 'name' and 'url'
5108
+ * const views = [
5109
+ * // if 'name' is undefined, one will be generated
5110
+ * // if 'url' is undefined, it will default the view URL to 'about:blank'
5111
+ * { name: 'google-view', url: 'http://google.com/'},
5112
+ * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
5113
+ * ];
5114
+ *
5115
+ * // Create a view beforehand to be included in the new tab stack
5116
+ * const outsideView = await fin.View.create({
5117
+ * name: 'outside-bloomberg-view',
5118
+ * url: 'https://bloomberg.com/',
5119
+ * target: fin.me.identity,
5120
+ * });
5121
+ *
5122
+ * // Views to add can be identities, or the reference views mentioned above
5123
+ * const viewsToAdd = [outsideView.identity, ...views];
5124
+ *
5125
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
5126
+ * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
5127
+ * // Or
5128
+ * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
5129
+ * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
5130
+ *
5131
+ * ```
5132
+ * @experimental
5133
+ */
5134
+ this.createAdjacentStack = async (views, options) => {
5135
+ const entityId = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
5136
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$c(this, _LayoutNode_client, "f"));
5137
+ };
5138
+ /**
5139
+ * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
5140
+ *
5141
+ * @param edge Edge whose adjacent TabStacks will be returned.
5142
+ *
5143
+ * @example
5144
+ * ```js
5145
+ * if (!fin.me.isView) {
5146
+ * throw new Error('Not running in a platform View.');
5147
+ * }
5148
+ *
5149
+ * const stack = await fin.me.getCurrentStack();
5150
+ * const columnOrRow = await stack.getParent();
5151
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
5152
+ * let rightStacks = await columnOrRow.getAdjacentStacks('right');
5153
+ * let leftStacks = await columnOrRow.getAdjacentStacks('left');
5154
+ * // or
5155
+ * let rightStacks = await stack.getAdjacentStacks('right');
5156
+ * let leftStacks = await stack.getAdjacentStacks('left');
5157
+ *
5158
+ * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
5159
+ *
5160
+ * ```
5161
+ * @experimental
5162
+ */
5163
+ this.getAdjacentStacks = async (edge) => {
5164
+ const adjacentStacks = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").getAdjacentStacks({
5165
+ targetId: this.entityId,
5166
+ edge
5167
+ });
5168
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
5169
+ type: 'stack',
5170
+ entityId: stack.entityId
5171
+ }, __classPrivateFieldGet$c(this, _LayoutNode_client, "f")));
5172
+ };
5173
+ __classPrivateFieldSet$a(this, _LayoutNode_client, client, "f");
5174
+ this.entityId = entityId;
5036
5175
  }
5037
- /**
5038
- * Navigates the WebContents forward one page.
5039
- *
5040
- * @example
5041
- * View:
5042
- * ```js
5043
- * async function navigateForward() {
5044
- * const view = await fin.View.getCurrent();
5045
- * await view.navigate('https://www.google.com');
5046
- * await view.navigateBack();
5047
- * return await view.navigateForward();
5048
- * }
5049
- * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
5050
- * ```
5051
- *
5052
- * Window:
5053
- * ```js
5054
- * async function navigateForward() {
5055
- * const win = await fin.Window.getCurrent();
5056
- * await win.navigate('https://www.google.com');
5057
- * await win.navigateBack();
5058
- * return await win.navigateForward();
5059
- * }
5060
- * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
5061
- * ```
5062
- * @remarks
5063
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5064
- * We do not expose an explicit superclass for this functionality, but it does have its own
5065
- * {@link OpenFin.WebContentsEvents event namespace}.
5066
- */
5067
- async navigateForward() {
5068
- await this.wire.sendAction('navigate-window-forward', { ...this.identity });
5176
+ }
5177
+ layoutEntities.LayoutNode = LayoutNode;
5178
+ _LayoutNode_client = new WeakMap();
5179
+ /**
5180
+ * @ignore
5181
+ * @internal
5182
+ * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
5183
+ * @param client
5184
+ * @param controllerId
5185
+ * @param identity
5186
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
5187
+ */
5188
+ LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
5189
+ 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.');
5190
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
5191
+ return consumer.consume({ id: controllerId });
5192
+ };
5193
+ LayoutNode.getEntity = (definition, client) => {
5194
+ const { entityId, type } = definition;
5195
+ switch (type) {
5196
+ case 'column':
5197
+ case 'row':
5198
+ return new ColumnOrRow(client, entityId, type);
5199
+ case 'stack':
5200
+ return new TabStack(client, entityId);
5201
+ default:
5202
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
5069
5203
  }
5070
- /**
5071
- * Stops any current navigation the WebContents is performing.
5072
- *
5073
- * @example
5074
- * View:
5075
- * ```js
5076
- * async function stopNavigation() {
5077
- * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
5078
- * await view.navigate('https://www.google.com');
5079
- * return await view.stopNavigation();
5080
- * }
5081
- * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
5082
- * ```
5083
- *
5084
- * Window:
5204
+ };
5205
+ /**
5206
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
5207
+ */
5208
+ class TabStack extends LayoutNode {
5209
+ /** @internal */
5210
+ constructor(client, entityId) {
5211
+ super(client, entityId);
5212
+ /**
5213
+ * @internal
5214
+ * ApiClient for {@link LayoutEntitiesController}
5215
+ */
5216
+ _TabStack_client.set(this, void 0);
5217
+ /**
5218
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
5219
+ */
5220
+ this.type = 'stack';
5221
+ /**
5222
+ * Retrieves a list of all views belonging to this {@link TabStack}.
5223
+ *
5224
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
5225
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
5226
+ * If that happens and then getViews() is called, it will return the identities in a different order than
5227
+ * than the currently rendered tab order.
5228
+ *
5229
+ *
5230
+ * @throws If the {@link TabStack} has been destroyed.
5231
+ * @example
5232
+ * ```js
5233
+ * if (!fin.me.isView) {
5234
+ * throw new Error('Not running in a platform View.');
5235
+ * }
5236
+ *
5237
+ * const stack = await fin.me.getCurrentStack();
5238
+ * // Alternatively, you can wrap any view and get the stack from there
5239
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
5240
+ * // const stack = await viewFromSomewhere.getCurrentStack();
5241
+ * const views = await stack.getViews();
5242
+ * console.log(`Stack contains ${views.length} view(s)`);
5243
+ * ```
5244
+ * @experimental
5245
+ */
5246
+ this.getViews = () => __classPrivateFieldGet$c(this, _TabStack_client, "f").getStackViews(this.entityId);
5247
+ /**
5248
+ * Adds or creates a view in this {@link TabStack}.
5249
+ *
5250
+ * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
5251
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
5252
+ *
5253
+ * @param view The identity of an existing view to add, or options to create a view.
5254
+ * @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)
5255
+ * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
5256
+ * @throws If the view does not exist or fails to create.
5257
+ * @throws If the {@link TabStack} has been destroyed.
5258
+ * @example
5259
+ * ```js
5260
+ * if (!fin.me.isView) {
5261
+ * throw new Error('Not running in a platform View.');
5262
+ * }
5263
+ *
5264
+ * const stack = await fin.me.getCurrentStack();
5265
+ * // Alternatively, you can wrap any view and get the stack from there
5266
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
5267
+ * // const stack = await viewFromSomewhere.getCurrentStack();
5268
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
5269
+ * console.log('Identity of the google view just added', { googleViewIdentity });
5270
+ * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
5271
+ * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
5272
+ * console.log('Identity of the apple view just added', { appleViewIdentity });
5273
+ * ```
5274
+ * @experimental
5275
+ */
5276
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$c(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
5277
+ /**
5278
+ * Removes a view from this {@link TabStack}.
5279
+ *
5280
+ * @remarks Throws an exception if the view identity does not exist or was already destroyed.
5281
+ *
5282
+ * @param view - Identity of the view to remove.
5283
+ * @throws If the view does not exist or does not belong to the stack.
5284
+ * @throws If the {@link TabStack} has been destroyed.
5285
+ *
5286
+ * @example
5287
+ * ```js
5288
+ * if (!fin.me.isView) {
5289
+ * throw new Error('Not running in a platform View.');
5290
+ * }
5291
+ *
5292
+ * const stack = await fin.me.getCurrentStack();
5293
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
5294
+ *
5295
+ * await stack.removeView(googleViewIdentity);
5296
+ *
5297
+ * try {
5298
+ * await stack.removeView(googleViewIdentity);
5299
+ * } catch (error) {
5300
+ * // Tried to remove a view ('google-view') which does not belong to the stack.
5301
+ * console.log(error);
5302
+ * }
5303
+ * ```
5304
+ */
5305
+ this.removeView = async (view) => {
5306
+ await __classPrivateFieldGet$c(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
5307
+ };
5308
+ /**
5309
+ * Sets the active view of the {@link TabStack} without focusing it.
5310
+ * @param view - Identity of the view to activate.
5311
+ * @returns Promise which resolves with void once the view has been activated.
5312
+ * @throws If the {@link TabStack} has been destroyed.
5313
+ * @throws If the view does not exist.
5314
+ * @example
5315
+ * Change the active tab of a known View's TabStack:
5316
+ * ```js
5317
+ * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
5318
+ * const stack = await targetView.getCurrentStack();
5319
+ * await stack.setActiveView(targetView.identity);
5320
+ * ```
5321
+ *
5322
+ * Set the current View as active within its TabStack:
5323
+ * ```js
5324
+ * const stack = await fin.me.getCurrentStack();
5325
+ * await stack.setActiveView(fin.me.identity);
5326
+ * ```
5327
+ * @experimental
5328
+ */
5329
+ this.setActiveView = async (view) => {
5330
+ await __classPrivateFieldGet$c(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
5331
+ };
5332
+ __classPrivateFieldSet$a(this, _TabStack_client, client, "f");
5333
+ }
5334
+ }
5335
+ layoutEntities.TabStack = TabStack;
5336
+ _TabStack_client = new WeakMap();
5337
+ /**
5338
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
5339
+ */
5340
+ class ColumnOrRow extends LayoutNode {
5341
+ /**
5342
+ * @internal
5343
+ */
5344
+ constructor(client, entityId, type) {
5345
+ super(client, entityId);
5346
+ /**
5347
+ * @ignore
5348
+ * @internal
5349
+ * ApiClient for {@link LayoutEntitiesController}
5350
+ */
5351
+ _ColumnOrRow_client.set(this, void 0);
5352
+ /**
5353
+ * Retrieves the content array of the ColumnOrRow
5354
+ *
5355
+ * @example
5356
+ * ```js
5357
+ * if (!fin.me.isView) {
5358
+ * throw new Error('Not running in a platform View.');
5359
+ * }
5360
+ *
5361
+ * const stack = await fin.me.getCurrentStack();
5362
+ * // Retrieves the parent ColumnOrRow
5363
+ * const columnOrRow = await stack.getParent();
5364
+ *
5365
+ * // returns [TabStack]
5366
+ * const contentArray = await columnOrRow.getContent();
5367
+ * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
5368
+ * ```
5369
+ */
5370
+ this.getContent = async () => {
5371
+ const contentItemEntities = await __classPrivateFieldGet$c(this, _ColumnOrRow_client, "f").getContent(this.entityId);
5372
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$c(this, _ColumnOrRow_client, "f")));
5373
+ };
5374
+ __classPrivateFieldSet$a(this, _ColumnOrRow_client, client, "f");
5375
+ this.type = type;
5376
+ }
5377
+ }
5378
+ layoutEntities.ColumnOrRow = ColumnOrRow;
5379
+ _ColumnOrRow_client = new WeakMap();
5380
+
5381
+ var layout_constants = {};
5382
+
5383
+ Object.defineProperty(layout_constants, "__esModule", { value: true });
5384
+ layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
5385
+ layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
5386
+ // TODO: eventually export this somehow
5387
+ layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
5388
+
5389
+ var main = {};
5390
+
5391
+ Object.defineProperty(main, "__esModule", { value: true });
5392
+ main.WebContents = void 0;
5393
+ const base_1$i = base;
5394
+ class WebContents extends base_1$i.EmitterBase {
5395
+ /**
5396
+ * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
5397
+ * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
5398
+ */
5399
+ constructor(wire, identity, entityType) {
5400
+ super(wire, entityType, identity.uuid, identity.name);
5401
+ this.identity = identity;
5402
+ this.entityType = entityType;
5403
+ }
5404
+ /**
5405
+ * Gets a base64 encoded image of all or part of the WebContents.
5406
+ * @param options Options for the capturePage call.
5407
+ *
5408
+ * @example
5409
+ *
5410
+ * View:
5085
5411
  * ```js
5086
- * async function stopNavigation() {
5087
- * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
5088
- * await win.navigate('https://www.google.com');
5089
- * return await win.stopNavigation();
5412
+ * const view = fin.View.getCurrentSync();
5413
+ *
5414
+ * // PNG image of a full visible View
5415
+ * console.log(await view.capturePage());
5416
+ *
5417
+ * // Low-quality JPEG image of a defined visible area of the view
5418
+ * const options = {
5419
+ * area: {
5420
+ * height: 100,
5421
+ * width: 100,
5422
+ * x: 10,
5423
+ * y: 10,
5424
+ * },
5425
+ * format: 'jpg',
5426
+ * quality: 20
5090
5427
  * }
5091
- * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
5428
+ * console.log(await view.capturePage(options));
5429
+ * ```
5430
+ *
5431
+ * Window:
5432
+ * ```js
5433
+ * const wnd = await fin.Window.getCurrent();
5434
+ *
5435
+ * // PNG image of a full visible window
5436
+ * console.log(await wnd.capturePage());
5437
+ *
5438
+ * // Low-quality JPEG image of a defined visible area of the window
5439
+ * const options = {
5440
+ * area: {
5441
+ * height: 100,
5442
+ * width: 100,
5443
+ * x: 10,
5444
+ * y: 10,
5445
+ * },
5446
+ * format: 'jpg',
5447
+ * quality: 20
5448
+ * }
5449
+ * console.log(await wnd.capturePage(options));
5092
5450
  * ```
5451
+ *
5093
5452
  * @remarks
5094
5453
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5095
5454
  * We do not expose an explicit superclass for this functionality, but it does have its own
5096
5455
  * {@link OpenFin.WebContentsEvents event namespace}.
5097
5456
  */
5098
- stopNavigation() {
5099
- return this.wire.sendAction('stop-window-navigation', { ...this.identity }).then(() => undefined);
5457
+ capturePage(options) {
5458
+ return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
5100
5459
  }
5101
5460
  /**
5102
- * Reloads the WebContents
5461
+ * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
5462
+ * applications you have created.
5463
+ * @param code JavaScript code to be executed on the view.
5103
5464
  *
5104
5465
  * @example
5105
5466
  * View:
5106
5467
  * ```js
5107
- * async function reload() {
5108
- * const view = await fin.View.getCurrent();
5109
- * return await view.reload();
5468
+ * async function executeJavaScript(code) {
5469
+ * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
5470
+ * return await view.executeJavaScript(code);
5110
5471
  * }
5111
5472
  *
5112
- * reload().then(() => {
5113
- * console.log('Reloaded view')
5114
- * }).catch(err => console.log(err));
5473
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
5115
5474
  * ```
5116
5475
  *
5117
5476
  * Window:
5118
5477
  * ```js
5119
- * async function reloadWindow() {
5120
- * const app = await fin.Application.start({
5121
- * name: 'myApp',
5122
- * uuid: 'app-1',
5123
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.reload.html',
5124
- * autoShow: true
5125
- * });
5126
- * const win = await app.getWindow();
5127
- * return await win.reload();
5478
+ * async function executeJavaScript(code) {
5479
+ * const app = await fin.Application.start({
5480
+ * name: 'myApp',
5481
+ * uuid: 'app-1',
5482
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
5483
+ * autoShow: true
5484
+ * });
5485
+ * const win = await app.getWindow();
5486
+ * return await win.executeJavaScript(code);
5128
5487
  * }
5129
5488
  *
5130
- * reloadWindow().then(() => {
5131
- * console.log('Reloaded window')
5132
- * }).catch(err => console.log(err));
5489
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
5133
5490
  * ```
5134
5491
  * @remarks
5135
5492
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5136
5493
  * We do not expose an explicit superclass for this functionality, but it does have its own
5137
5494
  * {@link OpenFin.WebContentsEvents event namespace}.
5138
5495
  */
5139
- reload(ignoreCache = false) {
5496
+ executeJavaScript(code) {
5140
5497
  return this.wire
5141
- .sendAction('reload-window', {
5142
- ignoreCache,
5143
- ...this.identity
5144
- })
5145
- .then(() => undefined);
5498
+ .sendAction('execute-javascript-in-window', { ...this.identity, code })
5499
+ .then(({ payload }) => payload.data);
5146
5500
  }
5147
5501
  /**
5148
- * Prints the WebContents.
5149
- * @param options Printer Options
5502
+ * Returns the zoom level of the WebContents.
5150
5503
  *
5151
- * Note: When `silent` is set to `true`, the API will pick the system's default printer if deviceName
5152
- * is empty and the default settings for printing.
5504
+ * @example
5505
+ * View:
5506
+ * ```js
5507
+ * async function getZoomLevel() {
5508
+ * const view = await fin.View.getCurrent();
5509
+ * return await view.getZoomLevel();
5510
+ * }
5153
5511
  *
5154
- * Use the CSS style `page-break-before: always;` to force print to a new page.
5512
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
5513
+ * ```
5155
5514
  *
5156
- * @example
5515
+ * Window:
5157
5516
  * ```js
5158
- * const view = fin.View.getCurrentSync();
5517
+ * async function createWin() {
5518
+ * const app = await fin.Application.start({
5519
+ * name: 'myApp',
5520
+ * uuid: 'app-1',
5521
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
5522
+ * autoShow: true
5523
+ * });
5524
+ * return await app.getWindow();
5525
+ * }
5159
5526
  *
5160
- * view.print({ silent: false, deviceName: 'system-printer-name' }).then(() => {
5161
- * console.log('print call has been sent to the system');
5162
- * });
5527
+ * async function getZoomLevel() {
5528
+ * const win = await createWin();
5529
+ * return await win.getZoomLevel();
5530
+ * }
5531
+ *
5532
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
5163
5533
  * ```
5164
5534
  * @remarks
5165
5535
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5166
5536
  * We do not expose an explicit superclass for this functionality, but it does have its own
5167
5537
  * {@link OpenFin.WebContentsEvents event namespace}.
5168
5538
  */
5169
- print(options = {}) {
5170
- return this.wire.sendAction('print', { ...this.identity, options }).then(() => undefined);
5539
+ getZoomLevel() {
5540
+ return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
5171
5541
  }
5172
5542
  /**
5173
- * Find and highlight text on a page.
5174
- * @param searchTerm Term to find in page
5175
- * @param options Search options
5176
- *
5177
- * Note: By default, each subsequent call will highlight the next text that matches the search term.
5178
- *
5179
- * Returns a promise with the results for the request. By subscribing to the
5180
- * found-in-page event, you can get the results of this call as well.
5543
+ * Sets the zoom level of the WebContents.
5544
+ * @param level The zoom level
5181
5545
  *
5182
5546
  * @example
5183
5547
  * View:
5184
5548
  * ```js
5185
- * const view = fin.View.getCurrentSync();
5186
- *
5187
- * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
5188
- * view.addListener('found-in-page', (event) => {
5189
- * console.log(event);
5190
- * });
5549
+ * async function setZoomLevel(number) {
5550
+ * const view = await fin.View.getCurrent();
5551
+ * return await view.setZoomLevel(number);
5552
+ * }
5191
5553
  *
5192
- * // The promise also returns the results for the request
5193
- * view.findInPage('a').then((result) => {
5194
- * console.log(result)
5195
- * });
5554
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
5196
5555
  * ```
5197
5556
  *
5198
5557
  * Window:
5199
5558
  * ```js
5200
- * const win = fin.Window.getCurrentSync();
5559
+ * async function createWin() {
5560
+ * const app = await fin.Application.start({
5561
+ * name: 'myApp',
5562
+ * uuid: 'app-1',
5563
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
5564
+ * autoShow: true
5565
+ * });
5566
+ * return await app.getWindow();
5567
+ * }
5201
5568
  *
5202
- * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
5203
- * win.addListener('found-in-page', (event) => {
5204
- * console.log(event);
5205
- * });
5569
+ * async function setZoomLevel(number) {
5570
+ * const win = await createWin();
5571
+ * return await win.setZoomLevel(number);
5572
+ * }
5206
5573
  *
5207
- * // The promise also returns the results for the request
5208
- * win.findInPage('a').then((result) => {
5209
- * console.log(result)
5210
- * });
5574
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
5211
5575
  * ```
5212
5576
  * @remarks
5213
5577
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5214
5578
  * We do not expose an explicit superclass for this functionality, but it does have its own
5215
5579
  * {@link OpenFin.WebContentsEvents event namespace}.
5216
5580
  */
5217
- findInPage(searchTerm, options) {
5218
- return this.wire
5219
- .sendAction('find-in-page', { ...this.identity, searchTerm, options })
5220
- .then(({ payload }) => payload.data);
5581
+ setZoomLevel(level) {
5582
+ return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
5221
5583
  }
5222
5584
  /**
5223
- * Stop a {@link View#findInPage findInPage} call by specifying any of these actions:
5585
+ * Navigates the WebContents to a specified URL.
5224
5586
  *
5225
- * * clearSelection - Clear the selection.
5226
- * * keepSelection - Translate the selection into a normal selection.
5227
- * * activateSelection - Focus and click the selection node.
5587
+ * Note: The url must contain the protocol prefix such as http:// or https://.
5588
+ * @param url - The URL to navigate the WebContents to.
5228
5589
  *
5229
5590
  * @example
5230
5591
  * View:
5231
5592
  * ```js
5232
- * const view = fin.View.getCurrentSync();
5233
- *
5234
- * view.addListener('found-in-page', (event) => {
5235
- * setTimeout(() => {
5236
- * view.stopFindInPage('clearSelection');
5237
- * }, 5000);
5238
- * });
5593
+ * async function createView() {
5594
+ * const me = await fin.Window.getCurrent();
5595
+ * return fin.View.create({
5596
+ * name: 'viewName',
5597
+ * target: me.identity,
5598
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
5599
+ * });
5600
+ * }
5239
5601
  *
5240
- * view.findInPage('a').then(results => {
5241
- * console.log(results);
5242
- * });
5602
+ * createView()
5603
+ * .then(view => view.navigate('https://example.com'))
5604
+ * .then(() => console.log('navigation complete'))
5605
+ * .catch(err => console.log(err));
5243
5606
  * ```
5244
5607
  *
5245
5608
  * Window:
5246
5609
  * ```js
5247
- * const win = fin.Window.getCurrentSync();
5248
- *
5249
- * win.addListener('found-in-page', (event) => {
5250
- * setTimeout(() => {
5251
- * win.stopFindInPage('clearSelection');
5252
- * }, 5000);
5253
- * });
5254
- *
5255
- * win.findInPage('a').then(results => {
5256
- * console.log(results);
5257
- * });
5610
+ * async function navigate() {
5611
+ * const win = await fin.Window.getCurrent();
5612
+ * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
5613
+ * }
5614
+ * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
5258
5615
  * ```
5616
+ * @experimental
5259
5617
  * @remarks
5260
5618
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5261
5619
  * We do not expose an explicit superclass for this functionality, but it does have its own
5262
5620
  * {@link OpenFin.WebContentsEvents event namespace}.
5263
5621
  */
5264
- stopFindInPage(action) {
5265
- return this.wire.sendAction('stop-find-in-page', { ...this.identity, action }).then(() => undefined);
5622
+ navigate(url) {
5623
+ return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
5266
5624
  }
5267
5625
  /**
5268
- * Returns an array with all system printers
5269
- * @deprecated use System.getPrinters instead
5626
+ * Navigates the WebContents back one page.
5270
5627
  *
5271
5628
  * @example
5272
5629
  * View:
5273
5630
  * ```js
5274
- * const view = fin.View.getCurrentSync();
5275
- *
5276
- * view.getPrinters()
5277
- * .then((printers) => {
5278
- * printers.forEach((printer) => {
5279
- * if (printer.isDefault) {
5280
- * console.log(printer);
5281
- * }
5282
- * });
5283
- * })
5284
- * .catch((err) => {
5285
- * console.log(err);
5286
- * });
5631
+ * async function navigateBack() {
5632
+ * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
5633
+ * await view.navigate('https://www.google.com');
5634
+ * return await view.navigateBack();
5635
+ * }
5636
+ * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
5287
5637
  * ```
5288
5638
  *
5289
5639
  * Window:
5290
5640
  * ```js
5291
- * const win = fin.Window.getCurrentSync();
5292
- *
5293
- * win.getPrinters()
5294
- * .then((printers) => {
5295
- * printers.forEach((printer) => {
5296
- * if (printer.isDefault) {
5297
- * console.log(printer);
5298
- * }
5299
- * });
5300
- * })
5301
- * .catch((err) => {
5302
- * console.log(err);
5303
- * });
5641
+ * async function navigateBack() {
5642
+ * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
5643
+ * await win.navigate('https://www.google.com');
5644
+ * return await win.navigateBack();
5645
+ * }
5646
+ * navigateBack().then(() => console.log('Navigated back')).catch(err => console.log(err));
5304
5647
  * ```
5305
5648
  * @remarks
5306
5649
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5307
5650
  * We do not expose an explicit superclass for this functionality, but it does have its own
5308
5651
  * {@link OpenFin.WebContentsEvents event namespace}.
5309
5652
  */
5310
- getPrinters() {
5311
- return this.wire.sendAction('get-printers', { ...this.identity }).then(({ payload }) => payload.data);
5653
+ navigateBack() {
5654
+ return this.wire.sendAction('navigate-window-back', { ...this.identity }).then(() => undefined);
5312
5655
  }
5313
5656
  /**
5314
- * Gives focus to the WebContents.
5657
+ * Navigates the WebContents forward one page.
5315
5658
  *
5316
5659
  * @example
5660
+ * View:
5317
5661
  * ```js
5318
- * async function focusWindow() {
5319
- * const app = await fin.Application.start({
5320
- * name: 'myApp',
5321
- * uuid: 'app-1',
5322
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.focus.html',
5323
- * autoShow: true
5324
- * });
5325
- * const win = await app.getWindow();
5326
- * return await win.focus();
5662
+ * async function navigateForward() {
5663
+ * const view = await fin.View.getCurrent();
5664
+ * await view.navigate('https://www.google.com');
5665
+ * await view.navigateBack();
5666
+ * return await view.navigateForward();
5327
5667
  * }
5668
+ * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
5669
+ * ```
5328
5670
  *
5329
- * focusWindow().then(() => console.log('Window focused')).catch(err => console.log(err));
5671
+ * Window:
5672
+ * ```js
5673
+ * async function navigateForward() {
5674
+ * const win = await fin.Window.getCurrent();
5675
+ * await win.navigate('https://www.google.com');
5676
+ * await win.navigateBack();
5677
+ * return await win.navigateForward();
5678
+ * }
5679
+ * navigateForward().then(() => console.log('Navigated forward')).catch(err => console.log(err));
5330
5680
  * ```
5331
5681
  * @remarks
5332
5682
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5333
5683
  * We do not expose an explicit superclass for this functionality, but it does have its own
5334
5684
  * {@link OpenFin.WebContentsEvents event namespace}.
5335
5685
  */
5336
- async focus({ emitSynthFocused } = { emitSynthFocused: true }) {
5337
- await this.wire.sendAction('focus-window', { emitSynthFocused, ...this.identity });
5338
- }
5686
+ async navigateForward() {
5687
+ await this.wire.sendAction('navigate-window-forward', { ...this.identity });
5688
+ }
5339
5689
  /**
5340
- * Shows the Chromium Developer Tools
5690
+ * Stops any current navigation the WebContents is performing.
5341
5691
  *
5342
5692
  * @example
5343
5693
  * View:
5344
5694
  * ```js
5345
- * async function showDeveloperTools() {
5346
- * const view = await fin.View.getCurrent();
5347
- * return view.showDeveloperTools();
5695
+ * async function stopNavigation() {
5696
+ * const view = await fin.View.wrap({ name: 'testapp-view', uuid: 'testapp' });
5697
+ * await view.navigate('https://www.google.com');
5698
+ * return await view.stopNavigation();
5348
5699
  * }
5349
- *
5350
- * showDevelopertools()
5351
- * .then(() => console.log('Showing dev tools'))
5352
- * .catch(err => console.error(err));
5700
+ * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
5353
5701
  * ```
5354
5702
  *
5355
5703
  * Window:
5356
5704
  * ```js
5357
- * async function showDeveloperTools() {
5358
- * const win = await fin.Window.getCurrent();
5359
- * return win.showDeveloperTools();
5705
+ * async function stopNavigation() {
5706
+ * const win = await fin.Window.wrap({ name: 'testapp', uuid: 'testapp' });
5707
+ * await win.navigate('https://www.google.com');
5708
+ * return await win.stopNavigation();
5360
5709
  * }
5361
- *
5362
- * showDevelopertools()
5363
- * .then(() => console.log('Showing dev tools'))
5364
- * .catch(err => console.error(err));
5710
+ * stopNavigation().then(() => console.log('you shall not navigate')).catch(err => console.log(err));
5365
5711
  * ```
5366
5712
  * @remarks
5367
5713
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5368
5714
  * We do not expose an explicit superclass for this functionality, but it does have its own
5369
5715
  * {@link OpenFin.WebContentsEvents event namespace}.
5370
5716
  */
5371
- async showDeveloperTools() {
5372
- // Note this hits the system action map in core state for legacy reasons.
5373
- await this.wire.sendAction('show-developer-tools', this.identity);
5717
+ stopNavigation() {
5718
+ return this.wire.sendAction('stop-window-navigation', { ...this.identity }).then(() => undefined);
5374
5719
  }
5375
5720
  /**
5376
- * Retrieves the process information associated with a WebContents.
5377
- *
5378
- * Note: This includes any iframes associated with the WebContents
5721
+ * Reloads the WebContents
5379
5722
  *
5380
5723
  * @example
5381
5724
  * View:
5382
5725
  * ```js
5383
- * const view = await fin.View.getCurrent();
5384
- * const processInfo = await view.getProcessInfo();
5726
+ * async function reload() {
5727
+ * const view = await fin.View.getCurrent();
5728
+ * return await view.reload();
5729
+ * }
5730
+ *
5731
+ * reload().then(() => {
5732
+ * console.log('Reloaded view')
5733
+ * }).catch(err => console.log(err));
5385
5734
  * ```
5386
5735
  *
5387
5736
  * Window:
5388
5737
  * ```js
5389
- * const win = await fin.Window.getCurrent();
5390
- * const processInfo = await win.getProcessInfo();
5738
+ * async function reloadWindow() {
5739
+ * const app = await fin.Application.start({
5740
+ * name: 'myApp',
5741
+ * uuid: 'app-1',
5742
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.reload.html',
5743
+ * autoShow: true
5744
+ * });
5745
+ * const win = await app.getWindow();
5746
+ * return await win.reload();
5747
+ * }
5748
+ *
5749
+ * reloadWindow().then(() => {
5750
+ * console.log('Reloaded window')
5751
+ * }).catch(err => console.log(err));
5391
5752
  * ```
5392
5753
  * @remarks
5393
5754
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5394
5755
  * We do not expose an explicit superclass for this functionality, but it does have its own
5395
5756
  * {@link OpenFin.WebContentsEvents event namespace}.
5396
5757
  */
5397
- async getProcessInfo() {
5398
- const { payload: { data } } = await this.wire.sendAction('get-process-info', this.identity);
5399
- return data;
5758
+ reload(ignoreCache = false) {
5759
+ return this.wire
5760
+ .sendAction('reload-window', {
5761
+ ignoreCache,
5762
+ ...this.identity
5763
+ })
5764
+ .then(() => undefined);
5400
5765
  }
5401
5766
  /**
5402
- * Retrieves information on all Shared Workers.
5403
- *
5404
- * @example
5405
- * View:
5406
- * ```js
5407
- * const view = await fin.View.create({
5408
- * name: 'viewName',
5409
- * target: fin.me.identity,
5410
- * bounds: {top: 10, left: 10, width: 200, height: 200}
5411
- * });
5767
+ * Prints the WebContents.
5768
+ * @param options Printer Options
5412
5769
  *
5413
- * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
5770
+ * Note: When `silent` is set to `true`, the API will pick the system's default printer if deviceName
5771
+ * is empty and the default settings for printing.
5414
5772
  *
5415
- * const sharedWorkers = await view.getSharedWorkers();
5416
- * ```
5773
+ * Use the CSS style `page-break-before: always;` to force print to a new page.
5417
5774
  *
5418
- * Window:
5775
+ * @example
5419
5776
  * ```js
5420
- * const winOption = {
5421
- * name:'child',
5422
- * defaultWidth: 300,
5423
- * defaultHeight: 300,
5424
- * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
5425
- * frame: true,
5426
- * autoShow: true
5427
- * };
5428
- * const win = await fin.Window.create(winOption);
5429
- * const sharedWorkers = await win.getSharedWorkers();
5777
+ * const view = fin.View.getCurrentSync();
5778
+ *
5779
+ * view.print({ silent: false, deviceName: 'system-printer-name' }).then(() => {
5780
+ * console.log('print call has been sent to the system');
5781
+ * });
5430
5782
  * ```
5431
5783
  * @remarks
5432
5784
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5433
5785
  * We do not expose an explicit superclass for this functionality, but it does have its own
5434
5786
  * {@link OpenFin.WebContentsEvents event namespace}.
5435
5787
  */
5436
- async getSharedWorkers() {
5437
- return this.wire.sendAction('get-shared-workers', this.identity).then(({ payload }) => payload.data);
5788
+ print(options = {}) {
5789
+ return this.wire.sendAction('print', { ...this.identity, options }).then(() => undefined);
5438
5790
  }
5439
5791
  /**
5440
- * Opens the developer tools for the shared worker context.
5792
+ * Find and highlight text on a page.
5793
+ * @param searchTerm Term to find in page
5794
+ * @param options Search options
5795
+ *
5796
+ * Note: By default, each subsequent call will highlight the next text that matches the search term.
5797
+ *
5798
+ * Returns a promise with the results for the request. By subscribing to the
5799
+ * found-in-page event, you can get the results of this call as well.
5441
5800
  *
5442
5801
  * @example
5443
5802
  * View:
5444
5803
  * ```js
5445
- * const view = await fin.View.create({
5446
- * name: 'viewName',
5447
- * target: fin.me.identity,
5448
- * bounds: {top: 10, left: 10, width: 200, height: 200}
5449
- * });
5804
+ * const view = fin.View.getCurrentSync();
5450
5805
  *
5451
- * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
5806
+ * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
5807
+ * view.addListener('found-in-page', (event) => {
5808
+ * console.log(event);
5809
+ * });
5452
5810
  *
5453
- * await view.inspectSharedWorker();
5811
+ * // The promise also returns the results for the request
5812
+ * view.findInPage('a').then((result) => {
5813
+ * console.log(result)
5814
+ * });
5454
5815
  * ```
5455
5816
  *
5456
- * Example:
5817
+ * Window:
5457
5818
  * ```js
5458
- * const winOption = {
5459
- * name:'child',
5460
- * defaultWidth: 300,
5461
- * defaultHeight: 300,
5462
- * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
5463
- * frame: true,
5464
- * autoShow: true
5465
- * };
5466
- * const win = await fin.Window.create(winOption);
5467
- * await win.inspectSharedWorker();
5819
+ * const win = fin.Window.getCurrentSync();
5820
+ *
5821
+ * //By subscribing to the 'found in page' event we can get the results of each findInPage call made.
5822
+ * win.addListener('found-in-page', (event) => {
5823
+ * console.log(event);
5824
+ * });
5825
+ *
5826
+ * // The promise also returns the results for the request
5827
+ * win.findInPage('a').then((result) => {
5828
+ * console.log(result)
5829
+ * });
5468
5830
  * ```
5469
5831
  * @remarks
5470
5832
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5471
5833
  * We do not expose an explicit superclass for this functionality, but it does have its own
5472
5834
  * {@link OpenFin.WebContentsEvents event namespace}.
5473
5835
  */
5474
- async inspectSharedWorker() {
5475
- await this.wire.sendAction('inspect-shared-worker', { ...this.identity });
5836
+ findInPage(searchTerm, options) {
5837
+ return this.wire
5838
+ .sendAction('find-in-page', { ...this.identity, searchTerm, options })
5839
+ .then(({ payload }) => payload.data);
5476
5840
  }
5477
5841
  /**
5478
- * Inspects the shared worker based on its ID.
5479
- * @param workerId - The id of the shared worker.
5842
+ * Stop a {@link View#findInPage findInPage} call by specifying any of these actions:
5843
+ *
5844
+ * * clearSelection - Clear the selection.
5845
+ * * keepSelection - Translate the selection into a normal selection.
5846
+ * * activateSelection - Focus and click the selection node.
5480
5847
  *
5481
5848
  * @example
5482
5849
  * View:
5483
5850
  * ```js
5484
- * const view = await fin.View.create({
5485
- * name: 'viewName',
5486
- * target: fin.me.identity,
5487
- * bounds: {top: 10, left: 10, width: 200, height: 200}
5488
- * });
5851
+ * const view = fin.View.getCurrentSync();
5489
5852
  *
5490
- * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
5853
+ * view.addListener('found-in-page', (event) => {
5854
+ * setTimeout(() => {
5855
+ * view.stopFindInPage('clearSelection');
5856
+ * }, 5000);
5857
+ * });
5491
5858
  *
5492
- * const sharedWorkers = await view.getSharedWorkers();
5493
- * await view.inspectSharedWorkerById(sharedWorkers[0].id);
5859
+ * view.findInPage('a').then(results => {
5860
+ * console.log(results);
5861
+ * });
5494
5862
  * ```
5495
5863
  *
5496
5864
  * Window:
5497
5865
  * ```js
5498
- * const winOption = {
5499
- * name:'child',
5500
- * defaultWidth: 300,
5501
- * defaultHeight: 300,
5502
- * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
5503
- * frame: true,
5504
- * autoShow: true
5505
- * };
5506
- * const win = await fin.Window.create(winOption);
5507
- * const sharedWorkers = await win.getSharedWorkers();
5508
- * await win.inspectSharedWorkerById(sharedWorkers[0].id);
5866
+ * const win = fin.Window.getCurrentSync();
5867
+ *
5868
+ * win.addListener('found-in-page', (event) => {
5869
+ * setTimeout(() => {
5870
+ * win.stopFindInPage('clearSelection');
5871
+ * }, 5000);
5872
+ * });
5873
+ *
5874
+ * win.findInPage('a').then(results => {
5875
+ * console.log(results);
5876
+ * });
5509
5877
  * ```
5510
5878
  * @remarks
5511
5879
  * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5512
5880
  * We do not expose an explicit superclass for this functionality, but it does have its own
5513
5881
  * {@link OpenFin.WebContentsEvents event namespace}.
5514
5882
  */
5515
- async inspectSharedWorkerById(workerId) {
5516
- await this.wire.sendAction('inspect-shared-worker-by-id', { ...this.identity, workerId });
5883
+ stopFindInPage(action) {
5884
+ return this.wire.sendAction('stop-find-in-page', { ...this.identity, action }).then(() => undefined);
5517
5885
  }
5518
5886
  /**
5519
- * Opens the developer tools for the service worker context.
5887
+ * Returns an array with all system printers
5888
+ * @deprecated use System.getPrinters instead
5520
5889
  *
5521
5890
  * @example
5522
5891
  * View:
5523
5892
  * ```js
5524
- * const view = await fin.View.create({
5525
- * name: 'viewName',
5526
- * target: fin.me.identity,
5527
- * bounds: {top: 10, left: 10, width: 200, height: 200}
5528
- * });
5529
- *
5530
- * await view.navigate('http://googlechrome.github.io/samples/service-worker/basic/index.html');
5893
+ * const view = fin.View.getCurrentSync();
5531
5894
  *
5532
- * await view.inspectServiceWorker();
5895
+ * view.getPrinters()
5896
+ * .then((printers) => {
5897
+ * printers.forEach((printer) => {
5898
+ * if (printer.isDefault) {
5899
+ * console.log(printer);
5900
+ * }
5901
+ * });
5902
+ * })
5903
+ * .catch((err) => {
5904
+ * console.log(err);
5905
+ * });
5533
5906
  * ```
5534
5907
  *
5535
5908
  * Window:
5536
5909
  * ```js
5537
- * const winOption = {
5538
- * name:'child',
5539
- * defaultWidth: 300,
5540
- * defaultHeight: 300,
5541
- * url: 'http://googlechrome.github.io/samples/service-worker/basic/index.html',
5542
- * frame: true,
5543
- * autoShow: true
5544
- * };
5545
- * const win = await fin.Window.create(winOption);
5546
- * await win.inspectServiceWorker();
5547
- * ```
5548
- * @remarks
5549
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5550
- * We do not expose an explicit superclass for this functionality, but it does have its own
5551
- * {@link OpenFin.WebContentsEvents event namespace}.
5552
- */
5553
- async inspectServiceWorker() {
5554
- await this.wire.sendAction('inspect-service-worker', { ...this.identity });
5910
+ * const win = fin.Window.getCurrentSync();
5911
+ *
5912
+ * win.getPrinters()
5913
+ * .then((printers) => {
5914
+ * printers.forEach((printer) => {
5915
+ * if (printer.isDefault) {
5916
+ * console.log(printer);
5917
+ * }
5918
+ * });
5919
+ * })
5920
+ * .catch((err) => {
5921
+ * console.log(err);
5922
+ * });
5923
+ * ```
5924
+ * @remarks
5925
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5926
+ * We do not expose an explicit superclass for this functionality, but it does have its own
5927
+ * {@link OpenFin.WebContentsEvents event namespace}.
5928
+ */
5929
+ getPrinters() {
5930
+ return this.wire.sendAction('get-printers', { ...this.identity }).then(({ payload }) => payload.data);
5555
5931
  }
5556
5932
  /**
5557
- * Shows a popup window.
5558
- *
5559
- * Note: If this WebContents is a view and its attached window has a popup open, this will close it.
5933
+ * Gives focus to the WebContents.
5560
5934
  *
5561
- * Shows a popup window. Including a `name` in `options` will attempt to show an existing window as a popup, if
5562
- * that window doesn't exist or no `name` is included a window will be created. If the caller view or the caller
5563
- * view's parent window currently has a popup window open, calling `showPopupWindow` again will dismiss the currently
5564
- * open popup window before showing the new popup window. Also, if the caller view is destroyed or detached, the popup
5565
- * will be dismissed.
5935
+ * @example
5936
+ * ```js
5937
+ * async function focusWindow() {
5938
+ * const app = await fin.Application.start({
5939
+ * name: 'myApp',
5940
+ * uuid: 'app-1',
5941
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.focus.html',
5942
+ * autoShow: true
5943
+ * });
5944
+ * const win = await app.getWindow();
5945
+ * return await win.focus();
5946
+ * }
5566
5947
  *
5567
- * Note: in the case where the window being shown as a popup needs to be created, it is a child of the caller view's parent window.
5948
+ * focusWindow().then(() => console.log('Window focused')).catch(err => console.log(err));
5949
+ * ```
5950
+ * @remarks
5951
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5952
+ * We do not expose an explicit superclass for this functionality, but it does have its own
5953
+ * {@link OpenFin.WebContentsEvents event namespace}.
5954
+ */
5955
+ async focus({ emitSynthFocused } = { emitSynthFocused: true }) {
5956
+ await this.wire.sendAction('focus-window', { emitSynthFocused, ...this.identity });
5957
+ }
5958
+ /**
5959
+ * Shows the Chromium Developer Tools
5568
5960
  *
5569
5961
  * @example
5962
+ * View:
5963
+ * ```js
5964
+ * async function showDeveloperTools() {
5965
+ * const view = await fin.View.getCurrent();
5966
+ * return view.showDeveloperTools();
5967
+ * }
5570
5968
  *
5571
- * Create and show a single-use popup window that returns a single result to the caller. `initialOptions` allows
5572
- * us to pass window options to the popup window that will be created. `resultDispatchBehavior: 'close'` ensures
5573
- * that once the popup window calls `dispatchPopupResult` it is closed. `blurBehavior: 'close'` will yield a dismissed
5574
- * result should the popup window lose focus.
5969
+ * showDevelopertools()
5970
+ * .then(() => console.log('Showing dev tools'))
5971
+ * .catch(err => console.error(err));
5972
+ * ```
5575
5973
  *
5974
+ * Window:
5576
5975
  * ```js
5577
- * const result = await fin.me.showPopupWindow({
5578
- * initialOptions: {
5579
- * frame: false
5580
- * },
5581
- * url: '<my_popup_url>',
5582
- * resultDispatchBehavior: 'close',
5583
- * blurBehavior: 'close',
5584
- * focus: true,
5585
- * height: 300,
5586
- * width: 300,
5587
- * x: 0,
5588
- * y: 0
5589
- * });
5590
- * ```
5976
+ * async function showDeveloperTools() {
5977
+ * const win = await fin.Window.getCurrent();
5978
+ * return win.showDeveloperTools();
5979
+ * }
5591
5980
  *
5592
- * Same as above but using an existing window as a popup by referencing its `name`:
5981
+ * showDevelopertools()
5982
+ * .then(() => console.log('Showing dev tools'))
5983
+ * .catch(err => console.error(err));
5984
+ * ```
5985
+ * @remarks
5986
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5987
+ * We do not expose an explicit superclass for this functionality, but it does have its own
5988
+ * {@link OpenFin.WebContentsEvents event namespace}.
5989
+ */
5990
+ async showDeveloperTools() {
5991
+ // Note this hits the system action map in core state for legacy reasons.
5992
+ await this.wire.sendAction('show-developer-tools', this.identity);
5993
+ }
5994
+ /**
5995
+ * Retrieves the process information associated with a WebContents.
5593
5996
  *
5594
- * Note: if a window with the `name` provided doesn't exist, it will be created.
5997
+ * Note: This includes any iframes associated with the WebContents
5595
5998
  *
5999
+ * @example
6000
+ * View:
5596
6001
  * ```js
5597
- * const result = await fin.me.showPopupWindow({
5598
- * initialOptions: {
5599
- * frame: true
5600
- * },
5601
- * name: 'my-popup', // shows the 'my-popup' window if it exists, otherwise creates it
5602
- * url: '<my_popup_url>', // navigates to this url if it doesn't match the location.href of the 'my-popup' window
5603
- * resultDispatchBehavior: 'close',
5604
- * blurBehavior: 'close',
5605
- * focus: true,
5606
- * hideOnClose: true, // persist window on 'dismissed' result, alternatively change onResultDispatch and blurBehavior to 'hide'
5607
- * height: 300,
5608
- * width: 300,
5609
- * x: 0,
5610
- * y: 0
5611
- * });
6002
+ * const view = await fin.View.getCurrent();
6003
+ * const processInfo = await view.getProcessInfo();
5612
6004
  * ```
5613
6005
  *
5614
- * Create and show a popup window that is able to return multiple results to the caller via an `onPopupResult` callback. Each
5615
- * time the popup window calls `dispatchPopupResult`, the callback will be executed on the result. Once the popup window is
5616
- * closed or hidden, the `showPopupWindow` promise will resolve with a `dismissed` result that will include the most recently
5617
- * dispatched result as `lastDispatchResult`:
5618
- *
6006
+ * Window:
5619
6007
  * ```js
5620
- * const popupResultCallback = (payload) => {
5621
- * if (payload.result === 'clicked') {
5622
- * if (payload.data.topic === 'color-changed') {
5623
- * // do something like
5624
- * // setColor(payload.data.value);
5625
- * }
5626
- * }
5627
- * };
5628
- *
5629
- * await fin.me.showPopupWindow({
5630
- * initialOptions: {
5631
- * frame: false
5632
- * },
5633
- * url: '<my_popup_url>',
5634
- * resultDispatchBehavior: 'none',
5635
- * blurBehavior: 'close',
5636
- * focus: true,
5637
- * height: 300,
5638
- * width: 300,
5639
- * x: 0,
5640
- * y: 0,
5641
- * onPopupResult: popupResultCallback
5642
- * });
6008
+ * const win = await fin.Window.getCurrent();
6009
+ * const processInfo = await win.getProcessInfo();
5643
6010
  * ```
6011
+ * @remarks
6012
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
6013
+ * We do not expose an explicit superclass for this functionality, but it does have its own
6014
+ * {@link OpenFin.WebContentsEvents event namespace}.
6015
+ */
6016
+ async getProcessInfo() {
6017
+ const { payload: { data } } = await this.wire.sendAction('get-process-info', this.identity);
6018
+ return data;
6019
+ }
6020
+ /**
6021
+ * Retrieves information on all Shared Workers.
5644
6022
  *
5645
- * Same as above but using an existing window as a popup:
5646
- *
6023
+ * @example
6024
+ * View:
5647
6025
  * ```js
5648
- * const popupResultCallback = (payload) => {
5649
- * if (payload.result === 'clicked') {
5650
- * if (payload.data.topic === 'color-changed') {
5651
- * // do something like
5652
- * // setColor(payload.data.value);
5653
- * }
5654
- * }
5655
- * };
6026
+ * const view = await fin.View.create({
6027
+ * name: 'viewName',
6028
+ * target: fin.me.identity,
6029
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
6030
+ * });
5656
6031
  *
5657
- * await fin.me.showPopupWindow({
5658
- * initialOptions: {
5659
- * frame: false
5660
- * },
5661
- * name: 'my-popup', // shows the 'my-popup' window if it exists, otherwise creates it
5662
- * url: '<my_popup_url>', // navigates to this url if it doesn't match the location.href of the 'my-popup' window
5663
- * resultDispatchBehavior: 'none',
5664
- * blurBehavior: 'hide',
5665
- * focus: true,
5666
- * hideOnClose: true, // we can just use this or we can change blurBehavior to 'hide'
5667
- * height: 300,
5668
- * width: 300,
5669
- * x: 0,
5670
- * y: 0,
5671
- * onPopupResult: popupResultCallback
5672
- * });
5673
- * ```
6032
+ * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
5674
6033
  *
5675
- * Create or show a popup window that disables user movement (positioning and resizing) in the caller
5676
- * view's parent window by using `blurBehavior: 'modal'`:
6034
+ * const sharedWorkers = await view.getSharedWorkers();
6035
+ * ```
5677
6036
  *
6037
+ * Window:
5678
6038
  * ```js
5679
- * const result = await fin.me.showPopupWindow({
5680
- * initialOptions: {
5681
- * frame: false
5682
- * },
5683
- * url: '<my_popup_url>',
5684
- * resultDispatchBehavior: 'close',
5685
- * blurBehavior: 'modal',
5686
- * focus: true,
5687
- * height: 300,
5688
- * width: 300,
5689
- * x: 0,
5690
- * y: 0
5691
- * });
6039
+ * const winOption = {
6040
+ * name:'child',
6041
+ * defaultWidth: 300,
6042
+ * defaultHeight: 300,
6043
+ * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
6044
+ * frame: true,
6045
+ * autoShow: true
6046
+ * };
6047
+ * const win = await fin.Window.create(winOption);
6048
+ * const sharedWorkers = await win.getSharedWorkers();
5692
6049
  * ```
6050
+ * @remarks
6051
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
6052
+ * We do not expose an explicit superclass for this functionality, but it does have its own
6053
+ * {@link OpenFin.WebContentsEvents event namespace}.
6054
+ */
6055
+ async getSharedWorkers() {
6056
+ return this.wire.sendAction('get-shared-workers', this.identity).then(({ payload }) => payload.data);
6057
+ }
6058
+ /**
6059
+ * Opens the developer tools for the shared worker context.
5693
6060
  *
5694
- * Create a popup window as a modal:
6061
+ * @example
6062
+ * View:
6063
+ * ```js
6064
+ * const view = await fin.View.create({
6065
+ * name: 'viewName',
6066
+ * target: fin.me.identity,
6067
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
6068
+ * });
5695
6069
  *
5696
- * Note: The only way to ensure true modal behavior is to create the window being shown as a popup with a
5697
- * `modalParentIdentity` that uses the caller view's parent window identity.
6070
+ * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
5698
6071
  *
5699
- * ```js
5700
- * const result = await fin.me.showPopupWindow({
6072
+ * await view.inspectSharedWorker();
6073
+ * ```
6074
+ *
6075
+ * Example:
6076
+ * ```js
6077
+ * const winOption = {
6078
+ * name:'child',
6079
+ * defaultWidth: 300,
6080
+ * defaultHeight: 300,
6081
+ * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
6082
+ * frame: true,
6083
+ * autoShow: true
6084
+ * };
6085
+ * const win = await fin.Window.create(winOption);
6086
+ * await win.inspectSharedWorker();
6087
+ * ```
6088
+ * @remarks
6089
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
6090
+ * We do not expose an explicit superclass for this functionality, but it does have its own
6091
+ * {@link OpenFin.WebContentsEvents event namespace}.
6092
+ */
6093
+ async inspectSharedWorker() {
6094
+ await this.wire.sendAction('inspect-shared-worker', { ...this.identity });
6095
+ }
6096
+ /**
6097
+ * Inspects the shared worker based on its ID.
6098
+ * @param workerId - The id of the shared worker.
6099
+ *
6100
+ * @example
6101
+ * View:
6102
+ * ```js
6103
+ * const view = await fin.View.create({
6104
+ * name: 'viewName',
6105
+ * target: fin.me.identity,
6106
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
6107
+ * });
6108
+ *
6109
+ * await view.navigate('http://mdn.github.io/simple-shared-worker/index2.html');
6110
+ *
6111
+ * const sharedWorkers = await view.getSharedWorkers();
6112
+ * await view.inspectSharedWorkerById(sharedWorkers[0].id);
6113
+ * ```
6114
+ *
6115
+ * Window:
6116
+ * ```js
6117
+ * const winOption = {
6118
+ * name:'child',
6119
+ * defaultWidth: 300,
6120
+ * defaultHeight: 300,
6121
+ * url: 'http://mdn.github.io/simple-shared-worker/index2.html',
6122
+ * frame: true,
6123
+ * autoShow: true
6124
+ * };
6125
+ * const win = await fin.Window.create(winOption);
6126
+ * const sharedWorkers = await win.getSharedWorkers();
6127
+ * await win.inspectSharedWorkerById(sharedWorkers[0].id);
6128
+ * ```
6129
+ * @remarks
6130
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
6131
+ * We do not expose an explicit superclass for this functionality, but it does have its own
6132
+ * {@link OpenFin.WebContentsEvents event namespace}.
6133
+ */
6134
+ async inspectSharedWorkerById(workerId) {
6135
+ await this.wire.sendAction('inspect-shared-worker-by-id', { ...this.identity, workerId });
6136
+ }
6137
+ /**
6138
+ * Opens the developer tools for the service worker context.
6139
+ *
6140
+ * @example
6141
+ * View:
6142
+ * ```js
6143
+ * const view = await fin.View.create({
6144
+ * name: 'viewName',
6145
+ * target: fin.me.identity,
6146
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
6147
+ * });
6148
+ *
6149
+ * await view.navigate('http://googlechrome.github.io/samples/service-worker/basic/index.html');
6150
+ *
6151
+ * await view.inspectServiceWorker();
6152
+ * ```
6153
+ *
6154
+ * Window:
6155
+ * ```js
6156
+ * const winOption = {
6157
+ * name:'child',
6158
+ * defaultWidth: 300,
6159
+ * defaultHeight: 300,
6160
+ * url: 'http://googlechrome.github.io/samples/service-worker/basic/index.html',
6161
+ * frame: true,
6162
+ * autoShow: true
6163
+ * };
6164
+ * const win = await fin.Window.create(winOption);
6165
+ * await win.inspectServiceWorker();
6166
+ * ```
6167
+ * @remarks
6168
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
6169
+ * We do not expose an explicit superclass for this functionality, but it does have its own
6170
+ * {@link OpenFin.WebContentsEvents event namespace}.
6171
+ */
6172
+ async inspectServiceWorker() {
6173
+ await this.wire.sendAction('inspect-service-worker', { ...this.identity });
6174
+ }
6175
+ /**
6176
+ * Shows a popup window.
6177
+ *
6178
+ * Note: If this WebContents is a view and its attached window has a popup open, this will close it.
6179
+ *
6180
+ * Shows a popup window. Including a `name` in `options` will attempt to show an existing window as a popup, if
6181
+ * that window doesn't exist or no `name` is included a window will be created. If the caller view or the caller
6182
+ * view's parent window currently has a popup window open, calling `showPopupWindow` again will dismiss the currently
6183
+ * open popup window before showing the new popup window. Also, if the caller view is destroyed or detached, the popup
6184
+ * will be dismissed.
6185
+ *
6186
+ * Note: in the case where the window being shown as a popup needs to be created, it is a child of the caller view's parent window.
6187
+ *
6188
+ * @example
6189
+ *
6190
+ * Create and show a single-use popup window that returns a single result to the caller. `initialOptions` allows
6191
+ * us to pass window options to the popup window that will be created. `resultDispatchBehavior: 'close'` ensures
6192
+ * that once the popup window calls `dispatchPopupResult` it is closed. `blurBehavior: 'close'` will yield a dismissed
6193
+ * result should the popup window lose focus.
6194
+ *
6195
+ * ```js
6196
+ * const result = await fin.me.showPopupWindow({
6197
+ * initialOptions: {
6198
+ * frame: false
6199
+ * },
6200
+ * url: '<my_popup_url>',
6201
+ * resultDispatchBehavior: 'close',
6202
+ * blurBehavior: 'close',
6203
+ * focus: true,
6204
+ * height: 300,
6205
+ * width: 300,
6206
+ * x: 0,
6207
+ * y: 0
6208
+ * });
6209
+ * ```
6210
+ *
6211
+ * Same as above but using an existing window as a popup by referencing its `name`:
6212
+ *
6213
+ * Note: if a window with the `name` provided doesn't exist, it will be created.
6214
+ *
6215
+ * ```js
6216
+ * const result = await fin.me.showPopupWindow({
6217
+ * initialOptions: {
6218
+ * frame: true
6219
+ * },
6220
+ * name: 'my-popup', // shows the 'my-popup' window if it exists, otherwise creates it
6221
+ * url: '<my_popup_url>', // navigates to this url if it doesn't match the location.href of the 'my-popup' window
6222
+ * resultDispatchBehavior: 'close',
6223
+ * blurBehavior: 'close',
6224
+ * focus: true,
6225
+ * hideOnClose: true, // persist window on 'dismissed' result, alternatively change onResultDispatch and blurBehavior to 'hide'
6226
+ * height: 300,
6227
+ * width: 300,
6228
+ * x: 0,
6229
+ * y: 0
6230
+ * });
6231
+ * ```
6232
+ *
6233
+ * Create and show a popup window that is able to return multiple results to the caller via an `onPopupResult` callback. Each
6234
+ * time the popup window calls `dispatchPopupResult`, the callback will be executed on the result. Once the popup window is
6235
+ * closed or hidden, the `showPopupWindow` promise will resolve with a `dismissed` result that will include the most recently
6236
+ * dispatched result as `lastDispatchResult`:
6237
+ *
6238
+ * ```js
6239
+ * const popupResultCallback = (payload) => {
6240
+ * if (payload.result === 'clicked') {
6241
+ * if (payload.data.topic === 'color-changed') {
6242
+ * // do something like
6243
+ * // setColor(payload.data.value);
6244
+ * }
6245
+ * }
6246
+ * };
6247
+ *
6248
+ * await fin.me.showPopupWindow({
6249
+ * initialOptions: {
6250
+ * frame: false
6251
+ * },
6252
+ * url: '<my_popup_url>',
6253
+ * resultDispatchBehavior: 'none',
6254
+ * blurBehavior: 'close',
6255
+ * focus: true,
6256
+ * height: 300,
6257
+ * width: 300,
6258
+ * x: 0,
6259
+ * y: 0,
6260
+ * onPopupResult: popupResultCallback
6261
+ * });
6262
+ * ```
6263
+ *
6264
+ * Same as above but using an existing window as a popup:
6265
+ *
6266
+ * ```js
6267
+ * const popupResultCallback = (payload) => {
6268
+ * if (payload.result === 'clicked') {
6269
+ * if (payload.data.topic === 'color-changed') {
6270
+ * // do something like
6271
+ * // setColor(payload.data.value);
6272
+ * }
6273
+ * }
6274
+ * };
6275
+ *
6276
+ * await fin.me.showPopupWindow({
6277
+ * initialOptions: {
6278
+ * frame: false
6279
+ * },
6280
+ * name: 'my-popup', // shows the 'my-popup' window if it exists, otherwise creates it
6281
+ * url: '<my_popup_url>', // navigates to this url if it doesn't match the location.href of the 'my-popup' window
6282
+ * resultDispatchBehavior: 'none',
6283
+ * blurBehavior: 'hide',
6284
+ * focus: true,
6285
+ * hideOnClose: true, // we can just use this or we can change blurBehavior to 'hide'
6286
+ * height: 300,
6287
+ * width: 300,
6288
+ * x: 0,
6289
+ * y: 0,
6290
+ * onPopupResult: popupResultCallback
6291
+ * });
6292
+ * ```
6293
+ *
6294
+ * Create or show a popup window that disables user movement (positioning and resizing) in the caller
6295
+ * view's parent window by using `blurBehavior: 'modal'`:
6296
+ *
6297
+ * ```js
6298
+ * const result = await fin.me.showPopupWindow({
6299
+ * initialOptions: {
6300
+ * frame: false
6301
+ * },
6302
+ * url: '<my_popup_url>',
6303
+ * resultDispatchBehavior: 'close',
6304
+ * blurBehavior: 'modal',
6305
+ * focus: true,
6306
+ * height: 300,
6307
+ * width: 300,
6308
+ * x: 0,
6309
+ * y: 0
6310
+ * });
6311
+ * ```
6312
+ *
6313
+ * Create a popup window as a modal:
6314
+ *
6315
+ * Note: The only way to ensure true modal behavior is to create the window being shown as a popup with a
6316
+ * `modalParentIdentity` that uses the caller view's parent window identity.
6317
+ *
6318
+ * ```js
6319
+ * const result = await fin.me.showPopupWindow({
5701
6320
  * initialOptions: {
5702
6321
  * frame: false,
5703
6322
  * modalParentIdentity: fin.me.identity
@@ -8470,11 +9089,18 @@ var hasRequiredInstance;
8470
9089
  function requireInstance () {
8471
9090
  if (hasRequiredInstance) return Instance$7;
8472
9091
  hasRequiredInstance = 1;
9092
+ var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9093
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9094
+ 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");
9095
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9096
+ };
8473
9097
  var _View_providerChannelClient;
8474
9098
  Object.defineProperty(Instance$7, "__esModule", { value: true });
8475
9099
  Instance$7.View = void 0;
8476
9100
  const transport_errors_1 = transportErrors;
8477
9101
  const lazy_1 = lazy;
9102
+ const layout_entities_1 = layoutEntities;
9103
+ const layout_constants_1 = layout_constants;
8478
9104
  const main_1 = main;
8479
9105
  const window_1 = requireWindow();
8480
9106
  /**
@@ -8792,7 +9418,7 @@ function requireInstance () {
8792
9418
  return ack.payload.data;
8793
9419
  };
8794
9420
  /**
8795
- * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
9421
+ * Retrieves the layout for the window the view is attached to.
8796
9422
  *
8797
9423
  * @example
8798
9424
  * ```js
@@ -8808,10 +9434,27 @@ function requireInstance () {
8808
9434
  this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
8809
9435
  // don't expose
8810
9436
  });
8811
- return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
8812
- };
8813
- /**
8814
- * Gets the View's options.
9437
+ const layoutWindow = await this.getCurrentWindow();
9438
+ try {
9439
+ const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
9440
+ const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
9441
+ const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
9442
+ return this.fin.Platform.Layout.wrap(layoutIdentity);
9443
+ }
9444
+ catch (e) {
9445
+ const allowedErrors = [
9446
+ 'No action registered at target for',
9447
+ 'getLayoutIdentityForViewOrThrow is not a function'
9448
+ ];
9449
+ if (!allowedErrors.some((m) => e.message.includes(m))) {
9450
+ throw e;
9451
+ }
9452
+ // fallback logic for missing endpoint
9453
+ return this.fin.Platform.Layout.wrap(layoutWindow.identity);
9454
+ }
9455
+ };
9456
+ /**
9457
+ * Gets the View's options.
8815
9458
  *
8816
9459
  * @example
8817
9460
  * ```js
@@ -8924,8 +9567,11 @@ function requireInstance () {
8924
9567
  // don't expose
8925
9568
  });
8926
9569
  try {
8927
- const layout = await this.getParentLayout();
8928
- return layout.getStackByViewIdentity(this.identity);
9570
+ const layoutWindow = await this.getCurrentWindow();
9571
+ const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
9572
+ const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
9573
+ const stackDefinition = (await client.getStackByView(this.identity));
9574
+ return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
8929
9575
  }
8930
9576
  catch (error) {
8931
9577
  throw new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.', error });
@@ -9531,27 +10177,24 @@ function errorToPOJO(error) {
9531
10177
  }
9532
10178
  errors.errorToPOJO = errorToPOJO;
9533
10179
 
9534
- var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10180
+ var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9535
10181
  if (kind === "m") throw new TypeError("Private method is not writable");
9536
10182
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9537
10183
  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");
9538
10184
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9539
10185
  };
9540
- var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10186
+ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9541
10187
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9542
10188
  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");
9543
10189
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9544
10190
  };
9545
- var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
9546
- return (mod && mod.__esModule) ? mod : { "default": mod };
9547
- };
9548
10191
  var _Transport_wire, _Transport_fin;
9549
10192
  Object.defineProperty(transport, "__esModule", { value: true });
9550
10193
  var Transport_1 = transport.Transport = void 0;
9551
- const events_1$5 = require$$0$1;
10194
+ const events_1$5 = require$$0;
9552
10195
  const wire_1 = wire;
9553
10196
  const transport_errors_1$2 = transportErrors;
9554
- const eventAggregator_1 = __importDefault$2(eventAggregator);
10197
+ const eventAggregator_1 = eventAggregator;
9555
10198
  const me_1$1 = me;
9556
10199
  const errors_1$1 = errors;
9557
10200
  class Transport extends events_1$5.EventEmitter {
@@ -9565,19 +10208,19 @@ class Transport extends events_1$5.EventEmitter {
9565
10208
  // Typing as unknown to avoid circular dependency, should not be used directly.
9566
10209
  _Transport_fin.set(this, void 0);
9567
10210
  this.connectSync = () => {
9568
- const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10211
+ const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9569
10212
  wire.connectSync();
9570
10213
  };
9571
10214
  // This function is only used in our tests.
9572
10215
  this.getPort = () => {
9573
- const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10216
+ const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9574
10217
  return wire.getPort();
9575
10218
  };
9576
- __classPrivateFieldSet$a(this, _Transport_wire, new WireType(this.onmessage.bind(this)), "f");
10219
+ __classPrivateFieldSet$9(this, _Transport_wire, new WireType(this.onmessage.bind(this)), "f");
9577
10220
  this.environment = environment;
9578
- this.sendRaw = __classPrivateFieldGet$c(this, _Transport_wire, "f").send.bind(__classPrivateFieldGet$c(this, _Transport_wire, "f"));
10221
+ this.sendRaw = __classPrivateFieldGet$b(this, _Transport_wire, "f").send.bind(__classPrivateFieldGet$b(this, _Transport_wire, "f"));
9579
10222
  this.registerMessageHandler(this.handleMessage.bind(this));
9580
- __classPrivateFieldGet$c(this, _Transport_wire, "f").on('disconnected', () => {
10223
+ __classPrivateFieldGet$b(this, _Transport_wire, "f").on('disconnected', () => {
9581
10224
  for (const [, { handleNack }] of this.wireListeners) {
9582
10225
  handleNack({ reason: 'Remote connection has closed' });
9583
10226
  }
@@ -9589,24 +10232,24 @@ class Transport extends events_1$5.EventEmitter {
9589
10232
  this.me = (0, me_1$1.getBaseMe)(entityType, uuid, name);
9590
10233
  }
9591
10234
  getFin() {
9592
- if (!__classPrivateFieldGet$c(this, _Transport_fin, "f")) {
10235
+ if (!__classPrivateFieldGet$b(this, _Transport_fin, "f")) {
9593
10236
  throw new Error('No Fin object registered for this transport');
9594
10237
  }
9595
- return __classPrivateFieldGet$c(this, _Transport_fin, "f");
10238
+ return __classPrivateFieldGet$b(this, _Transport_fin, "f");
9596
10239
  }
9597
10240
  registerFin(_fin) {
9598
- if (__classPrivateFieldGet$c(this, _Transport_fin, "f")) {
10241
+ if (__classPrivateFieldGet$b(this, _Transport_fin, "f")) {
9599
10242
  throw new Error('Fin object has already been registered for this transport');
9600
10243
  }
9601
- __classPrivateFieldSet$a(this, _Transport_fin, _fin, "f");
10244
+ __classPrivateFieldSet$9(this, _Transport_fin, _fin, "f");
9602
10245
  }
9603
10246
  shutdown() {
9604
- const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10247
+ const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9605
10248
  return wire.shutdown();
9606
10249
  }
9607
10250
  async connect(config) {
9608
10251
  if ((0, wire_1.isConfigWithReceiver)(config)) {
9609
- await __classPrivateFieldGet$c(this, _Transport_wire, "f").connect(config.receiver);
10252
+ await __classPrivateFieldGet$b(this, _Transport_wire, "f").connect(config.receiver);
9610
10253
  return this.authorize(config);
9611
10254
  }
9612
10255
  if ((0, wire_1.isRemoteConfig)(config)) {
@@ -9622,13 +10265,13 @@ class Transport extends events_1$5.EventEmitter {
9622
10265
  return undefined;
9623
10266
  }
9624
10267
  async connectRemote(config) {
9625
- await __classPrivateFieldGet$c(this, _Transport_wire, "f").connect(new (this.environment.getWsConstructor())(config.address));
10268
+ await __classPrivateFieldGet$b(this, _Transport_wire, "f").connect(new (this.environment.getWsConstructor())(config.address));
9626
10269
  return this.authorize(config);
9627
10270
  }
9628
10271
  async connectByPort(config) {
9629
10272
  const { address, uuid } = config;
9630
10273
  const reqAuthPayload = { ...config, type: 'file-token' };
9631
- const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10274
+ const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9632
10275
  await wire.connect(new (this.environment.getWsConstructor())(config.address));
9633
10276
  const requestExtAuthRet = await this.sendAction('request-external-authorization', {
9634
10277
  uuid,
@@ -9664,7 +10307,7 @@ class Transport extends events_1$5.EventEmitter {
9664
10307
  payload,
9665
10308
  messageId
9666
10309
  };
9667
- const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10310
+ const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9668
10311
  this.addWireListener(messageId, resolve, (payload) => this.nackHandler(payload, reject, callSites), uncorrelated);
9669
10312
  return wire.send(msg).catch(reject);
9670
10313
  });
@@ -9686,7 +10329,7 @@ class Transport extends events_1$5.EventEmitter {
9686
10329
  const resolver = (data) => {
9687
10330
  resolve(data.payload);
9688
10331
  };
9689
- const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10332
+ const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9690
10333
  return wire
9691
10334
  .send(origData)
9692
10335
  .then(() => this.addWireListener(id, resolver, (payload) => this.nackHandler(payload, reject), false))
@@ -9765,7 +10408,7 @@ _Transport_wire = new WeakMap(), _Transport_fin = new WeakMap();
9765
10408
  var websocket = {};
9766
10409
 
9767
10410
  Object.defineProperty(websocket, "__esModule", { value: true });
9768
- const events_1$4 = require$$0$1;
10411
+ const events_1$4 = require$$0;
9769
10412
  const transport_errors_1$1 = transportErrors;
9770
10413
  const messageReceiver_1 = bridge.messageReceiver;
9771
10414
  /* `READY_STATE` is an instance var set by `constructor` to reference the `WebTransportSocket.READY_STATE` enum.
@@ -9842,7 +10485,7 @@ system.System = void 0;
9842
10485
  const base_1$d = base;
9843
10486
  const transport_errors_1 = transportErrors;
9844
10487
  const window_1 = requireWindow();
9845
- const events_1$3 = require$$0$1;
10488
+ const events_1$3 = require$$0;
9846
10489
  /**
9847
10490
  * An object representing the core of OpenFin Runtime. Allows the developer
9848
10491
  * to perform system-level actions, such as accessing logs, viewing processes,
@@ -10326,8 +10969,7 @@ class System extends base_1$d.EmitterBase {
10326
10969
  return this.wire.sendAction('get-rvm-info').then(({ payload }) => payload.data);
10327
10970
  }
10328
10971
  /**
10329
- * Retrieves general system information. If you need more detailed information about the
10330
- * OS and the currently logged in user, use `fin.System.getOSInfo()` instead.
10972
+ * Retrieves system information.
10331
10973
  *
10332
10974
  * @example
10333
10975
  * ```js
@@ -10337,17 +10979,6 @@ class System extends base_1$d.EmitterBase {
10337
10979
  getHostSpecs() {
10338
10980
  return this.wire.sendAction('get-host-specs').then(({ payload }) => payload.data);
10339
10981
  }
10340
- /**
10341
- * Retrieves information about the OS and the currently logged in user.
10342
- *
10343
- * @example
10344
- * ```js
10345
- * fin.System.getOSInfo().then(specs => console.log(specs)).catch(err => console.log(err));
10346
- * ```
10347
- */
10348
- getOSInfo() {
10349
- return this.wire.sendAction('get-os-info').then(({ payload }) => payload.data);
10350
- }
10351
10982
  /**
10352
10983
  * Runs an executable or batch file. A path to the file must be included in options.
10353
10984
  * <br> A uuid may be optionally provided. If not provided, OpenFin will create a uuid for the new process.
@@ -11697,22 +12328,6 @@ class System extends base_1$d.EmitterBase {
11697
12328
  async setDomainSettings(domainSettings) {
11698
12329
  await this.wire.sendAction('set-domain-settings', { domainSettings, ...this.identity });
11699
12330
  }
11700
- /**
11701
- * Attempts to install and enable extensions for the security realm. Users may want to call this function in response
11702
- * to an `extensions-install-failed` event. Only extensions allowed by every application on the current security realm
11703
- * will be installed/enabled.
11704
- */
11705
- async refreshExtensions() {
11706
- const { payload } = await this.wire.sendAction('refresh-extensions');
11707
- return payload.data;
11708
- }
11709
- /**
11710
- * Gets the currently-installed
11711
- */
11712
- async getInstalledExtensions() {
11713
- const { payload } = await this.wire.sendAction('get-installed-extensions');
11714
- return payload.data;
11715
- }
11716
12331
  }
11717
12332
  system.System = System;
11718
12333
 
@@ -12113,12 +12728,12 @@ class ChannelBase {
12113
12728
  }
12114
12729
  channel.ChannelBase = ChannelBase;
12115
12730
 
12116
- var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12731
+ var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12117
12732
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12118
12733
  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");
12119
12734
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12120
12735
  };
12121
- var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12736
+ var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12122
12737
  if (kind === "m") throw new TypeError("Private method is not writable");
12123
12738
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12124
12739
  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");
@@ -12160,7 +12775,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
12160
12775
  static closeChannelByEndpointId(id) {
12161
12776
  const channel = channelClientsByEndpointId.get(id);
12162
12777
  if (channel) {
12163
- __classPrivateFieldGet$b(channel, _ChannelClient_close, "f").call(channel);
12778
+ __classPrivateFieldGet$a(channel, _ChannelClient_close, "f").call(channel);
12164
12779
  }
12165
12780
  }
12166
12781
  /**
@@ -12171,7 +12786,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
12171
12786
  for (const channelClient of channelClientsByEndpointId.values()) {
12172
12787
  if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
12173
12788
  channelClient.disconnectListener(eventPayload);
12174
- __classPrivateFieldGet$b(channelClient, _ChannelClient_close, "f").call(channelClient);
12789
+ __classPrivateFieldGet$a(channelClient, _ChannelClient_close, "f").call(channelClient);
12175
12790
  }
12176
12791
  }
12177
12792
  }
@@ -12186,12 +12801,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
12186
12801
  this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
12187
12802
  _ChannelClient_close.set(this, () => {
12188
12803
  channelClientsByEndpointId.delete(this.endpointId);
12189
- __classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").close();
12804
+ __classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").close();
12190
12805
  });
12191
- __classPrivateFieldSet$9(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
12806
+ __classPrivateFieldSet$8(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
12192
12807
  this.disconnectListener = () => undefined;
12193
12808
  this.endpointId = routingInfo.endpointId;
12194
- __classPrivateFieldSet$9(this, _ChannelClient_strategy, strategy, "f");
12809
+ __classPrivateFieldSet$8(this, _ChannelClient_strategy, strategy, "f");
12195
12810
  channelClientsByEndpointId.set(this.endpointId, this);
12196
12811
  strategy.receive(this.processAction);
12197
12812
  }
@@ -12199,7 +12814,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
12199
12814
  * a read-only provider identity
12200
12815
  */
12201
12816
  get providerIdentity() {
12202
- const protectedObj = __classPrivateFieldGet$b(this, _ChannelClient_protectedObj, "f");
12817
+ const protectedObj = __classPrivateFieldGet$a(this, _ChannelClient_protectedObj, "f");
12203
12818
  return protectedObj.providerIdentity;
12204
12819
  }
12205
12820
  /**
@@ -12228,8 +12843,8 @@ class ChannelClient extends channel_1$1.ChannelBase {
12228
12843
  * ```
12229
12844
  */
12230
12845
  async dispatch(action, payload) {
12231
- if (__classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
12232
- return __classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload);
12846
+ if (__classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
12847
+ return __classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload);
12233
12848
  }
12234
12849
  throw new Error('The client you are trying to dispatch from is disconnected from the target provider.');
12235
12850
  }
@@ -12279,10 +12894,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
12279
12894
  */
12280
12895
  async disconnect() {
12281
12896
  await this.sendDisconnectAction();
12282
- __classPrivateFieldGet$b(this, _ChannelClient_close, "f").call(this);
12897
+ __classPrivateFieldGet$a(this, _ChannelClient_close, "f").call(this);
12283
12898
  }
12284
12899
  async sendDisconnectAction() {
12285
- const protectedObj = __classPrivateFieldGet$b(this, _ChannelClient_protectedObj, "f");
12900
+ const protectedObj = __classPrivateFieldGet$a(this, _ChannelClient_protectedObj, "f");
12286
12901
  await protectedObj.close();
12287
12902
  }
12288
12903
  /**
@@ -12315,13 +12930,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
12315
12930
 
12316
12931
  var strategy$3 = {};
12317
12932
 
12318
- var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12933
+ var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12319
12934
  if (kind === "m") throw new TypeError("Private method is not writable");
12320
12935
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12321
12936
  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");
12322
12937
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12323
12938
  };
12324
- var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12939
+ var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12325
12940
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12326
12941
  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");
12327
12942
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -12346,7 +12961,7 @@ class ClassicStrategy {
12346
12961
  // connection problems occur
12347
12962
  _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map);
12348
12963
  this.send = async (endpointId, action, payload) => {
12349
- const to = __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
12964
+ const to = __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
12350
12965
  if (!to) {
12351
12966
  throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
12352
12967
  }
@@ -12358,28 +12973,28 @@ class ClassicStrategy {
12358
12973
  }
12359
12974
  delete cleanId.isLocalEndpointId;
12360
12975
  // grab the promise before awaiting it to save in our pending messages map
12361
- const p = __classPrivateFieldGet$a(this, _ClassicStrategy_wire, "f")
12976
+ const p = __classPrivateFieldGet$9(this, _ClassicStrategy_wire, "f")
12362
12977
  .sendAction('send-channel-message', {
12363
12978
  ...cleanId,
12364
12979
  providerIdentity: this.providerIdentity,
12365
12980
  action,
12366
12981
  payload
12367
12982
  });
12368
- __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
12983
+ __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
12369
12984
  const raw = await p.catch((error) => {
12370
12985
  throw new Error(error.message);
12371
12986
  }).finally(() => {
12372
12987
  // clean up the pending promise
12373
- __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
12988
+ __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
12374
12989
  });
12375
12990
  return raw.payload.data.result;
12376
12991
  };
12377
12992
  this.close = async () => {
12378
12993
  this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
12379
- [...__classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
12380
- __classPrivateFieldSet$8(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
12994
+ [...__classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
12995
+ __classPrivateFieldSet$7(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
12381
12996
  };
12382
- __classPrivateFieldSet$8(this, _ClassicStrategy_wire, wire, "f");
12997
+ __classPrivateFieldSet$7(this, _ClassicStrategy_wire, wire, "f");
12383
12998
  }
12384
12999
  onEndpointDisconnect(endpointId, listener) {
12385
13000
  // Never fires for 'classic'.
@@ -12388,20 +13003,20 @@ class ClassicStrategy {
12388
13003
  this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
12389
13004
  }
12390
13005
  async closeEndpoint(endpointId) {
12391
- const id = __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
12392
- __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
12393
- const pendingSet = __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
13006
+ const id = __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
13007
+ __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
13008
+ const pendingSet = __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
12394
13009
  pendingSet?.forEach((p) => {
12395
13010
  const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
12396
13011
  p.cancel(new Error(errorMsg));
12397
13012
  });
12398
13013
  }
12399
13014
  isEndpointConnected(endpointId) {
12400
- return __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
13015
+ return __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
12401
13016
  }
12402
13017
  addEndpoint(endpointId, payload) {
12403
- __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
12404
- __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
13018
+ __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
13019
+ __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
12405
13020
  }
12406
13021
  isValidEndpointPayload(payload) {
12407
13022
  return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
@@ -12417,12 +13032,12 @@ var strategy$2 = {};
12417
13032
 
12418
13033
  var endpoint = {};
12419
13034
 
12420
- var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13035
+ var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12421
13036
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12422
13037
  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");
12423
13038
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12424
13039
  };
12425
- var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13040
+ var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12426
13041
  if (kind === "m") throw new TypeError("Private method is not writable");
12427
13042
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12428
13043
  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");
@@ -12457,8 +13072,8 @@ class RTCEndpoint {
12457
13072
  if (this.rtc.rtcClient.connectionState !== 'connected') {
12458
13073
  this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
12459
13074
  this.close();
12460
- if (__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
12461
- __classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f").call(this);
13075
+ if (__classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f")) {
13076
+ __classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f").call(this);
12462
13077
  }
12463
13078
  }
12464
13079
  };
@@ -12506,9 +13121,9 @@ class RTCEndpoint {
12506
13121
  data = new TextDecoder().decode(e.data);
12507
13122
  }
12508
13123
  const { messageId, action, payload } = JSON.parse(data);
12509
- if (__classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f")) {
13124
+ if (__classPrivateFieldGet$8(this, _RTCEndpoint_processAction, "f")) {
12510
13125
  try {
12511
- const res = await __classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
13126
+ const res = await __classPrivateFieldGet$8(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
12512
13127
  this.rtc.channels.response.send(JSON.stringify({
12513
13128
  messageId,
12514
13129
  payload: res,
@@ -12542,25 +13157,25 @@ class RTCEndpoint {
12542
13157
  datachannel.onclose = (e) => {
12543
13158
  [...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.')));
12544
13159
  this.close();
12545
- if (__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
12546
- __classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f").call(this);
13160
+ if (__classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f")) {
13161
+ __classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f").call(this);
12547
13162
  }
12548
13163
  };
12549
13164
  });
12550
13165
  }
12551
13166
  onDisconnect(listener) {
12552
- if (!__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
12553
- __classPrivateFieldSet$7(this, _RTCEndpoint_disconnectListener, listener, "f");
13167
+ if (!__classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f")) {
13168
+ __classPrivateFieldSet$6(this, _RTCEndpoint_disconnectListener, listener, "f");
12554
13169
  }
12555
13170
  else {
12556
13171
  throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
12557
13172
  }
12558
13173
  }
12559
13174
  receive(listener) {
12560
- if (__classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f")) {
13175
+ if (__classPrivateFieldGet$8(this, _RTCEndpoint_processAction, "f")) {
12561
13176
  throw new Error('You have already set a listener for this RTC Endpoint.');
12562
13177
  }
12563
- __classPrivateFieldSet$7(this, _RTCEndpoint_processAction, listener, "f");
13178
+ __classPrivateFieldSet$6(this, _RTCEndpoint_processAction, listener, "f");
12564
13179
  }
12565
13180
  get connected() {
12566
13181
  return this.rtc.rtcClient.connectionState === 'connected';
@@ -12571,12 +13186,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
12571
13186
 
12572
13187
  var strategy$1 = {};
12573
13188
 
12574
- var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13189
+ var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12575
13190
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12576
13191
  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");
12577
13192
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12578
13193
  };
12579
- var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13194
+ var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12580
13195
  if (kind === "m") throw new TypeError("Private method is not writable");
12581
13196
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12582
13197
  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");
@@ -12597,11 +13212,11 @@ class EndpointStrategy {
12597
13212
  return this.getEndpointById(endpointId).send(action, payload);
12598
13213
  };
12599
13214
  this.close = async () => {
12600
- if (__classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f")) {
12601
- __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
12602
- __classPrivateFieldSet$6(this, _EndpointStrategy_endpointMap, new Map(), "f");
13215
+ if (__classPrivateFieldGet$7(this, _EndpointStrategy_connected, "f")) {
13216
+ __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
13217
+ __classPrivateFieldSet$5(this, _EndpointStrategy_endpointMap, new Map(), "f");
12603
13218
  }
12604
- __classPrivateFieldSet$6(this, _EndpointStrategy_connected, false, "f");
13219
+ __classPrivateFieldSet$5(this, _EndpointStrategy_connected, false, "f");
12605
13220
  };
12606
13221
  this.isValidEndpointPayload = validateEndpoint;
12607
13222
  }
@@ -12609,39 +13224,39 @@ class EndpointStrategy {
12609
13224
  this.getEndpointById(endpointId).onDisconnect(listener);
12610
13225
  }
12611
13226
  receive(listener) {
12612
- if (__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")) {
13227
+ if (__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f")) {
12613
13228
  throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
12614
13229
  }
12615
- __classPrivateFieldSet$6(this, _EndpointStrategy_processAction, listener, "f");
13230
+ __classPrivateFieldSet$5(this, _EndpointStrategy_processAction, listener, "f");
12616
13231
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12617
- __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")));
13232
+ __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f")));
12618
13233
  }
12619
13234
  getEndpointById(endpointId) {
12620
- const endpoint = __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
13235
+ const endpoint = __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
12621
13236
  if (!endpoint) {
12622
13237
  throw new Error(`Client with endpoint id ${endpointId} is not connected`);
12623
13238
  }
12624
13239
  return endpoint;
12625
13240
  }
12626
13241
  get connected() {
12627
- return __classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f");
13242
+ return __classPrivateFieldGet$7(this, _EndpointStrategy_connected, "f");
12628
13243
  }
12629
13244
  isEndpointConnected(endpointId) {
12630
- return __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
13245
+ return __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
12631
13246
  }
12632
13247
  addEndpoint(endpointId, payload) {
12633
- if (!__classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f")) {
13248
+ if (!__classPrivateFieldGet$7(this, _EndpointStrategy_connected, "f")) {
12634
13249
  console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
12635
13250
  return;
12636
13251
  }
12637
13252
  const clientStrat = new this.EndpointType(payload);
12638
- if (__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")) {
12639
- clientStrat.receive(__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f"));
13253
+ if (__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f")) {
13254
+ clientStrat.receive(__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f"));
12640
13255
  }
12641
- __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
13256
+ __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
12642
13257
  }
12643
13258
  async closeEndpoint(endpointId) {
12644
- __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
13259
+ __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
12645
13260
  }
12646
13261
  }
12647
13262
  strategy$1.EndpointStrategy = EndpointStrategy;
@@ -12823,12 +13438,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
12823
13438
  }
12824
13439
  runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
12825
13440
 
12826
- var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13441
+ var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12827
13442
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12828
13443
  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");
12829
13444
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12830
13445
  };
12831
- var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13446
+ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12832
13447
  if (kind === "m") throw new TypeError("Private method is not writable");
12833
13448
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12834
13449
  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");
@@ -12870,18 +13485,18 @@ class ChannelProvider extends channel_1.ChannelBase {
12870
13485
  * a read-only array containing all the identities of connecting clients.
12871
13486
  */
12872
13487
  get connections() {
12873
- return [...__classPrivateFieldGet$7(this, _ChannelProvider_connections, "f")];
13488
+ return [...__classPrivateFieldGet$6(this, _ChannelProvider_connections, "f")];
12874
13489
  }
12875
13490
  static handleClientDisconnection(channel, payload) {
12876
13491
  const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
12877
13492
  if (removeById) {
12878
- __classPrivateFieldGet$7(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
13493
+ __classPrivateFieldGet$6(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
12879
13494
  }
12880
13495
  else {
12881
13496
  const multipleRemoves = channel.connections.filter((identity) => {
12882
13497
  return identity.uuid === payload.uuid && identity.name === payload.name;
12883
13498
  });
12884
- multipleRemoves.forEach(__classPrivateFieldGet$7(channel, _ChannelProvider_removeEndpoint, "f"));
13499
+ multipleRemoves.forEach(__classPrivateFieldGet$6(channel, _ChannelProvider_removeEndpoint, "f"));
12885
13500
  }
12886
13501
  channel.disconnectListener(payload);
12887
13502
  }
@@ -12898,8 +13513,8 @@ class ChannelProvider extends channel_1.ChannelBase {
12898
13513
  _ChannelProvider_strategy.set(this, void 0);
12899
13514
  _ChannelProvider_removeEndpoint.set(this, (identity) => {
12900
13515
  const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
12901
- __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
12902
- __classPrivateFieldSet$5(this, _ChannelProvider_connections, remainingConnections, "f");
13516
+ __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
13517
+ __classPrivateFieldSet$4(this, _ChannelProvider_connections, remainingConnections, "f");
12903
13518
  });
12904
13519
  // Must be bound.
12905
13520
  this.processAction = async (action, payload, senderIdentity) => {
@@ -12913,17 +13528,17 @@ class ChannelProvider extends channel_1.ChannelBase {
12913
13528
  return super.processAction(action, payload, senderIdentity);
12914
13529
  };
12915
13530
  _ChannelProvider_close.set(this, () => {
12916
- __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").close();
13531
+ __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").close();
12917
13532
  const remove = ChannelProvider.removalMap.get(this);
12918
13533
  if (remove) {
12919
13534
  remove();
12920
13535
  }
12921
13536
  });
12922
- __classPrivateFieldSet$5(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
13537
+ __classPrivateFieldSet$4(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
12923
13538
  this.connectListener = () => undefined;
12924
13539
  this.disconnectListener = () => undefined;
12925
- __classPrivateFieldSet$5(this, _ChannelProvider_connections, [], "f");
12926
- __classPrivateFieldSet$5(this, _ChannelProvider_strategy, strategy, "f");
13540
+ __classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
13541
+ __classPrivateFieldSet$4(this, _ChannelProvider_strategy, strategy, "f");
12927
13542
  strategy.receive(this.processAction);
12928
13543
  }
12929
13544
  /**
@@ -12954,13 +13569,13 @@ class ChannelProvider extends channel_1.ChannelBase {
12954
13569
  */
12955
13570
  dispatch(to, action, payload) {
12956
13571
  const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
12957
- if (endpointId && __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
12958
- return __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload);
13572
+ if (endpointId && __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
13573
+ return __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload);
12959
13574
  }
12960
13575
  return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
12961
13576
  }
12962
13577
  async processConnection(senderId, payload) {
12963
- __classPrivateFieldGet$7(this, _ChannelProvider_connections, "f").push(senderId);
13578
+ __classPrivateFieldGet$6(this, _ChannelProvider_connections, "f").push(senderId);
12964
13579
  return this.connectListener(senderId, payload);
12965
13580
  }
12966
13581
  /**
@@ -12983,7 +13598,7 @@ class ChannelProvider extends channel_1.ChannelBase {
12983
13598
  * ```
12984
13599
  */
12985
13600
  publish(action, payload) {
12986
- return this.connections.map((to) => __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
13601
+ return this.connections.map((to) => __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
12987
13602
  }
12988
13603
  /**
12989
13604
  * Register a listener that is called on every new client connection.
@@ -13057,11 +13672,11 @@ class ChannelProvider extends channel_1.ChannelBase {
13057
13672
  * ```
13058
13673
  */
13059
13674
  async destroy() {
13060
- const protectedObj = __classPrivateFieldGet$7(this, _ChannelProvider_protectedObj, "f");
13675
+ const protectedObj = __classPrivateFieldGet$6(this, _ChannelProvider_protectedObj, "f");
13061
13676
  protectedObj.providerIdentity;
13062
- __classPrivateFieldSet$5(this, _ChannelProvider_connections, [], "f");
13677
+ __classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
13063
13678
  await protectedObj.close();
13064
- __classPrivateFieldGet$7(this, _ChannelProvider_close, "f").call(this);
13679
+ __classPrivateFieldGet$6(this, _ChannelProvider_close, "f").call(this);
13065
13680
  }
13066
13681
  /**
13067
13682
  * Returns an array with info on every Client connected to the Provider
@@ -13131,7 +13746,7 @@ class ChannelProvider extends channel_1.ChannelBase {
13131
13746
  getEndpointIdForOpenFinId(clientIdentity, action) {
13132
13747
  const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
13133
13748
  if (matchingConnections.length >= 2) {
13134
- const protectedObj = __classPrivateFieldGet$7(this, _ChannelProvider_protectedObj, "f");
13749
+ const protectedObj = __classPrivateFieldGet$6(this, _ChannelProvider_protectedObj, "f");
13135
13750
  const { uuid, name } = clientIdentity;
13136
13751
  const providerUuid = protectedObj?.providerIdentity.uuid;
13137
13752
  const providerName = protectedObj?.providerIdentity.name;
@@ -13340,20 +13955,17 @@ class CombinedStrategy {
13340
13955
  }
13341
13956
  strategy.default = CombinedStrategy;
13342
13957
 
13343
- var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13958
+ var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13344
13959
  if (kind === "m") throw new TypeError("Private method is not writable");
13345
13960
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13346
13961
  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");
13347
13962
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
13348
13963
  };
13349
- var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13964
+ var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13350
13965
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13351
13966
  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");
13352
13967
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13353
13968
  };
13354
- var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
13355
- return (mod && mod.__esModule) ? mod : { "default": mod };
13356
- };
13357
13969
  var _ConnectionManager_messageReceiver, _ConnectionManager_rtcConnectionManager;
13358
13970
  Object.defineProperty(connectionManager, "__esModule", { value: true });
13359
13971
  connectionManager.ConnectionManager = void 0;
@@ -13365,7 +13977,7 @@ const ice_manager_1 = iceManager;
13365
13977
  const provider_1$1 = provider;
13366
13978
  const message_receiver_1 = messageReceiver;
13367
13979
  const protocol_manager_1 = protocolManager;
13368
- const strategy_3 = __importDefault$1(strategy);
13980
+ const strategy_3 = strategy;
13369
13981
  class ConnectionManager extends base_1$a.Base {
13370
13982
  static getProtocolOptionsFromStrings(protocols) {
13371
13983
  return protocols.map((protocol) => {
@@ -13395,8 +14007,8 @@ class ConnectionManager extends base_1$a.Base {
13395
14007
  };
13396
14008
  this.providerMap = new Map();
13397
14009
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
13398
- __classPrivateFieldSet$4(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
13399
- __classPrivateFieldSet$4(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
14010
+ __classPrivateFieldSet$3(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
14011
+ __classPrivateFieldSet$3(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
13400
14012
  wire.registerMessageHandler(this.onmessage.bind(this));
13401
14013
  }
13402
14014
  createProvider(options, providerIdentity) {
@@ -13407,7 +14019,7 @@ class ConnectionManager extends base_1$a.Base {
13407
14019
  case 'rtc':
13408
14020
  return new strategy_2.RTCStrategy();
13409
14021
  case 'classic':
13410
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f"),
14022
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$5(this, _ConnectionManager_messageReceiver, "f"),
13411
14023
  // Providers do not have an endpointId, use channelId as endpointId in the strategy.
13412
14024
  providerIdentity.channelId, providerIdentity);
13413
14025
  default:
@@ -13443,7 +14055,7 @@ class ConnectionManager extends base_1$a.Base {
13443
14055
  const supportedProtocols = await Promise.all(protocols.map(async (type) => {
13444
14056
  switch (type) {
13445
14057
  case 'rtc': {
13446
- const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
14058
+ const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$5(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
13447
14059
  rtcPacket = { rtcClient, channels, channelsOpened };
13448
14060
  return {
13449
14061
  type: 'rtc',
@@ -13470,18 +14082,18 @@ class ConnectionManager extends base_1$a.Base {
13470
14082
  routingInfo.endpointId = this.wire.environment.getNextMessageId();
13471
14083
  // For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
13472
14084
  // clients that are in the same context as the newly-connected client.
13473
- __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
14085
+ __classPrivateFieldGet$5(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
13474
14086
  }
13475
14087
  const answer = routingInfo.answer ?? {
13476
14088
  supportedProtocols: [{ type: 'classic', version: 1 }]
13477
14089
  };
13478
14090
  const createStrategyFromAnswer = async (protocol) => {
13479
14091
  if (protocol.type === 'rtc' && rtcPacket) {
13480
- await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
14092
+ await __classPrivateFieldGet$5(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
13481
14093
  return new strategy_2.RTCStrategy();
13482
14094
  }
13483
14095
  if (protocol.type === 'classic') {
13484
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
14096
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$5(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
13485
14097
  }
13486
14098
  return null;
13487
14099
  };
@@ -13549,7 +14161,7 @@ class ConnectionManager extends base_1$a.Base {
13549
14161
  clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
13550
14162
  const answer = await accumP;
13551
14163
  if (protocolToUse.type === 'rtc') {
13552
- const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
14164
+ const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$5(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
13553
14165
  answer.supportedProtocols.push({
13554
14166
  type: 'rtc',
13555
14167
  version: strategy_2.RTCInfo.version,
@@ -13597,13 +14209,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
13597
14209
  *
13598
14210
  * @packageDocumentation
13599
14211
  */
13600
- var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14212
+ var __classPrivateFieldSet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13601
14213
  if (kind === "m") throw new TypeError("Private method is not writable");
13602
14214
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13603
14215
  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");
13604
14216
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
13605
14217
  };
13606
- var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
14218
+ var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13607
14219
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13608
14220
  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");
13609
14221
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -13612,7 +14224,7 @@ var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnec
13612
14224
  Object.defineProperty(channel$1, "__esModule", { value: true });
13613
14225
  channel$1.Channel = void 0;
13614
14226
  /* eslint-disable no-console */
13615
- const events_1$2 = require$$0$1;
14227
+ const events_1$2 = require$$0;
13616
14228
  const lazy_1$1 = lazy;
13617
14229
  const base_1$9 = base;
13618
14230
  const client_1 = client;
@@ -13660,11 +14272,11 @@ class Channel extends base_1$9.EmitterBase {
13660
14272
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
13661
14273
  }),
13662
14274
  this.on('connected', (...args) => {
13663
- __classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").emit('connected', ...args);
14275
+ __classPrivateFieldGet$4(this, _Channel_internalEmitter, "f").emit('connected', ...args);
13664
14276
  })
13665
14277
  ]).catch(() => new Error('error setting up channel connection listeners'));
13666
14278
  }));
13667
- __classPrivateFieldSet$3(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
14279
+ __classPrivateFieldSet$2(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
13668
14280
  }
13669
14281
  /**
13670
14282
  *
@@ -13739,7 +14351,7 @@ class Channel extends base_1$9.EmitterBase {
13739
14351
  resolve(true);
13740
14352
  }
13741
14353
  };
13742
- __classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
14354
+ __classPrivateFieldGet$4(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
13743
14355
  });
13744
14356
  try {
13745
14357
  if (retryInfo.count > 0) {
@@ -13771,7 +14383,7 @@ class Channel extends base_1$9.EmitterBase {
13771
14383
  finally {
13772
14384
  retryInfo.count += 1;
13773
14385
  // in case of other errors, remove our listener
13774
- __classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
14386
+ __classPrivateFieldGet$4(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
13775
14387
  }
13776
14388
  } while (shouldWait); // If we're waiting we retry the above loop
13777
14389
  // Should wait was false, no channel was found.
@@ -13830,12 +14442,12 @@ class Channel extends base_1$9.EmitterBase {
13830
14442
  async connect(channelName, options = {}) {
13831
14443
  // Make sure we don't connect before listeners are set up
13832
14444
  // This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
13833
- await __classPrivateFieldGet$5(this, _Channel_readyToConnect, "f").getValue();
14445
+ await __classPrivateFieldGet$4(this, _Channel_readyToConnect, "f").getValue();
13834
14446
  if (!channelName || typeof channelName !== 'string') {
13835
14447
  throw new Error('Please provide a channelName string to connect to a channel.');
13836
14448
  }
13837
14449
  const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
13838
- const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createClientOffer(opts);
14450
+ const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createClientOffer(opts);
13839
14451
  let connectionUrl;
13840
14452
  if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
13841
14453
  connectionUrl = (await this.fin.me.getInfo()).url;
@@ -13847,7 +14459,7 @@ class Channel extends base_1$9.EmitterBase {
13847
14459
  connectionUrl
13848
14460
  };
13849
14461
  const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
13850
- const strategy = await __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
14462
+ const strategy = await __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
13851
14463
  const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
13852
14464
  // It is the client's responsibility to handle endpoint disconnection to the provider.
13853
14465
  // If the endpoint dies, the client will force a disconnection through the core.
@@ -13916,7 +14528,7 @@ class Channel extends base_1$9.EmitterBase {
13916
14528
  throw new Error('Please provide a channelName to create a channel');
13917
14529
  }
13918
14530
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
13919
- const channel = __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
14531
+ const channel = __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
13920
14532
  // TODO: fix typing (internal)
13921
14533
  // @ts-expect-error
13922
14534
  this.on('client-disconnected', (eventPayload) => {
@@ -13939,7 +14551,7 @@ interappbus.InterAppPayload = interappbus.InterApplicationBus = void 0;
13939
14551
  *
13940
14552
  * @packageDocumentation
13941
14553
  */
13942
- const events_1$1 = require$$0$1;
14554
+ const events_1$1 = require$$0;
13943
14555
  const base_1$8 = base;
13944
14556
  const ref_counter_1 = refCounter;
13945
14557
  const index_1$2 = channel$1;
@@ -14482,7 +15094,7 @@ var Factory$2 = {};
14482
15094
 
14483
15095
  var Instance$2 = {};
14484
15096
 
14485
- var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
15097
+ var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
14486
15098
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
14487
15099
  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");
14488
15100
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -14515,7 +15127,7 @@ class Platform extends base_1$5.EmitterBase {
14515
15127
  const target = identity || this.identity;
14516
15128
  const { uuid } = target;
14517
15129
  if (!clientMap.has(uuid)) {
14518
- const clientPromise = __classPrivateFieldGet$4(this, _Platform_connectToProvider, "f").call(this, uuid);
15130
+ const clientPromise = __classPrivateFieldGet$3(this, _Platform_connectToProvider, "f").call(this, uuid);
14519
15131
  clientMap.set(uuid, clientPromise);
14520
15132
  }
14521
15133
  // we set it above
@@ -15152,842 +15764,178 @@ class Platform extends base_1$5.EmitterBase {
15152
15764
  * platform.
15153
15765
  * This method can be called from the window itself, or from any child view. Context data is shared by all
15154
15766
  * entities within a window.
15155
- *
15156
- * @example
15157
- * Setting own context:
15158
- * ```js
15159
- * const platform = fin.Platform.getCurrentSync();
15160
- * const contextData = {
15161
- * security: 'STOCK',
15162
- * currentView: 'detailed'
15163
- * }
15164
- *
15165
- * await platform.setWindowContext(contextData);
15166
- * // Context of current window is now set to `contextData`
15167
- * ```
15168
- *
15169
- * Setting the context of another window or view:
15170
- * ```js
15171
- * const platform = fin.Platform.getCurrentSync();
15172
- * const contextData = {
15173
- * security: 'STOCK',
15174
- * currentView: 'detailed'
15175
- * }
15176
- *
15177
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
15178
- * await platform.setWindowContext(contextData, windowOrViewIdentity);
15179
- * // Context of the target window or view is now set to `contextData`
15180
- * ```
15181
- *
15182
- * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
15183
- * This event will fire when a host window's context is updated or when the view is reparented to a new window:
15184
- *
15185
- * ```js
15186
- * // From a view
15187
- * const contextChangeHandler = ({ context }) => {
15188
- * console.log('Host window\'s context has changed. New context data:', context);
15189
- * // react to new context data here
15190
- * }
15191
- * await fin.me.on('host-context-changed', contextChangeHandler);
15192
- *
15193
- * const platform = await fin.Platform.getCurrentSync();
15194
- * const contextData = {
15195
- * security: 'STOCK',
15196
- * currentView: 'detailed'
15197
- * }
15198
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
15199
- * ```
15200
- *
15201
- * To listen to a window's context updates, use the `context-changed` event:
15202
- * ```js
15203
- * // From a window
15204
- * const contextChangeHandler = ({ context }) => {
15205
- * console.log('This window\'s context has changed. New context data:', context);
15206
- * // react to new context data here
15207
- * }
15208
- * await fin.me.on('context-changed', contextChangeHandler);
15209
- *
15210
- * const platform = await fin.Platform.getCurrentSync();
15211
- * const contextData = {
15212
- * security: 'STOCK',
15213
- * currentView: 'detailed'
15214
- * }
15215
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
15216
- * ```
15217
- * @experimental
15218
- */
15219
- async setWindowContext(context = {}, target) {
15220
- this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
15221
- // don't expose
15222
- });
15223
- if (!context) {
15224
- throw new Error('Please provide a serializable object or string to set the context.');
15225
- }
15226
- const client = await this.getClient();
15227
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
15228
- await client.dispatch('set-window-context', {
15229
- context,
15230
- entityType,
15231
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
15232
- });
15233
- }
15234
- /**
15235
- * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
15236
- * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
15237
- * @param target - A target window or view may optionally be provided. If no target is provided, target will be
15238
- * the current window (if called from a Window) or the current host window (if called from a View).
15239
- *
15240
- * @remarks This method can be called from the window itself, or from any child view. Context data is shared
15241
- * by all entities within a window.
15242
- *
15243
- * @example
15244
- *
15245
- * Retrieving context from current window:
15246
- * ```js
15247
- * const platform = fin.Platform.getCurrentSync();
15248
- * const customContext = { answer: 42 };
15249
- * await platform.setWindowContext(customContext);
15250
- *
15251
- * const myContext = await platform.getWindowContext();
15252
- * console.log(myContext); // { answer: 42 }
15253
- * ```
15254
- *
15255
- * Retrieving the context of another window or view:
15256
- * ```js
15257
- * const platform = fin.Platform.getCurrentSync();
15258
- *
15259
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
15260
- *
15261
- * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
15262
- * console.log(targetWindowContext); // context of target window
15263
- * ```
15264
- * @experimental
15265
- */
15266
- async getWindowContext(target) {
15267
- this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
15268
- // don't expose
15269
- });
15270
- const client = await this.getClient();
15271
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
15272
- return client.dispatch('get-window-context', {
15273
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
15274
- entityType
15275
- });
15276
- }
15277
- /**
15278
- * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
15279
- * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
15280
- * @param winId
15281
- * @param options
15282
- *
15283
- * @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,
15284
- * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
15285
- *
15286
- * @example
15287
- *
15288
- * ```js
15289
- * // Close the current Window inside a Window context
15290
- * const platform = await fin.Platform.getCurrent();
15291
- * platform.closeWindow(fin.me.identity);
15292
- *
15293
- * // Close the Window from inside a View context
15294
- * const platform = await fin.Platform.getCurrent();
15295
- * const parentWindow = await fin.me.getCurrentWindow();
15296
- * platform.closeWindow(parentWindow.identity);
15297
- *
15298
- * // Close the Window and do not fire the before unload handler on Views
15299
- * const platform = await fin.Platform.getCurrent();
15300
- * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
15301
- * ```
15302
- * @experimental
15303
- */
15304
- async closeWindow(windowId, options = { skipBeforeUnload: false }) {
15305
- this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
15306
- // don't expose
15307
- });
15308
- const client = await this.getClient();
15309
- return client.dispatch('close-window', { windowId, options });
15310
- }
15311
- }
15312
- Instance$2.Platform = Platform;
15313
- _Platform_connectToProvider = new WeakMap();
15314
-
15315
- var layout = {};
15316
-
15317
- var Factory$1 = {};
15318
-
15319
- var Instance$1 = {};
15320
-
15321
- var layoutEntities = {};
15322
-
15323
- var apiExposer$1 = {};
15324
-
15325
- var apiConsumer = {};
15326
-
15327
- Object.defineProperty(apiConsumer, "__esModule", { value: true });
15328
- apiConsumer.ApiConsumer = void 0;
15329
- /**
15330
- * Consumer for apis exposed with {@see ApiExposer}.
15331
- *
15332
- * A strategy that matches the strategy used to expose a target API must be provided.
15333
- */
15334
- class ApiConsumer {
15335
- // eslint-disable-next-line
15336
- constructor(strategy) {
15337
- this.strategy = strategy;
15338
- /**
15339
- * Consumes an api exposed using a given transport strategy, and generates a client
15340
- * for easy, type safe consumption of that client.
15341
- * @param options Strategy specific consumption options.
15342
- * @returns An api client matching the given type.
15343
- */
15344
- this.consume = async (options) => {
15345
- const exposedProperties = await this.strategy.getExposedFunctions(options);
15346
- return exposedProperties.reduce((client, prop) => ({
15347
- ...client,
15348
- [prop.key]: this.strategy.createFunction(prop, options)
15349
- }), {});
15350
- };
15351
- }
15352
- }
15353
- apiConsumer.ApiConsumer = ApiConsumer;
15354
-
15355
- var apiExposer = {};
15356
-
15357
- var decorators = {};
15358
-
15359
- Object.defineProperty(decorators, "__esModule", { value: true });
15360
- decorators.expose = decorators.getExposedProperties = void 0;
15361
- const exposedProperties = Symbol('exposedProperties');
15362
- const getExposedProperties = (target) => {
15363
- return target[exposedProperties] || target.prototype[exposedProperties] || [];
15364
- };
15365
- decorators.getExposedProperties = getExposedProperties;
15366
- /**
15367
- * Indicates that a class member function can be exposed using {@link ApiExposer}.
15368
- * @param options Options specific to the strategy used in {@link ApiExposer}
15369
- */
15370
- // Returns any as decorator typing is weird.
15371
- const expose = (options) => (target, key, descriptor) => {
15372
- target[exposedProperties] = target[exposedProperties] || [];
15373
- target[exposedProperties].push({ key, descriptor, options });
15374
- };
15375
- decorators.expose = expose;
15376
-
15377
- Object.defineProperty(apiExposer, "__esModule", { value: true });
15378
- apiExposer.ApiExposer = void 0;
15379
- const decorators_1 = decorators;
15380
- /**
15381
- * Exposes api services on the transport of choice.
15382
- */
15383
- class ApiExposer {
15384
- /**
15385
- * @param strategy The expose strategy to use to expose instances.
15386
- */
15387
- // eslint-disable-next-line
15388
- constructor(strategy) {
15389
- this.strategy = strategy;
15390
- /**
15391
- * Exposes an instance of a given api on
15392
- * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
15393
- * @param instanceOptions Transport strategy specific options to use when exposing.
15394
- */
15395
- this.exposeInstance = async (instance, instanceOptions) => {
15396
- const exposableProps = (0, decorators_1.getExposedProperties)(instance);
15397
- const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
15398
- const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
15399
- key,
15400
- options,
15401
- meta: instanceOptions
15402
- });
15403
- return {
15404
- key,
15405
- options: customConsumptionOptions
15406
- };
15407
- }));
15408
- await this.strategy.exposeMeta(instanceOptions, exposedProps);
15409
- };
15410
- }
15411
- ;
15412
- }
15413
- apiExposer.ApiExposer = ApiExposer;
15414
-
15415
- var strategies = {};
15416
-
15417
- var openfinChannels = {};
15418
-
15419
- var channelsConsumer = {};
15420
-
15421
- Object.defineProperty(channelsConsumer, "__esModule", { value: true });
15422
- channelsConsumer.ChannelsConsumer = void 0;
15423
- class ChannelsConsumer {
15424
- // eslint-disable-next-line
15425
- constructor(channel) {
15426
- this.channel = channel;
15427
- this.getExposedFunctions = async (options) => {
15428
- const { id } = options;
15429
- const { props } = await this.channel.dispatch(`api-meta:${id}`);
15430
- return props;
15431
- };
15432
- this.createFunction = (prop) => (...args) => {
15433
- const { action } = prop.options;
15434
- return this.channel.dispatch(action, { args });
15435
- };
15436
- }
15437
- ;
15438
- }
15439
- channelsConsumer.ChannelsConsumer = ChannelsConsumer;
15440
-
15441
- var channelsExposer = {};
15442
-
15443
- Object.defineProperty(channelsExposer, "__esModule", { value: true });
15444
- channelsExposer.ChannelsExposer = void 0;
15445
- class ChannelsExposer {
15446
- // eslint-disable-next-line
15447
- constructor(channelProviderOrClient) {
15448
- this.channelProviderOrClient = channelProviderOrClient;
15449
- this.exposeFunction = async (target, config) => {
15450
- const { key, options, meta } = config;
15451
- const { id } = meta;
15452
- const action = `${id}.${options?.action || key}`;
15453
- await this.channelProviderOrClient.register(action, async ({ args }) => {
15454
- return target(...args);
15455
- });
15456
- return { action };
15457
- };
15458
- this.exposeMeta = async ({ id }, props) => {
15459
- const action = `api-meta:${id}`;
15460
- await this.channelProviderOrClient.register(action, () => ({ props }));
15461
- };
15462
- }
15463
- }
15464
- channelsExposer.ChannelsExposer = ChannelsExposer;
15465
-
15466
- (function (exports) {
15467
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15468
- if (k2 === undefined) k2 = k;
15469
- var desc = Object.getOwnPropertyDescriptor(m, k);
15470
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15471
- desc = { enumerable: true, get: function() { return m[k]; } };
15472
- }
15473
- Object.defineProperty(o, k2, desc);
15474
- }) : (function(o, m, k, k2) {
15475
- if (k2 === undefined) k2 = k;
15476
- o[k2] = m[k];
15477
- }));
15478
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
15479
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15480
- };
15481
- Object.defineProperty(exports, "__esModule", { value: true });
15482
- __exportStar(channelsConsumer, exports);
15483
- __exportStar(channelsExposer, exports);
15484
- } (openfinChannels));
15485
-
15486
- (function (exports) {
15487
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15488
- if (k2 === undefined) k2 = k;
15489
- var desc = Object.getOwnPropertyDescriptor(m, k);
15490
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15491
- desc = { enumerable: true, get: function() { return m[k]; } };
15492
- }
15493
- Object.defineProperty(o, k2, desc);
15494
- }) : (function(o, m, k, k2) {
15495
- if (k2 === undefined) k2 = k;
15496
- o[k2] = m[k];
15497
- }));
15498
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
15499
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15500
- };
15501
- Object.defineProperty(exports, "__esModule", { value: true });
15502
- __exportStar(openfinChannels, exports);
15503
- } (strategies));
15504
-
15505
- (function (exports) {
15506
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15507
- if (k2 === undefined) k2 = k;
15508
- var desc = Object.getOwnPropertyDescriptor(m, k);
15509
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15510
- desc = { enumerable: true, get: function() { return m[k]; } };
15511
- }
15512
- Object.defineProperty(o, k2, desc);
15513
- }) : (function(o, m, k, k2) {
15514
- if (k2 === undefined) k2 = k;
15515
- o[k2] = m[k];
15516
- }));
15517
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
15518
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15519
- };
15520
- Object.defineProperty(exports, "__esModule", { value: true });
15521
- __exportStar(apiConsumer, exports);
15522
- __exportStar(apiExposer, exports);
15523
- __exportStar(strategies, exports);
15524
- __exportStar(decorators, exports);
15525
- } (apiExposer$1));
15526
-
15527
- var channelApiRelay = {};
15528
-
15529
- Object.defineProperty(channelApiRelay, "__esModule", { value: true });
15530
- channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
15531
- const EXPECTED_ERRORS = [
15532
- 'no longer connected',
15533
- 'RTCDataChannel closed unexpectedly',
15534
- 'The client you are trying to dispatch from is disconnected from the target provider',
15535
- ];
15536
- // Checks possible error messages that we want to trap, client error message can originate
15537
- // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
15538
- const isDisconnectedError = (errorMsg) => {
15539
- return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
15540
- };
15541
- /**
15542
- * @internal
15543
- * Create a channel relay for a given channel exposition, allowing a single provider to route
15544
- * actions to the designated clients.
15545
- *
15546
- * Designed to be used in conjunction with @expose
15547
- *
15548
- * @param channelProvider The channel provider to relay the actions on.
15549
- * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
15550
- */
15551
- const relayChannelClientApi = async (channelProvider, relayId) => {
15552
- channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
15553
- return channelProvider.dispatch(target, action, payload);
15554
- });
15555
- await Promise.resolve();
15556
- };
15557
- channelApiRelay.relayChannelClientApi = relayChannelClientApi;
15558
- const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
15559
- try {
15560
- return await client.dispatch(`relay:${relayId}`, {
15561
- action,
15562
- payload,
15563
- target
15564
- });
15565
- }
15566
- catch (e) {
15567
- if (isDisconnectedError(e.message) && relayErrorMsg) {
15568
- throw new Error(relayErrorMsg);
15569
- }
15570
- throw e;
15571
- }
15572
- };
15573
- channelApiRelay.createRelayedDispatch = createRelayedDispatch;
15574
-
15575
- var __classPrivateFieldSet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
15576
- if (kind === "m") throw new TypeError("Private method is not writable");
15577
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15578
- 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");
15579
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15580
- };
15581
- var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
15582
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
15583
- 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");
15584
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15585
- };
15586
- var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
15587
- Object.defineProperty(layoutEntities, "__esModule", { value: true });
15588
- layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
15589
- const api_exposer_1 = apiExposer$1;
15590
- const channel_api_relay_1 = channelApiRelay;
15591
- /*
15592
- This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
15593
- intertwined, and share members via parent abstract class LayoutNode. To prevent circular
15594
- refs, we define and export all the classes here.
15595
- */
15596
- /**
15597
- * @ignore
15598
- * @internal
15599
- * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
15600
- * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
15601
- */
15602
- class LayoutNode {
15603
- /**
15604
- * @internal
15605
- * @ignore
15606
- */
15607
- constructor(client, entityId) {
15608
- /**
15609
- * @ignore
15610
- * @internal
15611
- * ApiClient for {@link LayoutEntitiesController}
15612
- */
15613
- _LayoutNode_client.set(this, void 0);
15614
- /**
15615
- * Checks if the TabStack or ColumnOrRow is the root content item
15616
- *
15617
- * @example
15618
- * ```js
15619
- * if (!fin.me.isView) {
15620
- * throw new Error('Not running in a platform View.');
15621
- * }
15622
- *
15623
- * const stack = await fin.me.getCurrentStack();
15624
- * const isRoot = await stack.isRoot();
15625
- * // The TabStack is root: false
15626
- * console.log(`The TabStack is root: ${isRoot}`);
15627
- *
15628
- * // Retrieves the parent ColumnOrRow
15629
- * const parent = await stack.getParent();
15630
- * const parentIsRoot = await parent.isRoot();
15631
- * // The parent ColumnOrRow is root: true
15632
- * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
15633
- * ```
15634
- */
15635
- this.isRoot = () => __classPrivateFieldGet$3(this, _LayoutNode_client, "f").isRoot(this.entityId);
15636
- /**
15637
- * Checks if the TabStack or ColumnOrRow exists
15638
- *
15639
- * @example
15640
- * ```js
15641
- * if (!fin.me.isView) {
15642
- * throw new Error('Not running in a platform View.');
15643
- * }
15644
- *
15645
- * const stack = await fin.me.getCurrentStack();
15646
- * // Retrieves the parent ColumnOrRow
15647
- * const columnOrRow = await stack.getParent();
15648
- * let exists = await stack.exists();
15649
- * // or
15650
- * let exists = await columnOrRow.exists();
15651
- * // The entity exists: true
15652
- * console.log(`The entity exists: ${exists}`);
15653
- * ```
15654
- */
15655
- this.exists = () => __classPrivateFieldGet$3(this, _LayoutNode_client, "f").exists(this.entityId);
15656
- /**
15657
- * Retrieves the parent of the TabStack or ColumnOrRow
15658
- *
15659
- * @example
15660
- * ```js
15661
- * if (!fin.me.isView) {
15662
- * throw new Error('Not running in a platform View.');
15663
- * }
15664
- *
15665
- * const stack = await fin.me.getCurrentStack();
15666
- * // Retrieves the parent ColumnOrRow
15667
- * const columnOrRow = await stack.getParent();
15668
- *
15669
- * // undefined if entity is the root item
15670
- * let parent = await columnOrRow.getParent();
15671
- * // or
15672
- * let parent = await stack.getParent();
15673
- * ```
15674
- */
15675
- this.getParent = async () => {
15676
- const parent = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").getParent(this.entityId);
15677
- if (!parent) {
15678
- return undefined;
15679
- }
15680
- return LayoutNode.getEntity(parent, __classPrivateFieldGet$3(this, _LayoutNode_client, "f"));
15681
- };
15682
- /**
15683
- * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
15684
- *
15685
- * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
15686
- * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
15687
- * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
15688
- * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
15689
- *
15690
- * @param views The views that will populate the new TabStack.
15691
- * @param options Additional options that control new TabStack creation.
15692
- * @returns The newly-created TabStack.
15693
- *
15694
- * @example
15695
- * ```js
15696
- * if (!fin.me.isView) {
15697
- * throw new Error('Not running in a platform View.');
15698
- * }
15699
- *
15700
- * const stack = await fin.me.getCurrentStack();
15701
- * const columnOrRow = await stack.getParent();
15702
- *
15703
- * // Create view references by supplying a 'name' and 'url'
15704
- * const views = [
15705
- * // if 'name' is undefined, one will be generated
15706
- * // if 'url' is undefined, it will default the view URL to 'about:blank'
15707
- * { name: 'google-view', url: 'http://google.com/'},
15708
- * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
15709
- * ];
15710
- *
15711
- * // Create a view beforehand to be included in the new tab stack
15712
- * const outsideView = await fin.View.create({
15713
- * name: 'outside-bloomberg-view',
15714
- * url: 'https://bloomberg.com/',
15715
- * target: fin.me.identity,
15716
- * });
15717
- *
15718
- * // Views to add can be identities, or the reference views mentioned above
15719
- * const viewsToAdd = [outsideView.identity, ...views];
15720
- *
15721
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
15722
- * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
15723
- * // Or
15724
- * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
15725
- * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
15726
- *
15727
- * ```
15728
- * @experimental
15729
- */
15730
- this.createAdjacentStack = async (views, options) => {
15731
- const entityId = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
15732
- return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$3(this, _LayoutNode_client, "f"));
15733
- };
15734
- /**
15735
- * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
15736
- *
15737
- * @param edge Edge whose adjacent TabStacks will be returned.
15738
- *
15739
- * @example
15740
- * ```js
15741
- * if (!fin.me.isView) {
15742
- * throw new Error('Not running in a platform View.');
15743
- * }
15744
- *
15745
- * const stack = await fin.me.getCurrentStack();
15746
- * const columnOrRow = await stack.getParent();
15747
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
15748
- * let rightStacks = await columnOrRow.getAdjacentStacks('right');
15749
- * let leftStacks = await columnOrRow.getAdjacentStacks('left');
15750
- * // or
15751
- * let rightStacks = await stack.getAdjacentStacks('right');
15752
- * let leftStacks = await stack.getAdjacentStacks('left');
15753
- *
15754
- * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
15755
- *
15756
- * ```
15757
- * @experimental
15758
- */
15759
- this.getAdjacentStacks = async (edge) => {
15760
- const adjacentStacks = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").getAdjacentStacks({
15761
- targetId: this.entityId,
15762
- edge
15763
- });
15764
- return adjacentStacks.map((stack) => LayoutNode.getEntity({
15765
- type: 'stack',
15766
- entityId: stack.entityId
15767
- }, __classPrivateFieldGet$3(this, _LayoutNode_client, "f")));
15768
- };
15769
- __classPrivateFieldSet$2(this, _LayoutNode_client, client, "f");
15770
- this.entityId = entityId;
15771
- }
15772
- }
15773
- layoutEntities.LayoutNode = LayoutNode;
15774
- _LayoutNode_client = new WeakMap();
15775
- /**
15776
- * @ignore
15777
- * @internal
15778
- * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
15779
- * @param client
15780
- * @param controllerId
15781
- * @param identity
15782
- * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
15783
- */
15784
- LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
15785
- 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.');
15786
- const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
15787
- return consumer.consume({ id: controllerId });
15788
- };
15789
- LayoutNode.getEntity = (definition, client) => {
15790
- const { entityId, type } = definition;
15791
- switch (type) {
15792
- case 'column':
15793
- case 'row':
15794
- return new ColumnOrRow(client, entityId, type);
15795
- case 'stack':
15796
- return new TabStack(client, entityId);
15797
- default:
15798
- throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
15799
- }
15800
- };
15801
- /**
15802
- * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
15803
- */
15804
- class TabStack extends LayoutNode {
15805
- /** @internal */
15806
- constructor(client, entityId) {
15807
- super(client, entityId);
15808
- /**
15809
- * @internal
15810
- * ApiClient for {@link LayoutEntitiesController}
15811
- */
15812
- _TabStack_client.set(this, void 0);
15813
- /**
15814
- * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
15815
- */
15816
- this.type = 'stack';
15817
- /**
15818
- * Retrieves a list of all views belonging to this {@link TabStack}.
15819
- *
15820
- * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
15821
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
15822
- * If that happens and then getViews() is called, it will return the identities in a different order than
15823
- * than the currently rendered tab order.
15824
- *
15825
- *
15826
- * @throws If the {@link TabStack} has been destroyed.
15827
- * @example
15828
- * ```js
15829
- * if (!fin.me.isView) {
15830
- * throw new Error('Not running in a platform View.');
15831
- * }
15832
- *
15833
- * const stack = await fin.me.getCurrentStack();
15834
- * // Alternatively, you can wrap any view and get the stack from there
15835
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
15836
- * // const stack = await viewFromSomewhere.getCurrentStack();
15837
- * const views = await stack.getViews();
15838
- * console.log(`Stack contains ${views.length} view(s)`);
15839
- * ```
15840
- * @experimental
15841
- */
15842
- this.getViews = () => __classPrivateFieldGet$3(this, _TabStack_client, "f").getStackViews(this.entityId);
15843
- /**
15844
- * Adds or creates a view in this {@link TabStack}.
15845
- *
15846
- * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
15847
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
15848
- *
15849
- * @param view The identity of an existing view to add, or options to create a view.
15850
- * @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)
15851
- * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
15852
- * @throws If the view does not exist or fails to create.
15853
- * @throws If the {@link TabStack} has been destroyed.
15854
- * @example
15855
- * ```js
15856
- * if (!fin.me.isView) {
15857
- * throw new Error('Not running in a platform View.');
15858
- * }
15859
- *
15860
- * const stack = await fin.me.getCurrentStack();
15861
- * // Alternatively, you can wrap any view and get the stack from there
15862
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
15863
- * // const stack = await viewFromSomewhere.getCurrentStack();
15864
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
15865
- * console.log('Identity of the google view just added', { googleViewIdentity });
15866
- * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
15867
- * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
15868
- * console.log('Identity of the apple view just added', { appleViewIdentity });
15869
- * ```
15870
- * @experimental
15871
- */
15872
- this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$3(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
15873
- /**
15874
- * Removes a view from this {@link TabStack}.
15875
- *
15876
- * @remarks Throws an exception if the view identity does not exist or was already destroyed.
15877
- *
15878
- * @param view - Identity of the view to remove.
15879
- * @throws If the view does not exist or does not belong to the stack.
15880
- * @throws If the {@link TabStack} has been destroyed.
15881
- *
15882
- * @example
15883
- * ```js
15884
- * if (!fin.me.isView) {
15885
- * throw new Error('Not running in a platform View.');
15886
- * }
15887
- *
15888
- * const stack = await fin.me.getCurrentStack();
15889
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
15890
- *
15891
- * await stack.removeView(googleViewIdentity);
15892
- *
15893
- * try {
15894
- * await stack.removeView(googleViewIdentity);
15895
- * } catch (error) {
15896
- * // Tried to remove a view ('google-view') which does not belong to the stack.
15897
- * console.log(error);
15898
- * }
15899
- * ```
15900
- */
15901
- this.removeView = async (view) => {
15902
- await __classPrivateFieldGet$3(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
15903
- };
15904
- /**
15905
- * Sets the active view of the {@link TabStack} without focusing it.
15906
- * @param view - Identity of the view to activate.
15907
- * @returns Promise which resolves with void once the view has been activated.
15908
- * @throws If the {@link TabStack} has been destroyed.
15909
- * @throws If the view does not exist.
15910
- * @example
15911
- * Change the active tab of a known View's TabStack:
15912
- * ```js
15913
- * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
15914
- * const stack = await targetView.getCurrentStack();
15915
- * await stack.setActiveView(targetView.identity);
15916
- * ```
15917
- *
15918
- * Set the current View as active within its TabStack:
15919
- * ```js
15920
- * const stack = await fin.me.getCurrentStack();
15921
- * await stack.setActiveView(fin.me.identity);
15922
- * ```
15923
- * @experimental
15924
- */
15925
- this.setActiveView = async (view) => {
15926
- await __classPrivateFieldGet$3(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
15927
- };
15928
- __classPrivateFieldSet$2(this, _TabStack_client, client, "f");
15767
+ *
15768
+ * @example
15769
+ * Setting own context:
15770
+ * ```js
15771
+ * const platform = fin.Platform.getCurrentSync();
15772
+ * const contextData = {
15773
+ * security: 'STOCK',
15774
+ * currentView: 'detailed'
15775
+ * }
15776
+ *
15777
+ * await platform.setWindowContext(contextData);
15778
+ * // Context of current window is now set to `contextData`
15779
+ * ```
15780
+ *
15781
+ * Setting the context of another window or view:
15782
+ * ```js
15783
+ * const platform = fin.Platform.getCurrentSync();
15784
+ * const contextData = {
15785
+ * security: 'STOCK',
15786
+ * currentView: 'detailed'
15787
+ * }
15788
+ *
15789
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
15790
+ * await platform.setWindowContext(contextData, windowOrViewIdentity);
15791
+ * // Context of the target window or view is now set to `contextData`
15792
+ * ```
15793
+ *
15794
+ * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
15795
+ * This event will fire when a host window's context is updated or when the view is reparented to a new window:
15796
+ *
15797
+ * ```js
15798
+ * // From a view
15799
+ * const contextChangeHandler = ({ context }) => {
15800
+ * console.log('Host window\'s context has changed. New context data:', context);
15801
+ * // react to new context data here
15802
+ * }
15803
+ * await fin.me.on('host-context-changed', contextChangeHandler);
15804
+ *
15805
+ * const platform = await fin.Platform.getCurrentSync();
15806
+ * const contextData = {
15807
+ * security: 'STOCK',
15808
+ * currentView: 'detailed'
15809
+ * }
15810
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
15811
+ * ```
15812
+ *
15813
+ * To listen to a window's context updates, use the `context-changed` event:
15814
+ * ```js
15815
+ * // From a window
15816
+ * const contextChangeHandler = ({ context }) => {
15817
+ * console.log('This window\'s context has changed. New context data:', context);
15818
+ * // react to new context data here
15819
+ * }
15820
+ * await fin.me.on('context-changed', contextChangeHandler);
15821
+ *
15822
+ * const platform = await fin.Platform.getCurrentSync();
15823
+ * const contextData = {
15824
+ * security: 'STOCK',
15825
+ * currentView: 'detailed'
15826
+ * }
15827
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
15828
+ * ```
15829
+ * @experimental
15830
+ */
15831
+ async setWindowContext(context = {}, target) {
15832
+ this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
15833
+ // don't expose
15834
+ });
15835
+ if (!context) {
15836
+ throw new Error('Please provide a serializable object or string to set the context.');
15837
+ }
15838
+ const client = await this.getClient();
15839
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
15840
+ await client.dispatch('set-window-context', {
15841
+ context,
15842
+ entityType,
15843
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
15844
+ });
15929
15845
  }
15930
- }
15931
- layoutEntities.TabStack = TabStack;
15932
- _TabStack_client = new WeakMap();
15933
- /**
15934
- * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
15935
- */
15936
- class ColumnOrRow extends LayoutNode {
15937
15846
  /**
15938
- * @internal
15847
+ * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
15848
+ * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
15849
+ * @param target - A target window or view may optionally be provided. If no target is provided, target will be
15850
+ * the current window (if called from a Window) or the current host window (if called from a View).
15851
+ *
15852
+ * @remarks This method can be called from the window itself, or from any child view. Context data is shared
15853
+ * by all entities within a window.
15854
+ *
15855
+ * @example
15856
+ *
15857
+ * Retrieving context from current window:
15858
+ * ```js
15859
+ * const platform = fin.Platform.getCurrentSync();
15860
+ * const customContext = { answer: 42 };
15861
+ * await platform.setWindowContext(customContext);
15862
+ *
15863
+ * const myContext = await platform.getWindowContext();
15864
+ * console.log(myContext); // { answer: 42 }
15865
+ * ```
15866
+ *
15867
+ * Retrieving the context of another window or view:
15868
+ * ```js
15869
+ * const platform = fin.Platform.getCurrentSync();
15870
+ *
15871
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
15872
+ *
15873
+ * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
15874
+ * console.log(targetWindowContext); // context of target window
15875
+ * ```
15876
+ * @experimental
15939
15877
  */
15940
- constructor(client, entityId, type) {
15941
- super(client, entityId);
15942
- /**
15943
- * @ignore
15944
- * @internal
15945
- * ApiClient for {@link LayoutEntitiesController}
15946
- */
15947
- _ColumnOrRow_client.set(this, void 0);
15948
- /**
15949
- * Retrieves the content array of the ColumnOrRow
15950
- *
15951
- * @example
15952
- * ```js
15953
- * if (!fin.me.isView) {
15954
- * throw new Error('Not running in a platform View.');
15955
- * }
15956
- *
15957
- * const stack = await fin.me.getCurrentStack();
15958
- * // Retrieves the parent ColumnOrRow
15959
- * const columnOrRow = await stack.getParent();
15960
- *
15961
- * // returns [TabStack]
15962
- * const contentArray = await columnOrRow.getContent();
15963
- * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
15964
- * ```
15965
- */
15966
- this.getContent = async () => {
15967
- const contentItemEntities = await __classPrivateFieldGet$3(this, _ColumnOrRow_client, "f").getContent(this.entityId);
15968
- return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$3(this, _ColumnOrRow_client, "f")));
15969
- };
15970
- __classPrivateFieldSet$2(this, _ColumnOrRow_client, client, "f");
15971
- this.type = type;
15878
+ async getWindowContext(target) {
15879
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
15880
+ // don't expose
15881
+ });
15882
+ const client = await this.getClient();
15883
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
15884
+ return client.dispatch('get-window-context', {
15885
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
15886
+ entityType
15887
+ });
15888
+ }
15889
+ /**
15890
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
15891
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
15892
+ * @param winId
15893
+ * @param options
15894
+ *
15895
+ * @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,
15896
+ * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
15897
+ *
15898
+ * @example
15899
+ *
15900
+ * ```js
15901
+ * // Close the current Window inside a Window context
15902
+ * const platform = await fin.Platform.getCurrent();
15903
+ * platform.closeWindow(fin.me.identity);
15904
+ *
15905
+ * // Close the Window from inside a View context
15906
+ * const platform = await fin.Platform.getCurrent();
15907
+ * const parentWindow = await fin.me.getCurrentWindow();
15908
+ * platform.closeWindow(parentWindow.identity);
15909
+ *
15910
+ * // Close the Window and do not fire the before unload handler on Views
15911
+ * const platform = await fin.Platform.getCurrent();
15912
+ * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
15913
+ * ```
15914
+ * @experimental
15915
+ */
15916
+ async closeWindow(windowId, options = { skipBeforeUnload: false }) {
15917
+ this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
15918
+ // don't expose
15919
+ });
15920
+ const client = await this.getClient();
15921
+ return client.dispatch('close-window', { windowId, options });
15972
15922
  }
15973
15923
  }
15974
- layoutEntities.ColumnOrRow = ColumnOrRow;
15975
- _ColumnOrRow_client = new WeakMap();
15924
+ Instance$2.Platform = Platform;
15925
+ _Platform_connectToProvider = new WeakMap();
15976
15926
 
15977
- var layout_constants = {};
15927
+ var layout = {};
15978
15928
 
15979
- Object.defineProperty(layout_constants, "__esModule", { value: true });
15980
- layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
15981
- layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
15982
- // TODO: eventually export this somehow
15983
- layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
15929
+ var Factory$1 = {};
15930
+
15931
+ var Instance$1 = {};
15984
15932
 
15985
15933
  var __classPrivateFieldGet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
15986
15934
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
15987
15935
  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");
15988
15936
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15989
15937
  };
15990
- var _Layout_instances, _Layout_layoutClient, _Layout_forwardLayoutAction;
15938
+ var _Layout_layoutClient;
15991
15939
  Object.defineProperty(Instance$1, "__esModule", { value: true });
15992
15940
  Instance$1.Layout = void 0;
15993
15941
  const lazy_1 = lazy;
@@ -16129,19 +16077,12 @@ const layout_constants_1$1 = layout_constants;
16129
16077
  * ```
16130
16078
  */
16131
16079
  class Layout extends base_1$4.Base {
16132
- /**
16133
- * @internal
16134
- */
16135
- static getClient(layout) {
16136
- return __classPrivateFieldGet$2(layout, _Layout_layoutClient, "f").getValue();
16137
- }
16138
16080
  /**
16139
16081
  * @internal
16140
16082
  */
16141
16083
  // eslint-disable-next-line no-shadow
16142
16084
  constructor(identity, wire) {
16143
16085
  super(wire);
16144
- _Layout_instances.add(this);
16145
16086
  /**
16146
16087
  * @internal
16147
16088
  * Lazily constructed {@link LayoutEntitiesClient} bound to this platform's client and identity
@@ -16360,71 +16301,9 @@ class Layout extends base_1$4.Base {
16360
16301
  const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
16361
16302
  return layout_entities_1.LayoutNode.getEntity(root, client);
16362
16303
  }
16363
- /**
16364
- * Retrieves the OpenFin.TabStack instance which the View belongs to.
16365
- *
16366
- * @example
16367
- * ```js
16368
- * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
16369
- * const stack = await fin.View.wrapSync(viewIdentity).getStackByViewIdentity(viewIdentity);
16370
- * console.log(await stack.getViews());
16371
- * ```
16372
- */
16373
- async getStackByViewIdentity(identity) {
16374
- this.wire.sendAction('layout-get-stack-by-view').catch(() => {
16375
- // don't expose
16376
- });
16377
- const client = await __classPrivateFieldGet$2(this, _Layout_layoutClient, "f").getValue();
16378
- const stack = await client.getStackByView(identity);
16379
- if (!stack) {
16380
- throw new Error(`No stack found for view: ${identity.uuid}/${identity.name}`);
16381
- }
16382
- return layout_entities_1.LayoutNode.getEntity(stack, client);
16383
- }
16384
- /**
16385
- * Adds a view to the platform layout. Behaves like @link{Platform#createView} with the current layout as the target.
16386
- *
16387
- * @param viewOptions - The options for creating the view.
16388
- * @param options - Optional parameters for adding the view.
16389
- * @param options.location - The location where the view should be added.
16390
- * @param options.targetView - The target view to which the new view should be added.
16391
- * @returns A promise that resolves to an object containing the identity of the added view.
16392
- */
16393
- async addView(viewOptions, { location, targetView } = {}) {
16394
- this.wire.sendAction('layout-add-view').catch((e) => {
16395
- // don't expose
16396
- });
16397
- const { identity } = await __classPrivateFieldGet$2(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-add-view', {
16398
- viewOptions,
16399
- location,
16400
- targetView
16401
- });
16402
- return { identity };
16403
- }
16404
- /**
16405
- * Closes a view by its identity. Throws an error if the view does not belong to the current layout.
16406
- * Behaves like @link{Platform#closeView} but only closes the view if it belongs the current layout.
16407
- *
16408
- * @param viewIdentity - The identity of the view to close.
16409
- * @returns A promise that resolves when the view is closed.
16410
- */
16411
- async closeView(viewIdentity) {
16412
- this.wire.sendAction('layout-close-view').catch((e) => {
16413
- // don't expose
16414
- });
16415
- await __classPrivateFieldGet$2(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-close-view', { viewIdentity });
16416
- }
16417
16304
  }
16418
16305
  Instance$1.Layout = Layout;
16419
- _Layout_layoutClient = new WeakMap(), _Layout_instances = new WeakSet(), _Layout_forwardLayoutAction =
16420
- /**
16421
- * @internal
16422
- * Use to type-guard actions sent to the layout via the provider.
16423
- */
16424
- async function _Layout_forwardLayoutAction(action, payload) {
16425
- const client = await this.platform.getClient();
16426
- return client.dispatch(action, { target: this.identity, opts: payload });
16427
- };
16306
+ _Layout_layoutClient = new WeakMap();
16428
16307
 
16429
16308
  var __classPrivateFieldGet$1 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
16430
16309
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -16615,7 +16494,7 @@ class LayoutModule extends base_1$3.Base {
16615
16494
  this.wire.sendAction('layout-get-current').catch((e) => {
16616
16495
  // don't expose
16617
16496
  });
16618
- if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
16497
+ if (!this.fin.me.isWindow) {
16619
16498
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
16620
16499
  }
16621
16500
  const { uuid, name } = this.fin.me;
@@ -16638,54 +16517,12 @@ class LayoutModule extends base_1$3.Base {
16638
16517
  this.wire.sendAction('layout-get-current-sync').catch((e) => {
16639
16518
  // don't expose
16640
16519
  });
16641
- if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
16520
+ if (!this.fin.me.isWindow) {
16642
16521
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
16643
16522
  }
16644
16523
  const { uuid, name } = this.fin.me;
16645
16524
  return this.wrapSync({ uuid, name });
16646
16525
  }
16647
- /**
16648
- * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
16649
- *
16650
- * @example
16651
- * ```js
16652
- * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
16653
- * const layout = await fin.Platform.Layout.getLayoutByViewIdentity(viewIdentity);
16654
- * console.log(await layout.getCurrentViews());
16655
- * ```
16656
- */
16657
- async getLayoutByViewIdentity(viewIdentity) {
16658
- this.wire.sendAction('layout-get-by-view-identity').catch(() => {
16659
- // don't expose
16660
- });
16661
- const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
16662
- let layoutWindowIdentity = winIdentity;
16663
- // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
16664
- if (layoutWindowIdentity.identity) {
16665
- layoutWindowIdentity = layoutWindowIdentity.identity;
16666
- }
16667
- try {
16668
- const layoutWindow = this.wrapSync(layoutWindowIdentity);
16669
- const client = await Instance_1$2.Layout.getClient(layoutWindow);
16670
- const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(viewIdentity);
16671
- return this.wrapSync(layoutIdentity);
16672
- }
16673
- catch (e) {
16674
- const allowedErrors = [
16675
- 'No action registered at target for',
16676
- 'getLayoutIdentityForViewOrThrow is not a function'
16677
- ];
16678
- if (!allowedErrors.some((m) => e.message.includes(m))) {
16679
- throw e;
16680
- }
16681
- // If a view is attached to provider window, return null
16682
- if (layoutWindowIdentity.uuid === layoutWindowIdentity.name) {
16683
- throw new Error(`View identity ${JSON.stringify(viewIdentity)} is not attached to any layout in provider window ${JSON.stringify(layoutWindowIdentity)}.`);
16684
- }
16685
- // fallback logic for missing endpoint in older runtimes
16686
- return this.wrapSync(layoutWindowIdentity);
16687
- }
16688
- }
16689
16526
  }
16690
16527
  Factory$1.LayoutModule = LayoutModule;
16691
16528
  _LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
@@ -17281,7 +17118,7 @@ Factory.SnapshotSourceModule = SnapshotSourceModule;
17281
17118
 
17282
17119
  Object.defineProperty(fin$1, "__esModule", { value: true });
17283
17120
  var Fin_1 = fin$1.Fin = void 0;
17284
- const events_1 = require$$0$1;
17121
+ const events_1 = require$$0;
17285
17122
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
17286
17123
  const index_1 = system;
17287
17124
  const index_2 = requireWindow();
@@ -17330,15 +17167,12 @@ Fin_1 = fin$1.Fin = Fin;
17330
17167
 
17331
17168
  var browser = {};
17332
17169
 
17333
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
17334
- return (mod && mod.__esModule) ? mod : { "default": mod };
17335
- };
17336
17170
  Object.defineProperty(browser, "__esModule", { value: true });
17337
17171
  browser.remoteConnectInterop = browser.remoteConnect = getRemoteConnectionPayload_1 = browser.getRemoteConnectionPayload = void 0;
17338
17172
  const fin_1 = fin$1;
17339
17173
  const browser_1 = browser$1;
17340
17174
  const transport_1 = transport;
17341
- const websocket_1 = __importDefault(websocket);
17175
+ const websocket_1 = websocket;
17342
17176
  async function getRemoteConnectionPayload(fin, uuid = `browser-connection-${Math.random().toString().slice(2)}`, interopProviderId = fin.me.uuid) {
17343
17177
  const { token } = await fin.System.registerExternalConnection(uuid);
17344
17178
  const { port } = await fin.System.getRuntimeInfo();