@openfin/core 41.100.63 → 41.100.64

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