@openfin/core 43.102.1 → 43.102.2

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/stub.js +1157 -1136
  2. package/package.json +4 -4
package/out/stub.js CHANGED
@@ -822,11 +822,11 @@ const handleDeprecatedWarnings = (options) => {
822
822
  };
823
823
  warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
824
824
 
825
- var hasRequiredFactory$1;
825
+ var hasRequiredFactory$2;
826
826
 
827
- function requireFactory$1 () {
828
- if (hasRequiredFactory$1) return Factory$6;
829
- hasRequiredFactory$1 = 1;
827
+ function requireFactory$2 () {
828
+ if (hasRequiredFactory$2) return Factory$6;
829
+ hasRequiredFactory$2 = 1;
830
830
  Object.defineProperty(Factory$6, "__esModule", { value: true });
831
831
  Factory$6.ViewModule = void 0;
832
832
  const base_1 = base;
@@ -1041,8 +1041,8 @@ var main = {};
1041
1041
 
1042
1042
  Object.defineProperty(main, "__esModule", { value: true });
1043
1043
  main.WebContents = void 0;
1044
- const base_1$p = base;
1045
- class WebContents extends base_1$p.EmitterBase {
1044
+ const base_1$n = base;
1045
+ class WebContents extends base_1$n.EmitterBase {
1046
1046
  /**
1047
1047
  * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1048
1048
  * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
@@ -2123,11 +2123,11 @@ class WebContents extends base_1$p.EmitterBase {
2123
2123
  }
2124
2124
  main.WebContents = WebContents;
2125
2125
 
2126
- var hasRequiredInstance$1;
2126
+ var hasRequiredInstance$2;
2127
2127
 
2128
- function requireInstance$1 () {
2129
- if (hasRequiredInstance$1) return Instance$5;
2130
- hasRequiredInstance$1 = 1;
2128
+ function requireInstance$2 () {
2129
+ if (hasRequiredInstance$2) return Instance$5;
2130
+ hasRequiredInstance$2 = 1;
2131
2131
  var _View_providerChannelClient;
2132
2132
  Object.defineProperty(Instance$5, "__esModule", { value: true });
2133
2133
  Instance$5.View = void 0;
@@ -2707,1139 +2707,1160 @@ function requireView () {
2707
2707
  *
2708
2708
  * @packageDocumentation
2709
2709
  */
2710
- __exportStar(requireFactory$1(), exports);
2711
- __exportStar(requireInstance$1(), exports);
2710
+ __exportStar(requireFactory$2(), exports);
2711
+ __exportStar(requireInstance$2(), exports);
2712
2712
  } (view));
2713
2713
  return view;
2714
2714
  }
2715
2715
 
2716
- Object.defineProperty(Instance$6, "__esModule", { value: true });
2717
- Instance$6.Application = void 0;
2718
- /* eslint-disable import/prefer-default-export */
2719
- const base_1$o = base;
2720
- const window_1$1 = requireWindow();
2721
- const view_1 = requireView();
2722
- /**
2723
- * An object representing an application. Allows the developer to create,
2724
- * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2725
- */
2726
- class Application extends base_1$o.EmitterBase {
2727
- /**
2728
- * @internal
2729
- */
2730
- constructor(wire, identity) {
2731
- super(wire, 'application', identity.uuid);
2732
- this.identity = identity;
2733
- this.window = new window_1$1._Window(this.wire, {
2734
- uuid: this.identity.uuid,
2735
- name: this.identity.uuid
2736
- });
2737
- }
2738
- windowListFromIdentityList(identityList) {
2739
- const windowList = [];
2740
- identityList.forEach((identity) => {
2741
- windowList.push(new window_1$1._Window(this.wire, {
2742
- uuid: identity.uuid,
2743
- name: identity.name
2744
- }));
2745
- });
2746
- return windowList;
2747
- }
2748
- /**
2749
- * Determines if the application is currently running.
2750
- *
2751
- * @example
2752
- *
2753
- * ```js
2754
- * async function isAppRunning() {
2755
- * const app = await fin.Application.getCurrent();
2756
- * return await app.isRunning();
2757
- * }
2758
- * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2759
- * ```
2760
- */
2761
- isRunning() {
2762
- return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2763
- }
2764
- /**
2765
- * Closes the application and any child windows created by the application.
2766
- * Cleans the application from state so it is no longer found in getAllApplications.
2767
- * @param force Close will be prevented from closing when force is false and
2768
- * ‘close-requested’ has been subscribed to for application’s main window.
2769
- *
2770
- * @example
2771
- *
2772
- * ```js
2773
- * async function closeApp() {
2774
- * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2775
- * const app = await fin.Application.wrap({uuid: 'app2'});
2776
- * await app.quit();
2777
- * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2778
- *
2779
- * }
2780
- * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2781
- * ```
2782
- */
2783
- async quit(force = false) {
2784
- try {
2785
- await this._close(force);
2786
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
2787
- }
2788
- catch (error) {
2789
- const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2790
- if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2791
- throw error;
2792
- }
2793
- }
2794
- }
2795
- async _close(force = false) {
2796
- try {
2797
- await this.wire.sendAction('close-application', { force, ...this.identity });
2798
- }
2799
- catch (error) {
2800
- if (!error.message.includes('Remote connection has closed')) {
2801
- throw error;
2802
- }
2803
- }
2804
- }
2805
- /**
2806
- * @deprecated use Application.quit instead
2807
- * Closes the application and any child windows created by the application.
2808
- * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2809
- * @param callback - called if the method succeeds.
2810
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2811
- *
2812
- * @example
2813
- *
2814
- * ```js
2815
- * async function closeApp() {
2816
- * const app = await fin.Application.getCurrent();
2817
- * return await app.close();
2818
- * }
2819
- * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2820
- * ```
2821
- */
2822
- close(force = false) {
2823
- console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2824
- this.wire.sendAction('application-close', this.identity).catch((e) => {
2825
- // we do not want to expose this error, just continue if this analytics-only call fails
2826
- });
2827
- return this._close(force);
2828
- }
2829
- /**
2830
- * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2831
- *
2832
- * @example
2833
- *
2834
- * ```js
2835
- * async function getChildWindows() {
2836
- * const app = await fin.Application.getCurrent();
2837
- * return await app.getChildWindows();
2838
- * }
2839
- *
2840
- * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2841
- * ```
2842
- */
2843
- getChildWindows() {
2844
- return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2845
- const identityList = [];
2846
- payload.data.forEach((winName) => {
2847
- identityList.push({ uuid: this.identity.uuid, name: winName });
2848
- });
2849
- return this.windowListFromIdentityList(identityList);
2850
- });
2851
- }
2852
- /**
2853
- * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2854
- * if the application was not created from a manifest.
2855
- *
2856
- * @example
2857
- *
2858
- * ```js
2859
- * async function getManifest() {
2860
- * const app = await fin.Application.getCurrent();
2861
- * return await app.getManifest();
2862
- * }
2863
- *
2864
- * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2865
- * ```
2866
- */
2867
- getManifest() {
2868
- return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2869
- }
2870
- /**
2871
- * Retrieves UUID of the application that launches this application. Invokes the error callback
2872
- * if the application was created from a manifest.
2873
- *
2874
- * @example
2875
- *
2876
- * ```js
2877
- * async function getParentUuid() {
2878
- * const app = await fin.Application.start({
2879
- * uuid: 'app-1',
2880
- * name: 'myApp',
2881
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2882
- * autoShow: true
2883
- * });
2884
- * return await app.getParentUuid();
2885
- * }
2886
- *
2887
- * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2888
- * ```
2889
- */
2890
- getParentUuid() {
2891
- return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2892
- }
2893
- /**
2894
- * Retrieves current application's shortcut configuration.
2895
- *
2896
- * @example
2897
- *
2898
- * ```js
2899
- * async function getShortcuts() {
2900
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
2901
- * return await app.getShortcuts();
2902
- * }
2903
- * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2904
- * ```
2905
- */
2906
- getShortcuts() {
2907
- return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2908
- }
2909
- /**
2910
- * Retrieves current application's views.
2911
- * @experimental
2912
- *
2913
- * @example
2914
- *
2915
- * ```js
2916
- * async function getViews() {
2917
- * const app = await fin.Application.getCurrent();
2918
- * return await app.getViews();
2919
- * }
2920
- * getViews().then(views => console.log(views)).catch(err => console.log(err));
2921
- * ```
2922
- */
2923
- async getViews() {
2924
- const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2925
- return payload.data.map((id) => new view_1.View(this.wire, id));
2926
- }
2927
- /**
2928
- * Returns the current zoom level of the application.
2929
- *
2930
- * @example
2931
- *
2932
- * ```js
2933
- * async function getZoomLevel() {
2934
- * const app = await fin.Application.getCurrent();
2935
- * return await app.getZoomLevel();
2936
- * }
2937
- *
2938
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2939
- * ```
2940
- */
2941
- getZoomLevel() {
2942
- return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2943
- }
2944
- /**
2945
- * Returns an instance of the main Window of the application
2946
- *
2947
- * @example
2948
- *
2949
- * ```js
2950
- * async function getWindow() {
2951
- * const app = await fin.Application.start({
2952
- * uuid: 'app-1',
2953
- * name: 'myApp',
2954
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
2955
- * autoShow: true
2956
- * });
2957
- * return await app.getWindow();
2958
- * }
2959
- *
2960
- * getWindow().then(win => {
2961
- * win.showAt(0, 400);
2962
- * win.flash();
2963
- * }).catch(err => console.log(err));
2964
- * ```
2965
- */
2966
- getWindow() {
2967
- this.wire.sendAction('application-get-window', this.identity).catch((e) => {
2968
- // we do not want to expose this error, just continue if this analytics-only call fails
2969
- });
2970
- return Promise.resolve(this.window);
2971
- }
2972
- /**
2973
- * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
2974
- * @param userName - username to be passed to the RVM.
2975
- * @param appName - app name to be passed to the RVM.
2976
- *
2977
- * @example
2978
- *
2979
- * ```js
2980
- * async function registerUser() {
2981
- * const app = await fin.Application.getCurrent();
2982
- * return await app.registerUser('user', 'myApp');
2983
- * }
2984
- *
2985
- * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
2986
- * ```
2987
- */
2988
- registerUser(userName, appName) {
2989
- return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
2990
- }
2991
- /**
2992
- * Removes the application’s icon from the tray.
2993
- *
2994
- * @example
2995
- *
2996
- * ```js
2997
- * async function removeTrayIcon() {
2998
- * const app = await fin.Application.getCurrent();
2999
- * return await app.removeTrayIcon();
3000
- * }
3001
- *
3002
- * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
3003
- * ```
3004
- */
3005
- removeTrayIcon() {
3006
- return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
3007
- }
3008
- /**
3009
- * Restarts the application.
3010
- *
3011
- * @example
3012
- *
3013
- * ```js
3014
- * async function restartApp() {
3015
- * const app = await fin.Application.getCurrent();
3016
- * return await app.restart();
3017
- * }
3018
- * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
3019
- * ```
3020
- */
3021
- restart() {
3022
- return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3023
- }
3024
- /**
3025
- * DEPRECATED method to run the application.
3026
- * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3027
- *
3028
- * @example
3029
- *
3030
- * ```js
3031
- * async function run() {
3032
- * const app = await fin.Application.create({
3033
- * name: 'myApp',
3034
- * uuid: 'app-1',
3035
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3036
- * autoShow: true
3037
- * });
3038
- * await app.run();
3039
- * }
3040
- * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3041
- * ```
3042
- *
3043
- * @ignore
3044
- */
3045
- run() {
3046
- console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3047
- this.wire.sendAction('application-run', this.identity).catch((e) => {
3048
- // we do not want to expose this error, just continue if this analytics-only call fails
3049
- });
3050
- return this._run();
3051
- }
3052
- _run(opts = {}) {
3053
- return this.wire
3054
- .sendAction('run-application', {
3055
- manifestUrl: this._manifestUrl,
3056
- opts,
3057
- ...this.identity
3058
- })
3059
- .then(() => undefined);
3060
- }
3061
- /**
3062
- * Instructs the RVM to schedule one restart of the application.
3063
- *
3064
- * @example
3065
- *
3066
- * ```js
3067
- * async function scheduleRestart() {
3068
- * const app = await fin.Application.getCurrent();
3069
- * return await app.scheduleRestart();
3070
- * }
3071
- *
3072
- * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3073
- * ```
3074
- */
3075
- scheduleRestart() {
3076
- return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3077
- }
3078
- /**
3079
- * Sends a message to the RVM to upload the application's logs. On success,
3080
- * an object containing logId is returned.
3081
- *
3082
- * @example
3083
- *
3084
- * ```js
3085
- * async function sendLog() {
3086
- * const app = await fin.Application.getCurrent();
3087
- * return await app.sendApplicationLog();
3088
- * }
3089
- *
3090
- * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3091
- * ```
3092
- */
3093
- async sendApplicationLog() {
3094
- const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3095
- return payload.data;
3096
- }
3097
- /**
3098
- * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3099
- * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3100
- *
3101
- * Note: If the "name" property is omitted it defaults to "tasks".
3102
- * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3103
- *
3104
- *
3105
- * @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).
3106
- *
3107
- * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3108
- * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3109
- *
3110
- * Note: If the "name" property is omitted it defaults to "tasks".
3111
- *
3112
- * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3113
- * uuid or shortcut.name is changed.
3114
- *
3115
- * @example
3116
- *
3117
- * ```js
3118
- * const app = fin.Application.getCurrentSync();
3119
- * const appName = 'My App';
3120
- * const jumpListConfig = [ // array of JumpList categories
3121
- * {
3122
- * // has no name and no type so `type` is assumed to be "tasks"
3123
- * items: [ // array of JumpList items
3124
- * {
3125
- * type: 'task',
3126
- * title: `Launch ${appName}`,
3127
- * description: `Runs ${appName} with the default configuration`,
3128
- * deepLink: 'fins://path.to/app/manifest.json',
3129
- * iconPath: 'https://path.to/app/icon.ico',
3130
- * iconIndex: 0
3131
- * },
3132
- * { type: 'separator' },
3133
- * {
3134
- * type: 'task',
3135
- * title: `Restore ${appName}`,
3136
- * description: 'Restore to last configuration',
3137
- * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3138
- * iconPath: 'https://path.to/app/icon.ico',
3139
- * iconIndex: 0
3140
- * },
3141
- * ]
3142
- * },
3143
- * {
3144
- * name: 'Tools',
3145
- * items: [ // array of JumpList items
3146
- * {
3147
- * type: 'task',
3148
- * title: 'Tool A',
3149
- * description: 'Runs Tool A',
3150
- * deepLink: 'fins://path.to/tool-a/manifest.json',
3151
- * iconPath: 'https://path.to/tool-a/icon.ico',
3152
- * iconIndex: 0
3153
- * },
3154
- * {
3155
- * type: 'task',
3156
- * title: 'Tool B',
3157
- * description: 'Runs Tool B',
3158
- * deepLink: 'fins://path.to/tool-b/manifest.json',
3159
- * iconPath: 'https://path.to/tool-b/icon.ico',
3160
- * iconIndex: 0
3161
- * }]
3162
- * }
3163
- * ];
3164
- *
3165
- * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3166
- * ```
3167
- *
3168
- * To handle deeplink args:
3169
- * ```js
3170
- * function handleUseLastConfiguration() {
3171
- * // this handler is called when the app is being launched
3172
- * app.on('run-requested', event => {
3173
- * if(event.userAppConfigArgs['use-last-configuration']) {
3174
- * // your logic here
3175
- * }
3176
- * });
3177
- * // this handler is called when the app was already running when the launch was requested
3178
- * fin.desktop.main(function(args) {
3179
- * if(args && args['use-last-configuration']) {
3180
- * // your logic here
3181
- * }
3182
- * });
3183
- * }
3184
- * ```
3185
- */
3186
- async setJumpList(jumpListCategories) {
3187
- await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3188
- }
3189
- /**
3190
- * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3191
- * @param icon Image URL or base64 encoded string to be used as the icon
3192
- *
3193
- * @example
3194
- *
3195
- * ```js
3196
- * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3197
- * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3198
- * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3199
- * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3200
- * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3201
- *
3202
- * async function setTrayIcon(icon) {
3203
- * const app = await fin.Application.getCurrent();
3204
- * return await app.setTrayIcon(icon);
3205
- * }
3206
- *
3207
- * // use image url to set tray icon
3208
- * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3209
- *
3210
- * // use base64 encoded string to set tray icon
3211
- * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3212
- *
3213
- * // use a dataURL to set tray icon
3214
- * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3215
- * ```
3216
- */
3217
- setTrayIcon(icon) {
3218
- return this.wire
3219
- .sendAction('set-tray-icon', {
3220
- enabledIcon: icon,
3221
- ...this.identity
3222
- })
3223
- .then(() => undefined);
3224
- }
3225
- /**
3226
- * Set hover text for this application's system tray icon.
3227
- * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
3228
- * @param toolTip
3229
- *
3230
- * @example
3231
- *
3232
- * ```js
3233
- * const app = fin.Application.getCurrentSync();
3234
- * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3235
- *
3236
- * await app.setTrayIcon(iconUrl);
3237
- *
3238
- * await app.setTrayIconToolTip('My Application');
3239
- * ```
3240
- */
3241
- async setTrayIconToolTip(toolTip) {
3242
- await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
3243
- }
3244
- /**
3245
- * Sets new application's shortcut configuration. Windows only.
3246
- * @param config New application's shortcut configuration.
3247
- *
3248
- * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3249
- * to be able to change shortcut states.
3250
- *
3251
- * @example
3252
- *
3253
- * ```js
3254
- * async function setShortcuts(config) {
3255
- * const app = await fin.Application.getCurrent();
3256
- * return app.setShortcuts(config);
3257
- * }
3258
- *
3259
- * setShortcuts({
3260
- * desktop: true,
3261
- * startMenu: false,
3262
- * systemStartup: true
3263
- * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3264
- * ```
3265
- */
3266
- setShortcuts(config) {
3267
- return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3268
- }
3269
- /**
3270
- * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3271
- * @param queryString The new query string for this app's shortcuts.
3272
- *
3273
- * @example
3274
- *
3275
- * ```js
3276
- * const newQueryArgs = 'arg=true&arg2=false';
3277
- * const app = await fin.Application.getCurrent();
3278
- * try {
3279
- * await app.setShortcutQueryParams(newQueryArgs);
3280
- * } catch(err) {
3281
- * console.error(err)
3282
- * }
3283
- * ```
3284
- */
3285
- async setShortcutQueryParams(queryString) {
3286
- await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3287
- }
3288
- /**
3289
- * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3290
- * larger or smaller to default limits of 300% and 50% of original size, respectively.
3291
- * @param level The zoom level
3292
- *
3293
- * @example
3294
- *
3295
- * ```js
3296
- * async function setZoomLevel(number) {
3297
- * const app = await fin.Application.getCurrent();
3298
- * return await app.setZoomLevel(number);
3299
- * }
3300
- *
3301
- * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3302
- * ```
3303
- */
3304
- setZoomLevel(level) {
3305
- return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3306
- }
3307
- /**
3308
- * Sets a username to correlate with App Log Management.
3309
- * @param username Username to correlate with App's Log.
3310
- *
3311
- * @example
3312
- *
3313
- * ```js
3314
- * async function setAppLogUser() {
3315
- * const app = await fin.Application.getCurrent();
3316
- * return await app.setAppLogUsername('username');
3317
- * }
3318
- *
3319
- * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3320
- *
3321
- * ```
3322
- */
3323
- async setAppLogUsername(username) {
3324
- await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3325
- }
3326
- /**
3327
- * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3328
- * @remarks The only information currently returned is the position and dimensions.
3329
- *
3330
- * @example
3331
- *
3332
- * ```js
3333
- * async function getTrayIconInfo() {
3334
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3335
- * return await app.getTrayIconInfo();
3336
- * }
3337
- * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3338
- * ```
3339
- */
3340
- getTrayIconInfo() {
3341
- return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3342
- }
3343
- /**
3344
- * Checks if the application has an associated tray icon.
3345
- *
3346
- * @example
3347
- *
3348
- * ```js
3349
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3350
- * const hasTrayIcon = await app.hasTrayIcon();
3351
- * console.log(hasTrayIcon);
3352
- * ```
3353
- */
3354
- hasTrayIcon() {
3355
- return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3356
- }
3357
- /**
3358
- * Closes the application by terminating its process.
3359
- *
3360
- * @example
3361
- *
3362
- * ```js
3363
- * async function terminateApp() {
3364
- * const app = await fin.Application.getCurrent();
3365
- * return await app.terminate();
3366
- * }
3367
- * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3368
- * ```
3369
- */
3370
- terminate() {
3371
- return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3372
- }
3373
- /**
3374
- * Waits for a hanging application. This method can be called in response to an application
3375
- * "not-responding" to allow the application to continue and to generate another "not-responding"
3376
- * message after a certain period of time.
3377
- *
3378
- * @ignore
3379
- */
3380
- wait() {
3381
- return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3382
- }
3383
- /**
3384
- * Retrieves information about the application.
3385
- *
3386
- * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3387
- * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3388
- * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3389
- *
3390
- * @example
3391
- *
3392
- * ```js
3393
- * async function getInfo() {
3394
- * const app = await fin.Application.getCurrent();
3395
- * return await app.getInfo();
3396
- * }
3397
- *
3398
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3399
- * ```
3400
- */
3401
- getInfo() {
3402
- return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3403
- }
3404
- /**
3405
- * Retrieves all process information for entities (windows and views) associated with an application.
3406
- *
3407
- * @example
3408
- * ```js
3409
- * const app = await fin.Application.getCurrent();
3410
- * const processInfo = await app.getProcessInfo();
3411
- * ```
3412
- * @experimental
3413
- */
3414
- async getProcessInfo() {
3415
- const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3416
- return data;
3417
- }
3418
- /**
3419
- * Sets file auto download location. It's only allowed in the same application.
3420
- *
3421
- * Note: This method is restricted by default and must be enabled via
3422
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3423
- * @param downloadLocation file auto download location
3424
- *
3425
- * @throws if setting file auto download location on different applications.
3426
- * @example
3427
- *
3428
- * ```js
3429
- * const downloadLocation = 'C:\\dev\\temp';
3430
- * const app = await fin.Application.getCurrent();
3431
- * try {
3432
- * await app.setFileDownloadLocation(downloadLocation);
3433
- * console.log('File download location is set');
3434
- * } catch(err) {
3435
- * console.error(err)
3436
- * }
3437
- * ```
3438
- */
3439
- async setFileDownloadLocation(downloadLocation) {
3440
- const { name } = this.wire.me;
3441
- const entityIdentity = { uuid: this.identity.uuid, name };
3442
- await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3443
- }
3444
- /**
3445
- * 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.
3446
- *
3447
- * Note: This method is restricted by default and must be enabled via
3448
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3449
- *
3450
- * @throws if getting file auto download location on different applications.
3451
- * @example
3452
- *
3453
- * ```js
3454
- * const app = await fin.Application.getCurrent();
3455
- * const fileDownloadDir = await app.getFileDownloadLocation();
3456
- * ```
3457
- */
3458
- async getFileDownloadLocation() {
3459
- const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3460
- return data;
3461
- }
3462
- /**
3463
- * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3464
- * @param options
3465
- * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3466
- * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3467
- * of all possible data shapes for the entire menu, and the click handler should process
3468
- * these with a "reducer" pattern.
3469
- * @throws if the application has no tray icon set
3470
- * @throws if the system tray is currently hidden
3471
- * @example
3472
- *
3473
- * ```js
3474
- * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3475
- * const app = fin.Application.getCurrentSync();
3476
- *
3477
- * await app.setTrayIcon(iconUrl);
3478
- *
3479
- * const template = [
3480
- * {
3481
- * label: 'Menu Item 1',
3482
- * data: 'hello from item 1'
3483
- * },
3484
- * { type: 'separator' },
3485
- * {
3486
- * label: 'Menu Item 2',
3487
- * type: 'checkbox',
3488
- * checked: true,
3489
- * data: 'The user clicked the checkbox'
3490
- * },
3491
- * {
3492
- * label: 'see more',
3493
- * enabled: false,
3494
- * submenu: [
3495
- * { label: 'submenu 1', data: 'hello from submenu' }
3496
- * ]
3497
- * }
3498
- * ];
3499
- *
3500
- * app.addListener('tray-icon-clicked', (event) => {
3501
- * // right-click
3502
- * if (event.button === 2) {
3503
- * app.showTrayIconPopupMenu({ template }).then(r => {
3504
- * if (r.result === 'closed') {
3505
- * console.log('nothing happened');
3506
- * } else {
3507
- * console.log(r.data);
3508
- * }
3509
- * });
3510
- * }
3511
- * });
3512
- * ```
3513
- */
3514
- async showTrayIconPopupMenu(options) {
3515
- const { name } = this.wire.me;
3516
- const entityIdentity = { uuid: this.identity.uuid, name };
3517
- const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3518
- return payload.data;
3519
- }
3520
- /**
3521
- * Closes the tray icon menu.
3522
- *
3523
- * @throws if the application has no tray icon set
3524
- * @example
3525
- *
3526
- * ```js
3527
- * const app = fin.Application.getCurrentSync();
3528
- *
3529
- * await app.closeTrayIconPopupMenu();
3530
- * ```
3531
- */
3532
- async closeTrayIconPopupMenu() {
3533
- const { name } = this.wire.me;
3534
- const entityIdentity = { uuid: this.identity.uuid, name };
3535
- await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3536
- }
3537
- }
3538
- Instance$6.Application = Application;
2716
+ var hasRequiredInstance$1;
3539
2717
 
3540
- Object.defineProperty(Factory$7, "__esModule", { value: true });
3541
- Factory$7.ApplicationModule = void 0;
3542
- const base_1$n = base;
3543
- const validate_1$4 = validate;
3544
- const Instance_1$5 = Instance$6;
3545
- /**
3546
- * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3547
- */
3548
- class ApplicationModule extends base_1$n.Base {
3549
- /**
3550
- * Asynchronously returns an API handle for the given Application identity.
3551
- *
3552
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3553
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3554
- * for an Application throughout its entire lifecycle.
3555
- *
3556
- * @example
3557
- *
3558
- * ```js
3559
- * fin.Application.wrap({ uuid: 'testapp' })
3560
- * .then(app => app.isRunning())
3561
- * .then(running => console.log('Application is running: ' + running))
3562
- * .catch(err => console.log(err));
3563
- * ```
3564
- *
3565
- */
3566
- async wrap(identity) {
3567
- this.wire.sendAction('wrap-application').catch((e) => {
3568
- // we do not want to expose this error, just continue if this analytics-only call fails
3569
- });
3570
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3571
- if (errorMsg) {
3572
- throw new Error(errorMsg);
3573
- }
3574
- return new Instance_1$5.Application(this.wire, identity);
3575
- }
3576
- /**
3577
- * Synchronously returns an API handle for the given Application identity.
3578
- *
3579
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3580
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3581
- * for an Aplication throughout its entire lifecycle.
3582
- *
3583
- * @example
3584
- *
3585
- * ```js
3586
- * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3587
- * await app.close();
3588
- * ```
3589
- *
3590
- */
3591
- wrapSync(identity) {
3592
- this.wire.sendAction('wrap-application-sync').catch((e) => {
3593
- // we do not want to expose this error, just continue if this analytics-only call fails
3594
- });
3595
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3596
- if (errorMsg) {
3597
- throw new Error(errorMsg);
3598
- }
3599
- return new Instance_1$5.Application(this.wire, identity);
3600
- }
3601
- async _create(appOptions) {
3602
- // set defaults:
3603
- if (appOptions.waitForPageLoad === undefined) {
3604
- appOptions.waitForPageLoad = false;
3605
- }
3606
- if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3607
- appOptions.autoShow = true;
3608
- }
3609
- await this.wire.sendAction('create-application', appOptions);
3610
- return this.wrap({ uuid: appOptions.uuid });
3611
- }
3612
- /**
3613
- * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3614
- *
3615
- * @example
3616
- *
3617
- * ```js
3618
- * async function createApp() {
3619
- * const app = await fin.Application.create({
3620
- * name: 'myApp',
3621
- * uuid: 'app-3',
3622
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3623
- * autoShow: true
3624
- * });
3625
- * await app.run();
3626
- * }
3627
- *
3628
- * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3629
- * ```
3630
- *
3631
- * @ignore
3632
- */
3633
- create(appOptions) {
3634
- console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3635
- this.wire.sendAction('application-create').catch((e) => {
3636
- // we do not want to expose this error, just continue if this analytics-only call fails
3637
- });
3638
- return this._create(appOptions);
3639
- }
3640
- /**
3641
- * Creates and starts a new Application.
3642
- *
3643
- * @example
3644
- *
3645
- * ```js
3646
- * async function start() {
3647
- * return fin.Application.start({
3648
- * name: 'app-1',
3649
- * uuid: 'app-1',
3650
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3651
- * autoShow: true
3652
- * });
3653
- * }
3654
- * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3655
- * ```
3656
- *
3657
- */
3658
- async start(appOptions) {
3659
- this.wire.sendAction('start-application').catch((e) => {
3660
- // we do not want to expose this error, just continue if this analytics-only call fails
3661
- });
3662
- const app = await this._create(appOptions);
3663
- await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3664
- return app;
3665
- }
3666
- /**
3667
- * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3668
- * Returns once the RVM is finished attempting to launch the applications.
3669
- * @param opts - Parameters that the RVM will use.
3670
- *
3671
- * @example
3672
- *
3673
- * ```js
3674
- *
3675
- * const applicationInfoArray = [
3676
- * {
3677
- * "uuid": 'App-1',
3678
- * "manifestUrl": 'http://localhost:5555/app1.json',
3679
- * },
3680
- * {
3681
- * "uuid": 'App-2',
3682
- * "manifestUrl": 'http://localhost:5555/app2.json',
3683
- * },
3684
- * {
3685
- * "uuid": 'App-3',
3686
- * "manifestUrl": 'http://localhost:5555/app3.json',
3687
- * }
3688
- * ]
3689
- *
3690
- * fin.Application.startManyManifests(applicationInfoArray)
3691
- * .then(() => {
3692
- * console.log('RVM has finished launching the application list.');
3693
- * })
3694
- * .catch((err) => {
3695
- * console.log(err);
3696
- * })
3697
- * ```
3698
- *
3699
- * @experimental
3700
- */
3701
- async startManyManifests(applications, opts) {
3702
- return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3703
- }
3704
- /**
3705
- * Asynchronously returns an Application object that represents the current application
3706
- *
3707
- * @example
3708
- *
3709
- * ```js
3710
- * async function isCurrentAppRunning () {
3711
- * const app = await fin.Application.getCurrent();
3712
- * return app.isRunning();
3713
- * }
3714
- *
3715
- * isCurrentAppRunning().then(running => {
3716
- * console.log(`Current app is running: ${running}`);
3717
- * }).catch(err => {
3718
- * console.error(err);
3719
- * });
3720
- *
3721
- * ```
3722
- */
3723
- getCurrent() {
3724
- this.wire.sendAction('get-current-application').catch((e) => {
3725
- // we do not want to expose this error, just continue if this analytics-only call fails
3726
- });
3727
- return this.wrap({ uuid: this.wire.me.uuid });
3728
- }
3729
- /**
3730
- * Synchronously returns an Application object that represents the current application
3731
- *
3732
- * @example
3733
- *
3734
- * ```js
3735
- * async function isCurrentAppRunning () {
3736
- * const app = fin.Application.getCurrentSync();
3737
- * return app.isRunning();
3738
- * }
3739
- *
3740
- * isCurrentAppRunning().then(running => {
3741
- * console.log(`Current app is running: ${running}`);
3742
- * }).catch(err => {
3743
- * console.error(err);
3744
- * });
3745
- *
3746
- * ```
3747
- */
3748
- getCurrentSync() {
3749
- this.wire.sendAction('get-current-application-sync').catch((e) => {
3750
- // we do not want to expose this error, just continue if this analytics-only call fails
3751
- });
3752
- return this.wrapSync({ uuid: this.wire.me.uuid });
3753
- }
3754
- /**
3755
- * Retrieves application's manifest and returns a running instance of the application.
3756
- * @param manifestUrl - The URL of app's manifest.
3757
- * @param opts - Parameters that the RVM will use.
3758
- *
3759
- * @example
3760
- *
3761
- * ```js
3762
- * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3763
- *
3764
- * // For a local manifest file:
3765
- * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3766
- * ```
3767
- */
3768
- async startFromManifest(manifestUrl, opts) {
3769
- this.wire.sendAction('application-start-from-manifest').catch((e) => {
3770
- // we do not want to expose this error, just continue if this analytics-only call fails
3771
- });
3772
- const app = await this._createFromManifest(manifestUrl);
3773
- // @ts-expect-error using private method without warning.
3774
- await app._run(opts); // eslint-disable-line no-underscore-dangle
3775
- return app;
3776
- }
3777
- /**
3778
- * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3779
- * Retrieves application's manifest and returns a wrapped application.
3780
- * @param manifestUrl - The URL of app's manifest.
3781
- * @param callback - called if the method succeeds.
3782
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3783
- *
3784
- * @example
3785
- *
3786
- * ```js
3787
- * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3788
- * ```
3789
- * @ignore
3790
- */
3791
- createFromManifest(manifestUrl) {
3792
- console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3793
- this.wire.sendAction('application-create-from-manifest').catch((e) => {
3794
- // we do not want to expose this error, just continue if this analytics-only call fails
3795
- });
3796
- return this._createFromManifest(manifestUrl);
3797
- }
3798
- _createFromManifest(manifestUrl) {
3799
- return this.wire
3800
- .sendAction('get-application-manifest', { manifestUrl })
3801
- .then(({ payload }) => {
3802
- const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3803
- return this.wrap({ uuid });
3804
- })
3805
- .then((app) => {
3806
- app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3807
- return app;
3808
- });
3809
- }
2718
+ function requireInstance$1 () {
2719
+ if (hasRequiredInstance$1) return Instance$6;
2720
+ hasRequiredInstance$1 = 1;
2721
+ Object.defineProperty(Instance$6, "__esModule", { value: true });
2722
+ Instance$6.Application = void 0;
2723
+ /* eslint-disable import/prefer-default-export */
2724
+ const base_1 = base;
2725
+ const window_1 = requireWindow();
2726
+ const view_1 = requireView();
2727
+ /**
2728
+ * An object representing an application. Allows the developer to create,
2729
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2730
+ */
2731
+ class Application extends base_1.EmitterBase {
2732
+ /**
2733
+ * @internal
2734
+ */
2735
+ constructor(wire, identity) {
2736
+ super(wire, 'application', identity.uuid);
2737
+ this.identity = identity;
2738
+ this.window = new window_1._Window(this.wire, {
2739
+ uuid: this.identity.uuid,
2740
+ name: this.identity.uuid
2741
+ });
2742
+ }
2743
+ windowListFromIdentityList(identityList) {
2744
+ const windowList = [];
2745
+ identityList.forEach((identity) => {
2746
+ windowList.push(new window_1._Window(this.wire, {
2747
+ uuid: identity.uuid,
2748
+ name: identity.name
2749
+ }));
2750
+ });
2751
+ return windowList;
2752
+ }
2753
+ /**
2754
+ * Determines if the application is currently running.
2755
+ *
2756
+ * @example
2757
+ *
2758
+ * ```js
2759
+ * async function isAppRunning() {
2760
+ * const app = await fin.Application.getCurrent();
2761
+ * return await app.isRunning();
2762
+ * }
2763
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2764
+ * ```
2765
+ */
2766
+ isRunning() {
2767
+ return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2768
+ }
2769
+ /**
2770
+ * Closes the application and any child windows created by the application.
2771
+ * Cleans the application from state so it is no longer found in getAllApplications.
2772
+ * @param force Close will be prevented from closing when force is false and
2773
+ * ‘close-requested’ has been subscribed to for application’s main window.
2774
+ *
2775
+ * @example
2776
+ *
2777
+ * ```js
2778
+ * async function closeApp() {
2779
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2780
+ * const app = await fin.Application.wrap({uuid: 'app2'});
2781
+ * await app.quit();
2782
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2783
+ *
2784
+ * }
2785
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2786
+ * ```
2787
+ */
2788
+ async quit(force = false) {
2789
+ try {
2790
+ await this._close(force);
2791
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
2792
+ }
2793
+ catch (error) {
2794
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2795
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2796
+ throw error;
2797
+ }
2798
+ }
2799
+ }
2800
+ async _close(force = false) {
2801
+ try {
2802
+ await this.wire.sendAction('close-application', { force, ...this.identity });
2803
+ }
2804
+ catch (error) {
2805
+ if (!error.message.includes('Remote connection has closed')) {
2806
+ throw error;
2807
+ }
2808
+ }
2809
+ }
2810
+ /**
2811
+ * @deprecated use Application.quit instead
2812
+ * Closes the application and any child windows created by the application.
2813
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2814
+ * @param callback - called if the method succeeds.
2815
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2816
+ *
2817
+ * @example
2818
+ *
2819
+ * ```js
2820
+ * async function closeApp() {
2821
+ * const app = await fin.Application.getCurrent();
2822
+ * return await app.close();
2823
+ * }
2824
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2825
+ * ```
2826
+ */
2827
+ close(force = false) {
2828
+ console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2829
+ this.wire.sendAction('application-close', this.identity).catch((e) => {
2830
+ // we do not want to expose this error, just continue if this analytics-only call fails
2831
+ });
2832
+ return this._close(force);
2833
+ }
2834
+ /**
2835
+ * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2836
+ *
2837
+ * @example
2838
+ *
2839
+ * ```js
2840
+ * async function getChildWindows() {
2841
+ * const app = await fin.Application.getCurrent();
2842
+ * return await app.getChildWindows();
2843
+ * }
2844
+ *
2845
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2846
+ * ```
2847
+ */
2848
+ getChildWindows() {
2849
+ return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2850
+ const identityList = [];
2851
+ payload.data.forEach((winName) => {
2852
+ identityList.push({ uuid: this.identity.uuid, name: winName });
2853
+ });
2854
+ return this.windowListFromIdentityList(identityList);
2855
+ });
2856
+ }
2857
+ /**
2858
+ * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2859
+ * if the application was not created from a manifest.
2860
+ *
2861
+ * @example
2862
+ *
2863
+ * ```js
2864
+ * async function getManifest() {
2865
+ * const app = await fin.Application.getCurrent();
2866
+ * return await app.getManifest();
2867
+ * }
2868
+ *
2869
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2870
+ * ```
2871
+ */
2872
+ getManifest() {
2873
+ return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2874
+ }
2875
+ /**
2876
+ * Retrieves UUID of the application that launches this application. Invokes the error callback
2877
+ * if the application was created from a manifest.
2878
+ *
2879
+ * @example
2880
+ *
2881
+ * ```js
2882
+ * async function getParentUuid() {
2883
+ * const app = await fin.Application.start({
2884
+ * uuid: 'app-1',
2885
+ * name: 'myApp',
2886
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2887
+ * autoShow: true
2888
+ * });
2889
+ * return await app.getParentUuid();
2890
+ * }
2891
+ *
2892
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2893
+ * ```
2894
+ */
2895
+ getParentUuid() {
2896
+ return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2897
+ }
2898
+ /**
2899
+ * Retrieves current application's shortcut configuration.
2900
+ *
2901
+ * @example
2902
+ *
2903
+ * ```js
2904
+ * async function getShortcuts() {
2905
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
2906
+ * return await app.getShortcuts();
2907
+ * }
2908
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2909
+ * ```
2910
+ */
2911
+ getShortcuts() {
2912
+ return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2913
+ }
2914
+ /**
2915
+ * Retrieves current application's views.
2916
+ * @experimental
2917
+ *
2918
+ * @example
2919
+ *
2920
+ * ```js
2921
+ * async function getViews() {
2922
+ * const app = await fin.Application.getCurrent();
2923
+ * return await app.getViews();
2924
+ * }
2925
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
2926
+ * ```
2927
+ */
2928
+ async getViews() {
2929
+ const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2930
+ return payload.data.map((id) => new view_1.View(this.wire, id));
2931
+ }
2932
+ /**
2933
+ * Returns the current zoom level of the application.
2934
+ *
2935
+ * @example
2936
+ *
2937
+ * ```js
2938
+ * async function getZoomLevel() {
2939
+ * const app = await fin.Application.getCurrent();
2940
+ * return await app.getZoomLevel();
2941
+ * }
2942
+ *
2943
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2944
+ * ```
2945
+ */
2946
+ getZoomLevel() {
2947
+ return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2948
+ }
2949
+ /**
2950
+ * Returns an instance of the main Window of the application
2951
+ *
2952
+ * @example
2953
+ *
2954
+ * ```js
2955
+ * async function getWindow() {
2956
+ * const app = await fin.Application.start({
2957
+ * uuid: 'app-1',
2958
+ * name: 'myApp',
2959
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
2960
+ * autoShow: true
2961
+ * });
2962
+ * return await app.getWindow();
2963
+ * }
2964
+ *
2965
+ * getWindow().then(win => {
2966
+ * win.showAt(0, 400);
2967
+ * win.flash();
2968
+ * }).catch(err => console.log(err));
2969
+ * ```
2970
+ */
2971
+ getWindow() {
2972
+ this.wire.sendAction('application-get-window', this.identity).catch((e) => {
2973
+ // we do not want to expose this error, just continue if this analytics-only call fails
2974
+ });
2975
+ return Promise.resolve(this.window);
2976
+ }
2977
+ /**
2978
+ * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
2979
+ * @param userName - username to be passed to the RVM.
2980
+ * @param appName - app name to be passed to the RVM.
2981
+ *
2982
+ * @example
2983
+ *
2984
+ * ```js
2985
+ * async function registerUser() {
2986
+ * const app = await fin.Application.getCurrent();
2987
+ * return await app.registerUser('user', 'myApp');
2988
+ * }
2989
+ *
2990
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
2991
+ * ```
2992
+ */
2993
+ registerUser(userName, appName) {
2994
+ return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
2995
+ }
2996
+ /**
2997
+ * Removes the application’s icon from the tray.
2998
+ *
2999
+ * @example
3000
+ *
3001
+ * ```js
3002
+ * async function removeTrayIcon() {
3003
+ * const app = await fin.Application.getCurrent();
3004
+ * return await app.removeTrayIcon();
3005
+ * }
3006
+ *
3007
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
3008
+ * ```
3009
+ */
3010
+ removeTrayIcon() {
3011
+ return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
3012
+ }
3013
+ /**
3014
+ * Restarts the application.
3015
+ *
3016
+ * @example
3017
+ *
3018
+ * ```js
3019
+ * async function restartApp() {
3020
+ * const app = await fin.Application.getCurrent();
3021
+ * return await app.restart();
3022
+ * }
3023
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
3024
+ * ```
3025
+ */
3026
+ restart() {
3027
+ return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3028
+ }
3029
+ /**
3030
+ * DEPRECATED method to run the application.
3031
+ * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3032
+ *
3033
+ * @example
3034
+ *
3035
+ * ```js
3036
+ * async function run() {
3037
+ * const app = await fin.Application.create({
3038
+ * name: 'myApp',
3039
+ * uuid: 'app-1',
3040
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3041
+ * autoShow: true
3042
+ * });
3043
+ * await app.run();
3044
+ * }
3045
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3046
+ * ```
3047
+ *
3048
+ * @ignore
3049
+ */
3050
+ run() {
3051
+ console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3052
+ this.wire.sendAction('application-run', this.identity).catch((e) => {
3053
+ // we do not want to expose this error, just continue if this analytics-only call fails
3054
+ });
3055
+ return this._run();
3056
+ }
3057
+ _run(opts = {}) {
3058
+ return this.wire
3059
+ .sendAction('run-application', {
3060
+ manifestUrl: this._manifestUrl,
3061
+ opts,
3062
+ ...this.identity
3063
+ })
3064
+ .then(() => undefined);
3065
+ }
3066
+ /**
3067
+ * Instructs the RVM to schedule one restart of the application.
3068
+ *
3069
+ * @example
3070
+ *
3071
+ * ```js
3072
+ * async function scheduleRestart() {
3073
+ * const app = await fin.Application.getCurrent();
3074
+ * return await app.scheduleRestart();
3075
+ * }
3076
+ *
3077
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3078
+ * ```
3079
+ */
3080
+ scheduleRestart() {
3081
+ return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3082
+ }
3083
+ /**
3084
+ * Sends a message to the RVM to upload the application's logs. On success,
3085
+ * an object containing logId is returned.
3086
+ *
3087
+ * @example
3088
+ *
3089
+ * ```js
3090
+ * async function sendLog() {
3091
+ * const app = await fin.Application.getCurrent();
3092
+ * return await app.sendApplicationLog();
3093
+ * }
3094
+ *
3095
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3096
+ * ```
3097
+ */
3098
+ async sendApplicationLog() {
3099
+ const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3100
+ return payload.data;
3101
+ }
3102
+ /**
3103
+ * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3104
+ * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3105
+ *
3106
+ * Note: If the "name" property is omitted it defaults to "tasks".
3107
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3108
+ *
3109
+ *
3110
+ * @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).
3111
+ *
3112
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3113
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3114
+ *
3115
+ * Note: If the "name" property is omitted it defaults to "tasks".
3116
+ *
3117
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3118
+ * uuid or shortcut.name is changed.
3119
+ *
3120
+ * @example
3121
+ *
3122
+ * ```js
3123
+ * const app = fin.Application.getCurrentSync();
3124
+ * const appName = 'My App';
3125
+ * const jumpListConfig = [ // array of JumpList categories
3126
+ * {
3127
+ * // has no name and no type so `type` is assumed to be "tasks"
3128
+ * items: [ // array of JumpList items
3129
+ * {
3130
+ * type: 'task',
3131
+ * title: `Launch ${appName}`,
3132
+ * description: `Runs ${appName} with the default configuration`,
3133
+ * deepLink: 'fins://path.to/app/manifest.json',
3134
+ * iconPath: 'https://path.to/app/icon.ico',
3135
+ * iconIndex: 0
3136
+ * },
3137
+ * { type: 'separator' },
3138
+ * {
3139
+ * type: 'task',
3140
+ * title: `Restore ${appName}`,
3141
+ * description: 'Restore to last configuration',
3142
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3143
+ * iconPath: 'https://path.to/app/icon.ico',
3144
+ * iconIndex: 0
3145
+ * },
3146
+ * ]
3147
+ * },
3148
+ * {
3149
+ * name: 'Tools',
3150
+ * items: [ // array of JumpList items
3151
+ * {
3152
+ * type: 'task',
3153
+ * title: 'Tool A',
3154
+ * description: 'Runs Tool A',
3155
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
3156
+ * iconPath: 'https://path.to/tool-a/icon.ico',
3157
+ * iconIndex: 0
3158
+ * },
3159
+ * {
3160
+ * type: 'task',
3161
+ * title: 'Tool B',
3162
+ * description: 'Runs Tool B',
3163
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
3164
+ * iconPath: 'https://path.to/tool-b/icon.ico',
3165
+ * iconIndex: 0
3166
+ * }]
3167
+ * }
3168
+ * ];
3169
+ *
3170
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3171
+ * ```
3172
+ *
3173
+ * To handle deeplink args:
3174
+ * ```js
3175
+ * function handleUseLastConfiguration() {
3176
+ * // this handler is called when the app is being launched
3177
+ * app.on('run-requested', event => {
3178
+ * if(event.userAppConfigArgs['use-last-configuration']) {
3179
+ * // your logic here
3180
+ * }
3181
+ * });
3182
+ * // this handler is called when the app was already running when the launch was requested
3183
+ * fin.desktop.main(function(args) {
3184
+ * if(args && args['use-last-configuration']) {
3185
+ * // your logic here
3186
+ * }
3187
+ * });
3188
+ * }
3189
+ * ```
3190
+ */
3191
+ async setJumpList(jumpListCategories) {
3192
+ await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3193
+ }
3194
+ /**
3195
+ * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3196
+ * @param icon Image URL or base64 encoded string to be used as the icon
3197
+ *
3198
+ * @example
3199
+ *
3200
+ * ```js
3201
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3202
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3203
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3204
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3205
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3206
+ *
3207
+ * async function setTrayIcon(icon) {
3208
+ * const app = await fin.Application.getCurrent();
3209
+ * return await app.setTrayIcon(icon);
3210
+ * }
3211
+ *
3212
+ * // use image url to set tray icon
3213
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3214
+ *
3215
+ * // use base64 encoded string to set tray icon
3216
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3217
+ *
3218
+ * // use a dataURL to set tray icon
3219
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3220
+ * ```
3221
+ */
3222
+ setTrayIcon(icon) {
3223
+ return this.wire
3224
+ .sendAction('set-tray-icon', {
3225
+ enabledIcon: icon,
3226
+ ...this.identity
3227
+ })
3228
+ .then(() => undefined);
3229
+ }
3230
+ /**
3231
+ * Set hover text for this application's system tray icon.
3232
+ * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
3233
+ * @param toolTip
3234
+ *
3235
+ * @example
3236
+ *
3237
+ * ```js
3238
+ * const app = fin.Application.getCurrentSync();
3239
+ * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3240
+ *
3241
+ * await app.setTrayIcon(iconUrl);
3242
+ *
3243
+ * await app.setTrayIconToolTip('My Application');
3244
+ * ```
3245
+ */
3246
+ async setTrayIconToolTip(toolTip) {
3247
+ await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
3248
+ }
3249
+ /**
3250
+ * Sets new application's shortcut configuration. Windows only.
3251
+ * @param config New application's shortcut configuration.
3252
+ *
3253
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3254
+ * to be able to change shortcut states.
3255
+ *
3256
+ * @example
3257
+ *
3258
+ * ```js
3259
+ * async function setShortcuts(config) {
3260
+ * const app = await fin.Application.getCurrent();
3261
+ * return app.setShortcuts(config);
3262
+ * }
3263
+ *
3264
+ * setShortcuts({
3265
+ * desktop: true,
3266
+ * startMenu: false,
3267
+ * systemStartup: true
3268
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3269
+ * ```
3270
+ */
3271
+ setShortcuts(config) {
3272
+ return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3273
+ }
3274
+ /**
3275
+ * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3276
+ * @param queryString The new query string for this app's shortcuts.
3277
+ *
3278
+ * @example
3279
+ *
3280
+ * ```js
3281
+ * const newQueryArgs = 'arg=true&arg2=false';
3282
+ * const app = await fin.Application.getCurrent();
3283
+ * try {
3284
+ * await app.setShortcutQueryParams(newQueryArgs);
3285
+ * } catch(err) {
3286
+ * console.error(err)
3287
+ * }
3288
+ * ```
3289
+ */
3290
+ async setShortcutQueryParams(queryString) {
3291
+ await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3292
+ }
3293
+ /**
3294
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3295
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
3296
+ * @param level The zoom level
3297
+ *
3298
+ * @example
3299
+ *
3300
+ * ```js
3301
+ * async function setZoomLevel(number) {
3302
+ * const app = await fin.Application.getCurrent();
3303
+ * return await app.setZoomLevel(number);
3304
+ * }
3305
+ *
3306
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3307
+ * ```
3308
+ */
3309
+ setZoomLevel(level) {
3310
+ return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3311
+ }
3312
+ /**
3313
+ * Sets a username to correlate with App Log Management.
3314
+ * @param username Username to correlate with App's Log.
3315
+ *
3316
+ * @example
3317
+ *
3318
+ * ```js
3319
+ * async function setAppLogUser() {
3320
+ * const app = await fin.Application.getCurrent();
3321
+ * return await app.setAppLogUsername('username');
3322
+ * }
3323
+ *
3324
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3325
+ *
3326
+ * ```
3327
+ */
3328
+ async setAppLogUsername(username) {
3329
+ await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3330
+ }
3331
+ /**
3332
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3333
+ * @remarks The only information currently returned is the position and dimensions.
3334
+ *
3335
+ * @example
3336
+ *
3337
+ * ```js
3338
+ * async function getTrayIconInfo() {
3339
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3340
+ * return await app.getTrayIconInfo();
3341
+ * }
3342
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3343
+ * ```
3344
+ */
3345
+ getTrayIconInfo() {
3346
+ return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3347
+ }
3348
+ /**
3349
+ * Checks if the application has an associated tray icon.
3350
+ *
3351
+ * @example
3352
+ *
3353
+ * ```js
3354
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3355
+ * const hasTrayIcon = await app.hasTrayIcon();
3356
+ * console.log(hasTrayIcon);
3357
+ * ```
3358
+ */
3359
+ hasTrayIcon() {
3360
+ return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3361
+ }
3362
+ /**
3363
+ * Closes the application by terminating its process.
3364
+ *
3365
+ * @example
3366
+ *
3367
+ * ```js
3368
+ * async function terminateApp() {
3369
+ * const app = await fin.Application.getCurrent();
3370
+ * return await app.terminate();
3371
+ * }
3372
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3373
+ * ```
3374
+ */
3375
+ terminate() {
3376
+ return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3377
+ }
3378
+ /**
3379
+ * Waits for a hanging application. This method can be called in response to an application
3380
+ * "not-responding" to allow the application to continue and to generate another "not-responding"
3381
+ * message after a certain period of time.
3382
+ *
3383
+ * @ignore
3384
+ */
3385
+ wait() {
3386
+ return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3387
+ }
3388
+ /**
3389
+ * Retrieves information about the application.
3390
+ *
3391
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3392
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3393
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3394
+ *
3395
+ * @example
3396
+ *
3397
+ * ```js
3398
+ * async function getInfo() {
3399
+ * const app = await fin.Application.getCurrent();
3400
+ * return await app.getInfo();
3401
+ * }
3402
+ *
3403
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3404
+ * ```
3405
+ */
3406
+ getInfo() {
3407
+ return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3408
+ }
3409
+ /**
3410
+ * Retrieves all process information for entities (windows and views) associated with an application.
3411
+ *
3412
+ * @example
3413
+ * ```js
3414
+ * const app = await fin.Application.getCurrent();
3415
+ * const processInfo = await app.getProcessInfo();
3416
+ * ```
3417
+ * @experimental
3418
+ */
3419
+ async getProcessInfo() {
3420
+ const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3421
+ return data;
3422
+ }
3423
+ /**
3424
+ * Sets file auto download location. It's only allowed in the same application.
3425
+ *
3426
+ * Note: This method is restricted by default and must be enabled via
3427
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3428
+ * @param downloadLocation file auto download location
3429
+ *
3430
+ * @throws if setting file auto download location on different applications.
3431
+ * @example
3432
+ *
3433
+ * ```js
3434
+ * const downloadLocation = 'C:\\dev\\temp';
3435
+ * const app = await fin.Application.getCurrent();
3436
+ * try {
3437
+ * await app.setFileDownloadLocation(downloadLocation);
3438
+ * console.log('File download location is set');
3439
+ * } catch(err) {
3440
+ * console.error(err)
3441
+ * }
3442
+ * ```
3443
+ */
3444
+ async setFileDownloadLocation(downloadLocation) {
3445
+ const { name } = this.wire.me;
3446
+ const entityIdentity = { uuid: this.identity.uuid, name };
3447
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3448
+ }
3449
+ /**
3450
+ * 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.
3451
+ *
3452
+ * Note: This method is restricted by default and must be enabled via
3453
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3454
+ *
3455
+ * @throws if getting file auto download location on different applications.
3456
+ * @example
3457
+ *
3458
+ * ```js
3459
+ * const app = await fin.Application.getCurrent();
3460
+ * const fileDownloadDir = await app.getFileDownloadLocation();
3461
+ * ```
3462
+ */
3463
+ async getFileDownloadLocation() {
3464
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3465
+ return data;
3466
+ }
3467
+ /**
3468
+ * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3469
+ * @param options
3470
+ * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3471
+ * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3472
+ * of all possible data shapes for the entire menu, and the click handler should process
3473
+ * these with a "reducer" pattern.
3474
+ * @throws if the application has no tray icon set
3475
+ * @throws if the system tray is currently hidden
3476
+ * @example
3477
+ *
3478
+ * ```js
3479
+ * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3480
+ * const app = fin.Application.getCurrentSync();
3481
+ *
3482
+ * await app.setTrayIcon(iconUrl);
3483
+ *
3484
+ * const template = [
3485
+ * {
3486
+ * label: 'Menu Item 1',
3487
+ * data: 'hello from item 1'
3488
+ * },
3489
+ * { type: 'separator' },
3490
+ * {
3491
+ * label: 'Menu Item 2',
3492
+ * type: 'checkbox',
3493
+ * checked: true,
3494
+ * data: 'The user clicked the checkbox'
3495
+ * },
3496
+ * {
3497
+ * label: 'see more',
3498
+ * enabled: false,
3499
+ * submenu: [
3500
+ * { label: 'submenu 1', data: 'hello from submenu' }
3501
+ * ]
3502
+ * }
3503
+ * ];
3504
+ *
3505
+ * app.addListener('tray-icon-clicked', (event) => {
3506
+ * // right-click
3507
+ * if (event.button === 2) {
3508
+ * app.showTrayIconPopupMenu({ template }).then(r => {
3509
+ * if (r.result === 'closed') {
3510
+ * console.log('nothing happened');
3511
+ * } else {
3512
+ * console.log(r.data);
3513
+ * }
3514
+ * });
3515
+ * }
3516
+ * });
3517
+ * ```
3518
+ */
3519
+ async showTrayIconPopupMenu(options) {
3520
+ const { name } = this.wire.me;
3521
+ const entityIdentity = { uuid: this.identity.uuid, name };
3522
+ const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3523
+ return payload.data;
3524
+ }
3525
+ /**
3526
+ * Closes the tray icon menu.
3527
+ *
3528
+ * @throws if the application has no tray icon set
3529
+ * @example
3530
+ *
3531
+ * ```js
3532
+ * const app = fin.Application.getCurrentSync();
3533
+ *
3534
+ * await app.closeTrayIconPopupMenu();
3535
+ * ```
3536
+ */
3537
+ async closeTrayIconPopupMenu() {
3538
+ const { name } = this.wire.me;
3539
+ const entityIdentity = { uuid: this.identity.uuid, name };
3540
+ await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3541
+ }
3542
+ }
3543
+ Instance$6.Application = Application;
3544
+ return Instance$6;
3810
3545
  }
3811
- Factory$7.ApplicationModule = ApplicationModule;
3812
3546
 
3813
- (function (exports) {
3814
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3815
- if (k2 === undefined) k2 = k;
3816
- var desc = Object.getOwnPropertyDescriptor(m, k);
3817
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3818
- desc = { enumerable: true, get: function() { return m[k]; } };
3819
- }
3820
- Object.defineProperty(o, k2, desc);
3821
- }) : (function(o, m, k, k2) {
3822
- if (k2 === undefined) k2 = k;
3823
- o[k2] = m[k];
3824
- }));
3825
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3826
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3827
- };
3828
- Object.defineProperty(exports, "__esModule", { value: true });
3547
+ var hasRequiredFactory$1;
3548
+
3549
+ function requireFactory$1 () {
3550
+ if (hasRequiredFactory$1) return Factory$7;
3551
+ hasRequiredFactory$1 = 1;
3552
+ Object.defineProperty(Factory$7, "__esModule", { value: true });
3553
+ Factory$7.ApplicationModule = void 0;
3554
+ const base_1 = base;
3555
+ const validate_1 = validate;
3556
+ const Instance_1 = requireInstance$1();
3829
3557
  /**
3830
- * Entry points for the OpenFin `Application` API (`fin.Application`).
3831
- *
3832
- * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3833
- * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3834
- *
3835
- * 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),
3836
- * both of these were documented on the same page.
3837
- *
3838
- * @packageDocumentation
3558
+ * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3839
3559
  */
3840
- __exportStar(Factory$7, exports);
3841
- __exportStar(Instance$6, exports);
3842
- } (application));
3560
+ class ApplicationModule extends base_1.Base {
3561
+ /**
3562
+ * Asynchronously returns an API handle for the given Application identity.
3563
+ *
3564
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3565
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3566
+ * for an Application throughout its entire lifecycle.
3567
+ *
3568
+ * @example
3569
+ *
3570
+ * ```js
3571
+ * fin.Application.wrap({ uuid: 'testapp' })
3572
+ * .then(app => app.isRunning())
3573
+ * .then(running => console.log('Application is running: ' + running))
3574
+ * .catch(err => console.log(err));
3575
+ * ```
3576
+ *
3577
+ */
3578
+ async wrap(identity) {
3579
+ this.wire.sendAction('wrap-application').catch((e) => {
3580
+ // we do not want to expose this error, just continue if this analytics-only call fails
3581
+ });
3582
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
3583
+ if (errorMsg) {
3584
+ throw new Error(errorMsg);
3585
+ }
3586
+ return new Instance_1.Application(this.wire, identity);
3587
+ }
3588
+ /**
3589
+ * Synchronously returns an API handle for the given Application identity.
3590
+ *
3591
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3592
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3593
+ * for an Aplication throughout its entire lifecycle.
3594
+ *
3595
+ * @example
3596
+ *
3597
+ * ```js
3598
+ * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3599
+ * await app.close();
3600
+ * ```
3601
+ *
3602
+ */
3603
+ wrapSync(identity) {
3604
+ this.wire.sendAction('wrap-application-sync').catch((e) => {
3605
+ // we do not want to expose this error, just continue if this analytics-only call fails
3606
+ });
3607
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
3608
+ if (errorMsg) {
3609
+ throw new Error(errorMsg);
3610
+ }
3611
+ return new Instance_1.Application(this.wire, identity);
3612
+ }
3613
+ async _create(appOptions) {
3614
+ // set defaults:
3615
+ if (appOptions.waitForPageLoad === undefined) {
3616
+ appOptions.waitForPageLoad = false;
3617
+ }
3618
+ if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3619
+ appOptions.autoShow = true;
3620
+ }
3621
+ await this.wire.sendAction('create-application', appOptions);
3622
+ return this.wrap({ uuid: appOptions.uuid });
3623
+ }
3624
+ /**
3625
+ * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3626
+ *
3627
+ * @example
3628
+ *
3629
+ * ```js
3630
+ * async function createApp() {
3631
+ * const app = await fin.Application.create({
3632
+ * name: 'myApp',
3633
+ * uuid: 'app-3',
3634
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3635
+ * autoShow: true
3636
+ * });
3637
+ * await app.run();
3638
+ * }
3639
+ *
3640
+ * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3641
+ * ```
3642
+ *
3643
+ * @ignore
3644
+ */
3645
+ create(appOptions) {
3646
+ console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3647
+ this.wire.sendAction('application-create').catch((e) => {
3648
+ // we do not want to expose this error, just continue if this analytics-only call fails
3649
+ });
3650
+ return this._create(appOptions);
3651
+ }
3652
+ /**
3653
+ * Creates and starts a new Application.
3654
+ *
3655
+ * @example
3656
+ *
3657
+ * ```js
3658
+ * async function start() {
3659
+ * return fin.Application.start({
3660
+ * name: 'app-1',
3661
+ * uuid: 'app-1',
3662
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3663
+ * autoShow: true
3664
+ * });
3665
+ * }
3666
+ * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3667
+ * ```
3668
+ *
3669
+ */
3670
+ async start(appOptions) {
3671
+ this.wire.sendAction('start-application').catch((e) => {
3672
+ // we do not want to expose this error, just continue if this analytics-only call fails
3673
+ });
3674
+ const app = await this._create(appOptions);
3675
+ await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3676
+ return app;
3677
+ }
3678
+ /**
3679
+ * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3680
+ * Returns once the RVM is finished attempting to launch the applications.
3681
+ * @param opts - Parameters that the RVM will use.
3682
+ *
3683
+ * @example
3684
+ *
3685
+ * ```js
3686
+ *
3687
+ * const applicationInfoArray = [
3688
+ * {
3689
+ * "uuid": 'App-1',
3690
+ * "manifestUrl": 'http://localhost:5555/app1.json',
3691
+ * },
3692
+ * {
3693
+ * "uuid": 'App-2',
3694
+ * "manifestUrl": 'http://localhost:5555/app2.json',
3695
+ * },
3696
+ * {
3697
+ * "uuid": 'App-3',
3698
+ * "manifestUrl": 'http://localhost:5555/app3.json',
3699
+ * }
3700
+ * ]
3701
+ *
3702
+ * fin.Application.startManyManifests(applicationInfoArray)
3703
+ * .then(() => {
3704
+ * console.log('RVM has finished launching the application list.');
3705
+ * })
3706
+ * .catch((err) => {
3707
+ * console.log(err);
3708
+ * })
3709
+ * ```
3710
+ *
3711
+ * @experimental
3712
+ */
3713
+ async startManyManifests(applications, opts) {
3714
+ return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3715
+ }
3716
+ /**
3717
+ * Asynchronously returns an Application object that represents the current application
3718
+ *
3719
+ * @example
3720
+ *
3721
+ * ```js
3722
+ * async function isCurrentAppRunning () {
3723
+ * const app = await fin.Application.getCurrent();
3724
+ * return app.isRunning();
3725
+ * }
3726
+ *
3727
+ * isCurrentAppRunning().then(running => {
3728
+ * console.log(`Current app is running: ${running}`);
3729
+ * }).catch(err => {
3730
+ * console.error(err);
3731
+ * });
3732
+ *
3733
+ * ```
3734
+ */
3735
+ getCurrent() {
3736
+ this.wire.sendAction('get-current-application').catch((e) => {
3737
+ // we do not want to expose this error, just continue if this analytics-only call fails
3738
+ });
3739
+ return this.wrap({ uuid: this.wire.me.uuid });
3740
+ }
3741
+ /**
3742
+ * Synchronously returns an Application object that represents the current application
3743
+ *
3744
+ * @example
3745
+ *
3746
+ * ```js
3747
+ * async function isCurrentAppRunning () {
3748
+ * const app = fin.Application.getCurrentSync();
3749
+ * return app.isRunning();
3750
+ * }
3751
+ *
3752
+ * isCurrentAppRunning().then(running => {
3753
+ * console.log(`Current app is running: ${running}`);
3754
+ * }).catch(err => {
3755
+ * console.error(err);
3756
+ * });
3757
+ *
3758
+ * ```
3759
+ */
3760
+ getCurrentSync() {
3761
+ this.wire.sendAction('get-current-application-sync').catch((e) => {
3762
+ // we do not want to expose this error, just continue if this analytics-only call fails
3763
+ });
3764
+ return this.wrapSync({ uuid: this.wire.me.uuid });
3765
+ }
3766
+ /**
3767
+ * Retrieves application's manifest and returns a running instance of the application.
3768
+ * @param manifestUrl - The URL of app's manifest.
3769
+ * @param opts - Parameters that the RVM will use.
3770
+ *
3771
+ * @example
3772
+ *
3773
+ * ```js
3774
+ * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3775
+ *
3776
+ * // For a local manifest file:
3777
+ * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3778
+ * ```
3779
+ */
3780
+ async startFromManifest(manifestUrl, opts) {
3781
+ this.wire.sendAction('application-start-from-manifest').catch((e) => {
3782
+ // we do not want to expose this error, just continue if this analytics-only call fails
3783
+ });
3784
+ const app = await this._createFromManifest(manifestUrl);
3785
+ // @ts-expect-error using private method without warning.
3786
+ await app._run(opts); // eslint-disable-line no-underscore-dangle
3787
+ return app;
3788
+ }
3789
+ /**
3790
+ * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3791
+ * Retrieves application's manifest and returns a wrapped application.
3792
+ * @param manifestUrl - The URL of app's manifest.
3793
+ * @param callback - called if the method succeeds.
3794
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3795
+ *
3796
+ * @example
3797
+ *
3798
+ * ```js
3799
+ * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3800
+ * ```
3801
+ * @ignore
3802
+ */
3803
+ createFromManifest(manifestUrl) {
3804
+ console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3805
+ this.wire.sendAction('application-create-from-manifest').catch((e) => {
3806
+ // we do not want to expose this error, just continue if this analytics-only call fails
3807
+ });
3808
+ return this._createFromManifest(manifestUrl);
3809
+ }
3810
+ _createFromManifest(manifestUrl) {
3811
+ return this.wire
3812
+ .sendAction('get-application-manifest', { manifestUrl })
3813
+ .then(({ payload }) => {
3814
+ const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3815
+ return this.wrap({ uuid });
3816
+ })
3817
+ .then((app) => {
3818
+ app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3819
+ return app;
3820
+ });
3821
+ }
3822
+ }
3823
+ Factory$7.ApplicationModule = ApplicationModule;
3824
+ return Factory$7;
3825
+ }
3826
+
3827
+ var hasRequiredApplication;
3828
+
3829
+ function requireApplication () {
3830
+ if (hasRequiredApplication) return application;
3831
+ hasRequiredApplication = 1;
3832
+ (function (exports) {
3833
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3834
+ if (k2 === undefined) k2 = k;
3835
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3836
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3837
+ desc = { enumerable: true, get: function() { return m[k]; } };
3838
+ }
3839
+ Object.defineProperty(o, k2, desc);
3840
+ }) : (function(o, m, k, k2) {
3841
+ if (k2 === undefined) k2 = k;
3842
+ o[k2] = m[k];
3843
+ }));
3844
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3845
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3846
+ };
3847
+ Object.defineProperty(exports, "__esModule", { value: true });
3848
+ /**
3849
+ * Entry points for the OpenFin `Application` API (`fin.Application`).
3850
+ *
3851
+ * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3852
+ * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3853
+ *
3854
+ * 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),
3855
+ * both of these were documented on the same page.
3856
+ *
3857
+ * @packageDocumentation
3858
+ */
3859
+ __exportStar(requireFactory$1(), exports);
3860
+ __exportStar(requireInstance$1(), exports);
3861
+ } (application));
3862
+ return application;
3863
+ }
3843
3864
 
3844
3865
  var promisifySubscription$1 = {};
3845
3866
 
@@ -3883,7 +3904,7 @@ function requireInstance () {
3883
3904
  /* eslint-disable @typescript-eslint/no-unused-vars */
3884
3905
  /* eslint-disable no-console */
3885
3906
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
3886
- const application_1 = application;
3907
+ const application_1 = requireApplication();
3887
3908
  const main_1 = main;
3888
3909
  const view_1 = requireView();
3889
3910
  const warnings_1 = warnings;
@@ -17850,7 +17871,7 @@ const events_1$3 = require$$0;
17850
17871
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
17851
17872
  const index_1 = system;
17852
17873
  const index_2 = requireWindow();
17853
- const index_3 = application;
17874
+ const index_3 = requireApplication();
17854
17875
  const index_4 = interappbus;
17855
17876
  const index_5 = clipboard;
17856
17877
  const index_6 = externalApplication;