@openfin/core 41.103.2 → 41.103.9

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.
package/out/stub.js CHANGED
@@ -332,35 +332,6 @@ var system = {};
332
332
 
333
333
  var base = {};
334
334
 
335
- var promises = {};
336
-
337
- Object.defineProperty(promises, "__esModule", { value: true });
338
- promises.promiseMapSerial = promises.serial = promises.promiseMap = promises.promisify = void 0;
339
- function promisify(func) {
340
- return (...args) => new Promise((resolve, reject) => {
341
- func(...args, (err, val) => (err ? reject(err) : resolve(val)));
342
- });
343
- }
344
- promises.promisify = promisify;
345
- async function promiseMap(arr, asyncF) {
346
- return Promise.all(arr.map(asyncF));
347
- }
348
- promises.promiseMap = promiseMap;
349
- async function serial(arr) {
350
- const ret = [];
351
- for (const func of arr) {
352
- // eslint-disable-next-line no-await-in-loop
353
- const next = await func();
354
- ret.push(next);
355
- }
356
- return ret;
357
- }
358
- promises.serial = serial;
359
- async function promiseMapSerial(arr, func) {
360
- return serial(arr.map((value, index, array) => () => func(value, index, array)));
361
- }
362
- promises.promiseMapSerial = promiseMapSerial;
363
-
364
335
  var __classPrivateFieldSet$h = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
365
336
  if (kind === "m") throw new TypeError("Private method is not writable");
366
337
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -375,7 +346,6 @@ var __classPrivateFieldGet$i = (commonjsGlobal && commonjsGlobal.__classPrivateF
375
346
  var _EmitterBase_emitterAccessor, _EmitterBase_deregisterOnceListeners;
376
347
  Object.defineProperty(base, "__esModule", { value: true });
377
348
  base.Reply = base.EmitterBase = base.Base = void 0;
378
- const promises_1 = promises;
379
349
  class Base {
380
350
  /**
381
351
  * @internal
@@ -453,27 +423,8 @@ class EmitterBase extends Base {
453
423
  return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
454
424
  };
455
425
  this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
456
- /**
457
- * Cleans up after removal of a listener, e.g. deleting any lingering deregistration handlers for a
458
- * `once` subscription.
459
- *
460
- * @remarks Implementing this as a `removeListener` handler ensures that direct removal of a listener
461
- * on the base emitter will not leak additional core handlers. We could do this in the forwarding method,
462
- * which would involve less "magic," but would be more-vulnerable to accidental re-introduction of a leak.
463
- */
464
- this.cleanUpRemovedListener = (eventType, listener) => {
465
- const deregister = __classPrivateFieldGet$i(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
466
- if (deregister) {
467
- const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
468
- emitter.removeListener(eventType, deregister);
469
- }
470
- };
471
426
  this.getOrCreateEmitter = () => {
472
- const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
473
- if (!emitter.listeners('removeListener').includes(this.cleanUpRemovedListener)) {
474
- emitter.on('removeListener', this.cleanUpRemovedListener);
475
- }
476
- return emitter;
427
+ return this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
477
428
  };
478
429
  this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
479
430
  this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
@@ -513,7 +464,6 @@ class EmitterBase extends Base {
513
464
  };
514
465
  __classPrivateFieldSet$h(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
515
466
  __classPrivateFieldSet$h(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
516
- this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
517
467
  }
518
468
  /**
519
469
  * Adds a listener to the end of the listeners array for the specified event.
@@ -591,6 +541,10 @@ class EmitterBase extends Base {
591
541
  const emitter = await this.deregisterEventListener(eventType, options);
592
542
  if (emitter) {
593
543
  emitter.removeListener(eventType, listener);
544
+ const deregister = __classPrivateFieldGet$i(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
545
+ if (deregister) {
546
+ emitter.removeListener(eventType, deregister);
547
+ }
594
548
  this.deleteEmitterIfNothingRegistered(emitter);
595
549
  }
596
550
  return this;
@@ -626,12 +580,13 @@ class EmitterBase extends Base {
626
580
  }
627
581
  else if (this.hasEmitter()) {
628
582
  const events = this.getOrCreateEmitter().eventNames();
629
- await (0, promises_1.promiseMap)(events, removeByEvent);
583
+ await Promise.all(events.map(removeByEvent));
630
584
  }
631
585
  return this;
632
586
  }
633
587
  deleteEmitterIfNothingRegistered(emitter) {
634
- if (emitter.eventNames().every((type) => type === 'removeListener')) {
588
+ // TODO: maybe emitterMap should clean up itself..
589
+ if (emitter.eventNames().length === 0) {
635
590
  this.wire.eventAggregator.delete(__classPrivateFieldGet$i(this, _EmitterBase_emitterAccessor, "f"));
636
591
  }
637
592
  }
@@ -864,11 +819,11 @@ const handleDeprecatedWarnings = (options) => {
864
819
  };
865
820
  warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
866
821
 
867
- var hasRequiredFactory$2;
822
+ var hasRequiredFactory$1;
868
823
 
869
- function requireFactory$2 () {
870
- if (hasRequiredFactory$2) return Factory$6;
871
- hasRequiredFactory$2 = 1;
824
+ function requireFactory$1 () {
825
+ if (hasRequiredFactory$1) return Factory$6;
826
+ hasRequiredFactory$1 = 1;
872
827
  Object.defineProperty(Factory$6, "__esModule", { value: true });
873
828
  Factory$6.ViewModule = void 0;
874
829
  const base_1 = base;
@@ -940,9 +895,7 @@ function requireFactory$2 () {
940
895
  * @experimental
941
896
  */
942
897
  async wrap(identity) {
943
- this.wire.sendAction('view-wrap').catch((e) => {
944
- // we do not want to expose this error, just continue if this analytics-only call fails
945
- });
898
+ this.wire.recordAnalytic('view-wrap');
946
899
  const errorMsg = (0, validate_1.validateIdentity)(identity);
947
900
  if (errorMsg) {
948
901
  throw new Error(errorMsg);
@@ -964,9 +917,7 @@ function requireFactory$2 () {
964
917
  * @experimental
965
918
  */
966
919
  wrapSync(identity) {
967
- this.wire.sendAction('view-wrap-sync').catch((e) => {
968
- // we do not want to expose this error, just continue if this analytics-only call fails
969
- });
920
+ this.wire.recordAnalytic('view-wrap-sync');
970
921
  const errorMsg = (0, validate_1.validateIdentity)(identity);
971
922
  if (errorMsg) {
972
923
  throw new Error(errorMsg);
@@ -986,9 +937,7 @@ function requireFactory$2 () {
986
937
  * @experimental
987
938
  */
988
939
  getCurrent() {
989
- this.wire.sendAction('view-get-current').catch((e) => {
990
- // we do not want to expose this error, just continue if this analytics-only call fails
991
- });
940
+ this.wire.recordAnalytic('view-get-current');
992
941
  if (!this.wire.me.isView) {
993
942
  throw new Error('You are not in a View context');
994
943
  }
@@ -1007,9 +956,7 @@ function requireFactory$2 () {
1007
956
  * @experimental
1008
957
  */
1009
958
  getCurrentSync() {
1010
- this.wire.sendAction('view-get-current-sync').catch((e) => {
1011
- // we do not want to expose this error, just continue if this analytics-only call fails
1012
- });
959
+ this.wire.recordAnalytic('view-get-current-sync');
1013
960
  if (!this.wire.me.isView) {
1014
961
  throw new Error('You are not in a View context');
1015
962
  }
@@ -1083,8 +1030,8 @@ var main = {};
1083
1030
 
1084
1031
  Object.defineProperty(main, "__esModule", { value: true });
1085
1032
  main.WebContents = void 0;
1086
- const base_1$m = base;
1087
- class WebContents extends base_1$m.EmitterBase {
1033
+ const base_1$o = base;
1034
+ class WebContents extends base_1$o.EmitterBase {
1088
1035
  /**
1089
1036
  * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1090
1037
  * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
@@ -2077,9 +2024,7 @@ class WebContents extends base_1$m.EmitterBase {
2077
2024
  * {@link OpenFin.WebContentsEvents event namespace}.
2078
2025
  */
2079
2026
  async showPopupWindow(options) {
2080
- this.wire.sendAction(`${this.entityType}-show-popup-window`, this.identity).catch(() => {
2081
- // we do not want to expose this error, just continue if this analytics-only call fails
2082
- });
2027
+ this.wire.recordAnalytic(`${this.entityType}-show-popup-window`);
2083
2028
  if (options?.onPopupReady) {
2084
2029
  const readyListener = async ({ popupName }) => {
2085
2030
  try {
@@ -2165,11 +2110,11 @@ class WebContents extends base_1$m.EmitterBase {
2165
2110
  }
2166
2111
  main.WebContents = WebContents;
2167
2112
 
2168
- var hasRequiredInstance$2;
2113
+ var hasRequiredInstance$1;
2169
2114
 
2170
- function requireInstance$2 () {
2171
- if (hasRequiredInstance$2) return Instance$5;
2172
- hasRequiredInstance$2 = 1;
2115
+ function requireInstance$1 () {
2116
+ if (hasRequiredInstance$1) return Instance$5;
2117
+ hasRequiredInstance$1 = 1;
2173
2118
  var _View_providerChannelClient;
2174
2119
  Object.defineProperty(Instance$5, "__esModule", { value: true });
2175
2120
  Instance$5.View = void 0;
@@ -2505,9 +2450,7 @@ function requireInstance$2 () {
2505
2450
  * @experimental
2506
2451
  */
2507
2452
  this.getParentLayout = async () => {
2508
- this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
2509
- // don't expose
2510
- });
2453
+ this.wire.recordAnalytic('view-get-parent-layout');
2511
2454
  return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
2512
2455
  };
2513
2456
  /**
@@ -2620,9 +2563,7 @@ function requireInstance$2 () {
2620
2563
  * ```
2621
2564
  */
2622
2565
  this.getCurrentStack = async () => {
2623
- this.wire.sendAction('view-get-current-stack').catch(() => {
2624
- // don't expose
2625
- });
2566
+ this.wire.recordAnalytic('view-get-current-stack');
2626
2567
  try {
2627
2568
  const layout = await this.getParentLayout();
2628
2569
  return layout.getStackByViewIdentity(this.identity);
@@ -2749,1160 +2690,1117 @@ function requireView () {
2749
2690
  *
2750
2691
  * @packageDocumentation
2751
2692
  */
2752
- __exportStar(requireFactory$2(), exports);
2753
- __exportStar(requireInstance$2(), exports);
2693
+ __exportStar(requireFactory$1(), exports);
2694
+ __exportStar(requireInstance$1(), exports);
2754
2695
  } (view));
2755
2696
  return view;
2756
2697
  }
2757
2698
 
2758
- var hasRequiredInstance$1;
2759
-
2760
- function requireInstance$1 () {
2761
- if (hasRequiredInstance$1) return Instance$6;
2762
- hasRequiredInstance$1 = 1;
2763
- Object.defineProperty(Instance$6, "__esModule", { value: true });
2764
- Instance$6.Application = void 0;
2765
- /* eslint-disable import/prefer-default-export */
2766
- const base_1 = base;
2767
- const window_1 = requireWindow();
2768
- const view_1 = requireView();
2769
- /**
2770
- * An object representing an application. Allows the developer to create,
2771
- * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2772
- */
2773
- class Application extends base_1.EmitterBase {
2774
- /**
2775
- * @internal
2776
- */
2777
- constructor(wire, identity) {
2778
- super(wire, 'application', identity.uuid);
2779
- this.identity = identity;
2780
- this.window = new window_1._Window(this.wire, {
2781
- uuid: this.identity.uuid,
2782
- name: this.identity.uuid
2783
- });
2784
- }
2785
- windowListFromIdentityList(identityList) {
2786
- const windowList = [];
2787
- identityList.forEach((identity) => {
2788
- windowList.push(new window_1._Window(this.wire, {
2789
- uuid: identity.uuid,
2790
- name: identity.name
2791
- }));
2792
- });
2793
- return windowList;
2794
- }
2795
- /**
2796
- * Determines if the application is currently running.
2797
- *
2798
- * @example
2799
- *
2800
- * ```js
2801
- * async function isAppRunning() {
2802
- * const app = await fin.Application.getCurrent();
2803
- * return await app.isRunning();
2804
- * }
2805
- * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2806
- * ```
2807
- */
2808
- isRunning() {
2809
- return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2810
- }
2811
- /**
2812
- * Closes the application and any child windows created by the application.
2813
- * Cleans the application from state so it is no longer found in getAllApplications.
2814
- * @param force Close will be prevented from closing when force is false and
2815
- * ‘close-requested’ has been subscribed to for application’s main window.
2816
- *
2817
- * @example
2818
- *
2819
- * ```js
2820
- * async function closeApp() {
2821
- * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2822
- * const app = await fin.Application.wrap({uuid: 'app2'});
2823
- * await app.quit();
2824
- * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2825
- *
2826
- * }
2827
- * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2828
- * ```
2829
- */
2830
- async quit(force = false) {
2831
- try {
2832
- await this._close(force);
2833
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
2834
- }
2835
- catch (error) {
2836
- const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2837
- if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2838
- throw error;
2839
- }
2840
- }
2841
- }
2842
- async _close(force = false) {
2843
- try {
2844
- await this.wire.sendAction('close-application', { force, ...this.identity });
2845
- }
2846
- catch (error) {
2847
- if (!error.message.includes('Remote connection has closed')) {
2848
- throw error;
2849
- }
2850
- }
2851
- }
2852
- /**
2853
- * @deprecated use Application.quit instead
2854
- * Closes the application and any child windows created by the application.
2855
- * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2856
- * @param callback - called if the method succeeds.
2857
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2858
- *
2859
- * @example
2860
- *
2861
- * ```js
2862
- * async function closeApp() {
2863
- * const app = await fin.Application.getCurrent();
2864
- * return await app.close();
2865
- * }
2866
- * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2867
- * ```
2868
- */
2869
- close(force = false) {
2870
- console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2871
- this.wire.sendAction('application-close', this.identity).catch((e) => {
2872
- // we do not want to expose this error, just continue if this analytics-only call fails
2873
- });
2874
- return this._close(force);
2875
- }
2876
- /**
2877
- * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2878
- *
2879
- * @example
2880
- *
2881
- * ```js
2882
- * async function getChildWindows() {
2883
- * const app = await fin.Application.getCurrent();
2884
- * return await app.getChildWindows();
2885
- * }
2886
- *
2887
- * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2888
- * ```
2889
- */
2890
- getChildWindows() {
2891
- return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2892
- const identityList = [];
2893
- payload.data.forEach((winName) => {
2894
- identityList.push({ uuid: this.identity.uuid, name: winName });
2895
- });
2896
- return this.windowListFromIdentityList(identityList);
2897
- });
2898
- }
2899
- /**
2900
- * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2901
- * if the application was not created from a manifest.
2902
- *
2903
- * @example
2904
- *
2905
- * ```js
2906
- * async function getManifest() {
2907
- * const app = await fin.Application.getCurrent();
2908
- * return await app.getManifest();
2909
- * }
2910
- *
2911
- * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2912
- * ```
2913
- */
2914
- getManifest() {
2915
- return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2916
- }
2917
- /**
2918
- * Retrieves UUID of the application that launches this application. Invokes the error callback
2919
- * if the application was created from a manifest.
2920
- *
2921
- * @example
2922
- *
2923
- * ```js
2924
- * async function getParentUuid() {
2925
- * const app = await fin.Application.start({
2926
- * uuid: 'app-1',
2927
- * name: 'myApp',
2928
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2929
- * autoShow: true
2930
- * });
2931
- * return await app.getParentUuid();
2932
- * }
2933
- *
2934
- * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2935
- * ```
2936
- */
2937
- getParentUuid() {
2938
- return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2939
- }
2940
- /**
2941
- * Retrieves current application's shortcut configuration.
2942
- *
2943
- * @example
2944
- *
2945
- * ```js
2946
- * async function getShortcuts() {
2947
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
2948
- * return await app.getShortcuts();
2949
- * }
2950
- * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2951
- * ```
2952
- */
2953
- getShortcuts() {
2954
- return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2955
- }
2956
- /**
2957
- * Retrieves current application's views.
2958
- * @experimental
2959
- *
2960
- * @example
2961
- *
2962
- * ```js
2963
- * async function getViews() {
2964
- * const app = await fin.Application.getCurrent();
2965
- * return await app.getViews();
2966
- * }
2967
- * getViews().then(views => console.log(views)).catch(err => console.log(err));
2968
- * ```
2969
- */
2970
- async getViews() {
2971
- const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2972
- return payload.data.map((id) => new view_1.View(this.wire, id));
2973
- }
2974
- /**
2975
- * Returns the current zoom level of the application.
2976
- *
2977
- * @example
2978
- *
2979
- * ```js
2980
- * async function getZoomLevel() {
2981
- * const app = await fin.Application.getCurrent();
2982
- * return await app.getZoomLevel();
2983
- * }
2984
- *
2985
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2986
- * ```
2987
- */
2988
- getZoomLevel() {
2989
- return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2990
- }
2991
- /**
2992
- * Returns an instance of the main Window of the application
2993
- *
2994
- * @example
2995
- *
2996
- * ```js
2997
- * async function getWindow() {
2998
- * const app = await fin.Application.start({
2999
- * uuid: 'app-1',
3000
- * name: 'myApp',
3001
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
3002
- * autoShow: true
3003
- * });
3004
- * return await app.getWindow();
3005
- * }
3006
- *
3007
- * getWindow().then(win => {
3008
- * win.showAt(0, 400);
3009
- * win.flash();
3010
- * }).catch(err => console.log(err));
3011
- * ```
3012
- */
3013
- getWindow() {
3014
- this.wire.sendAction('application-get-window', this.identity).catch((e) => {
3015
- // we do not want to expose this error, just continue if this analytics-only call fails
3016
- });
3017
- return Promise.resolve(this.window);
3018
- }
3019
- /**
3020
- * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
3021
- * @param userName - username to be passed to the RVM.
3022
- * @param appName - app name to be passed to the RVM.
3023
- *
3024
- * @example
3025
- *
3026
- * ```js
3027
- * async function registerUser() {
3028
- * const app = await fin.Application.getCurrent();
3029
- * return await app.registerUser('user', 'myApp');
3030
- * }
3031
- *
3032
- * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
3033
- * ```
3034
- */
3035
- registerUser(userName, appName) {
3036
- return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
3037
- }
3038
- /**
3039
- * Removes the application’s icon from the tray.
3040
- *
3041
- * @example
3042
- *
3043
- * ```js
3044
- * async function removeTrayIcon() {
3045
- * const app = await fin.Application.getCurrent();
3046
- * return await app.removeTrayIcon();
3047
- * }
3048
- *
3049
- * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
3050
- * ```
3051
- */
3052
- removeTrayIcon() {
3053
- return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
3054
- }
3055
- /**
3056
- * Restarts the application.
3057
- *
3058
- * @example
3059
- *
3060
- * ```js
3061
- * async function restartApp() {
3062
- * const app = await fin.Application.getCurrent();
3063
- * return await app.restart();
3064
- * }
3065
- * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
3066
- * ```
3067
- */
3068
- restart() {
3069
- return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3070
- }
3071
- /**
3072
- * DEPRECATED method to run the application.
3073
- * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3074
- *
3075
- * @example
3076
- *
3077
- * ```js
3078
- * async function run() {
3079
- * const app = await fin.Application.create({
3080
- * name: 'myApp',
3081
- * uuid: 'app-1',
3082
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3083
- * autoShow: true
3084
- * });
3085
- * await app.run();
3086
- * }
3087
- * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3088
- * ```
3089
- *
3090
- * @ignore
3091
- */
3092
- run() {
3093
- console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3094
- this.wire.sendAction('application-run', this.identity).catch((e) => {
3095
- // we do not want to expose this error, just continue if this analytics-only call fails
3096
- });
3097
- return this._run();
3098
- }
3099
- _run(opts = {}) {
3100
- return this.wire
3101
- .sendAction('run-application', {
3102
- manifestUrl: this._manifestUrl,
3103
- opts,
3104
- ...this.identity
3105
- })
3106
- .then(() => undefined);
3107
- }
3108
- /**
3109
- * Instructs the RVM to schedule one restart of the application.
3110
- *
3111
- * @example
3112
- *
3113
- * ```js
3114
- * async function scheduleRestart() {
3115
- * const app = await fin.Application.getCurrent();
3116
- * return await app.scheduleRestart();
3117
- * }
3118
- *
3119
- * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3120
- * ```
3121
- */
3122
- scheduleRestart() {
3123
- return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3124
- }
3125
- /**
3126
- * Sends a message to the RVM to upload the application's logs. On success,
3127
- * an object containing logId is returned.
3128
- *
3129
- * @example
3130
- *
3131
- * ```js
3132
- * async function sendLog() {
3133
- * const app = await fin.Application.getCurrent();
3134
- * return await app.sendApplicationLog();
3135
- * }
3136
- *
3137
- * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3138
- * ```
3139
- */
3140
- async sendApplicationLog() {
3141
- const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3142
- return payload.data;
3143
- }
3144
- /**
3145
- * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3146
- * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3147
- *
3148
- * Note: If the "name" property is omitted it defaults to "tasks".
3149
- * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3150
- *
3151
- *
3152
- * @remarks If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3153
- *
3154
- * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3155
- * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3156
- *
3157
- * Note: If the "name" property is omitted it defaults to "tasks".
3158
- *
3159
- * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3160
- * uuid or shortcut.name is changed.
3161
- *
3162
- * @example
3163
- *
3164
- * ```js
3165
- * const app = fin.Application.getCurrentSync();
3166
- * const appName = 'My App';
3167
- * const jumpListConfig = [ // array of JumpList categories
3168
- * {
3169
- * // has no name and no type so `type` is assumed to be "tasks"
3170
- * items: [ // array of JumpList items
3171
- * {
3172
- * type: 'task',
3173
- * title: `Launch ${appName}`,
3174
- * description: `Runs ${appName} with the default configuration`,
3175
- * deepLink: 'fins://path.to/app/manifest.json',
3176
- * iconPath: 'https://path.to/app/icon.ico',
3177
- * iconIndex: 0
3178
- * },
3179
- * { type: 'separator' },
3180
- * {
3181
- * type: 'task',
3182
- * title: `Restore ${appName}`,
3183
- * description: 'Restore to last configuration',
3184
- * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3185
- * iconPath: 'https://path.to/app/icon.ico',
3186
- * iconIndex: 0
3187
- * },
3188
- * ]
3189
- * },
3190
- * {
3191
- * name: 'Tools',
3192
- * items: [ // array of JumpList items
3193
- * {
3194
- * type: 'task',
3195
- * title: 'Tool A',
3196
- * description: 'Runs Tool A',
3197
- * deepLink: 'fins://path.to/tool-a/manifest.json',
3198
- * iconPath: 'https://path.to/tool-a/icon.ico',
3199
- * iconIndex: 0
3200
- * },
3201
- * {
3202
- * type: 'task',
3203
- * title: 'Tool B',
3204
- * description: 'Runs Tool B',
3205
- * deepLink: 'fins://path.to/tool-b/manifest.json',
3206
- * iconPath: 'https://path.to/tool-b/icon.ico',
3207
- * iconIndex: 0
3208
- * }]
3209
- * }
3210
- * ];
3211
- *
3212
- * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3213
- * ```
3214
- *
3215
- * To handle deeplink args:
3216
- * ```js
3217
- * function handleUseLastConfiguration() {
3218
- * // this handler is called when the app is being launched
3219
- * app.on('run-requested', event => {
3220
- * if(event.userAppConfigArgs['use-last-configuration']) {
3221
- * // your logic here
3222
- * }
3223
- * });
3224
- * // this handler is called when the app was already running when the launch was requested
3225
- * fin.desktop.main(function(args) {
3226
- * if(args && args['use-last-configuration']) {
3227
- * // your logic here
3228
- * }
3229
- * });
3230
- * }
3231
- * ```
3232
- */
3233
- async setJumpList(jumpListCategories) {
3234
- await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3235
- }
3236
- /**
3237
- * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3238
- * @param icon Image URL or base64 encoded string to be used as the icon
3239
- *
3240
- * @example
3241
- *
3242
- * ```js
3243
- * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3244
- * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3245
- * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3246
- * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3247
- * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3248
- *
3249
- * async function setTrayIcon(icon) {
3250
- * const app = await fin.Application.getCurrent();
3251
- * return await app.setTrayIcon(icon);
3252
- * }
3253
- *
3254
- * // use image url to set tray icon
3255
- * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3256
- *
3257
- * // use base64 encoded string to set tray icon
3258
- * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3259
- *
3260
- * // use a dataURL to set tray icon
3261
- * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3262
- * ```
3263
- */
3264
- setTrayIcon(icon) {
3265
- return this.wire
3266
- .sendAction('set-tray-icon', {
3267
- enabledIcon: icon,
3268
- ...this.identity
3269
- })
3270
- .then(() => undefined);
3271
- }
3272
- /**
3273
- * Set hover text for this application's system tray icon.
3274
- * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
3275
- * @param toolTip
3276
- *
3277
- * @example
3278
- *
3279
- * ```js
3280
- * const app = fin.Application.getCurrentSync();
3281
- * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3282
- *
3283
- * await app.setTrayIcon(iconUrl);
3284
- *
3285
- * await app.setTrayIconToolTip('My Application');
3286
- * ```
3287
- */
3288
- async setTrayIconToolTip(toolTip) {
3289
- await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
3290
- }
3291
- /**
3292
- * Sets new application's shortcut configuration. Windows only.
3293
- * @param config New application's shortcut configuration.
3294
- *
3295
- * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3296
- * to be able to change shortcut states.
3297
- *
3298
- * @example
3299
- *
3300
- * ```js
3301
- * async function setShortcuts(config) {
3302
- * const app = await fin.Application.getCurrent();
3303
- * return app.setShortcuts(config);
3304
- * }
3305
- *
3306
- * setShortcuts({
3307
- * desktop: true,
3308
- * startMenu: false,
3309
- * systemStartup: true
3310
- * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3311
- * ```
3312
- */
3313
- setShortcuts(config) {
3314
- return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3315
- }
3316
- /**
3317
- * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3318
- * @param queryString The new query string for this app's shortcuts.
3319
- *
3320
- * @example
3321
- *
3322
- * ```js
3323
- * const newQueryArgs = 'arg=true&arg2=false';
3324
- * const app = await fin.Application.getCurrent();
3325
- * try {
3326
- * await app.setShortcutQueryParams(newQueryArgs);
3327
- * } catch(err) {
3328
- * console.error(err)
3329
- * }
3330
- * ```
3331
- */
3332
- async setShortcutQueryParams(queryString) {
3333
- await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3334
- }
3335
- /**
3336
- * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3337
- * larger or smaller to default limits of 300% and 50% of original size, respectively.
3338
- * @param level The zoom level
3339
- *
3340
- * @example
3341
- *
3342
- * ```js
3343
- * async function setZoomLevel(number) {
3344
- * const app = await fin.Application.getCurrent();
3345
- * return await app.setZoomLevel(number);
3346
- * }
3347
- *
3348
- * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3349
- * ```
3350
- */
3351
- setZoomLevel(level) {
3352
- return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3353
- }
3354
- /**
3355
- * Sets a username to correlate with App Log Management.
3356
- * @param username Username to correlate with App's Log.
3357
- *
3358
- * @example
3359
- *
3360
- * ```js
3361
- * async function setAppLogUser() {
3362
- * const app = await fin.Application.getCurrent();
3363
- * return await app.setAppLogUsername('username');
3364
- * }
3365
- *
3366
- * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3367
- *
3368
- * ```
3369
- */
3370
- async setAppLogUsername(username) {
3371
- await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3372
- }
3373
- /**
3374
- * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3375
- * @remarks The only information currently returned is the position and dimensions.
3376
- *
3377
- * @example
3378
- *
3379
- * ```js
3380
- * async function getTrayIconInfo() {
3381
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3382
- * return await app.getTrayIconInfo();
3383
- * }
3384
- * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3385
- * ```
3386
- */
3387
- getTrayIconInfo() {
3388
- return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3389
- }
3390
- /**
3391
- * Checks if the application has an associated tray icon.
3392
- *
3393
- * @example
3394
- *
3395
- * ```js
3396
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3397
- * const hasTrayIcon = await app.hasTrayIcon();
3398
- * console.log(hasTrayIcon);
3399
- * ```
3400
- */
3401
- hasTrayIcon() {
3402
- return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3403
- }
3404
- /**
3405
- * Closes the application by terminating its process.
3406
- *
3407
- * @example
3408
- *
3409
- * ```js
3410
- * async function terminateApp() {
3411
- * const app = await fin.Application.getCurrent();
3412
- * return await app.terminate();
3413
- * }
3414
- * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3415
- * ```
3416
- */
3417
- terminate() {
3418
- return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3419
- }
3420
- /**
3421
- * Waits for a hanging application. This method can be called in response to an application
3422
- * "not-responding" to allow the application to continue and to generate another "not-responding"
3423
- * message after a certain period of time.
3424
- *
3425
- * @ignore
3426
- */
3427
- wait() {
3428
- return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3429
- }
3430
- /**
3431
- * Retrieves information about the application.
3432
- *
3433
- * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3434
- * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3435
- * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3436
- *
3437
- * @example
3438
- *
3439
- * ```js
3440
- * async function getInfo() {
3441
- * const app = await fin.Application.getCurrent();
3442
- * return await app.getInfo();
3443
- * }
3444
- *
3445
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3446
- * ```
3447
- */
3448
- getInfo() {
3449
- return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3450
- }
3451
- /**
3452
- * Retrieves all process information for entities (windows and views) associated with an application.
3453
- *
3454
- * @example
3455
- * ```js
3456
- * const app = await fin.Application.getCurrent();
3457
- * const processInfo = await app.getProcessInfo();
3458
- * ```
3459
- * @experimental
3460
- */
3461
- async getProcessInfo() {
3462
- const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3463
- return data;
3464
- }
3465
- /**
3466
- * Sets file auto download location. It's only allowed in the same application.
3467
- *
3468
- * Note: This method is restricted by default and must be enabled via
3469
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3470
- * @param downloadLocation file auto download location
3471
- *
3472
- * @throws if setting file auto download location on different applications.
3473
- * @example
3474
- *
3475
- * ```js
3476
- * const downloadLocation = 'C:\\dev\\temp';
3477
- * const app = await fin.Application.getCurrent();
3478
- * try {
3479
- * await app.setFileDownloadLocation(downloadLocation);
3480
- * console.log('File download location is set');
3481
- * } catch(err) {
3482
- * console.error(err)
3483
- * }
3484
- * ```
3485
- */
3486
- async setFileDownloadLocation(downloadLocation) {
3487
- const { name } = this.wire.me;
3488
- const entityIdentity = { uuid: this.identity.uuid, name };
3489
- await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3490
- }
3491
- /**
3492
- * Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
3493
- *
3494
- * Note: This method is restricted by default and must be enabled via
3495
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3496
- *
3497
- * @throws if getting file auto download location on different applications.
3498
- * @example
3499
- *
3500
- * ```js
3501
- * const app = await fin.Application.getCurrent();
3502
- * const fileDownloadDir = await app.getFileDownloadLocation();
3503
- * ```
3504
- */
3505
- async getFileDownloadLocation() {
3506
- const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3507
- return data;
3508
- }
3509
- /**
3510
- * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3511
- * @param options
3512
- * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3513
- * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3514
- * of all possible data shapes for the entire menu, and the click handler should process
3515
- * these with a "reducer" pattern.
3516
- * @throws if the application has no tray icon set
3517
- * @throws if the system tray is currently hidden
3518
- * @example
3519
- *
3520
- * ```js
3521
- * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3522
- * const app = fin.Application.getCurrentSync();
3523
- *
3524
- * await app.setTrayIcon(iconUrl);
3525
- *
3526
- * const template = [
3527
- * {
3528
- * label: 'Menu Item 1',
3529
- * data: 'hello from item 1'
3530
- * },
3531
- * { type: 'separator' },
3532
- * {
3533
- * label: 'Menu Item 2',
3534
- * type: 'checkbox',
3535
- * checked: true,
3536
- * data: 'The user clicked the checkbox'
3537
- * },
3538
- * {
3539
- * label: 'see more',
3540
- * enabled: false,
3541
- * submenu: [
3542
- * { label: 'submenu 1', data: 'hello from submenu' }
3543
- * ]
3544
- * }
3545
- * ];
3546
- *
3547
- * app.addListener('tray-icon-clicked', (event) => {
3548
- * // right-click
3549
- * if (event.button === 2) {
3550
- * app.showTrayIconPopupMenu({ template }).then(r => {
3551
- * if (r.result === 'closed') {
3552
- * console.log('nothing happened');
3553
- * } else {
3554
- * console.log(r.data);
3555
- * }
3556
- * });
3557
- * }
3558
- * });
3559
- * ```
3560
- */
3561
- async showTrayIconPopupMenu(options) {
3562
- const { name } = this.wire.me;
3563
- const entityIdentity = { uuid: this.identity.uuid, name };
3564
- const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3565
- return payload.data;
3566
- }
3567
- /**
3568
- * Closes the tray icon menu.
3569
- *
3570
- * @throws if the application has no tray icon set
3571
- * @example
3572
- *
3573
- * ```js
3574
- * const app = fin.Application.getCurrentSync();
3575
- *
3576
- * await app.closeTrayIconPopupMenu();
3577
- * ```
3578
- */
3579
- async closeTrayIconPopupMenu() {
3580
- const { name } = this.wire.me;
3581
- const entityIdentity = { uuid: this.identity.uuid, name };
3582
- await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3583
- }
3584
- }
3585
- Instance$6.Application = Application;
3586
- return Instance$6;
2699
+ Object.defineProperty(Instance$6, "__esModule", { value: true });
2700
+ Instance$6.Application = void 0;
2701
+ /* eslint-disable import/prefer-default-export */
2702
+ const base_1$n = base;
2703
+ const window_1$1 = requireWindow();
2704
+ const view_1 = requireView();
2705
+ /**
2706
+ * An object representing an application. Allows the developer to create,
2707
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2708
+ */
2709
+ class Application extends base_1$n.EmitterBase {
2710
+ /**
2711
+ * @internal
2712
+ */
2713
+ constructor(wire, identity) {
2714
+ super(wire, 'application', identity.uuid);
2715
+ this.identity = identity;
2716
+ this.window = new window_1$1._Window(this.wire, {
2717
+ uuid: this.identity.uuid,
2718
+ name: this.identity.uuid
2719
+ });
2720
+ }
2721
+ windowListFromIdentityList(identityList) {
2722
+ const windowList = [];
2723
+ identityList.forEach((identity) => {
2724
+ windowList.push(new window_1$1._Window(this.wire, {
2725
+ uuid: identity.uuid,
2726
+ name: identity.name
2727
+ }));
2728
+ });
2729
+ return windowList;
2730
+ }
2731
+ /**
2732
+ * Determines if the application is currently running.
2733
+ *
2734
+ * @example
2735
+ *
2736
+ * ```js
2737
+ * async function isAppRunning() {
2738
+ * const app = await fin.Application.getCurrent();
2739
+ * return await app.isRunning();
2740
+ * }
2741
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2742
+ * ```
2743
+ */
2744
+ isRunning() {
2745
+ return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2746
+ }
2747
+ /**
2748
+ * Closes the application and any child windows created by the application.
2749
+ * Cleans the application from state so it is no longer found in getAllApplications.
2750
+ * @param force Close will be prevented from closing when force is false and
2751
+ * ‘close-requested’ has been subscribed to for application’s main window.
2752
+ *
2753
+ * @example
2754
+ *
2755
+ * ```js
2756
+ * async function closeApp() {
2757
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2758
+ * const app = await fin.Application.wrap({uuid: 'app2'});
2759
+ * await app.quit();
2760
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2761
+ *
2762
+ * }
2763
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2764
+ * ```
2765
+ */
2766
+ async quit(force = false) {
2767
+ try {
2768
+ await this._close(force);
2769
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
2770
+ }
2771
+ catch (error) {
2772
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2773
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2774
+ throw error;
2775
+ }
2776
+ }
2777
+ }
2778
+ async _close(force = false) {
2779
+ try {
2780
+ await this.wire.sendAction('close-application', { force, ...this.identity });
2781
+ }
2782
+ catch (error) {
2783
+ if (!error.message.includes('Remote connection has closed')) {
2784
+ throw error;
2785
+ }
2786
+ }
2787
+ }
2788
+ /**
2789
+ * @deprecated use Application.quit instead
2790
+ * Closes the application and any child windows created by the application.
2791
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2792
+ * @param callback - called if the method succeeds.
2793
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2794
+ *
2795
+ * @example
2796
+ *
2797
+ * ```js
2798
+ * async function closeApp() {
2799
+ * const app = await fin.Application.getCurrent();
2800
+ * return await app.close();
2801
+ * }
2802
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2803
+ * ```
2804
+ */
2805
+ close(force = false) {
2806
+ console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2807
+ this.wire.recordAnalytic('application-close');
2808
+ return this._close(force);
2809
+ }
2810
+ /**
2811
+ * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2812
+ *
2813
+ * @example
2814
+ *
2815
+ * ```js
2816
+ * async function getChildWindows() {
2817
+ * const app = await fin.Application.getCurrent();
2818
+ * return await app.getChildWindows();
2819
+ * }
2820
+ *
2821
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2822
+ * ```
2823
+ */
2824
+ getChildWindows() {
2825
+ return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2826
+ const identityList = [];
2827
+ payload.data.forEach((winName) => {
2828
+ identityList.push({ uuid: this.identity.uuid, name: winName });
2829
+ });
2830
+ return this.windowListFromIdentityList(identityList);
2831
+ });
2832
+ }
2833
+ /**
2834
+ * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2835
+ * if the application was not created from a manifest.
2836
+ *
2837
+ * @example
2838
+ *
2839
+ * ```js
2840
+ * async function getManifest() {
2841
+ * const app = await fin.Application.getCurrent();
2842
+ * return await app.getManifest();
2843
+ * }
2844
+ *
2845
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2846
+ * ```
2847
+ */
2848
+ getManifest() {
2849
+ return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2850
+ }
2851
+ /**
2852
+ * Retrieves UUID of the application that launches this application. Invokes the error callback
2853
+ * if the application was created from a manifest.
2854
+ *
2855
+ * @example
2856
+ *
2857
+ * ```js
2858
+ * async function getParentUuid() {
2859
+ * const app = await fin.Application.start({
2860
+ * uuid: 'app-1',
2861
+ * name: 'myApp',
2862
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2863
+ * autoShow: true
2864
+ * });
2865
+ * return await app.getParentUuid();
2866
+ * }
2867
+ *
2868
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2869
+ * ```
2870
+ */
2871
+ getParentUuid() {
2872
+ return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2873
+ }
2874
+ /**
2875
+ * Retrieves current application's shortcut configuration.
2876
+ *
2877
+ * @example
2878
+ *
2879
+ * ```js
2880
+ * async function getShortcuts() {
2881
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
2882
+ * return await app.getShortcuts();
2883
+ * }
2884
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2885
+ * ```
2886
+ */
2887
+ getShortcuts() {
2888
+ return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2889
+ }
2890
+ /**
2891
+ * Retrieves current application's views.
2892
+ * @experimental
2893
+ *
2894
+ * @example
2895
+ *
2896
+ * ```js
2897
+ * async function getViews() {
2898
+ * const app = await fin.Application.getCurrent();
2899
+ * return await app.getViews();
2900
+ * }
2901
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
2902
+ * ```
2903
+ */
2904
+ async getViews() {
2905
+ const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2906
+ return payload.data.map((id) => new view_1.View(this.wire, id));
2907
+ }
2908
+ /**
2909
+ * Returns the current zoom level of the application.
2910
+ *
2911
+ * @example
2912
+ *
2913
+ * ```js
2914
+ * async function getZoomLevel() {
2915
+ * const app = await fin.Application.getCurrent();
2916
+ * return await app.getZoomLevel();
2917
+ * }
2918
+ *
2919
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2920
+ * ```
2921
+ */
2922
+ getZoomLevel() {
2923
+ return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2924
+ }
2925
+ /**
2926
+ * Returns an instance of the main Window of the application
2927
+ *
2928
+ * @example
2929
+ *
2930
+ * ```js
2931
+ * async function getWindow() {
2932
+ * const app = await fin.Application.start({
2933
+ * uuid: 'app-1',
2934
+ * name: 'myApp',
2935
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
2936
+ * autoShow: true
2937
+ * });
2938
+ * return await app.getWindow();
2939
+ * }
2940
+ *
2941
+ * getWindow().then(win => {
2942
+ * win.showAt(0, 400);
2943
+ * win.flash();
2944
+ * }).catch(err => console.log(err));
2945
+ * ```
2946
+ */
2947
+ getWindow() {
2948
+ this.wire.recordAnalytic('application-get-window');
2949
+ return Promise.resolve(this.window);
2950
+ }
2951
+ /**
2952
+ * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
2953
+ * @param userName - username to be passed to the RVM.
2954
+ * @param appName - app name to be passed to the RVM.
2955
+ *
2956
+ * @example
2957
+ *
2958
+ * ```js
2959
+ * async function registerUser() {
2960
+ * const app = await fin.Application.getCurrent();
2961
+ * return await app.registerUser('user', 'myApp');
2962
+ * }
2963
+ *
2964
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
2965
+ * ```
2966
+ */
2967
+ registerUser(userName, appName) {
2968
+ return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
2969
+ }
2970
+ /**
2971
+ * Removes the application’s icon from the tray.
2972
+ *
2973
+ * @example
2974
+ *
2975
+ * ```js
2976
+ * async function removeTrayIcon() {
2977
+ * const app = await fin.Application.getCurrent();
2978
+ * return await app.removeTrayIcon();
2979
+ * }
2980
+ *
2981
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
2982
+ * ```
2983
+ */
2984
+ removeTrayIcon() {
2985
+ return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
2986
+ }
2987
+ /**
2988
+ * Restarts the application.
2989
+ *
2990
+ * @example
2991
+ *
2992
+ * ```js
2993
+ * async function restartApp() {
2994
+ * const app = await fin.Application.getCurrent();
2995
+ * return await app.restart();
2996
+ * }
2997
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
2998
+ * ```
2999
+ */
3000
+ restart() {
3001
+ return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3002
+ }
3003
+ /**
3004
+ * DEPRECATED method to run the application.
3005
+ * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3006
+ *
3007
+ * @example
3008
+ *
3009
+ * ```js
3010
+ * async function run() {
3011
+ * const app = await fin.Application.create({
3012
+ * name: 'myApp',
3013
+ * uuid: 'app-1',
3014
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3015
+ * autoShow: true
3016
+ * });
3017
+ * await app.run();
3018
+ * }
3019
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3020
+ * ```
3021
+ *
3022
+ * @ignore
3023
+ */
3024
+ run() {
3025
+ console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3026
+ this.wire.recordAnalytic('application-run');
3027
+ return this._run();
3028
+ }
3029
+ _run(opts = {}) {
3030
+ return this.wire
3031
+ .sendAction('run-application', {
3032
+ manifestUrl: this._manifestUrl,
3033
+ opts,
3034
+ ...this.identity
3035
+ })
3036
+ .then(() => undefined);
3037
+ }
3038
+ /**
3039
+ * Instructs the RVM to schedule one restart of the application.
3040
+ *
3041
+ * @example
3042
+ *
3043
+ * ```js
3044
+ * async function scheduleRestart() {
3045
+ * const app = await fin.Application.getCurrent();
3046
+ * return await app.scheduleRestart();
3047
+ * }
3048
+ *
3049
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3050
+ * ```
3051
+ */
3052
+ scheduleRestart() {
3053
+ return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3054
+ }
3055
+ /**
3056
+ * Sends a message to the RVM to upload the application's logs. On success,
3057
+ * an object containing logId is returned.
3058
+ *
3059
+ * @example
3060
+ *
3061
+ * ```js
3062
+ * async function sendLog() {
3063
+ * const app = await fin.Application.getCurrent();
3064
+ * return await app.sendApplicationLog();
3065
+ * }
3066
+ *
3067
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3068
+ * ```
3069
+ */
3070
+ async sendApplicationLog() {
3071
+ const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3072
+ return payload.data;
3073
+ }
3074
+ /**
3075
+ * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3076
+ * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3077
+ *
3078
+ * Note: If the "name" property is omitted it defaults to "tasks".
3079
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3080
+ *
3081
+ *
3082
+ * @remarks If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3083
+ *
3084
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3085
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3086
+ *
3087
+ * Note: If the "name" property is omitted it defaults to "tasks".
3088
+ *
3089
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3090
+ * uuid or shortcut.name is changed.
3091
+ *
3092
+ * @example
3093
+ *
3094
+ * ```js
3095
+ * const app = fin.Application.getCurrentSync();
3096
+ * const appName = 'My App';
3097
+ * const jumpListConfig = [ // array of JumpList categories
3098
+ * {
3099
+ * // has no name and no type so `type` is assumed to be "tasks"
3100
+ * items: [ // array of JumpList items
3101
+ * {
3102
+ * type: 'task',
3103
+ * title: `Launch ${appName}`,
3104
+ * description: `Runs ${appName} with the default configuration`,
3105
+ * deepLink: 'fins://path.to/app/manifest.json',
3106
+ * iconPath: 'https://path.to/app/icon.ico',
3107
+ * iconIndex: 0
3108
+ * },
3109
+ * { type: 'separator' },
3110
+ * {
3111
+ * type: 'task',
3112
+ * title: `Restore ${appName}`,
3113
+ * description: 'Restore to last configuration',
3114
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3115
+ * iconPath: 'https://path.to/app/icon.ico',
3116
+ * iconIndex: 0
3117
+ * },
3118
+ * ]
3119
+ * },
3120
+ * {
3121
+ * name: 'Tools',
3122
+ * items: [ // array of JumpList items
3123
+ * {
3124
+ * type: 'task',
3125
+ * title: 'Tool A',
3126
+ * description: 'Runs Tool A',
3127
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
3128
+ * iconPath: 'https://path.to/tool-a/icon.ico',
3129
+ * iconIndex: 0
3130
+ * },
3131
+ * {
3132
+ * type: 'task',
3133
+ * title: 'Tool B',
3134
+ * description: 'Runs Tool B',
3135
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
3136
+ * iconPath: 'https://path.to/tool-b/icon.ico',
3137
+ * iconIndex: 0
3138
+ * }]
3139
+ * }
3140
+ * ];
3141
+ *
3142
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3143
+ * ```
3144
+ *
3145
+ * To handle deeplink args:
3146
+ * ```js
3147
+ * function handleUseLastConfiguration() {
3148
+ * // this handler is called when the app is being launched
3149
+ * app.on('run-requested', event => {
3150
+ * if(event.userAppConfigArgs['use-last-configuration']) {
3151
+ * // your logic here
3152
+ * }
3153
+ * });
3154
+ * // this handler is called when the app was already running when the launch was requested
3155
+ * fin.desktop.main(function(args) {
3156
+ * if(args && args['use-last-configuration']) {
3157
+ * // your logic here
3158
+ * }
3159
+ * });
3160
+ * }
3161
+ * ```
3162
+ */
3163
+ async setJumpList(jumpListCategories) {
3164
+ await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3165
+ }
3166
+ /**
3167
+ * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3168
+ * @param icon Image URL or base64 encoded string to be used as the icon
3169
+ *
3170
+ * @example
3171
+ *
3172
+ * ```js
3173
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3174
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3175
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3176
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3177
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3178
+ *
3179
+ * async function setTrayIcon(icon) {
3180
+ * const app = await fin.Application.getCurrent();
3181
+ * return await app.setTrayIcon(icon);
3182
+ * }
3183
+ *
3184
+ * // use image url to set tray icon
3185
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3186
+ *
3187
+ * // use base64 encoded string to set tray icon
3188
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3189
+ *
3190
+ * // use a dataURL to set tray icon
3191
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3192
+ * ```
3193
+ */
3194
+ setTrayIcon(icon) {
3195
+ return this.wire
3196
+ .sendAction('set-tray-icon', {
3197
+ enabledIcon: icon,
3198
+ ...this.identity
3199
+ })
3200
+ .then(() => undefined);
3201
+ }
3202
+ /**
3203
+ * Set hover text for this application's system tray icon.
3204
+ * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
3205
+ * @param toolTip
3206
+ *
3207
+ * @example
3208
+ *
3209
+ * ```js
3210
+ * const app = fin.Application.getCurrentSync();
3211
+ * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3212
+ *
3213
+ * await app.setTrayIcon(iconUrl);
3214
+ *
3215
+ * await app.setTrayIconToolTip('My Application');
3216
+ * ```
3217
+ */
3218
+ async setTrayIconToolTip(toolTip) {
3219
+ await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
3220
+ }
3221
+ /**
3222
+ * Sets new application's shortcut configuration. Windows only.
3223
+ * @param config New application's shortcut configuration.
3224
+ *
3225
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3226
+ * to be able to change shortcut states.
3227
+ *
3228
+ * @example
3229
+ *
3230
+ * ```js
3231
+ * async function setShortcuts(config) {
3232
+ * const app = await fin.Application.getCurrent();
3233
+ * return app.setShortcuts(config);
3234
+ * }
3235
+ *
3236
+ * setShortcuts({
3237
+ * desktop: true,
3238
+ * startMenu: false,
3239
+ * systemStartup: true
3240
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3241
+ * ```
3242
+ */
3243
+ setShortcuts(config) {
3244
+ return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3245
+ }
3246
+ /**
3247
+ * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3248
+ * @param queryString The new query string for this app's shortcuts.
3249
+ *
3250
+ * @example
3251
+ *
3252
+ * ```js
3253
+ * const newQueryArgs = 'arg=true&arg2=false';
3254
+ * const app = await fin.Application.getCurrent();
3255
+ * try {
3256
+ * await app.setShortcutQueryParams(newQueryArgs);
3257
+ * } catch(err) {
3258
+ * console.error(err)
3259
+ * }
3260
+ * ```
3261
+ */
3262
+ async setShortcutQueryParams(queryString) {
3263
+ await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3264
+ }
3265
+ /**
3266
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3267
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
3268
+ * @param level The zoom level
3269
+ *
3270
+ * @example
3271
+ *
3272
+ * ```js
3273
+ * async function setZoomLevel(number) {
3274
+ * const app = await fin.Application.getCurrent();
3275
+ * return await app.setZoomLevel(number);
3276
+ * }
3277
+ *
3278
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3279
+ * ```
3280
+ */
3281
+ setZoomLevel(level) {
3282
+ return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3283
+ }
3284
+ /**
3285
+ * Sets a username to correlate with App Log Management.
3286
+ * @param username Username to correlate with App's Log.
3287
+ *
3288
+ * @example
3289
+ *
3290
+ * ```js
3291
+ * async function setAppLogUser() {
3292
+ * const app = await fin.Application.getCurrent();
3293
+ * return await app.setAppLogUsername('username');
3294
+ * }
3295
+ *
3296
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3297
+ *
3298
+ * ```
3299
+ */
3300
+ async setAppLogUsername(username) {
3301
+ await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3302
+ }
3303
+ /**
3304
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3305
+ * @remarks The only information currently returned is the position and dimensions.
3306
+ *
3307
+ * @example
3308
+ *
3309
+ * ```js
3310
+ * async function getTrayIconInfo() {
3311
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3312
+ * return await app.getTrayIconInfo();
3313
+ * }
3314
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3315
+ * ```
3316
+ */
3317
+ getTrayIconInfo() {
3318
+ return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3319
+ }
3320
+ /**
3321
+ * Checks if the application has an associated tray icon.
3322
+ *
3323
+ * @example
3324
+ *
3325
+ * ```js
3326
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3327
+ * const hasTrayIcon = await app.hasTrayIcon();
3328
+ * console.log(hasTrayIcon);
3329
+ * ```
3330
+ */
3331
+ hasTrayIcon() {
3332
+ return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3333
+ }
3334
+ /**
3335
+ * Closes the application by terminating its process.
3336
+ *
3337
+ * @example
3338
+ *
3339
+ * ```js
3340
+ * async function terminateApp() {
3341
+ * const app = await fin.Application.getCurrent();
3342
+ * return await app.terminate();
3343
+ * }
3344
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3345
+ * ```
3346
+ */
3347
+ terminate() {
3348
+ return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3349
+ }
3350
+ /**
3351
+ * Waits for a hanging application. This method can be called in response to an application
3352
+ * "not-responding" to allow the application to continue and to generate another "not-responding"
3353
+ * message after a certain period of time.
3354
+ *
3355
+ * @ignore
3356
+ */
3357
+ wait() {
3358
+ return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3359
+ }
3360
+ /**
3361
+ * Retrieves information about the application.
3362
+ *
3363
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3364
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3365
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3366
+ *
3367
+ * @example
3368
+ *
3369
+ * ```js
3370
+ * async function getInfo() {
3371
+ * const app = await fin.Application.getCurrent();
3372
+ * return await app.getInfo();
3373
+ * }
3374
+ *
3375
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3376
+ * ```
3377
+ */
3378
+ getInfo() {
3379
+ return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3380
+ }
3381
+ /**
3382
+ * Retrieves all process information for entities (windows and views) associated with an application.
3383
+ *
3384
+ * @example
3385
+ * ```js
3386
+ * const app = await fin.Application.getCurrent();
3387
+ * const processInfo = await app.getProcessInfo();
3388
+ * ```
3389
+ * @experimental
3390
+ */
3391
+ async getProcessInfo() {
3392
+ const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3393
+ return data;
3394
+ }
3395
+ /**
3396
+ * Sets file auto download location. It's only allowed in the same application.
3397
+ *
3398
+ * Note: This method is restricted by default and must be enabled via
3399
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3400
+ * @param downloadLocation file auto download location
3401
+ *
3402
+ * @throws if setting file auto download location on different applications.
3403
+ * @example
3404
+ *
3405
+ * ```js
3406
+ * const downloadLocation = 'C:\\dev\\temp';
3407
+ * const app = await fin.Application.getCurrent();
3408
+ * try {
3409
+ * await app.setFileDownloadLocation(downloadLocation);
3410
+ * console.log('File download location is set');
3411
+ * } catch(err) {
3412
+ * console.error(err)
3413
+ * }
3414
+ * ```
3415
+ */
3416
+ async setFileDownloadLocation(downloadLocation) {
3417
+ const { name } = this.wire.me;
3418
+ const entityIdentity = { uuid: this.identity.uuid, name };
3419
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3420
+ }
3421
+ /**
3422
+ * Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
3423
+ *
3424
+ * Note: This method is restricted by default and must be enabled via
3425
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3426
+ *
3427
+ * @throws if getting file auto download location on different applications.
3428
+ * @example
3429
+ *
3430
+ * ```js
3431
+ * const app = await fin.Application.getCurrent();
3432
+ * const fileDownloadDir = await app.getFileDownloadLocation();
3433
+ * ```
3434
+ */
3435
+ async getFileDownloadLocation() {
3436
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3437
+ return data;
3438
+ }
3439
+ /**
3440
+ * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3441
+ * @param options
3442
+ * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3443
+ * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3444
+ * of all possible data shapes for the entire menu, and the click handler should process
3445
+ * these with a "reducer" pattern.
3446
+ * @throws if the application has no tray icon set
3447
+ * @throws if the system tray is currently hidden
3448
+ * @example
3449
+ *
3450
+ * ```js
3451
+ * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3452
+ * const app = fin.Application.getCurrentSync();
3453
+ *
3454
+ * await app.setTrayIcon(iconUrl);
3455
+ *
3456
+ * const template = [
3457
+ * {
3458
+ * label: 'Menu Item 1',
3459
+ * data: 'hello from item 1'
3460
+ * },
3461
+ * { type: 'separator' },
3462
+ * {
3463
+ * label: 'Menu Item 2',
3464
+ * type: 'checkbox',
3465
+ * checked: true,
3466
+ * data: 'The user clicked the checkbox'
3467
+ * },
3468
+ * {
3469
+ * label: 'see more',
3470
+ * enabled: false,
3471
+ * submenu: [
3472
+ * { label: 'submenu 1', data: 'hello from submenu' }
3473
+ * ]
3474
+ * }
3475
+ * ];
3476
+ *
3477
+ * app.addListener('tray-icon-clicked', (event) => {
3478
+ * // right-click
3479
+ * if (event.button === 2) {
3480
+ * app.showTrayIconPopupMenu({ template }).then(r => {
3481
+ * if (r.result === 'closed') {
3482
+ * console.log('nothing happened');
3483
+ * } else {
3484
+ * console.log(r.data);
3485
+ * }
3486
+ * });
3487
+ * }
3488
+ * });
3489
+ * ```
3490
+ */
3491
+ async showTrayIconPopupMenu(options) {
3492
+ const { name } = this.wire.me;
3493
+ const entityIdentity = { uuid: this.identity.uuid, name };
3494
+ const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3495
+ return payload.data;
3496
+ }
3497
+ /**
3498
+ * Closes the tray icon menu.
3499
+ *
3500
+ * @throws if the application has no tray icon set
3501
+ * @example
3502
+ *
3503
+ * ```js
3504
+ * const app = fin.Application.getCurrentSync();
3505
+ *
3506
+ * await app.closeTrayIconPopupMenu();
3507
+ * ```
3508
+ */
3509
+ async closeTrayIconPopupMenu() {
3510
+ const { name } = this.wire.me;
3511
+ const entityIdentity = { uuid: this.identity.uuid, name };
3512
+ await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3513
+ }
3587
3514
  }
3515
+ Instance$6.Application = Application;
3588
3516
 
3589
- var hasRequiredFactory$1;
3590
-
3591
- function requireFactory$1 () {
3592
- if (hasRequiredFactory$1) return Factory$7;
3593
- hasRequiredFactory$1 = 1;
3594
- Object.defineProperty(Factory$7, "__esModule", { value: true });
3595
- Factory$7.ApplicationModule = void 0;
3596
- const base_1 = base;
3597
- const validate_1 = validate;
3598
- const Instance_1 = requireInstance$1();
3599
- /**
3600
- * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3601
- */
3602
- class ApplicationModule extends base_1.Base {
3603
- /**
3604
- * Asynchronously returns an API handle for the given Application identity.
3605
- *
3606
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3607
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3608
- * for an Application throughout its entire lifecycle.
3609
- *
3610
- * @example
3611
- *
3612
- * ```js
3613
- * fin.Application.wrap({ uuid: 'testapp' })
3614
- * .then(app => app.isRunning())
3615
- * .then(running => console.log('Application is running: ' + running))
3616
- * .catch(err => console.log(err));
3617
- * ```
3618
- *
3619
- */
3620
- async wrap(identity) {
3621
- this.wire.sendAction('wrap-application').catch((e) => {
3622
- // we do not want to expose this error, just continue if this analytics-only call fails
3623
- });
3624
- const errorMsg = (0, validate_1.validateIdentity)(identity);
3625
- if (errorMsg) {
3626
- throw new Error(errorMsg);
3627
- }
3628
- return new Instance_1.Application(this.wire, identity);
3629
- }
3630
- /**
3631
- * Synchronously returns an API handle for the given Application identity.
3632
- *
3633
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3634
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3635
- * for an Aplication throughout its entire lifecycle.
3636
- *
3637
- * @example
3638
- *
3639
- * ```js
3640
- * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3641
- * await app.close();
3642
- * ```
3643
- *
3644
- */
3645
- wrapSync(identity) {
3646
- this.wire.sendAction('wrap-application-sync').catch((e) => {
3647
- // we do not want to expose this error, just continue if this analytics-only call fails
3648
- });
3649
- const errorMsg = (0, validate_1.validateIdentity)(identity);
3650
- if (errorMsg) {
3651
- throw new Error(errorMsg);
3652
- }
3653
- return new Instance_1.Application(this.wire, identity);
3654
- }
3655
- async _create(appOptions) {
3656
- // set defaults:
3657
- if (appOptions.waitForPageLoad === undefined) {
3658
- appOptions.waitForPageLoad = false;
3659
- }
3660
- if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3661
- appOptions.autoShow = true;
3662
- }
3663
- await this.wire.sendAction('create-application', appOptions);
3664
- return this.wrap({ uuid: appOptions.uuid });
3665
- }
3666
- /**
3667
- * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3668
- *
3669
- * @example
3670
- *
3671
- * ```js
3672
- * async function createApp() {
3673
- * const app = await fin.Application.create({
3674
- * name: 'myApp',
3675
- * uuid: 'app-3',
3676
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3677
- * autoShow: true
3678
- * });
3679
- * await app.run();
3680
- * }
3681
- *
3682
- * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3683
- * ```
3684
- *
3685
- * @ignore
3686
- */
3687
- create(appOptions) {
3688
- console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3689
- this.wire.sendAction('application-create').catch((e) => {
3690
- // we do not want to expose this error, just continue if this analytics-only call fails
3691
- });
3692
- return this._create(appOptions);
3693
- }
3694
- /**
3695
- * Creates and starts a new Application.
3696
- *
3697
- * @example
3698
- *
3699
- * ```js
3700
- * async function start() {
3701
- * return fin.Application.start({
3702
- * name: 'app-1',
3703
- * uuid: 'app-1',
3704
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3705
- * autoShow: true
3706
- * });
3707
- * }
3708
- * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3709
- * ```
3710
- *
3711
- */
3712
- async start(appOptions) {
3713
- this.wire.sendAction('start-application').catch((e) => {
3714
- // we do not want to expose this error, just continue if this analytics-only call fails
3715
- });
3716
- const app = await this._create(appOptions);
3717
- await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3718
- return app;
3719
- }
3720
- /**
3721
- * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3722
- * Returns once the RVM is finished attempting to launch the applications.
3723
- * @param opts - Parameters that the RVM will use.
3724
- *
3725
- * @example
3726
- *
3727
- * ```js
3728
- *
3729
- * const applicationInfoArray = [
3730
- * {
3731
- * "uuid": 'App-1',
3732
- * "manifestUrl": 'http://localhost:5555/app1.json',
3733
- * },
3734
- * {
3735
- * "uuid": 'App-2',
3736
- * "manifestUrl": 'http://localhost:5555/app2.json',
3737
- * },
3738
- * {
3739
- * "uuid": 'App-3',
3740
- * "manifestUrl": 'http://localhost:5555/app3.json',
3741
- * }
3742
- * ]
3743
- *
3744
- * fin.Application.startManyManifests(applicationInfoArray)
3745
- * .then(() => {
3746
- * console.log('RVM has finished launching the application list.');
3747
- * })
3748
- * .catch((err) => {
3749
- * console.log(err);
3750
- * })
3751
- * ```
3752
- *
3753
- * @experimental
3754
- */
3755
- async startManyManifests(applications, opts) {
3756
- return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3757
- }
3758
- /**
3759
- * Asynchronously returns an Application object that represents the current application
3760
- *
3761
- * @example
3762
- *
3763
- * ```js
3764
- * async function isCurrentAppRunning () {
3765
- * const app = await fin.Application.getCurrent();
3766
- * return app.isRunning();
3767
- * }
3768
- *
3769
- * isCurrentAppRunning().then(running => {
3770
- * console.log(`Current app is running: ${running}`);
3771
- * }).catch(err => {
3772
- * console.error(err);
3773
- * });
3774
- *
3775
- * ```
3776
- */
3777
- getCurrent() {
3778
- this.wire.sendAction('get-current-application').catch((e) => {
3779
- // we do not want to expose this error, just continue if this analytics-only call fails
3780
- });
3781
- return this.wrap({ uuid: this.wire.me.uuid });
3782
- }
3783
- /**
3784
- * Synchronously returns an Application object that represents the current application
3785
- *
3786
- * @example
3787
- *
3788
- * ```js
3789
- * async function isCurrentAppRunning () {
3790
- * const app = fin.Application.getCurrentSync();
3791
- * return app.isRunning();
3792
- * }
3793
- *
3794
- * isCurrentAppRunning().then(running => {
3795
- * console.log(`Current app is running: ${running}`);
3796
- * }).catch(err => {
3797
- * console.error(err);
3798
- * });
3799
- *
3800
- * ```
3801
- */
3802
- getCurrentSync() {
3803
- this.wire.sendAction('get-current-application-sync').catch((e) => {
3804
- // we do not want to expose this error, just continue if this analytics-only call fails
3805
- });
3806
- return this.wrapSync({ uuid: this.wire.me.uuid });
3807
- }
3808
- /**
3809
- * Retrieves application's manifest and returns a running instance of the application.
3810
- * @param manifestUrl - The URL of app's manifest.
3811
- * @param opts - Parameters that the RVM will use.
3812
- *
3813
- * @example
3814
- *
3815
- * ```js
3816
- * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3817
- *
3818
- * // For a local manifest file:
3819
- * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3820
- * ```
3821
- */
3822
- async startFromManifest(manifestUrl, opts) {
3823
- this.wire.sendAction('application-start-from-manifest').catch((e) => {
3824
- // we do not want to expose this error, just continue if this analytics-only call fails
3825
- });
3826
- const app = await this._createFromManifest(manifestUrl);
3827
- // @ts-expect-error using private method without warning.
3828
- await app._run(opts); // eslint-disable-line no-underscore-dangle
3829
- return app;
3830
- }
3831
- /**
3832
- * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3833
- * Retrieves application's manifest and returns a wrapped application.
3834
- * @param manifestUrl - The URL of app's manifest.
3835
- * @param callback - called if the method succeeds.
3836
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3837
- *
3838
- * @example
3839
- *
3840
- * ```js
3841
- * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3842
- * ```
3843
- * @ignore
3844
- */
3845
- createFromManifest(manifestUrl) {
3846
- console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3847
- this.wire.sendAction('application-create-from-manifest').catch((e) => {
3848
- // we do not want to expose this error, just continue if this analytics-only call fails
3849
- });
3850
- return this._createFromManifest(manifestUrl);
3851
- }
3852
- _createFromManifest(manifestUrl) {
3853
- return this.wire
3854
- .sendAction('get-application-manifest', { manifestUrl })
3855
- .then(({ payload }) => {
3856
- const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3857
- return this.wrap({ uuid });
3858
- })
3859
- .then((app) => {
3860
- app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3861
- return app;
3862
- });
3863
- }
3864
- }
3865
- Factory$7.ApplicationModule = ApplicationModule;
3866
- return Factory$7;
3517
+ Object.defineProperty(Factory$7, "__esModule", { value: true });
3518
+ Factory$7.ApplicationModule = void 0;
3519
+ const base_1$m = base;
3520
+ const validate_1$4 = validate;
3521
+ const Instance_1$5 = Instance$6;
3522
+ /**
3523
+ * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3524
+ */
3525
+ class ApplicationModule extends base_1$m.Base {
3526
+ /**
3527
+ * Asynchronously returns an API handle for the given Application identity.
3528
+ *
3529
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3530
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3531
+ * for an Application throughout its entire lifecycle.
3532
+ *
3533
+ * @example
3534
+ *
3535
+ * ```js
3536
+ * fin.Application.wrap({ uuid: 'testapp' })
3537
+ * .then(app => app.isRunning())
3538
+ * .then(running => console.log('Application is running: ' + running))
3539
+ * .catch(err => console.log(err));
3540
+ * ```
3541
+ *
3542
+ */
3543
+ async wrap(identity) {
3544
+ this.wire.recordAnalytic('wrap-application');
3545
+ const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3546
+ if (errorMsg) {
3547
+ throw new Error(errorMsg);
3548
+ }
3549
+ return new Instance_1$5.Application(this.wire, identity);
3550
+ }
3551
+ /**
3552
+ * Synchronously returns an API handle for the given Application identity.
3553
+ *
3554
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3555
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3556
+ * for an Aplication throughout its entire lifecycle.
3557
+ *
3558
+ * @example
3559
+ *
3560
+ * ```js
3561
+ * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3562
+ * await app.close();
3563
+ * ```
3564
+ *
3565
+ */
3566
+ wrapSync(identity) {
3567
+ this.wire.recordAnalytic('wrap-application-sync');
3568
+ const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3569
+ if (errorMsg) {
3570
+ throw new Error(errorMsg);
3571
+ }
3572
+ return new Instance_1$5.Application(this.wire, identity);
3573
+ }
3574
+ async _create(appOptions) {
3575
+ // set defaults:
3576
+ if (appOptions.waitForPageLoad === undefined) {
3577
+ appOptions.waitForPageLoad = false;
3578
+ }
3579
+ if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3580
+ appOptions.autoShow = true;
3581
+ }
3582
+ await this.wire.sendAction('create-application', appOptions);
3583
+ return this.wrap({ uuid: appOptions.uuid });
3584
+ }
3585
+ /**
3586
+ * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3587
+ *
3588
+ * @example
3589
+ *
3590
+ * ```js
3591
+ * async function createApp() {
3592
+ * const app = await fin.Application.create({
3593
+ * name: 'myApp',
3594
+ * uuid: 'app-3',
3595
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3596
+ * autoShow: true
3597
+ * });
3598
+ * await app.run();
3599
+ * }
3600
+ *
3601
+ * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3602
+ * ```
3603
+ *
3604
+ * @ignore
3605
+ */
3606
+ create(appOptions) {
3607
+ console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3608
+ this.wire.recordAnalytic('application-create');
3609
+ return this._create(appOptions);
3610
+ }
3611
+ /**
3612
+ * Creates and starts a new Application.
3613
+ *
3614
+ * @example
3615
+ *
3616
+ * ```js
3617
+ * async function start() {
3618
+ * return fin.Application.start({
3619
+ * name: 'app-1',
3620
+ * uuid: 'app-1',
3621
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3622
+ * autoShow: true
3623
+ * });
3624
+ * }
3625
+ * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3626
+ * ```
3627
+ *
3628
+ */
3629
+ async start(appOptions) {
3630
+ this.wire.recordAnalytic('start-application');
3631
+ const app = await this._create(appOptions);
3632
+ await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3633
+ return app;
3634
+ }
3635
+ /**
3636
+ * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3637
+ * Returns once the RVM is finished attempting to launch the applications.
3638
+ * @param opts - Parameters that the RVM will use.
3639
+ *
3640
+ * @example
3641
+ *
3642
+ * ```js
3643
+ *
3644
+ * const applicationInfoArray = [
3645
+ * {
3646
+ * "uuid": 'App-1',
3647
+ * "manifestUrl": 'http://localhost:5555/app1.json',
3648
+ * },
3649
+ * {
3650
+ * "uuid": 'App-2',
3651
+ * "manifestUrl": 'http://localhost:5555/app2.json',
3652
+ * },
3653
+ * {
3654
+ * "uuid": 'App-3',
3655
+ * "manifestUrl": 'http://localhost:5555/app3.json',
3656
+ * }
3657
+ * ]
3658
+ *
3659
+ * fin.Application.startManyManifests(applicationInfoArray)
3660
+ * .then(() => {
3661
+ * console.log('RVM has finished launching the application list.');
3662
+ * })
3663
+ * .catch((err) => {
3664
+ * console.log(err);
3665
+ * })
3666
+ * ```
3667
+ *
3668
+ * @experimental
3669
+ */
3670
+ async startManyManifests(applications, opts) {
3671
+ return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3672
+ }
3673
+ /**
3674
+ * Asynchronously returns an Application object that represents the current application
3675
+ *
3676
+ * @example
3677
+ *
3678
+ * ```js
3679
+ * async function isCurrentAppRunning () {
3680
+ * const app = await fin.Application.getCurrent();
3681
+ * return app.isRunning();
3682
+ * }
3683
+ *
3684
+ * isCurrentAppRunning().then(running => {
3685
+ * console.log(`Current app is running: ${running}`);
3686
+ * }).catch(err => {
3687
+ * console.error(err);
3688
+ * });
3689
+ *
3690
+ * ```
3691
+ */
3692
+ getCurrent() {
3693
+ this.wire.recordAnalytic('get-current-application');
3694
+ return this.wrap({ uuid: this.wire.me.uuid });
3695
+ }
3696
+ /**
3697
+ * Synchronously returns an Application object that represents the current application
3698
+ *
3699
+ * @example
3700
+ *
3701
+ * ```js
3702
+ * async function isCurrentAppRunning () {
3703
+ * const app = fin.Application.getCurrentSync();
3704
+ * return app.isRunning();
3705
+ * }
3706
+ *
3707
+ * isCurrentAppRunning().then(running => {
3708
+ * console.log(`Current app is running: ${running}`);
3709
+ * }).catch(err => {
3710
+ * console.error(err);
3711
+ * });
3712
+ *
3713
+ * ```
3714
+ */
3715
+ getCurrentSync() {
3716
+ this.wire.recordAnalytic('get-current-application-sync');
3717
+ return this.wrapSync({ uuid: this.wire.me.uuid });
3718
+ }
3719
+ /**
3720
+ * Retrieves application's manifest and returns a running instance of the application.
3721
+ * @param manifestUrl - The URL of app's manifest.
3722
+ * @param opts - Parameters that the RVM will use.
3723
+ *
3724
+ * @example
3725
+ *
3726
+ * ```js
3727
+ * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3728
+ *
3729
+ * // For a local manifest file:
3730
+ * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3731
+ * ```
3732
+ */
3733
+ async startFromManifest(manifestUrl, opts) {
3734
+ this.wire.recordAnalytic('application-start-from-manifest');
3735
+ const app = await this._createFromManifest(manifestUrl);
3736
+ // @ts-expect-error using private method without warning.
3737
+ await app._run(opts); // eslint-disable-line no-underscore-dangle
3738
+ return app;
3739
+ }
3740
+ /**
3741
+ * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3742
+ * Retrieves application's manifest and returns a wrapped application.
3743
+ * @param manifestUrl - The URL of app's manifest.
3744
+ * @param callback - called if the method succeeds.
3745
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3746
+ *
3747
+ * @example
3748
+ *
3749
+ * ```js
3750
+ * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3751
+ * ```
3752
+ * @ignore
3753
+ */
3754
+ createFromManifest(manifestUrl) {
3755
+ console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3756
+ this.wire.recordAnalytic('application-create-from-manifest');
3757
+ return this._createFromManifest(manifestUrl);
3758
+ }
3759
+ _createFromManifest(manifestUrl) {
3760
+ return this.wire
3761
+ .sendAction('get-application-manifest', { manifestUrl })
3762
+ .then(({ payload }) => {
3763
+ const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3764
+ return this.wrap({ uuid });
3765
+ })
3766
+ .then((app) => {
3767
+ app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3768
+ return app;
3769
+ });
3770
+ }
3867
3771
  }
3772
+ Factory$7.ApplicationModule = ApplicationModule;
3868
3773
 
3869
- var hasRequiredApplication;
3870
-
3871
- function requireApplication () {
3872
- if (hasRequiredApplication) return application;
3873
- hasRequiredApplication = 1;
3874
- (function (exports) {
3875
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3876
- if (k2 === undefined) k2 = k;
3877
- var desc = Object.getOwnPropertyDescriptor(m, k);
3878
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3879
- desc = { enumerable: true, get: function() { return m[k]; } };
3880
- }
3881
- Object.defineProperty(o, k2, desc);
3882
- }) : (function(o, m, k, k2) {
3883
- if (k2 === undefined) k2 = k;
3884
- o[k2] = m[k];
3885
- }));
3886
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3887
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3888
- };
3889
- Object.defineProperty(exports, "__esModule", { value: true });
3890
- /**
3891
- * Entry points for the OpenFin `Application` API (`fin.Application`).
3892
- *
3893
- * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3894
- * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3895
- *
3896
- * These are separate code entities, and are documented separately. In the [previous version of the API documentation](https://cdn.openfin.co/docs/javascript/32.114.76.10/index.html),
3897
- * both of these were documented on the same page.
3898
- *
3899
- * @packageDocumentation
3900
- */
3901
- __exportStar(requireFactory$1(), exports);
3902
- __exportStar(requireInstance$1(), exports);
3903
- } (application));
3904
- return application;
3905
- }
3774
+ (function (exports) {
3775
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3776
+ if (k2 === undefined) k2 = k;
3777
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3778
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3779
+ desc = { enumerable: true, get: function() { return m[k]; } };
3780
+ }
3781
+ Object.defineProperty(o, k2, desc);
3782
+ }) : (function(o, m, k, k2) {
3783
+ if (k2 === undefined) k2 = k;
3784
+ o[k2] = m[k];
3785
+ }));
3786
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3787
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3788
+ };
3789
+ Object.defineProperty(exports, "__esModule", { value: true });
3790
+ /**
3791
+ * Entry points for the OpenFin `Application` API (`fin.Application`).
3792
+ *
3793
+ * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3794
+ * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3795
+ *
3796
+ * These are separate code entities, and are documented separately. In the [previous version of the API documentation](https://cdn.openfin.co/docs/javascript/32.114.76.10/index.html),
3797
+ * both of these were documented on the same page.
3798
+ *
3799
+ * @packageDocumentation
3800
+ */
3801
+ __exportStar(Factory$7, exports);
3802
+ __exportStar(Instance$6, exports);
3803
+ } (application));
3906
3804
 
3907
3805
  var promisifySubscription$1 = {};
3908
3806
 
@@ -3946,7 +3844,7 @@ function requireInstance () {
3946
3844
  /* eslint-disable @typescript-eslint/no-unused-vars */
3947
3845
  /* eslint-disable no-console */
3948
3846
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
3949
- const application_1 = requireApplication();
3847
+ const application_1 = application;
3950
3848
  const main_1 = main;
3951
3849
  const view_1 = requireView();
3952
3850
  const warnings_1 = warnings;
@@ -3967,9 +3865,7 @@ function requireInstance () {
3967
3865
  super(wire, identity, 'window');
3968
3866
  }
3969
3867
  async createWindow(options) {
3970
- this.wire.sendAction('window-create-window', this.identity).catch((e) => {
3971
- // we do not want to expose this error, just continue if this analytics-only call fails
3972
- });
3868
+ this.wire.recordAnalytic('window-create-window');
3973
3869
  const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
3974
3870
  const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
3975
3871
  // set defaults:
@@ -4443,9 +4339,7 @@ function requireInstance () {
4443
4339
  * @experimental
4444
4340
  */
4445
4341
  async getLayout(layoutIdentity) {
4446
- this.wire.sendAction('window-get-layout', this.identity).catch((e) => {
4447
- // don't expose
4448
- });
4342
+ this.wire.recordAnalytic('window-get-layout');
4449
4343
  const opts = await this.getOptions();
4450
4344
  if (!opts.layout && !opts.layoutSnapshot) {
4451
4345
  throw new Error('Window does not have a Layout');
@@ -4494,9 +4388,7 @@ function requireInstance () {
4494
4388
  * ```
4495
4389
  */
4496
4390
  getParentApplication() {
4497
- this.wire.sendAction('window-get-parent-application', this.identity).catch((e) => {
4498
- // we do not want to expose this error, just continue if this analytics-only call fails
4499
- });
4391
+ this.wire.recordAnalytic('window-get-parent-application');
4500
4392
  return Promise.resolve(new application_1.Application(this.wire, this.identity));
4501
4393
  }
4502
4394
  /**
@@ -4519,9 +4411,7 @@ function requireInstance () {
4519
4411
  * ```
4520
4412
  */
4521
4413
  getParentWindow() {
4522
- this.wire.sendAction('window-get-parent-window', this.identity).catch((e) => {
4523
- // we do not want to expose this error, just continue if this analytics-only call fails
4524
- });
4414
+ this.wire.recordAnalytic('window-get-parent-window');
4525
4415
  return Promise.resolve(new application_1.Application(this.wire, this.identity)).then((app) => app.getWindow());
4526
4416
  }
4527
4417
  /**
@@ -4625,9 +4515,7 @@ function requireInstance () {
4625
4515
  * ```
4626
4516
  */
4627
4517
  getWebWindow() {
4628
- this.wire.sendAction('window-get-web-window', this.identity).catch((e) => {
4629
- // we do not want to expose this error, just continue if this analytics-only call fails
4630
- });
4518
+ this.wire.recordAnalytic('window-get-web-window');
4631
4519
  return this.wire.environment.getWebWindow(this.identity);
4632
4520
  }
4633
4521
  /**
@@ -4641,9 +4529,7 @@ function requireInstance () {
4641
4529
  * ```
4642
4530
  */
4643
4531
  isMainWindow() {
4644
- this.wire.sendAction('window-is-main-window', this.identity).catch((e) => {
4645
- // we do not want to expose this error, just continue if this analytics-only call fails
4646
- });
4532
+ this.wire.recordAnalytic('window-is-main-window');
4647
4533
  return this.me.uuid === this.me.name;
4648
4534
  }
4649
4535
  /**
@@ -5026,6 +4912,9 @@ function requireInstance () {
5026
4912
  * ```
5027
4913
  */
5028
4914
  updateOptions(options) {
4915
+ if ('frame' in options) {
4916
+ console.warn(`Deprecation Warning: Starting with version 45 it will not be possible to change the frame value after window has been created.`);
4917
+ }
5029
4918
  return this.wire.sendAction('update-window-options', { options, ...this.identity }).then(() => undefined);
5030
4919
  }
5031
4920
  /**
@@ -5162,9 +5051,7 @@ function requireInstance () {
5162
5051
  * ```
5163
5052
  */
5164
5053
  async dispatchPopupResult(data) {
5165
- this.wire.sendAction('window-dispatch-popup-result', this.identity).catch((e) => {
5166
- // we do not want to expose this error, just continue if this analytics-only call fails
5167
- });
5054
+ this.wire.recordAnalytic('window-dispatch-popup-result');
5168
5055
  await this.wire.sendAction('dispatch-popup-result', { data, ...this.identity });
5169
5056
  }
5170
5057
  /**
@@ -5264,9 +5151,7 @@ function requireFactory () {
5264
5151
  * ```
5265
5152
  */
5266
5153
  async wrap(identity) {
5267
- this.wire.sendAction('window-wrap').catch((e) => {
5268
- // we do not want to expose this error, just continue if this analytics-only call fails
5269
- });
5154
+ this.wire.recordAnalytic('window-wrap');
5270
5155
  const errorMsg = (0, validate_1.validateIdentity)(identity);
5271
5156
  if (errorMsg) {
5272
5157
  throw new Error(errorMsg);
@@ -5296,9 +5181,7 @@ function requireFactory () {
5296
5181
  * ```
5297
5182
  */
5298
5183
  wrapSync(identity) {
5299
- this.wire.sendAction('window-wrap-sync').catch((e) => {
5300
- // we do not want to expose this error, just continue if this analytics-only call fails
5301
- });
5184
+ this.wire.recordAnalytic('window-wrap-sync');
5302
5185
  const errorMsg = (0, validate_1.validateIdentity)(identity);
5303
5186
  if (errorMsg) {
5304
5187
  throw new Error(errorMsg);
@@ -5327,9 +5210,7 @@ function requireFactory () {
5327
5210
  * ```
5328
5211
  */
5329
5212
  create(options) {
5330
- this.wire.sendAction('create-window').catch((e) => {
5331
- // we do not want to expose this error, just continue if this analytics-only call fails
5332
- });
5213
+ this.wire.recordAnalytic('create-window');
5333
5214
  const win = new Instance_1._Window(this.wire, { uuid: this.me.uuid, name: options.name });
5334
5215
  return win.createWindow(options);
5335
5216
  }
@@ -5345,9 +5226,7 @@ function requireFactory () {
5345
5226
  * ```
5346
5227
  */
5347
5228
  getCurrent() {
5348
- this.wire.sendAction('get-current-window').catch((e) => {
5349
- // we do not want to expose this error, just continue if this analytics-only call fails
5350
- });
5229
+ this.wire.recordAnalytic('get-current-window');
5351
5230
  if (!this.wire.me.isWindow) {
5352
5231
  throw new Error('You are not in a Window context');
5353
5232
  }
@@ -5366,9 +5245,7 @@ function requireFactory () {
5366
5245
  * ```
5367
5246
  */
5368
5247
  getCurrentSync() {
5369
- this.wire.sendAction('get-current-window-sync').catch((e) => {
5370
- // we do not want to expose this error, just continue if this analytics-only call fails
5371
- });
5248
+ this.wire.recordAnalytic('get-current-window-sync');
5372
5249
  if (!this.wire.me.isWindow) {
5373
5250
  throw new Error('You are not in a Window context');
5374
5251
  }
@@ -5514,13 +5391,15 @@ class System extends base_1$l.EmitterBase {
5514
5391
  * * cookies: browser [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)
5515
5392
  * * localStorage: browser data that can be used across sessions ([local storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage))
5516
5393
  * * appcache: html5 [application cache](https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache)
5394
+ * * windowState: clears data written for windows using `saveWindowState`; after clearing, previously saved bounds and state will not be restored until new state is written
5517
5395
  * @example
5518
5396
  * ```js
5519
5397
  * const clearCacheOptions = {
5520
5398
  * appcache: true,
5521
5399
  * cache: true,
5522
5400
  * cookies: true,
5523
- * localStorage: true
5401
+ * localStorage: true,
5402
+ * windowState: true
5524
5403
  * };
5525
5404
  * fin.System.clearCache(clearCacheOptions).then(() => console.log('Cache cleared')).catch(err => console.log(err));
5526
5405
  * ```
@@ -6922,9 +6801,7 @@ class System extends base_1$l.EmitterBase {
6922
6801
  * @experimental
6923
6802
  */
6924
6803
  async registerShutdownHandler(handler) {
6925
- this.wire.sendAction('system-register-shutdown-handler').catch((e) => {
6926
- // don't expose, analytics-only call
6927
- });
6804
+ this.wire.recordAnalytic('system-register-shutdown-handler');
6928
6805
  const SystemShutdownEventName = 'system-shutdown';
6929
6806
  const SystemShutdownHandledEventName = 'system-shutdown-handled';
6930
6807
  const { uuid, name } = this.wire.me;
@@ -9628,6 +9505,16 @@ class InterApplicationBus extends base_1$g.Base {
9628
9505
  */
9629
9506
  constructor(wire) {
9630
9507
  super(wire);
9508
+ /**
9509
+ * Event types for the InterApplicationBus.
9510
+ *
9511
+ * @remarks The `subscriber-added` and `subscriber-removed` events are disabled by default.
9512
+ * To re-enable them, launch the runtime with the `--emit-legacy-iab-events` flag.
9513
+ * These events will be removed in a future version. Use {@link Channel} for connection
9514
+ * lifecycle management instead.
9515
+ *
9516
+ * @deprecated Use {@link Channel} `onConnection` / `onDisconnection` instead.
9517
+ */
9631
9518
  this.events = {
9632
9519
  subscriberAdded: 'subscriber-added',
9633
9520
  subscriberRemoved: 'subscriber-removed'
@@ -10114,9 +10001,7 @@ class ExternalApplicationModule extends base_1$d.Base {
10114
10001
  * ```
10115
10002
  */
10116
10003
  wrap(uuid) {
10117
- this.wire.sendAction('external-application-wrap').catch((e) => {
10118
- // we do not want to expose this error, just continue if this analytics-only call fails
10119
- });
10004
+ this.wire.recordAnalytic('external-application-wrap');
10120
10005
  return Promise.resolve(new Instance_1$4.ExternalApplication(this.wire, { uuid }));
10121
10006
  }
10122
10007
  /**
@@ -10133,9 +10018,7 @@ class ExternalApplicationModule extends base_1$d.Base {
10133
10018
  * ```
10134
10019
  */
10135
10020
  wrapSync(uuid) {
10136
- this.wire.sendAction('external-application-wrap-sync').catch((e) => {
10137
- // we do not want to expose this error, just continue if this analytics-only call fails
10138
- });
10021
+ this.wire.recordAnalytic('external-application-wrap-sync');
10139
10022
  return new Instance_1$4.ExternalApplication(this.wire, { uuid });
10140
10023
  }
10141
10024
  }
@@ -10270,9 +10153,7 @@ class _FrameModule extends base_1$b.Base {
10270
10153
  * ```
10271
10154
  */
10272
10155
  async wrap(identity) {
10273
- this.wire.sendAction('frame-wrap').catch((e) => {
10274
- // we do not want to expose this error, just continue if this analytics-only call fails
10275
- });
10156
+ this.wire.recordAnalytic('frame-wrap');
10276
10157
  const errorMsg = (0, validate_1$2.validateIdentity)(identity);
10277
10158
  if (errorMsg) {
10278
10159
  throw new Error(errorMsg);
@@ -10294,9 +10175,7 @@ class _FrameModule extends base_1$b.Base {
10294
10175
  * ```
10295
10176
  */
10296
10177
  wrapSync(identity) {
10297
- this.wire.sendAction('frame-wrap-sync').catch((e) => {
10298
- // we do not want to expose this error, just continue if this analytics-only call fails
10299
- });
10178
+ this.wire.recordAnalytic('frame-wrap-sync');
10300
10179
  const errorMsg = (0, validate_1$2.validateIdentity)(identity);
10301
10180
  if (errorMsg) {
10302
10181
  throw new Error(errorMsg);
@@ -10314,9 +10193,7 @@ class _FrameModule extends base_1$b.Base {
10314
10193
  * ```
10315
10194
  */
10316
10195
  getCurrent() {
10317
- this.wire.sendAction('frame-get-current').catch((e) => {
10318
- // we do not want to expose this error, just continue if this analytics-only call fails
10319
- });
10196
+ this.wire.recordAnalytic('frame-get-current');
10320
10197
  return Promise.resolve(new Instance_1$3._Frame(this.wire, this.wire.environment.getCurrentEntityIdentity()));
10321
10198
  }
10322
10199
  /**
@@ -10330,9 +10207,7 @@ class _FrameModule extends base_1$b.Base {
10330
10207
  * ```
10331
10208
  */
10332
10209
  getCurrentSync() {
10333
- this.wire.sendAction('frame-get-current-sync').catch((e) => {
10334
- // we do not want to expose this error, just continue if this analytics-only call fails
10335
- });
10210
+ this.wire.recordAnalytic('frame-get-current-sync');
10336
10211
  return new Instance_1$3._Frame(this.wire, this.wire.environment.getCurrentEntityIdentity());
10337
10212
  }
10338
10213
  }
@@ -12562,9 +12437,7 @@ class LayoutModule extends base_1$7.Base {
12562
12437
  * ```
12563
12438
  */
12564
12439
  this.init = async (options = {}) => {
12565
- this.wire.sendAction('layout-init').catch((e) => {
12566
- // don't expose
12567
- });
12440
+ this.wire.recordAnalytic('layout-init');
12568
12441
  if (!this.wire.environment.layoutAllowedInContext(this.fin)) {
12569
12442
  throw new Error('Layout.init can only be called from a Window context.');
12570
12443
  }
@@ -12642,9 +12515,7 @@ class LayoutModule extends base_1$7.Base {
12642
12515
  * ```
12643
12516
  */
12644
12517
  async wrap(identity) {
12645
- this.wire.sendAction('layout-wrap').catch((e) => {
12646
- // don't expose
12647
- });
12518
+ this.wire.recordAnalytic('layout-wrap');
12648
12519
  return new Instance_1$2.Layout(identity, this.wire);
12649
12520
  }
12650
12521
  /**
@@ -12667,9 +12538,7 @@ class LayoutModule extends base_1$7.Base {
12667
12538
  * ```
12668
12539
  */
12669
12540
  wrapSync(identity) {
12670
- this.wire.sendAction('layout-wrap-sync').catch((e) => {
12671
- // don't expose
12672
- });
12541
+ this.wire.recordAnalytic('layout-wrap-sync');
12673
12542
  return new Instance_1$2.Layout(identity, this.wire);
12674
12543
  }
12675
12544
  /**
@@ -12683,9 +12552,7 @@ class LayoutModule extends base_1$7.Base {
12683
12552
  * ```
12684
12553
  */
12685
12554
  async getCurrent() {
12686
- this.wire.sendAction('layout-get-current').catch((e) => {
12687
- // don't expose
12688
- });
12555
+ this.wire.recordAnalytic('layout-get-current');
12689
12556
  if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12690
12557
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12691
12558
  }
@@ -12706,9 +12573,7 @@ class LayoutModule extends base_1$7.Base {
12706
12573
  * ```
12707
12574
  */
12708
12575
  getCurrentSync() {
12709
- this.wire.sendAction('layout-get-current-sync').catch((e) => {
12710
- // don't expose
12711
- });
12576
+ this.wire.recordAnalytic('layout-get-current-sync');
12712
12577
  if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12713
12578
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12714
12579
  }
@@ -12726,9 +12591,7 @@ class LayoutModule extends base_1$7.Base {
12726
12591
  * ```
12727
12592
  */
12728
12593
  async getLayoutByViewIdentity(viewIdentity) {
12729
- this.wire.sendAction('layout-get-by-view-identity').catch(() => {
12730
- // don't expose
12731
- });
12594
+ this.wire.recordAnalytic('layout-get-by-view-identity');
12732
12595
  const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
12733
12596
  let layoutWindowIdentity = winIdentity;
12734
12597
  // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
@@ -12890,9 +12753,7 @@ class PlatformModule extends base_1$6.Base {
12890
12753
  * ```
12891
12754
  */
12892
12755
  async wrap(identity) {
12893
- this.wire.sendAction('platform-wrap').catch((e) => {
12894
- // don't expose
12895
- });
12756
+ this.wire.recordAnalytic('platform-wrap');
12896
12757
  return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12897
12758
  }
12898
12759
  /**
@@ -12907,9 +12768,7 @@ class PlatformModule extends base_1$6.Base {
12907
12768
  * ```
12908
12769
  */
12909
12770
  wrapSync(identity) {
12910
- this.wire.sendAction('platform-wrap-sync').catch((e) => {
12911
- // don't expose
12912
- });
12771
+ this.wire.recordAnalytic('platform-wrap-sync');
12913
12772
  return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12914
12773
  }
12915
12774
  /**
@@ -12923,9 +12782,7 @@ class PlatformModule extends base_1$6.Base {
12923
12782
  * ```
12924
12783
  */
12925
12784
  async getCurrent() {
12926
- this.wire.sendAction('platform-get-current').catch((e) => {
12927
- // don't expose
12928
- });
12785
+ this.wire.recordAnalytic('platform-get-current');
12929
12786
  return this.wrap({ uuid: this.wire.me.uuid });
12930
12787
  }
12931
12788
  /**
@@ -12939,9 +12796,7 @@ class PlatformModule extends base_1$6.Base {
12939
12796
  * ```
12940
12797
  */
12941
12798
  getCurrentSync() {
12942
- this.wire.sendAction('platform-get-current-sync').catch((e) => {
12943
- // don't expose
12944
- });
12799
+ this.wire.recordAnalytic('platform-get-current-sync');
12945
12800
  return this.wrapSync({ uuid: this.wire.me.uuid });
12946
12801
  }
12947
12802
  /**
@@ -12969,9 +12824,7 @@ class PlatformModule extends base_1$6.Base {
12969
12824
  * ```
12970
12825
  */
12971
12826
  start(platformOptions) {
12972
- this.wire.sendAction('platform-start').catch((e) => {
12973
- // don't expose
12974
- });
12827
+ this.wire.recordAnalytic('platform-start');
12975
12828
  // eslint-disable-next-line no-async-promise-executor
12976
12829
  return new Promise(async (resolve, reject) => {
12977
12830
  try {
@@ -13013,9 +12866,7 @@ class PlatformModule extends base_1$6.Base {
13013
12866
  * ```
13014
12867
  */
13015
12868
  startFromManifest(manifestUrl, opts) {
13016
- this.wire.sendAction('platform-start-from-manifest').catch((e) => {
13017
- // don't expose
13018
- });
12869
+ this.wire.recordAnalytic('platform-start-from-manifest');
13019
12870
  // eslint-disable-next-line no-async-promise-executor
13020
12871
  return new Promise(async (resolve, reject) => {
13021
12872
  try {
@@ -16057,7 +15908,6 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
16057
15908
  // Generate an ID to make a session context group with. We will pass that ID to the Broker.
16058
15909
  // The broker will then setContext on that session context group later with our Intent Result,
16059
15910
  const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
16060
- let isPromiseSettled = false;
16061
15911
  // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
16062
15912
  const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
16063
15913
  const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
@@ -16073,21 +15923,11 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
16073
15923
  reject(new Error('getResult is not supported in this environment'));
16074
15924
  });
16075
15925
  });
16076
- getResultPromise
16077
- .then(() => {
16078
- isPromiseSettled = true;
16079
- })
16080
- .catch(() => {
16081
- isPromiseSettled = true;
16082
- });
16083
15926
  // Set up the getResult call.
16084
15927
  const getResult = async () => {
16085
- // All this mumbo jumbo is needed to make sure that getResult resolves correctly and conforms to the FDC3 spec.
16086
- if (!isPromiseSettled) {
16087
- return undefined;
16088
- }
16089
15928
  let intentResult = await getResultPromise;
16090
- if (isPromiseSettled && !intentResult) {
15929
+ // void / no payload, or web path where subscribe resolves undefined (see getResultPromise above)
15930
+ if (intentResult == null) {
16091
15931
  return undefined;
16092
15932
  }
16093
15933
  if (typeof intentResult !== 'object') {
@@ -16178,9 +16018,7 @@ class FDC3ModuleBase {
16178
16018
  * @static
16179
16019
  */
16180
16020
  async broadcast(context) {
16181
- this.wire.sendAction('fdc3-broadcast').catch((e) => {
16182
- // we do not want to expose this error, just continue if this analytics-only call fails
16183
- });
16021
+ this.wire.recordAnalytic('fdc3-broadcast');
16184
16022
  return this.client.setContext(context);
16185
16023
  }
16186
16024
  /**
@@ -16191,9 +16029,7 @@ class FDC3ModuleBase {
16191
16029
  * @tutorial fdc3.open
16192
16030
  */
16193
16031
  async _open(app, context) {
16194
- this.wire.sendAction('fdc3-open').catch((e) => {
16195
- // we do not want to expose this error, just continue if this analytics-only call fails
16196
- });
16032
+ this.wire.recordAnalytic('fdc3-open');
16197
16033
  try {
16198
16034
  return await InteropClient_1$2.InteropClient.ferryFdc3Call(this.client, 'fdc3Open', { app, context });
16199
16035
  }
@@ -16217,9 +16053,7 @@ class FDC3ModuleBase {
16217
16053
  * @tutorial fdc3.getOrCreateChannel
16218
16054
  */
16219
16055
  async getOrCreateChannel(channelId, fdc3Factory) {
16220
- this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
16221
- // we do not want to expose this error, just continue if this analytics-only call fails
16222
- });
16056
+ this.wire.recordAnalytic('fdc3-get-or-create-channel');
16223
16057
  const hasChannelIdBeenUsed = await InteropClient_1$2.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
16224
16058
  channelId
16225
16059
  });
@@ -16247,9 +16081,7 @@ class FDC3ModuleBase {
16247
16081
  * @static
16248
16082
  */
16249
16083
  async getSystemChannels() {
16250
- this.wire.sendAction('fdc3-get-system-channels').catch((e) => {
16251
- // we do not want to expose this error, just continue if this analytics-only call fails
16252
- });
16084
+ this.wire.recordAnalytic('fdc3-get-system-channels');
16253
16085
  return this._getChannels();
16254
16086
  }
16255
16087
  /**
@@ -16264,9 +16096,7 @@ class FDC3ModuleBase {
16264
16096
  * @static
16265
16097
  */
16266
16098
  async joinChannel(channelId) {
16267
- this.wire.sendAction('fdc3-join-channel').catch((e) => {
16268
- // we do not want to expose this error, just continue if this analytics-only call fails
16269
- });
16099
+ this.wire.recordAnalytic('fdc3-join-channel');
16270
16100
  try {
16271
16101
  return await this.client.joinContextGroup(channelId);
16272
16102
  }
@@ -16289,9 +16119,7 @@ class FDC3ModuleBase {
16289
16119
  * @tutorial fdc3.getCurrentChannel
16290
16120
  */
16291
16121
  async getCurrentChannel() {
16292
- this.wire.sendAction('fdc3-get-current-channel').catch((e) => {
16293
- // we do not want to expose this error, just continue if this analytics-only call fails
16294
- });
16122
+ this.wire.recordAnalytic('fdc3-get-current-channel');
16295
16123
  const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
16296
16124
  if (!currentContextGroupInfo) {
16297
16125
  return null;
@@ -16306,9 +16134,7 @@ class FDC3ModuleBase {
16306
16134
  * @static
16307
16135
  */
16308
16136
  async leaveCurrentChannel() {
16309
- this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
16310
- // we do not want to expose this error, just continue if this analytics-only call fails
16311
- });
16137
+ this.wire.recordAnalytic('fdc3-leave-current-channel');
16312
16138
  return this.client.removeFromContextGroup();
16313
16139
  }
16314
16140
  // utils
@@ -16434,9 +16260,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16434
16260
  */
16435
16261
  // @ts-expect-error TODO [CORE-1524]
16436
16262
  addContextListener(contextType, handler) {
16437
- this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
16438
- // we do not want to expose this error, just continue if this analytics-only call fails
16439
- });
16263
+ this.wire.recordAnalytic('fdc3-add-context-listener');
16440
16264
  let listener;
16441
16265
  if (typeof contextType === 'function') {
16442
16266
  console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
@@ -16459,9 +16283,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16459
16283
  * @static
16460
16284
  */
16461
16285
  addIntentListener(intent, handler) {
16462
- this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
16463
- // we do not want to expose this error, just continue if this analytics-only call fails
16464
- });
16286
+ this.wire.recordAnalytic('fdc3-add-intent-listener');
16465
16287
  const contextHandler = (raisedIntent) => {
16466
16288
  const { context, metadata: intentMetadata } = raisedIntent;
16467
16289
  const { metadata } = context;
@@ -16489,9 +16311,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16489
16311
  * @static
16490
16312
  */
16491
16313
  async raiseIntent(intent, context, app) {
16492
- this.wire.sendAction('fdc3-raise-intent').catch((e) => {
16493
- // we do not want to expose this error, just continue if this analytics-only call fails
16494
- });
16314
+ this.wire.recordAnalytic('fdc3-raise-intent');
16495
16315
  const intentObj = app
16496
16316
  ? { name: intent, context, metadata: { target: app } }
16497
16317
  : { name: intent, context };
@@ -16511,9 +16331,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16511
16331
  * @tutorial fdc3.findIntent
16512
16332
  */
16513
16333
  async findIntent(intent, context) {
16514
- this.wire.sendAction('fdc3-find-intent').catch((e) => {
16515
- // we do not want to expose this error, just continue if this analytics-only call fails
16516
- });
16334
+ this.wire.recordAnalytic('fdc3-find-intent');
16517
16335
  try {
16518
16336
  return await this.client.getInfoForIntent({ name: intent, context });
16519
16337
  }
@@ -16529,9 +16347,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16529
16347
  * @tutorial fdc3.findIntentsByContext
16530
16348
  */
16531
16349
  async findIntentsByContext(context) {
16532
- this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
16533
- // we do not want to expose this error, just continue if this analytics-only call fails
16534
- });
16350
+ this.wire.recordAnalytic('fdc3-find-intents-by-context');
16535
16351
  try {
16536
16352
  return await this.client.getInfoForIntentsByContext(context);
16537
16353
  }
@@ -16548,9 +16364,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16548
16364
  * @tutorial fdc3.raiseIntentForContext
16549
16365
  */
16550
16366
  async raiseIntentForContext(context, app) {
16551
- this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
16552
- // we do not want to expose this error, just continue if this analytics-only call fails
16553
- });
16367
+ this.wire.recordAnalytic('fdc3-raise-intent-for-context');
16554
16368
  try {
16555
16369
  return await this.client.fireIntentForContext({ ...context, metadata: { target: app } });
16556
16370
  }
@@ -16574,9 +16388,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
16574
16388
  * @tutorial fdc3.getInfo
16575
16389
  */
16576
16390
  getInfo() {
16577
- this.wire.sendAction('fdc3-get-info').catch((e) => {
16578
- // we do not want to expose this error, just continue if this analytics-only call fails
16579
- });
16391
+ this.wire.recordAnalytic('fdc3-get-info');
16580
16392
  const version = this.wire.environment.getAdapterVersionSync();
16581
16393
  return {
16582
16394
  providerVersion: version,
@@ -16654,9 +16466,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16654
16466
  * @tutorial fdc3v2.findInstances
16655
16467
  */
16656
16468
  async findInstances(app) {
16657
- this.wire.sendAction('fdc3-find-instances').catch((e) => {
16658
- // we do not want to expose this error, just continue if this analytics-only call fails
16659
- });
16469
+ this.wire.recordAnalytic('fdc3-find-instances');
16660
16470
  try {
16661
16471
  return await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'fdc3FindInstances', app);
16662
16472
  }
@@ -16672,9 +16482,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16672
16482
  * @tutorial fdc3v2.getAppMetadata
16673
16483
  */
16674
16484
  async getAppMetadata(app) {
16675
- this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
16676
- // we do not want to expose this error, just continue if this analytics-only call fails
16677
- });
16485
+ this.wire.recordAnalytic('fdc3-get-app-metadata');
16678
16486
  try {
16679
16487
  return await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'fdc3GetAppMetadata', app);
16680
16488
  }
@@ -16692,9 +16500,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16692
16500
  */
16693
16501
  // @ts-expect-error TODO [CORE-1524]
16694
16502
  async addContextListener(contextType, handler) {
16695
- this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
16696
- // we do not want to expose this error, just continue if this analytics-only call fails
16697
- });
16503
+ this.wire.recordAnalytic('fdc3-add-context-listener');
16698
16504
  // The FDC3 ContextHandler only expects the context and optional ContextMetadata, so we wrap the handler
16699
16505
  // here so it only gets passed these parameters
16700
16506
  const getWrappedHandler = (handlerToWrap) => {
@@ -16723,9 +16529,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16723
16529
  * @tutorial fdc3.findIntent
16724
16530
  */
16725
16531
  async findIntent(intent, context, resultType) {
16726
- this.wire.sendAction('fdc3-find-intent').catch((e) => {
16727
- // we do not want to expose this error, just continue if this analytics-only call fails
16728
- });
16532
+ this.wire.recordAnalytic('fdc3-find-intent');
16729
16533
  try {
16730
16534
  return await this.client.getInfoForIntent({ name: intent, context, metadata: { resultType } });
16731
16535
  }
@@ -16742,9 +16546,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16742
16546
  * @tutorial fdc3v2.findIntentsByContext
16743
16547
  */
16744
16548
  async findIntentsByContext(context, resultType) {
16745
- this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
16746
- // we do not want to expose this error, just continue if this analytics-only call fails
16747
- });
16549
+ this.wire.recordAnalytic('fdc3-find-intents-by-context');
16748
16550
  const payload = resultType ? { context, metadata: { resultType } } : context;
16749
16551
  try {
16750
16552
  return await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2FindIntentsByContext', payload);
@@ -16763,9 +16565,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16763
16565
  * @tutorial fdc3v2.raiseIntent
16764
16566
  */
16765
16567
  async raiseIntent(intent, context, app) {
16766
- this.wire.sendAction('fdc3-raise-intent').catch((e) => {
16767
- // we do not want to expose this error, just continue if this analytics-only call fails
16768
- });
16568
+ this.wire.recordAnalytic('fdc3-raise-intent');
16769
16569
  try {
16770
16570
  if (typeof app === 'string') {
16771
16571
  console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
@@ -16786,9 +16586,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16786
16586
  */
16787
16587
  async raiseIntentForContext(context, app) {
16788
16588
  // TODO: We have to do the same thing we do for raiseIntent here as well.
16789
- this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
16790
- // we do not want to expose this error, just continue if this analytics-only call fails
16791
- });
16589
+ this.wire.recordAnalytic('fdc3-raise-intent-for-context');
16792
16590
  try {
16793
16591
  if (typeof app === 'string') {
16794
16592
  console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
@@ -16808,9 +16606,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
16808
16606
  * @tutorial fdc3.addIntentListener
16809
16607
  */
16810
16608
  async addIntentListener(intent, handler) {
16811
- this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
16812
- // we do not want to expose this error, just continue if this analytics-only call fails
16813
- });
16609
+ this.wire.recordAnalytic('fdc3-add-intent-listener');
16814
16610
  if (typeof intent !== 'string') {
16815
16611
  throw new Error('First argument must be an Intent name');
16816
16612
  }
@@ -16987,9 +16783,7 @@ class InteropModule extends base_1$2.Base {
16987
16783
  * ```
16988
16784
  */
16989
16785
  async init(name, override = defaultOverride) {
16990
- this.wire.sendAction('interop-init').catch(() => {
16991
- // don't expose, analytics-only call
16992
- });
16786
+ this.wire.recordAnalytic('interop-init');
16993
16787
  // Allows for manifest-level configuration, without having to override. (e.g. specifying custom context groups)
16994
16788
  const options = await this.wire.environment.getInteropInfo(this.wire.getFin());
16995
16789
  const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
@@ -17038,9 +16832,7 @@ class InteropModule extends base_1$2.Base {
17038
16832
  * ```
17039
16833
  */
17040
16834
  connectSync(name, interopConfig) {
17041
- this.wire.sendAction('interop-connect-sync').catch(() => {
17042
- // don't expose, analytics-only call
17043
- });
16835
+ this.wire.recordAnalytic('interop-connect-sync');
17044
16836
  return new InteropClient_1.InteropClient(this.wire, this.wire.environment.whenReady().then(() => {
17045
16837
  return this.fin.InterApplicationBus.Channel.connect(`interop-broker-${name}`, {
17046
16838
  payload: interopConfig
@@ -17209,9 +17001,7 @@ class SnapshotSource extends base_1$1.Base {
17209
17001
  * ```
17210
17002
  */
17211
17003
  async ready() {
17212
- this.wire.sendAction('snapshot-source-ready').catch((e) => {
17213
- // don't expose, analytics-only call
17214
- });
17004
+ this.wire.recordAnalytic('snapshot-source-ready');
17215
17005
  // eslint-disable-next-line no-async-promise-executor
17216
17006
  try {
17217
17007
  // If getClient was already called before this, do we have a timing issue where the channel might have been created but we missed the event but this still fails?
@@ -17227,9 +17017,7 @@ class SnapshotSource extends base_1$1.Base {
17227
17017
  *
17228
17018
  */
17229
17019
  async getSnapshot() {
17230
- this.wire.sendAction('snapshot-source-get-snapshot').catch((e) => {
17231
- // don't expose, analytics-only call
17232
- });
17020
+ this.wire.recordAnalytic('snapshot-source-get-snapshot');
17233
17021
  const client = await __classPrivateFieldGet$1(this, _SnapshotSource_getClient, "f").call(this);
17234
17022
  const response = (await client.dispatch('get-snapshot'));
17235
17023
  return (await response).snapshot;
@@ -17239,9 +17027,7 @@ class SnapshotSource extends base_1$1.Base {
17239
17027
  *
17240
17028
  */
17241
17029
  async applySnapshot(snapshot) {
17242
- this.wire.sendAction('snapshot-source-apply-snapshot').catch((e) => {
17243
- // don't expose, analytics-only call
17244
- });
17030
+ this.wire.recordAnalytic('snapshot-source-apply-snapshot');
17245
17031
  const client = await __classPrivateFieldGet$1(this, _SnapshotSource_getClient, "f").call(this);
17246
17032
  return client.dispatch('apply-snapshot', { snapshot });
17247
17033
  }
@@ -17282,9 +17068,7 @@ class SnapshotSourceModule extends base_1.Base {
17282
17068
  *
17283
17069
  */
17284
17070
  async init(provider) {
17285
- this.wire.sendAction('snapshot-source-init').catch((e) => {
17286
- // don't expose, analytics-only call
17287
- });
17071
+ this.wire.recordAnalytic('snapshot-source-init');
17288
17072
  if (typeof provider !== 'object' ||
17289
17073
  typeof provider.getSnapshot !== 'function' ||
17290
17074
  typeof provider.applySnapshot !== 'function') {
@@ -17308,9 +17092,7 @@ class SnapshotSourceModule extends base_1.Base {
17308
17092
  * ```
17309
17093
  */
17310
17094
  wrapSync(identity) {
17311
- this.wire.sendAction('snapshot-source-wrap-sync').catch((e) => {
17312
- // don't expose, analytics-only call
17313
- });
17095
+ this.wire.recordAnalytic('snapshot-source-wrap-sync');
17314
17096
  return new Instance_1.SnapshotSource(this.wire, identity);
17315
17097
  }
17316
17098
  /**
@@ -17324,9 +17106,7 @@ class SnapshotSourceModule extends base_1.Base {
17324
17106
  * ```
17325
17107
  */
17326
17108
  async wrap(identity) {
17327
- this.wire.sendAction('snapshot-source-wrap').catch((e) => {
17328
- // don't expose, analytics-only call
17329
- });
17109
+ this.wire.recordAnalytic('snapshot-source-wrap');
17330
17110
  return this.wrapSync(identity);
17331
17111
  }
17332
17112
  }
@@ -17369,7 +17149,7 @@ const events_1$3 = require$$0;
17369
17149
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
17370
17150
  const index_1 = system;
17371
17151
  const index_2 = requireWindow();
17372
- const index_3 = requireApplication();
17152
+ const index_3 = application;
17373
17153
  const index_4 = interappbus;
17374
17154
  const index_5 = clipboard;
17375
17155
  const index_6 = externalApplication;
@@ -17544,7 +17324,7 @@ var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFie
17544
17324
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
17545
17325
  return (mod && mod.__esModule) ? mod : { "default": mod };
17546
17326
  };
17547
- var _Transport_wire, _Transport_fin;
17327
+ var _Transport_instances, _Transport_wire, _Transport_analyticsEnabled, _Transport_analyticsBuffer, _Transport_analyticsFlushTimeout, _Transport_fin, _Transport_flushAnalytics;
17548
17328
  Object.defineProperty(transport, "__esModule", { value: true });
17549
17329
  var Transport_1 = transport.Transport = void 0;
17550
17330
  const events_1$1 = require$$0;
@@ -17556,11 +17336,15 @@ const errors_1 = errors;
17556
17336
  class Transport extends events_1$1.EventEmitter {
17557
17337
  constructor(factory, environment, config) {
17558
17338
  super();
17339
+ _Transport_instances.add(this);
17559
17340
  this.wireListeners = new Map();
17560
17341
  this.topicRefMap = new Map();
17561
17342
  this.eventAggregator = new eventAggregator_1.default();
17562
17343
  this.messageHandlers = [this.eventAggregator.dispatchEvent];
17563
17344
  _Transport_wire.set(this, void 0);
17345
+ _Transport_analyticsEnabled.set(this, true);
17346
+ _Transport_analyticsBuffer.set(this, new Map());
17347
+ _Transport_analyticsFlushTimeout.set(this, void 0);
17564
17348
  // Typing as unknown to avoid circular dependency, should not be used directly.
17565
17349
  _Transport_fin.set(this, void 0);
17566
17350
  this.connectSync = () => {
@@ -17574,6 +17358,7 @@ class Transport extends events_1$1.EventEmitter {
17574
17358
  };
17575
17359
  __classPrivateFieldSet(this, _Transport_wire, factory(this.onmessage.bind(this)), "f");
17576
17360
  this.environment = environment;
17361
+ __classPrivateFieldSet(this, _Transport_analyticsEnabled, config.apiDiagnostics !== false, "f");
17577
17362
  this.sendRaw = __classPrivateFieldGet(this, _Transport_wire, "f").send.bind(__classPrivateFieldGet(this, _Transport_wire, "f"));
17578
17363
  this.registerMessageHandler(this.handleMessage.bind(this));
17579
17364
  __classPrivateFieldGet(this, _Transport_wire, "f").on('disconnected', () => {
@@ -17581,6 +17366,9 @@ class Transport extends events_1$1.EventEmitter {
17581
17366
  handleNack({ reason: 'Remote connection has closed' });
17582
17367
  }
17583
17368
  this.wireListeners.clear();
17369
+ clearTimeout(__classPrivateFieldGet(this, _Transport_analyticsFlushTimeout, "f"));
17370
+ __classPrivateFieldSet(this, _Transport_analyticsFlushTimeout, undefined, "f");
17371
+ __classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").clear();
17584
17372
  this.emit('disconnected');
17585
17373
  });
17586
17374
  const { uuid, name } = config;
@@ -17599,6 +17387,18 @@ class Transport extends events_1$1.EventEmitter {
17599
17387
  }
17600
17388
  __classPrivateFieldSet(this, _Transport_fin, _fin, "f");
17601
17389
  }
17390
+ recordAnalytic(action) {
17391
+ if (!__classPrivateFieldGet(this, _Transport_analyticsEnabled, "f"))
17392
+ return;
17393
+ __classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").set(action, (__classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").get(action) ?? 0) + 1);
17394
+ if (__classPrivateFieldGet(this, _Transport_analyticsFlushTimeout, "f") === undefined) {
17395
+ const timeout = setTimeout(() => __classPrivateFieldGet(this, _Transport_instances, "m", _Transport_flushAnalytics).call(this), 30000);
17396
+ if (typeof timeout === 'object' && timeout !== null) {
17397
+ timeout.unref?.();
17398
+ }
17399
+ __classPrivateFieldSet(this, _Transport_analyticsFlushTimeout, timeout, "f");
17400
+ }
17401
+ }
17602
17402
  shutdown() {
17603
17403
  const wire = __classPrivateFieldGet(this, _Transport_wire, "f");
17604
17404
  return wire.shutdown();
@@ -17762,7 +17562,16 @@ class Transport extends events_1$1.EventEmitter {
17762
17562
  }
17763
17563
  }
17764
17564
  Transport_1 = transport.Transport = Transport;
17765
- _Transport_wire = new WeakMap(), _Transport_fin = new WeakMap();
17565
+ _Transport_wire = new WeakMap(), _Transport_analyticsEnabled = new WeakMap(), _Transport_analyticsBuffer = new WeakMap(), _Transport_analyticsFlushTimeout = new WeakMap(), _Transport_fin = new WeakMap(), _Transport_instances = new WeakSet(), _Transport_flushAnalytics = function _Transport_flushAnalytics() {
17566
+ __classPrivateFieldSet(this, _Transport_analyticsFlushTimeout, undefined, "f");
17567
+ if (__classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").size === 0)
17568
+ return;
17569
+ const counts = Object.fromEntries(__classPrivateFieldGet(this, _Transport_analyticsBuffer, "f"));
17570
+ __classPrivateFieldGet(this, _Transport_analyticsBuffer, "f").clear();
17571
+ this.sendAction('send-analytics-batch', { counts }).catch(() => {
17572
+ // analytics flush failure is non-fatal, counts are already cleared
17573
+ });
17574
+ };
17766
17575
 
17767
17576
  var stubEnvironment = {};
17768
17577