@openfin/core 40.102.2 → 40.103.4

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