@openfin/remote-adapter 36.79.1 → 36.79.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/out/remote-adapter.js +1125 -1104
  2. package/package.json +1 -1
@@ -590,11 +590,11 @@ const handleDeprecatedWarnings = (options) => {
590
590
  };
591
591
  warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
592
592
 
593
- var hasRequiredFactory$2;
593
+ var hasRequiredFactory$3;
594
594
 
595
- function requireFactory$2 () {
596
- if (hasRequiredFactory$2) return Factory$8;
597
- hasRequiredFactory$2 = 1;
595
+ function requireFactory$3 () {
596
+ if (hasRequiredFactory$3) return Factory$8;
597
+ hasRequiredFactory$3 = 1;
598
598
  Object.defineProperty(Factory$8, "__esModule", { value: true });
599
599
  Factory$8.ViewModule = void 0;
600
600
  const base_1 = base;
@@ -1463,8 +1463,8 @@ var main = {};
1463
1463
 
1464
1464
  Object.defineProperty(main, "__esModule", { value: true });
1465
1465
  main.WebContents = void 0;
1466
- const base_1$m = base;
1467
- class WebContents extends base_1$m.EmitterBase {
1466
+ const base_1$k = base;
1467
+ class WebContents extends base_1$k.EmitterBase {
1468
1468
  /**
1469
1469
  * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1470
1470
  * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
@@ -2542,1106 +2542,1127 @@ var Factory$6 = {};
2542
2542
 
2543
2543
  var Instance$5 = {};
2544
2544
 
2545
- Object.defineProperty(Instance$5, "__esModule", { value: true });
2546
- Instance$5.Application = void 0;
2547
- /* eslint-disable import/prefer-default-export */
2548
- const base_1$l = base;
2549
- const window_1$1 = requireWindow();
2550
- const view_1 = requireView();
2551
- /**
2552
- * An object representing an application. Allows the developer to create,
2553
- * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2554
- */
2555
- class Application extends base_1$l.EmitterBase {
2556
- /**
2557
- * @internal
2558
- */
2559
- constructor(wire, identity) {
2560
- super(wire, 'application', identity.uuid);
2561
- this.identity = identity;
2562
- this.window = new window_1$1._Window(this.wire, {
2563
- uuid: this.identity.uuid,
2564
- name: this.identity.uuid
2565
- });
2566
- }
2567
- windowListFromIdentityList(identityList) {
2568
- const windowList = [];
2569
- identityList.forEach((identity) => {
2570
- windowList.push(new window_1$1._Window(this.wire, {
2571
- uuid: identity.uuid,
2572
- name: identity.name
2573
- }));
2574
- });
2575
- return windowList;
2576
- }
2577
- /**
2578
- * Determines if the application is currently running.
2579
- *
2580
- * @example
2581
- *
2582
- * ```js
2583
- * async function isAppRunning() {
2584
- * const app = await fin.Application.getCurrent();
2585
- * return await app.isRunning();
2586
- * }
2587
- * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2588
- * ```
2589
- */
2590
- isRunning() {
2591
- return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2592
- }
2593
- /**
2594
- * Closes the application and any child windows created by the application.
2595
- * Cleans the application from state so it is no longer found in getAllApplications.
2596
- * @param force Close will be prevented from closing when force is false and
2597
- * ‘close-requested’ has been subscribed to for application’s main window.
2598
- *
2599
- * @example
2600
- *
2601
- * ```js
2602
- * async function closeApp() {
2603
- * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2604
- * const app = await fin.Application.wrap({uuid: 'app2'});
2605
- * await app.quit();
2606
- * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2607
- *
2608
- * }
2609
- * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2610
- * ```
2611
- */
2612
- async quit(force = false) {
2613
- try {
2614
- await this._close(force);
2615
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
2616
- }
2617
- catch (error) {
2618
- const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2619
- if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2620
- throw error;
2621
- }
2622
- }
2623
- }
2624
- async _close(force = false) {
2625
- try {
2626
- await this.wire.sendAction('close-application', { force, ...this.identity });
2627
- }
2628
- catch (error) {
2629
- if (!error.message.includes('Remote connection has closed')) {
2630
- throw error;
2631
- }
2632
- }
2633
- }
2634
- /**
2635
- * @deprecated use Application.quit instead
2636
- * Closes the application and any child windows created by the application.
2637
- * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2638
- * @param callback - called if the method succeeds.
2639
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2640
- *
2641
- * @example
2642
- *
2643
- * ```js
2644
- * async function closeApp() {
2645
- * const app = await fin.Application.getCurrent();
2646
- * return await app.close();
2647
- * }
2648
- * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2649
- * ```
2650
- */
2651
- close(force = false) {
2652
- console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2653
- this.wire.sendAction('application-close', this.identity).catch((e) => {
2654
- // we do not want to expose this error, just continue if this analytics-only call fails
2655
- });
2656
- return this._close(force);
2657
- }
2658
- /**
2659
- * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2660
- *
2661
- * @example
2662
- *
2663
- * ```js
2664
- * async function getChildWindows() {
2665
- * const app = await fin.Application.getCurrent();
2666
- * return await app.getChildWindows();
2667
- * }
2668
- *
2669
- * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2670
- * ```
2671
- */
2672
- getChildWindows() {
2673
- return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2674
- const identityList = [];
2675
- payload.data.forEach((winName) => {
2676
- identityList.push({ uuid: this.identity.uuid, name: winName });
2677
- });
2678
- return this.windowListFromIdentityList(identityList);
2679
- });
2680
- }
2681
- /**
2682
- * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2683
- * if the application was not created from a manifest.
2684
- *
2685
- * @example
2686
- *
2687
- * ```js
2688
- * async function getManifest() {
2689
- * const app = await fin.Application.getCurrent();
2690
- * return await app.getManifest();
2691
- * }
2692
- *
2693
- * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2694
- * ```
2695
- */
2696
- getManifest() {
2697
- return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2698
- }
2699
- /**
2700
- * Retrieves UUID of the application that launches this application. Invokes the error callback
2701
- * if the application was created from a manifest.
2702
- *
2703
- * @example
2704
- *
2705
- * ```js
2706
- * async function getParentUuid() {
2707
- * const app = await fin.Application.start({
2708
- * uuid: 'app-1',
2709
- * name: 'myApp',
2710
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2711
- * autoShow: true
2712
- * });
2713
- * return await app.getParentUuid();
2714
- * }
2715
- *
2716
- * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2717
- * ```
2718
- */
2719
- getParentUuid() {
2720
- return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2721
- }
2722
- /**
2723
- * Retrieves current application's shortcut configuration.
2724
- *
2725
- * @example
2726
- *
2727
- * ```js
2728
- * async function getShortcuts() {
2729
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
2730
- * return await app.getShortcuts();
2731
- * }
2732
- * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2733
- * ```
2734
- */
2735
- getShortcuts() {
2736
- return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2737
- }
2738
- /**
2739
- * Retrieves current application's views.
2740
- * @experimental
2741
- *
2742
- * @example
2743
- *
2744
- * ```js
2745
- * async function getViews() {
2746
- * const app = await fin.Application.getCurrent();
2747
- * return await app.getViews();
2748
- * }
2749
- * getViews().then(views => console.log(views)).catch(err => console.log(err));
2750
- * ```
2751
- */
2752
- async getViews() {
2753
- const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2754
- return payload.data.map((id) => new view_1.View(this.wire, id));
2755
- }
2756
- /**
2757
- * Returns the current zoom level of the application.
2758
- *
2759
- * @example
2760
- *
2761
- * ```js
2762
- * async function getZoomLevel() {
2763
- * const app = await fin.Application.getCurrent();
2764
- * return await app.getZoomLevel();
2765
- * }
2766
- *
2767
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2768
- * ```
2769
- */
2770
- getZoomLevel() {
2771
- return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2772
- }
2773
- /**
2774
- * Returns an instance of the main Window of the application
2775
- *
2776
- * @example
2777
- *
2778
- * ```js
2779
- * async function getWindow() {
2780
- * const app = await fin.Application.start({
2781
- * uuid: 'app-1',
2782
- * name: 'myApp',
2783
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
2784
- * autoShow: true
2785
- * });
2786
- * return await app.getWindow();
2787
- * }
2788
- *
2789
- * getWindow().then(win => {
2790
- * win.showAt(0, 400);
2791
- * win.flash();
2792
- * }).catch(err => console.log(err));
2793
- * ```
2794
- */
2795
- getWindow() {
2796
- this.wire.sendAction('application-get-window', this.identity).catch((e) => {
2797
- // we do not want to expose this error, just continue if this analytics-only call fails
2798
- });
2799
- return Promise.resolve(this.window);
2800
- }
2801
- /**
2802
- * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
2803
- * @param userName - username to be passed to the RVM.
2804
- * @param appName - app name to be passed to the RVM.
2805
- *
2806
- * @example
2807
- *
2808
- * ```js
2809
- * async function registerUser() {
2810
- * const app = await fin.Application.getCurrent();
2811
- * return await app.registerUser('user', 'myApp');
2812
- * }
2813
- *
2814
- * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
2815
- * ```
2816
- */
2817
- registerUser(userName, appName) {
2818
- return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
2819
- }
2820
- /**
2821
- * Removes the application’s icon from the tray.
2822
- *
2823
- * @example
2824
- *
2825
- * ```js
2826
- * async function removeTrayIcon() {
2827
- * const app = await fin.Application.getCurrent();
2828
- * return await app.removeTrayIcon();
2829
- * }
2830
- *
2831
- * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
2832
- * ```
2833
- */
2834
- removeTrayIcon() {
2835
- return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
2836
- }
2837
- /**
2838
- * Restarts the application.
2839
- *
2840
- * @example
2841
- *
2842
- * ```js
2843
- * async function restartApp() {
2844
- * const app = await fin.Application.getCurrent();
2845
- * return await app.restart();
2846
- * }
2847
- * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
2848
- * ```
2849
- */
2850
- restart() {
2851
- return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
2852
- }
2853
- /**
2854
- * DEPRECATED method to run the application.
2855
- * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
2856
- *
2857
- * @example
2858
- *
2859
- * ```js
2860
- * async function run() {
2861
- * const app = await fin.Application.create({
2862
- * name: 'myApp',
2863
- * uuid: 'app-1',
2864
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
2865
- * autoShow: true
2866
- * });
2867
- * await app.run();
2868
- * }
2869
- * run().then(() => console.log('Application is running')).catch(err => console.log(err));
2870
- * ```
2871
- *
2872
- * @ignore
2873
- */
2874
- run() {
2875
- console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
2876
- this.wire.sendAction('application-run', this.identity).catch((e) => {
2877
- // we do not want to expose this error, just continue if this analytics-only call fails
2878
- });
2879
- return this._run();
2880
- }
2881
- _run(opts = {}) {
2882
- return this.wire
2883
- .sendAction('run-application', {
2884
- manifestUrl: this._manifestUrl,
2885
- opts,
2886
- ...this.identity
2887
- })
2888
- .then(() => undefined);
2889
- }
2890
- /**
2891
- * Instructs the RVM to schedule one restart of the application.
2892
- *
2893
- * @example
2894
- *
2895
- * ```js
2896
- * async function scheduleRestart() {
2897
- * const app = await fin.Application.getCurrent();
2898
- * return await app.scheduleRestart();
2899
- * }
2900
- *
2901
- * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
2902
- * ```
2903
- */
2904
- scheduleRestart() {
2905
- return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
2906
- }
2907
- /**
2908
- * Sends a message to the RVM to upload the application's logs. On success,
2909
- * an object containing logId is returned.
2910
- *
2911
- * @example
2912
- *
2913
- * ```js
2914
- * async function sendLog() {
2915
- * const app = await fin.Application.getCurrent();
2916
- * return await app.sendApplicationLog();
2917
- * }
2918
- *
2919
- * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
2920
- * ```
2921
- */
2922
- async sendApplicationLog() {
2923
- const { payload } = await this.wire.sendAction('send-application-log', this.identity);
2924
- return payload.data;
2925
- }
2926
- /**
2927
- * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
2928
- * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
2929
- *
2930
- * Note: If the "name" property is omitted it defaults to "tasks".
2931
- * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
2932
- *
2933
- *
2934
- * @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).
2935
- *
2936
- * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
2937
- * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
2938
- *
2939
- * Note: If the "name" property is omitted it defaults to "tasks".
2940
- *
2941
- * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
2942
- * uuid or shortcut.name is changed.
2943
- *
2944
- * @example
2945
- *
2946
- * ```js
2947
- * const app = fin.Application.getCurrentSync();
2948
- * const appName = 'My App';
2949
- * const jumpListConfig = [ // array of JumpList categories
2950
- * {
2951
- * // has no name and no type so `type` is assumed to be "tasks"
2952
- * items: [ // array of JumpList items
2953
- * {
2954
- * type: 'task',
2955
- * title: `Launch ${appName}`,
2956
- * description: `Runs ${appName} with the default configuration`,
2957
- * deepLink: 'fins://path.to/app/manifest.json',
2958
- * iconPath: 'https://path.to/app/icon.ico',
2959
- * iconIndex: 0
2960
- * },
2961
- * { type: 'separator' },
2962
- * {
2963
- * type: 'task',
2964
- * title: `Restore ${appName}`,
2965
- * description: 'Restore to last configuration',
2966
- * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
2967
- * iconPath: 'https://path.to/app/icon.ico',
2968
- * iconIndex: 0
2969
- * },
2970
- * ]
2971
- * },
2972
- * {
2973
- * name: 'Tools',
2974
- * items: [ // array of JumpList items
2975
- * {
2976
- * type: 'task',
2977
- * title: 'Tool A',
2978
- * description: 'Runs Tool A',
2979
- * deepLink: 'fins://path.to/tool-a/manifest.json',
2980
- * iconPath: 'https://path.to/tool-a/icon.ico',
2981
- * iconIndex: 0
2982
- * },
2983
- * {
2984
- * type: 'task',
2985
- * title: 'Tool B',
2986
- * description: 'Runs Tool B',
2987
- * deepLink: 'fins://path.to/tool-b/manifest.json',
2988
- * iconPath: 'https://path.to/tool-b/icon.ico',
2989
- * iconIndex: 0
2990
- * }]
2991
- * }
2992
- * ];
2993
- *
2994
- * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
2995
- * ```
2996
- *
2997
- * To handle deeplink args:
2998
- * ```js
2999
- * function handleUseLastConfiguration() {
3000
- * // this handler is called when the app is being launched
3001
- * app.on('run-requested', event => {
3002
- * if(event.userAppConfigArgs['use-last-configuration']) {
3003
- * // your logic here
3004
- * }
3005
- * });
3006
- * // this handler is called when the app was already running when the launch was requested
3007
- * fin.desktop.main(function(args) {
3008
- * if(args && args['use-last-configuration']) {
3009
- * // your logic here
3010
- * }
3011
- * });
3012
- * }
3013
- * ```
3014
- */
3015
- async setJumpList(jumpListCategories) {
3016
- await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3017
- }
3018
- /**
3019
- * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3020
- * @param icon Image URL or base64 encoded string to be used as the icon
3021
- *
3022
- * @example
3023
- *
3024
- * ```js
3025
- * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3026
- * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3027
- * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3028
- * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3029
- * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3030
- *
3031
- * async function setTrayIcon(icon) {
3032
- * const app = await fin.Application.getCurrent();
3033
- * return await app.setTrayIcon(icon);
3034
- * }
3035
- *
3036
- * // use image url to set tray icon
3037
- * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3038
- *
3039
- * // use base64 encoded string to set tray icon
3040
- * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3041
- *
3042
- * // use a dataURL to set tray icon
3043
- * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3044
- * ```
3045
- */
3046
- setTrayIcon(icon) {
3047
- return this.wire
3048
- .sendAction('set-tray-icon', {
3049
- enabledIcon: icon,
3050
- ...this.identity
3051
- })
3052
- .then(() => undefined);
3053
- }
3054
- /**
3055
- * Sets new application's shortcut configuration. Windows only.
3056
- * @param config New application's shortcut configuration.
3057
- *
3058
- * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3059
- * to be able to change shortcut states.
3060
- *
3061
- * @example
3062
- *
3063
- * ```js
3064
- * async function setShortcuts(config) {
3065
- * const app = await fin.Application.getCurrent();
3066
- * return app.setShortcuts(config);
3067
- * }
3068
- *
3069
- * setShortcuts({
3070
- * desktop: true,
3071
- * startMenu: false,
3072
- * systemStartup: true
3073
- * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3074
- * ```
3075
- */
3076
- setShortcuts(config) {
3077
- return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3078
- }
3079
- /**
3080
- * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3081
- * @param queryString The new query string for this app's shortcuts.
3082
- *
3083
- * @example
3084
- *
3085
- * ```js
3086
- * const newQueryArgs = 'arg=true&arg2=false';
3087
- * const app = await fin.Application.getCurrent();
3088
- * try {
3089
- * await app.setShortcutQueryParams(newQueryArgs);
3090
- * } catch(err) {
3091
- * console.error(err)
3092
- * }
3093
- * ```
3094
- */
3095
- async setShortcutQueryParams(queryString) {
3096
- await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3097
- }
3098
- /**
3099
- * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3100
- * larger or smaller to default limits of 300% and 50% of original size, respectively.
3101
- * @param level The zoom level
3102
- *
3103
- * @example
3104
- *
3105
- * ```js
3106
- * async function setZoomLevel(number) {
3107
- * const app = await fin.Application.getCurrent();
3108
- * return await app.setZoomLevel(number);
3109
- * }
3110
- *
3111
- * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3112
- * ```
3113
- */
3114
- setZoomLevel(level) {
3115
- return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3116
- }
3117
- /**
3118
- * Sets a username to correlate with App Log Management.
3119
- * @param username Username to correlate with App's Log.
3120
- *
3121
- * @example
3122
- *
3123
- * ```js
3124
- * async function setAppLogUser() {
3125
- * const app = await fin.Application.getCurrent();
3126
- * return await app.setAppLogUsername('username');
3127
- * }
3128
- *
3129
- * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3130
- *
3131
- * ```
3132
- */
3133
- async setAppLogUsername(username) {
3134
- await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3135
- }
3136
- /**
3137
- * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3138
- * @remarks The only information currently returned is the position and dimensions.
3139
- *
3140
- * @example
3141
- *
3142
- * ```js
3143
- * async function getTrayIconInfo() {
3144
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3145
- * return await app.getTrayIconInfo();
3146
- * }
3147
- * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3148
- * ```
3149
- */
3150
- getTrayIconInfo() {
3151
- return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3152
- }
3153
- /**
3154
- * Checks if the application has an associated tray icon.
3155
- *
3156
- * @example
3157
- *
3158
- * ```js
3159
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3160
- * const hasTrayIcon = await app.hasTrayIcon();
3161
- * console.log(hasTrayIcon);
3162
- * ```
3163
- */
3164
- hasTrayIcon() {
3165
- return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3166
- }
3167
- /**
3168
- * Closes the application by terminating its process.
3169
- *
3170
- * @example
3171
- *
3172
- * ```js
3173
- * async function terminateApp() {
3174
- * const app = await fin.Application.getCurrent();
3175
- * return await app.terminate();
3176
- * }
3177
- * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3178
- * ```
3179
- */
3180
- terminate() {
3181
- return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3182
- }
3183
- /**
3184
- * Waits for a hanging application. This method can be called in response to an application
3185
- * "not-responding" to allow the application to continue and to generate another "not-responding"
3186
- * message after a certain period of time.
3187
- *
3188
- * @ignore
3189
- */
3190
- wait() {
3191
- return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3192
- }
3193
- /**
3194
- * Retrieves information about the application.
3195
- *
3196
- * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3197
- * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3198
- * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3199
- *
3200
- * @example
3201
- *
3202
- * ```js
3203
- * async function getInfo() {
3204
- * const app = await fin.Application.getCurrent();
3205
- * return await app.getInfo();
3206
- * }
3207
- *
3208
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3209
- * ```
3210
- */
3211
- getInfo() {
3212
- return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3213
- }
3214
- /**
3215
- * Retrieves all process information for entities (windows and views) associated with an application.
3216
- *
3217
- * @example
3218
- * ```js
3219
- * const app = await fin.Application.getCurrent();
3220
- * const processInfo = await app.getProcessInfo();
3221
- * ```
3222
- * @experimental
3223
- */
3224
- async getProcessInfo() {
3225
- const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3226
- return data;
3227
- }
3228
- /**
3229
- * Sets file auto download location. It's only allowed in the same application.
3230
- *
3231
- * Note: This method is restricted by default and must be enabled via
3232
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3233
- * @param downloadLocation file auto download location
3234
- *
3235
- * @throws if setting file auto download location on different applications.
3236
- * @example
3237
- *
3238
- * ```js
3239
- * const downloadLocation = 'C:\\dev\\temp';
3240
- * const app = await fin.Application.getCurrent();
3241
- * try {
3242
- * await app.setFileDownloadLocation(downloadLocation);
3243
- * console.log('File download location is set');
3244
- * } catch(err) {
3245
- * console.error(err)
3246
- * }
3247
- * ```
3248
- */
3249
- async setFileDownloadLocation(downloadLocation) {
3250
- const { name } = this.wire.me;
3251
- const entityIdentity = { uuid: this.identity.uuid, name };
3252
- await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3253
- }
3254
- /**
3255
- * 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.
3256
- *
3257
- * Note: This method is restricted by default and must be enabled via
3258
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3259
- *
3260
- * @throws if getting file auto download location on different applications.
3261
- * @example
3262
- *
3263
- * ```js
3264
- * const app = await fin.Application.getCurrent();
3265
- * const fileDownloadDir = await app.getFileDownloadLocation();
3266
- * ```
3267
- */
3268
- async getFileDownloadLocation() {
3269
- const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3270
- return data;
3271
- }
3272
- /**
3273
- * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3274
- * @param options
3275
- * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3276
- * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3277
- * of all possible data shapes for the entire menu, and the click handler should process
3278
- * these with a "reducer" pattern.
3279
- * @throws if the application has no tray icon set
3280
- * @throws if the system tray is currently hidden
3281
- * @example
3282
- *
3283
- * ```js
3284
- * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3285
- * const app = fin.Application.getCurrentSync();
3286
- *
3287
- * await app.setTrayIcon(iconUrl);
3288
- *
3289
- * const template = [
3290
- * {
3291
- * label: 'Menu Item 1',
3292
- * data: 'hello from item 1'
3293
- * },
3294
- * { type: 'separator' },
3295
- * {
3296
- * label: 'Menu Item 2',
3297
- * type: 'checkbox',
3298
- * checked: true,
3299
- * data: 'The user clicked the checkbox'
3300
- * },
3301
- * {
3302
- * label: 'see more',
3303
- * enabled: false,
3304
- * submenu: [
3305
- * { label: 'submenu 1', data: 'hello from submenu' }
3306
- * ]
3307
- * }
3308
- * ];
3309
- *
3310
- * app.addListener('tray-icon-clicked', (event) => {
3311
- * // right-click
3312
- * if (event.button === 2) {
3313
- * app.showTrayIconPopupMenu({ template }).then(r => {
3314
- * if (r.result === 'closed') {
3315
- * console.log('nothing happened');
3316
- * } else {
3317
- * console.log(r.data);
3318
- * }
3319
- * });
3320
- * }
3321
- * });
3322
- * ```
3323
- */
3324
- async showTrayIconPopupMenu(options) {
3325
- const { name } = this.wire.me;
3326
- const entityIdentity = { uuid: this.identity.uuid, name };
3327
- const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3328
- return payload.data;
3329
- }
3330
- /**
3331
- * CLoses the tray icon menu.
3332
- *
3333
- * @throws if the application has no tray icon set
3334
- * @example
3335
- *
3336
- * ```js
3337
- * const app = fin.Application.getCurrentSync();
3338
- *
3339
- * await app.closeTrayIconPopupMenu();
3340
- * ```
3341
- */
3342
- async closeTrayIconPopupMenu() {
3343
- const { name } = this.wire.me;
3344
- const entityIdentity = { uuid: this.identity.uuid, name };
3345
- await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3346
- }
3347
- }
3348
- Instance$5.Application = Application;
2545
+ var hasRequiredInstance$2;
3349
2546
 
3350
- Object.defineProperty(Factory$6, "__esModule", { value: true });
3351
- Factory$6.ApplicationModule = void 0;
3352
- const base_1$k = base;
3353
- const validate_1$4 = validate;
3354
- const Instance_1$5 = Instance$5;
3355
- /**
3356
- * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3357
- */
3358
- class ApplicationModule extends base_1$k.Base {
3359
- /**
3360
- * Asynchronously returns an Application object that represents an existing application.
3361
- *
3362
- * @example
3363
- *
3364
- * ```js
3365
- * fin.Application.wrap({ uuid: 'testapp' })
3366
- * .then(app => app.isRunning())
3367
- * .then(running => console.log('Application is running: ' + running))
3368
- * .catch(err => console.log(err));
3369
- * ```
3370
- *
3371
- */
3372
- async wrap(identity) {
3373
- this.wire.sendAction('wrap-application').catch((e) => {
3374
- // we do not want to expose this error, just continue if this analytics-only call fails
3375
- });
3376
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3377
- if (errorMsg) {
3378
- throw new Error(errorMsg);
3379
- }
3380
- return new Instance_1$5.Application(this.wire, identity);
3381
- }
3382
- /**
3383
- * Synchronously returns an Application object that represents an existing application.
3384
- *
3385
- * @example
3386
- *
3387
- * ```js
3388
- * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3389
- * await app.close();
3390
- * ```
3391
- *
3392
- */
3393
- wrapSync(identity) {
3394
- this.wire.sendAction('wrap-application-sync').catch((e) => {
3395
- // we do not want to expose this error, just continue if this analytics-only call fails
3396
- });
3397
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3398
- if (errorMsg) {
3399
- throw new Error(errorMsg);
3400
- }
3401
- return new Instance_1$5.Application(this.wire, identity);
3402
- }
3403
- async _create(appOptions) {
3404
- // set defaults:
3405
- if (appOptions.waitForPageLoad === undefined) {
3406
- appOptions.waitForPageLoad = false;
3407
- }
3408
- if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3409
- appOptions.autoShow = true;
3410
- }
3411
- await this.wire.sendAction('create-application', appOptions);
3412
- return this.wrap({ uuid: appOptions.uuid });
3413
- }
3414
- /**
3415
- * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3416
- *
3417
- * @example
3418
- *
3419
- * ```js
3420
- * async function createApp() {
3421
- * const app = await fin.Application.create({
3422
- * name: 'myApp',
3423
- * uuid: 'app-3',
3424
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3425
- * autoShow: true
3426
- * });
3427
- * await app.run();
3428
- * }
3429
- *
3430
- * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3431
- * ```
3432
- *
3433
- * @ignore
3434
- */
3435
- create(appOptions) {
3436
- console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3437
- this.wire.sendAction('application-create').catch((e) => {
3438
- // we do not want to expose this error, just continue if this analytics-only call fails
3439
- });
3440
- return this._create(appOptions);
3441
- }
3442
- /**
3443
- * Creates and starts a new Application.
3444
- *
3445
- * @example
3446
- *
3447
- * ```js
3448
- * async function start() {
3449
- * return fin.Application.start({
3450
- * name: 'app-1',
3451
- * uuid: 'app-1',
3452
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3453
- * autoShow: true
3454
- * });
3455
- * }
3456
- * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3457
- * ```
3458
- *
3459
- */
3460
- async start(appOptions) {
3461
- this.wire.sendAction('start-application').catch((e) => {
3462
- // we do not want to expose this error, just continue if this analytics-only call fails
3463
- });
3464
- const app = await this._create(appOptions);
3465
- await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3466
- return app;
3467
- }
3468
- /**
3469
- * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3470
- * Returns once the RVM is finished attempting to launch the applications.
3471
- * @param opts - Parameters that the RVM will use.
3472
- *
3473
- * @example
3474
- *
3475
- * ```js
3476
- *
3477
- * const applicationInfoArray = [
3478
- * {
3479
- * "uuid": 'App-1',
3480
- * "manifestUrl": 'http://localhost:5555/app1.json',
3481
- * },
3482
- * {
3483
- * "uuid": 'App-2',
3484
- * "manifestUrl": 'http://localhost:5555/app2.json',
3485
- * },
3486
- * {
3487
- * "uuid": 'App-3',
3488
- * "manifestUrl": 'http://localhost:5555/app3.json',
3489
- * }
3490
- * ]
3491
- *
3492
- * fin.Application.startManyManifests(applicationInfoArray)
3493
- * .then(() => {
3494
- * console.log('RVM has finished launching the application list.');
3495
- * })
3496
- * .catch((err) => {
3497
- * console.log(err);
3498
- * })
3499
- * ```
3500
- *
3501
- * @experimental
3502
- */
3503
- async startManyManifests(applications, opts) {
3504
- return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3505
- }
3506
- /**
3507
- * Asynchronously returns an Application object that represents the current application
3508
- *
3509
- * @example
3510
- *
3511
- * ```js
3512
- * async function isCurrentAppRunning () {
3513
- * const app = await fin.Application.getCurrent();
3514
- * return app.isRunning();
3515
- * }
3516
- *
3517
- * isCurrentAppRunning().then(running => {
3518
- * console.log(`Current app is running: ${running}`);
3519
- * }).catch(err => {
3520
- * console.error(err);
3521
- * });
3522
- *
3523
- * ```
3524
- */
3525
- getCurrent() {
3526
- this.wire.sendAction('get-current-application').catch((e) => {
3527
- // we do not want to expose this error, just continue if this analytics-only call fails
3528
- });
3529
- return this.wrap({ uuid: this.wire.me.uuid });
3530
- }
3531
- /**
3532
- * Synchronously returns an Application object that represents the current application
3533
- *
3534
- * @example
3535
- *
3536
- * ```js
3537
- * async function isCurrentAppRunning () {
3538
- * const app = fin.Application.getCurrentSync();
3539
- * return app.isRunning();
3540
- * }
3541
- *
3542
- * isCurrentAppRunning().then(running => {
3543
- * console.log(`Current app is running: ${running}`);
3544
- * }).catch(err => {
3545
- * console.error(err);
3546
- * });
3547
- *
3548
- * ```
3549
- */
3550
- getCurrentSync() {
3551
- this.wire.sendAction('get-current-application-sync').catch((e) => {
3552
- // we do not want to expose this error, just continue if this analytics-only call fails
3553
- });
3554
- return this.wrapSync({ uuid: this.wire.me.uuid });
3555
- }
3556
- /**
3557
- * Retrieves application's manifest and returns a running instance of the application.
3558
- * @param manifestUrl - The URL of app's manifest.
3559
- * @param opts - Parameters that the RVM will use.
3560
- *
3561
- * @example
3562
- *
3563
- * ```js
3564
- * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3565
- *
3566
- * // For a local manifest file:
3567
- * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3568
- * ```
3569
- */
3570
- async startFromManifest(manifestUrl, opts) {
3571
- this.wire.sendAction('application-start-from-manifest').catch((e) => {
3572
- // we do not want to expose this error, just continue if this analytics-only call fails
3573
- });
3574
- const app = await this._createFromManifest(manifestUrl);
3575
- // @ts-expect-error using private method without warning.
3576
- await app._run(opts); // eslint-disable-line no-underscore-dangle
3577
- return app;
3578
- }
3579
- /**
3580
- * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3581
- * Retrieves application's manifest and returns a wrapped application.
3582
- * @param manifestUrl - The URL of app's manifest.
3583
- * @param callback - called if the method succeeds.
3584
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3585
- *
3586
- * @example
3587
- *
3588
- * ```js
3589
- * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3590
- * ```
3591
- * @ignore
3592
- */
3593
- createFromManifest(manifestUrl) {
3594
- console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3595
- this.wire.sendAction('application-create-from-manifest').catch((e) => {
3596
- // we do not want to expose this error, just continue if this analytics-only call fails
3597
- });
3598
- return this._createFromManifest(manifestUrl);
3599
- }
3600
- _createFromManifest(manifestUrl) {
3601
- return this.wire
3602
- .sendAction('get-application-manifest', { manifestUrl })
3603
- .then(({ payload }) => {
3604
- const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3605
- return this.wrap({ uuid });
3606
- })
3607
- .then((app) => {
3608
- app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3609
- return app;
3610
- });
3611
- }
2547
+ function requireInstance$2 () {
2548
+ if (hasRequiredInstance$2) return Instance$5;
2549
+ hasRequiredInstance$2 = 1;
2550
+ Object.defineProperty(Instance$5, "__esModule", { value: true });
2551
+ Instance$5.Application = void 0;
2552
+ /* eslint-disable import/prefer-default-export */
2553
+ const base_1 = base;
2554
+ const window_1 = requireWindow();
2555
+ const view_1 = requireView();
2556
+ /**
2557
+ * An object representing an application. Allows the developer to create,
2558
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2559
+ */
2560
+ class Application extends base_1.EmitterBase {
2561
+ /**
2562
+ * @internal
2563
+ */
2564
+ constructor(wire, identity) {
2565
+ super(wire, 'application', identity.uuid);
2566
+ this.identity = identity;
2567
+ this.window = new window_1._Window(this.wire, {
2568
+ uuid: this.identity.uuid,
2569
+ name: this.identity.uuid
2570
+ });
2571
+ }
2572
+ windowListFromIdentityList(identityList) {
2573
+ const windowList = [];
2574
+ identityList.forEach((identity) => {
2575
+ windowList.push(new window_1._Window(this.wire, {
2576
+ uuid: identity.uuid,
2577
+ name: identity.name
2578
+ }));
2579
+ });
2580
+ return windowList;
2581
+ }
2582
+ /**
2583
+ * Determines if the application is currently running.
2584
+ *
2585
+ * @example
2586
+ *
2587
+ * ```js
2588
+ * async function isAppRunning() {
2589
+ * const app = await fin.Application.getCurrent();
2590
+ * return await app.isRunning();
2591
+ * }
2592
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2593
+ * ```
2594
+ */
2595
+ isRunning() {
2596
+ return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2597
+ }
2598
+ /**
2599
+ * Closes the application and any child windows created by the application.
2600
+ * Cleans the application from state so it is no longer found in getAllApplications.
2601
+ * @param force Close will be prevented from closing when force is false and
2602
+ * ‘close-requested’ has been subscribed to for application’s main window.
2603
+ *
2604
+ * @example
2605
+ *
2606
+ * ```js
2607
+ * async function closeApp() {
2608
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2609
+ * const app = await fin.Application.wrap({uuid: 'app2'});
2610
+ * await app.quit();
2611
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2612
+ *
2613
+ * }
2614
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2615
+ * ```
2616
+ */
2617
+ async quit(force = false) {
2618
+ try {
2619
+ await this._close(force);
2620
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
2621
+ }
2622
+ catch (error) {
2623
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2624
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2625
+ throw error;
2626
+ }
2627
+ }
2628
+ }
2629
+ async _close(force = false) {
2630
+ try {
2631
+ await this.wire.sendAction('close-application', { force, ...this.identity });
2632
+ }
2633
+ catch (error) {
2634
+ if (!error.message.includes('Remote connection has closed')) {
2635
+ throw error;
2636
+ }
2637
+ }
2638
+ }
2639
+ /**
2640
+ * @deprecated use Application.quit instead
2641
+ * Closes the application and any child windows created by the application.
2642
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2643
+ * @param callback - called if the method succeeds.
2644
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2645
+ *
2646
+ * @example
2647
+ *
2648
+ * ```js
2649
+ * async function closeApp() {
2650
+ * const app = await fin.Application.getCurrent();
2651
+ * return await app.close();
2652
+ * }
2653
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2654
+ * ```
2655
+ */
2656
+ close(force = false) {
2657
+ console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2658
+ this.wire.sendAction('application-close', this.identity).catch((e) => {
2659
+ // we do not want to expose this error, just continue if this analytics-only call fails
2660
+ });
2661
+ return this._close(force);
2662
+ }
2663
+ /**
2664
+ * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2665
+ *
2666
+ * @example
2667
+ *
2668
+ * ```js
2669
+ * async function getChildWindows() {
2670
+ * const app = await fin.Application.getCurrent();
2671
+ * return await app.getChildWindows();
2672
+ * }
2673
+ *
2674
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2675
+ * ```
2676
+ */
2677
+ getChildWindows() {
2678
+ return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2679
+ const identityList = [];
2680
+ payload.data.forEach((winName) => {
2681
+ identityList.push({ uuid: this.identity.uuid, name: winName });
2682
+ });
2683
+ return this.windowListFromIdentityList(identityList);
2684
+ });
2685
+ }
2686
+ /**
2687
+ * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2688
+ * if the application was not created from a manifest.
2689
+ *
2690
+ * @example
2691
+ *
2692
+ * ```js
2693
+ * async function getManifest() {
2694
+ * const app = await fin.Application.getCurrent();
2695
+ * return await app.getManifest();
2696
+ * }
2697
+ *
2698
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2699
+ * ```
2700
+ */
2701
+ getManifest() {
2702
+ return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2703
+ }
2704
+ /**
2705
+ * Retrieves UUID of the application that launches this application. Invokes the error callback
2706
+ * if the application was created from a manifest.
2707
+ *
2708
+ * @example
2709
+ *
2710
+ * ```js
2711
+ * async function getParentUuid() {
2712
+ * const app = await fin.Application.start({
2713
+ * uuid: 'app-1',
2714
+ * name: 'myApp',
2715
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2716
+ * autoShow: true
2717
+ * });
2718
+ * return await app.getParentUuid();
2719
+ * }
2720
+ *
2721
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2722
+ * ```
2723
+ */
2724
+ getParentUuid() {
2725
+ return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2726
+ }
2727
+ /**
2728
+ * Retrieves current application's shortcut configuration.
2729
+ *
2730
+ * @example
2731
+ *
2732
+ * ```js
2733
+ * async function getShortcuts() {
2734
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
2735
+ * return await app.getShortcuts();
2736
+ * }
2737
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2738
+ * ```
2739
+ */
2740
+ getShortcuts() {
2741
+ return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2742
+ }
2743
+ /**
2744
+ * Retrieves current application's views.
2745
+ * @experimental
2746
+ *
2747
+ * @example
2748
+ *
2749
+ * ```js
2750
+ * async function getViews() {
2751
+ * const app = await fin.Application.getCurrent();
2752
+ * return await app.getViews();
2753
+ * }
2754
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
2755
+ * ```
2756
+ */
2757
+ async getViews() {
2758
+ const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2759
+ return payload.data.map((id) => new view_1.View(this.wire, id));
2760
+ }
2761
+ /**
2762
+ * Returns the current zoom level of the application.
2763
+ *
2764
+ * @example
2765
+ *
2766
+ * ```js
2767
+ * async function getZoomLevel() {
2768
+ * const app = await fin.Application.getCurrent();
2769
+ * return await app.getZoomLevel();
2770
+ * }
2771
+ *
2772
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2773
+ * ```
2774
+ */
2775
+ getZoomLevel() {
2776
+ return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2777
+ }
2778
+ /**
2779
+ * Returns an instance of the main Window of the application
2780
+ *
2781
+ * @example
2782
+ *
2783
+ * ```js
2784
+ * async function getWindow() {
2785
+ * const app = await fin.Application.start({
2786
+ * uuid: 'app-1',
2787
+ * name: 'myApp',
2788
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
2789
+ * autoShow: true
2790
+ * });
2791
+ * return await app.getWindow();
2792
+ * }
2793
+ *
2794
+ * getWindow().then(win => {
2795
+ * win.showAt(0, 400);
2796
+ * win.flash();
2797
+ * }).catch(err => console.log(err));
2798
+ * ```
2799
+ */
2800
+ getWindow() {
2801
+ this.wire.sendAction('application-get-window', this.identity).catch((e) => {
2802
+ // we do not want to expose this error, just continue if this analytics-only call fails
2803
+ });
2804
+ return Promise.resolve(this.window);
2805
+ }
2806
+ /**
2807
+ * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
2808
+ * @param userName - username to be passed to the RVM.
2809
+ * @param appName - app name to be passed to the RVM.
2810
+ *
2811
+ * @example
2812
+ *
2813
+ * ```js
2814
+ * async function registerUser() {
2815
+ * const app = await fin.Application.getCurrent();
2816
+ * return await app.registerUser('user', 'myApp');
2817
+ * }
2818
+ *
2819
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
2820
+ * ```
2821
+ */
2822
+ registerUser(userName, appName) {
2823
+ return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
2824
+ }
2825
+ /**
2826
+ * Removes the application’s icon from the tray.
2827
+ *
2828
+ * @example
2829
+ *
2830
+ * ```js
2831
+ * async function removeTrayIcon() {
2832
+ * const app = await fin.Application.getCurrent();
2833
+ * return await app.removeTrayIcon();
2834
+ * }
2835
+ *
2836
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
2837
+ * ```
2838
+ */
2839
+ removeTrayIcon() {
2840
+ return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
2841
+ }
2842
+ /**
2843
+ * Restarts the application.
2844
+ *
2845
+ * @example
2846
+ *
2847
+ * ```js
2848
+ * async function restartApp() {
2849
+ * const app = await fin.Application.getCurrent();
2850
+ * return await app.restart();
2851
+ * }
2852
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
2853
+ * ```
2854
+ */
2855
+ restart() {
2856
+ return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
2857
+ }
2858
+ /**
2859
+ * DEPRECATED method to run the application.
2860
+ * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
2861
+ *
2862
+ * @example
2863
+ *
2864
+ * ```js
2865
+ * async function run() {
2866
+ * const app = await fin.Application.create({
2867
+ * name: 'myApp',
2868
+ * uuid: 'app-1',
2869
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
2870
+ * autoShow: true
2871
+ * });
2872
+ * await app.run();
2873
+ * }
2874
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
2875
+ * ```
2876
+ *
2877
+ * @ignore
2878
+ */
2879
+ run() {
2880
+ console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
2881
+ this.wire.sendAction('application-run', this.identity).catch((e) => {
2882
+ // we do not want to expose this error, just continue if this analytics-only call fails
2883
+ });
2884
+ return this._run();
2885
+ }
2886
+ _run(opts = {}) {
2887
+ return this.wire
2888
+ .sendAction('run-application', {
2889
+ manifestUrl: this._manifestUrl,
2890
+ opts,
2891
+ ...this.identity
2892
+ })
2893
+ .then(() => undefined);
2894
+ }
2895
+ /**
2896
+ * Instructs the RVM to schedule one restart of the application.
2897
+ *
2898
+ * @example
2899
+ *
2900
+ * ```js
2901
+ * async function scheduleRestart() {
2902
+ * const app = await fin.Application.getCurrent();
2903
+ * return await app.scheduleRestart();
2904
+ * }
2905
+ *
2906
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
2907
+ * ```
2908
+ */
2909
+ scheduleRestart() {
2910
+ return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
2911
+ }
2912
+ /**
2913
+ * Sends a message to the RVM to upload the application's logs. On success,
2914
+ * an object containing logId is returned.
2915
+ *
2916
+ * @example
2917
+ *
2918
+ * ```js
2919
+ * async function sendLog() {
2920
+ * const app = await fin.Application.getCurrent();
2921
+ * return await app.sendApplicationLog();
2922
+ * }
2923
+ *
2924
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
2925
+ * ```
2926
+ */
2927
+ async sendApplicationLog() {
2928
+ const { payload } = await this.wire.sendAction('send-application-log', this.identity);
2929
+ return payload.data;
2930
+ }
2931
+ /**
2932
+ * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
2933
+ * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
2934
+ *
2935
+ * Note: If the "name" property is omitted it defaults to "tasks".
2936
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
2937
+ *
2938
+ *
2939
+ * @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).
2940
+ *
2941
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
2942
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
2943
+ *
2944
+ * Note: If the "name" property is omitted it defaults to "tasks".
2945
+ *
2946
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
2947
+ * uuid or shortcut.name is changed.
2948
+ *
2949
+ * @example
2950
+ *
2951
+ * ```js
2952
+ * const app = fin.Application.getCurrentSync();
2953
+ * const appName = 'My App';
2954
+ * const jumpListConfig = [ // array of JumpList categories
2955
+ * {
2956
+ * // has no name and no type so `type` is assumed to be "tasks"
2957
+ * items: [ // array of JumpList items
2958
+ * {
2959
+ * type: 'task',
2960
+ * title: `Launch ${appName}`,
2961
+ * description: `Runs ${appName} with the default configuration`,
2962
+ * deepLink: 'fins://path.to/app/manifest.json',
2963
+ * iconPath: 'https://path.to/app/icon.ico',
2964
+ * iconIndex: 0
2965
+ * },
2966
+ * { type: 'separator' },
2967
+ * {
2968
+ * type: 'task',
2969
+ * title: `Restore ${appName}`,
2970
+ * description: 'Restore to last configuration',
2971
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
2972
+ * iconPath: 'https://path.to/app/icon.ico',
2973
+ * iconIndex: 0
2974
+ * },
2975
+ * ]
2976
+ * },
2977
+ * {
2978
+ * name: 'Tools',
2979
+ * items: [ // array of JumpList items
2980
+ * {
2981
+ * type: 'task',
2982
+ * title: 'Tool A',
2983
+ * description: 'Runs Tool A',
2984
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
2985
+ * iconPath: 'https://path.to/tool-a/icon.ico',
2986
+ * iconIndex: 0
2987
+ * },
2988
+ * {
2989
+ * type: 'task',
2990
+ * title: 'Tool B',
2991
+ * description: 'Runs Tool B',
2992
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
2993
+ * iconPath: 'https://path.to/tool-b/icon.ico',
2994
+ * iconIndex: 0
2995
+ * }]
2996
+ * }
2997
+ * ];
2998
+ *
2999
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3000
+ * ```
3001
+ *
3002
+ * To handle deeplink args:
3003
+ * ```js
3004
+ * function handleUseLastConfiguration() {
3005
+ * // this handler is called when the app is being launched
3006
+ * app.on('run-requested', event => {
3007
+ * if(event.userAppConfigArgs['use-last-configuration']) {
3008
+ * // your logic here
3009
+ * }
3010
+ * });
3011
+ * // this handler is called when the app was already running when the launch was requested
3012
+ * fin.desktop.main(function(args) {
3013
+ * if(args && args['use-last-configuration']) {
3014
+ * // your logic here
3015
+ * }
3016
+ * });
3017
+ * }
3018
+ * ```
3019
+ */
3020
+ async setJumpList(jumpListCategories) {
3021
+ await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3022
+ }
3023
+ /**
3024
+ * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3025
+ * @param icon Image URL or base64 encoded string to be used as the icon
3026
+ *
3027
+ * @example
3028
+ *
3029
+ * ```js
3030
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3031
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3032
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3033
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3034
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3035
+ *
3036
+ * async function setTrayIcon(icon) {
3037
+ * const app = await fin.Application.getCurrent();
3038
+ * return await app.setTrayIcon(icon);
3039
+ * }
3040
+ *
3041
+ * // use image url to set tray icon
3042
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3043
+ *
3044
+ * // use base64 encoded string to set tray icon
3045
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3046
+ *
3047
+ * // use a dataURL to set tray icon
3048
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3049
+ * ```
3050
+ */
3051
+ setTrayIcon(icon) {
3052
+ return this.wire
3053
+ .sendAction('set-tray-icon', {
3054
+ enabledIcon: icon,
3055
+ ...this.identity
3056
+ })
3057
+ .then(() => undefined);
3058
+ }
3059
+ /**
3060
+ * Sets new application's shortcut configuration. Windows only.
3061
+ * @param config New application's shortcut configuration.
3062
+ *
3063
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3064
+ * to be able to change shortcut states.
3065
+ *
3066
+ * @example
3067
+ *
3068
+ * ```js
3069
+ * async function setShortcuts(config) {
3070
+ * const app = await fin.Application.getCurrent();
3071
+ * return app.setShortcuts(config);
3072
+ * }
3073
+ *
3074
+ * setShortcuts({
3075
+ * desktop: true,
3076
+ * startMenu: false,
3077
+ * systemStartup: true
3078
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3079
+ * ```
3080
+ */
3081
+ setShortcuts(config) {
3082
+ return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3083
+ }
3084
+ /**
3085
+ * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3086
+ * @param queryString The new query string for this app's shortcuts.
3087
+ *
3088
+ * @example
3089
+ *
3090
+ * ```js
3091
+ * const newQueryArgs = 'arg=true&arg2=false';
3092
+ * const app = await fin.Application.getCurrent();
3093
+ * try {
3094
+ * await app.setShortcutQueryParams(newQueryArgs);
3095
+ * } catch(err) {
3096
+ * console.error(err)
3097
+ * }
3098
+ * ```
3099
+ */
3100
+ async setShortcutQueryParams(queryString) {
3101
+ await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3102
+ }
3103
+ /**
3104
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3105
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
3106
+ * @param level The zoom level
3107
+ *
3108
+ * @example
3109
+ *
3110
+ * ```js
3111
+ * async function setZoomLevel(number) {
3112
+ * const app = await fin.Application.getCurrent();
3113
+ * return await app.setZoomLevel(number);
3114
+ * }
3115
+ *
3116
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3117
+ * ```
3118
+ */
3119
+ setZoomLevel(level) {
3120
+ return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3121
+ }
3122
+ /**
3123
+ * Sets a username to correlate with App Log Management.
3124
+ * @param username Username to correlate with App's Log.
3125
+ *
3126
+ * @example
3127
+ *
3128
+ * ```js
3129
+ * async function setAppLogUser() {
3130
+ * const app = await fin.Application.getCurrent();
3131
+ * return await app.setAppLogUsername('username');
3132
+ * }
3133
+ *
3134
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3135
+ *
3136
+ * ```
3137
+ */
3138
+ async setAppLogUsername(username) {
3139
+ await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3140
+ }
3141
+ /**
3142
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3143
+ * @remarks The only information currently returned is the position and dimensions.
3144
+ *
3145
+ * @example
3146
+ *
3147
+ * ```js
3148
+ * async function getTrayIconInfo() {
3149
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3150
+ * return await app.getTrayIconInfo();
3151
+ * }
3152
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3153
+ * ```
3154
+ */
3155
+ getTrayIconInfo() {
3156
+ return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3157
+ }
3158
+ /**
3159
+ * Checks if the application has an associated tray icon.
3160
+ *
3161
+ * @example
3162
+ *
3163
+ * ```js
3164
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3165
+ * const hasTrayIcon = await app.hasTrayIcon();
3166
+ * console.log(hasTrayIcon);
3167
+ * ```
3168
+ */
3169
+ hasTrayIcon() {
3170
+ return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3171
+ }
3172
+ /**
3173
+ * Closes the application by terminating its process.
3174
+ *
3175
+ * @example
3176
+ *
3177
+ * ```js
3178
+ * async function terminateApp() {
3179
+ * const app = await fin.Application.getCurrent();
3180
+ * return await app.terminate();
3181
+ * }
3182
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3183
+ * ```
3184
+ */
3185
+ terminate() {
3186
+ return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3187
+ }
3188
+ /**
3189
+ * Waits for a hanging application. This method can be called in response to an application
3190
+ * "not-responding" to allow the application to continue and to generate another "not-responding"
3191
+ * message after a certain period of time.
3192
+ *
3193
+ * @ignore
3194
+ */
3195
+ wait() {
3196
+ return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3197
+ }
3198
+ /**
3199
+ * Retrieves information about the application.
3200
+ *
3201
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3202
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3203
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3204
+ *
3205
+ * @example
3206
+ *
3207
+ * ```js
3208
+ * async function getInfo() {
3209
+ * const app = await fin.Application.getCurrent();
3210
+ * return await app.getInfo();
3211
+ * }
3212
+ *
3213
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3214
+ * ```
3215
+ */
3216
+ getInfo() {
3217
+ return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3218
+ }
3219
+ /**
3220
+ * Retrieves all process information for entities (windows and views) associated with an application.
3221
+ *
3222
+ * @example
3223
+ * ```js
3224
+ * const app = await fin.Application.getCurrent();
3225
+ * const processInfo = await app.getProcessInfo();
3226
+ * ```
3227
+ * @experimental
3228
+ */
3229
+ async getProcessInfo() {
3230
+ const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3231
+ return data;
3232
+ }
3233
+ /**
3234
+ * Sets file auto download location. It's only allowed in the same application.
3235
+ *
3236
+ * Note: This method is restricted by default and must be enabled via
3237
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3238
+ * @param downloadLocation file auto download location
3239
+ *
3240
+ * @throws if setting file auto download location on different applications.
3241
+ * @example
3242
+ *
3243
+ * ```js
3244
+ * const downloadLocation = 'C:\\dev\\temp';
3245
+ * const app = await fin.Application.getCurrent();
3246
+ * try {
3247
+ * await app.setFileDownloadLocation(downloadLocation);
3248
+ * console.log('File download location is set');
3249
+ * } catch(err) {
3250
+ * console.error(err)
3251
+ * }
3252
+ * ```
3253
+ */
3254
+ async setFileDownloadLocation(downloadLocation) {
3255
+ const { name } = this.wire.me;
3256
+ const entityIdentity = { uuid: this.identity.uuid, name };
3257
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3258
+ }
3259
+ /**
3260
+ * 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.
3261
+ *
3262
+ * Note: This method is restricted by default and must be enabled via
3263
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3264
+ *
3265
+ * @throws if getting file auto download location on different applications.
3266
+ * @example
3267
+ *
3268
+ * ```js
3269
+ * const app = await fin.Application.getCurrent();
3270
+ * const fileDownloadDir = await app.getFileDownloadLocation();
3271
+ * ```
3272
+ */
3273
+ async getFileDownloadLocation() {
3274
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3275
+ return data;
3276
+ }
3277
+ /**
3278
+ * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3279
+ * @param options
3280
+ * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3281
+ * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3282
+ * of all possible data shapes for the entire menu, and the click handler should process
3283
+ * these with a "reducer" pattern.
3284
+ * @throws if the application has no tray icon set
3285
+ * @throws if the system tray is currently hidden
3286
+ * @example
3287
+ *
3288
+ * ```js
3289
+ * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3290
+ * const app = fin.Application.getCurrentSync();
3291
+ *
3292
+ * await app.setTrayIcon(iconUrl);
3293
+ *
3294
+ * const template = [
3295
+ * {
3296
+ * label: 'Menu Item 1',
3297
+ * data: 'hello from item 1'
3298
+ * },
3299
+ * { type: 'separator' },
3300
+ * {
3301
+ * label: 'Menu Item 2',
3302
+ * type: 'checkbox',
3303
+ * checked: true,
3304
+ * data: 'The user clicked the checkbox'
3305
+ * },
3306
+ * {
3307
+ * label: 'see more',
3308
+ * enabled: false,
3309
+ * submenu: [
3310
+ * { label: 'submenu 1', data: 'hello from submenu' }
3311
+ * ]
3312
+ * }
3313
+ * ];
3314
+ *
3315
+ * app.addListener('tray-icon-clicked', (event) => {
3316
+ * // right-click
3317
+ * if (event.button === 2) {
3318
+ * app.showTrayIconPopupMenu({ template }).then(r => {
3319
+ * if (r.result === 'closed') {
3320
+ * console.log('nothing happened');
3321
+ * } else {
3322
+ * console.log(r.data);
3323
+ * }
3324
+ * });
3325
+ * }
3326
+ * });
3327
+ * ```
3328
+ */
3329
+ async showTrayIconPopupMenu(options) {
3330
+ const { name } = this.wire.me;
3331
+ const entityIdentity = { uuid: this.identity.uuid, name };
3332
+ const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3333
+ return payload.data;
3334
+ }
3335
+ /**
3336
+ * CLoses the tray icon menu.
3337
+ *
3338
+ * @throws if the application has no tray icon set
3339
+ * @example
3340
+ *
3341
+ * ```js
3342
+ * const app = fin.Application.getCurrentSync();
3343
+ *
3344
+ * await app.closeTrayIconPopupMenu();
3345
+ * ```
3346
+ */
3347
+ async closeTrayIconPopupMenu() {
3348
+ const { name } = this.wire.me;
3349
+ const entityIdentity = { uuid: this.identity.uuid, name };
3350
+ await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3351
+ }
3352
+ }
3353
+ Instance$5.Application = Application;
3354
+ return Instance$5;
3612
3355
  }
3613
- Factory$6.ApplicationModule = ApplicationModule;
3614
3356
 
3615
- (function (exports) {
3616
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3617
- if (k2 === undefined) k2 = k;
3618
- var desc = Object.getOwnPropertyDescriptor(m, k);
3619
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3620
- desc = { enumerable: true, get: function() { return m[k]; } };
3621
- }
3622
- Object.defineProperty(o, k2, desc);
3623
- }) : (function(o, m, k, k2) {
3624
- if (k2 === undefined) k2 = k;
3625
- o[k2] = m[k];
3626
- }));
3627
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3628
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3629
- };
3630
- Object.defineProperty(exports, "__esModule", { value: true });
3357
+ var hasRequiredFactory$2;
3358
+
3359
+ function requireFactory$2 () {
3360
+ if (hasRequiredFactory$2) return Factory$6;
3361
+ hasRequiredFactory$2 = 1;
3362
+ Object.defineProperty(Factory$6, "__esModule", { value: true });
3363
+ Factory$6.ApplicationModule = void 0;
3364
+ const base_1 = base;
3365
+ const validate_1 = validate;
3366
+ const Instance_1 = requireInstance$2();
3631
3367
  /**
3632
- * Entry points for the OpenFin `Application` API (`fin.Application`).
3633
- *
3634
- * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3635
- * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3636
- *
3637
- * 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),
3638
- * both of these were documented on the same page.
3639
- *
3640
- * @packageDocumentation
3368
+ * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3641
3369
  */
3642
- __exportStar(Factory$6, exports);
3643
- __exportStar(Instance$5, exports);
3644
- } (application));
3370
+ class ApplicationModule extends base_1.Base {
3371
+ /**
3372
+ * Asynchronously returns an Application object that represents an existing application.
3373
+ *
3374
+ * @example
3375
+ *
3376
+ * ```js
3377
+ * fin.Application.wrap({ uuid: 'testapp' })
3378
+ * .then(app => app.isRunning())
3379
+ * .then(running => console.log('Application is running: ' + running))
3380
+ * .catch(err => console.log(err));
3381
+ * ```
3382
+ *
3383
+ */
3384
+ async wrap(identity) {
3385
+ this.wire.sendAction('wrap-application').catch((e) => {
3386
+ // we do not want to expose this error, just continue if this analytics-only call fails
3387
+ });
3388
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
3389
+ if (errorMsg) {
3390
+ throw new Error(errorMsg);
3391
+ }
3392
+ return new Instance_1.Application(this.wire, identity);
3393
+ }
3394
+ /**
3395
+ * Synchronously returns an Application object that represents an existing application.
3396
+ *
3397
+ * @example
3398
+ *
3399
+ * ```js
3400
+ * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3401
+ * await app.close();
3402
+ * ```
3403
+ *
3404
+ */
3405
+ wrapSync(identity) {
3406
+ this.wire.sendAction('wrap-application-sync').catch((e) => {
3407
+ // we do not want to expose this error, just continue if this analytics-only call fails
3408
+ });
3409
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
3410
+ if (errorMsg) {
3411
+ throw new Error(errorMsg);
3412
+ }
3413
+ return new Instance_1.Application(this.wire, identity);
3414
+ }
3415
+ async _create(appOptions) {
3416
+ // set defaults:
3417
+ if (appOptions.waitForPageLoad === undefined) {
3418
+ appOptions.waitForPageLoad = false;
3419
+ }
3420
+ if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3421
+ appOptions.autoShow = true;
3422
+ }
3423
+ await this.wire.sendAction('create-application', appOptions);
3424
+ return this.wrap({ uuid: appOptions.uuid });
3425
+ }
3426
+ /**
3427
+ * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3428
+ *
3429
+ * @example
3430
+ *
3431
+ * ```js
3432
+ * async function createApp() {
3433
+ * const app = await fin.Application.create({
3434
+ * name: 'myApp',
3435
+ * uuid: 'app-3',
3436
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3437
+ * autoShow: true
3438
+ * });
3439
+ * await app.run();
3440
+ * }
3441
+ *
3442
+ * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3443
+ * ```
3444
+ *
3445
+ * @ignore
3446
+ */
3447
+ create(appOptions) {
3448
+ console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3449
+ this.wire.sendAction('application-create').catch((e) => {
3450
+ // we do not want to expose this error, just continue if this analytics-only call fails
3451
+ });
3452
+ return this._create(appOptions);
3453
+ }
3454
+ /**
3455
+ * Creates and starts a new Application.
3456
+ *
3457
+ * @example
3458
+ *
3459
+ * ```js
3460
+ * async function start() {
3461
+ * return fin.Application.start({
3462
+ * name: 'app-1',
3463
+ * uuid: 'app-1',
3464
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3465
+ * autoShow: true
3466
+ * });
3467
+ * }
3468
+ * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3469
+ * ```
3470
+ *
3471
+ */
3472
+ async start(appOptions) {
3473
+ this.wire.sendAction('start-application').catch((e) => {
3474
+ // we do not want to expose this error, just continue if this analytics-only call fails
3475
+ });
3476
+ const app = await this._create(appOptions);
3477
+ await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3478
+ return app;
3479
+ }
3480
+ /**
3481
+ * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3482
+ * Returns once the RVM is finished attempting to launch the applications.
3483
+ * @param opts - Parameters that the RVM will use.
3484
+ *
3485
+ * @example
3486
+ *
3487
+ * ```js
3488
+ *
3489
+ * const applicationInfoArray = [
3490
+ * {
3491
+ * "uuid": 'App-1',
3492
+ * "manifestUrl": 'http://localhost:5555/app1.json',
3493
+ * },
3494
+ * {
3495
+ * "uuid": 'App-2',
3496
+ * "manifestUrl": 'http://localhost:5555/app2.json',
3497
+ * },
3498
+ * {
3499
+ * "uuid": 'App-3',
3500
+ * "manifestUrl": 'http://localhost:5555/app3.json',
3501
+ * }
3502
+ * ]
3503
+ *
3504
+ * fin.Application.startManyManifests(applicationInfoArray)
3505
+ * .then(() => {
3506
+ * console.log('RVM has finished launching the application list.');
3507
+ * })
3508
+ * .catch((err) => {
3509
+ * console.log(err);
3510
+ * })
3511
+ * ```
3512
+ *
3513
+ * @experimental
3514
+ */
3515
+ async startManyManifests(applications, opts) {
3516
+ return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3517
+ }
3518
+ /**
3519
+ * Asynchronously returns an Application object that represents the current application
3520
+ *
3521
+ * @example
3522
+ *
3523
+ * ```js
3524
+ * async function isCurrentAppRunning () {
3525
+ * const app = await fin.Application.getCurrent();
3526
+ * return app.isRunning();
3527
+ * }
3528
+ *
3529
+ * isCurrentAppRunning().then(running => {
3530
+ * console.log(`Current app is running: ${running}`);
3531
+ * }).catch(err => {
3532
+ * console.error(err);
3533
+ * });
3534
+ *
3535
+ * ```
3536
+ */
3537
+ getCurrent() {
3538
+ this.wire.sendAction('get-current-application').catch((e) => {
3539
+ // we do not want to expose this error, just continue if this analytics-only call fails
3540
+ });
3541
+ return this.wrap({ uuid: this.wire.me.uuid });
3542
+ }
3543
+ /**
3544
+ * Synchronously returns an Application object that represents the current application
3545
+ *
3546
+ * @example
3547
+ *
3548
+ * ```js
3549
+ * async function isCurrentAppRunning () {
3550
+ * const app = fin.Application.getCurrentSync();
3551
+ * return app.isRunning();
3552
+ * }
3553
+ *
3554
+ * isCurrentAppRunning().then(running => {
3555
+ * console.log(`Current app is running: ${running}`);
3556
+ * }).catch(err => {
3557
+ * console.error(err);
3558
+ * });
3559
+ *
3560
+ * ```
3561
+ */
3562
+ getCurrentSync() {
3563
+ this.wire.sendAction('get-current-application-sync').catch((e) => {
3564
+ // we do not want to expose this error, just continue if this analytics-only call fails
3565
+ });
3566
+ return this.wrapSync({ uuid: this.wire.me.uuid });
3567
+ }
3568
+ /**
3569
+ * Retrieves application's manifest and returns a running instance of the application.
3570
+ * @param manifestUrl - The URL of app's manifest.
3571
+ * @param opts - Parameters that the RVM will use.
3572
+ *
3573
+ * @example
3574
+ *
3575
+ * ```js
3576
+ * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3577
+ *
3578
+ * // For a local manifest file:
3579
+ * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3580
+ * ```
3581
+ */
3582
+ async startFromManifest(manifestUrl, opts) {
3583
+ this.wire.sendAction('application-start-from-manifest').catch((e) => {
3584
+ // we do not want to expose this error, just continue if this analytics-only call fails
3585
+ });
3586
+ const app = await this._createFromManifest(manifestUrl);
3587
+ // @ts-expect-error using private method without warning.
3588
+ await app._run(opts); // eslint-disable-line no-underscore-dangle
3589
+ return app;
3590
+ }
3591
+ /**
3592
+ * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3593
+ * Retrieves application's manifest and returns a wrapped application.
3594
+ * @param manifestUrl - The URL of app's manifest.
3595
+ * @param callback - called if the method succeeds.
3596
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3597
+ *
3598
+ * @example
3599
+ *
3600
+ * ```js
3601
+ * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3602
+ * ```
3603
+ * @ignore
3604
+ */
3605
+ createFromManifest(manifestUrl) {
3606
+ console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3607
+ this.wire.sendAction('application-create-from-manifest').catch((e) => {
3608
+ // we do not want to expose this error, just continue if this analytics-only call fails
3609
+ });
3610
+ return this._createFromManifest(manifestUrl);
3611
+ }
3612
+ _createFromManifest(manifestUrl) {
3613
+ return this.wire
3614
+ .sendAction('get-application-manifest', { manifestUrl })
3615
+ .then(({ payload }) => {
3616
+ const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3617
+ return this.wrap({ uuid });
3618
+ })
3619
+ .then((app) => {
3620
+ app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3621
+ return app;
3622
+ });
3623
+ }
3624
+ }
3625
+ Factory$6.ApplicationModule = ApplicationModule;
3626
+ return Factory$6;
3627
+ }
3628
+
3629
+ var hasRequiredApplication;
3630
+
3631
+ function requireApplication () {
3632
+ if (hasRequiredApplication) return application;
3633
+ hasRequiredApplication = 1;
3634
+ (function (exports) {
3635
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3636
+ if (k2 === undefined) k2 = k;
3637
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3638
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3639
+ desc = { enumerable: true, get: function() { return m[k]; } };
3640
+ }
3641
+ Object.defineProperty(o, k2, desc);
3642
+ }) : (function(o, m, k, k2) {
3643
+ if (k2 === undefined) k2 = k;
3644
+ o[k2] = m[k];
3645
+ }));
3646
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3647
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3648
+ };
3649
+ Object.defineProperty(exports, "__esModule", { value: true });
3650
+ /**
3651
+ * Entry points for the OpenFin `Application` API (`fin.Application`).
3652
+ *
3653
+ * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3654
+ * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3655
+ *
3656
+ * 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),
3657
+ * both of these were documented on the same page.
3658
+ *
3659
+ * @packageDocumentation
3660
+ */
3661
+ __exportStar(requireFactory$2(), exports);
3662
+ __exportStar(requireInstance$2(), exports);
3663
+ } (application));
3664
+ return application;
3665
+ }
3645
3666
 
3646
3667
  var hasRequiredInstance$1;
3647
3668
 
@@ -3654,7 +3675,7 @@ function requireInstance$1 () {
3654
3675
  /* eslint-disable @typescript-eslint/no-unused-vars */
3655
3676
  /* eslint-disable no-console */
3656
3677
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
3657
- const application_1 = application;
3678
+ const application_1 = requireApplication();
3658
3679
  const main_1 = main;
3659
3680
  const view_1 = requireView();
3660
3681
  const warnings_1 = warnings;
@@ -5706,7 +5727,7 @@ function requireView () {
5706
5727
  *
5707
5728
  * @packageDocumentation
5708
5729
  */
5709
- __exportStar(requireFactory$2(), exports);
5730
+ __exportStar(requireFactory$3(), exports);
5710
5731
  __exportStar(requireInstance(), exports);
5711
5732
  } (view));
5712
5733
  return view;
@@ -15772,7 +15793,7 @@ const events_1 = require$$0;
15772
15793
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
15773
15794
  const index_1 = system;
15774
15795
  const index_2 = requireWindow();
15775
- const index_3 = application;
15796
+ const index_3 = requireApplication();
15776
15797
  const index_4 = interappbus;
15777
15798
  const index_5 = clipboard;
15778
15799
  const index_6 = externalApplication;