@openfin/core 41.103.9 → 41.103.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/stub.js CHANGED
@@ -819,11 +819,11 @@ const handleDeprecatedWarnings = (options) => {
819
819
  };
820
820
  warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
821
821
 
822
- var hasRequiredFactory$1;
822
+ var hasRequiredFactory$2;
823
823
 
824
- function requireFactory$1 () {
825
- if (hasRequiredFactory$1) return Factory$6;
826
- hasRequiredFactory$1 = 1;
824
+ function requireFactory$2 () {
825
+ if (hasRequiredFactory$2) return Factory$6;
826
+ hasRequiredFactory$2 = 1;
827
827
  Object.defineProperty(Factory$6, "__esModule", { value: true });
828
828
  Factory$6.ViewModule = void 0;
829
829
  const base_1 = base;
@@ -1030,8 +1030,8 @@ var main = {};
1030
1030
 
1031
1031
  Object.defineProperty(main, "__esModule", { value: true });
1032
1032
  main.WebContents = void 0;
1033
- const base_1$o = base;
1034
- class WebContents extends base_1$o.EmitterBase {
1033
+ const base_1$m = base;
1034
+ class WebContents extends base_1$m.EmitterBase {
1035
1035
  /**
1036
1036
  * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1037
1037
  * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
@@ -2110,11 +2110,11 @@ class WebContents extends base_1$o.EmitterBase {
2110
2110
  }
2111
2111
  main.WebContents = WebContents;
2112
2112
 
2113
- var hasRequiredInstance$1;
2113
+ var hasRequiredInstance$2;
2114
2114
 
2115
- function requireInstance$1 () {
2116
- if (hasRequiredInstance$1) return Instance$5;
2117
- hasRequiredInstance$1 = 1;
2115
+ function requireInstance$2 () {
2116
+ if (hasRequiredInstance$2) return Instance$5;
2117
+ hasRequiredInstance$2 = 1;
2118
2118
  var _View_providerChannelClient;
2119
2119
  Object.defineProperty(Instance$5, "__esModule", { value: true });
2120
2120
  Instance$5.View = void 0;
@@ -2690,1117 +2690,1138 @@ function requireView () {
2690
2690
  *
2691
2691
  * @packageDocumentation
2692
2692
  */
2693
- __exportStar(requireFactory$1(), exports);
2694
- __exportStar(requireInstance$1(), exports);
2693
+ __exportStar(requireFactory$2(), exports);
2694
+ __exportStar(requireInstance$2(), exports);
2695
2695
  } (view));
2696
2696
  return view;
2697
2697
  }
2698
2698
 
2699
- Object.defineProperty(Instance$6, "__esModule", { value: true });
2700
- Instance$6.Application = void 0;
2701
- /* eslint-disable import/prefer-default-export */
2702
- const base_1$n = base;
2703
- const window_1$1 = requireWindow();
2704
- const view_1 = requireView();
2705
- /**
2706
- * An object representing an application. Allows the developer to create,
2707
- * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2708
- */
2709
- class Application extends base_1$n.EmitterBase {
2710
- /**
2711
- * @internal
2712
- */
2713
- constructor(wire, identity) {
2714
- super(wire, 'application', identity.uuid);
2715
- this.identity = identity;
2716
- this.window = new window_1$1._Window(this.wire, {
2717
- uuid: this.identity.uuid,
2718
- name: this.identity.uuid
2719
- });
2720
- }
2721
- windowListFromIdentityList(identityList) {
2722
- const windowList = [];
2723
- identityList.forEach((identity) => {
2724
- windowList.push(new window_1$1._Window(this.wire, {
2725
- uuid: identity.uuid,
2726
- name: identity.name
2727
- }));
2728
- });
2729
- return windowList;
2730
- }
2731
- /**
2732
- * Determines if the application is currently running.
2733
- *
2734
- * @example
2735
- *
2736
- * ```js
2737
- * async function isAppRunning() {
2738
- * const app = await fin.Application.getCurrent();
2739
- * return await app.isRunning();
2740
- * }
2741
- * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2742
- * ```
2743
- */
2744
- isRunning() {
2745
- return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2746
- }
2747
- /**
2748
- * Closes the application and any child windows created by the application.
2749
- * Cleans the application from state so it is no longer found in getAllApplications.
2750
- * @param force Close will be prevented from closing when force is false and
2751
- * ‘close-requested’ has been subscribed to for application’s main window.
2752
- *
2753
- * @example
2754
- *
2755
- * ```js
2756
- * async function closeApp() {
2757
- * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2758
- * const app = await fin.Application.wrap({uuid: 'app2'});
2759
- * await app.quit();
2760
- * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2761
- *
2762
- * }
2763
- * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2764
- * ```
2765
- */
2766
- async quit(force = false) {
2767
- try {
2768
- await this._close(force);
2769
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
2770
- }
2771
- catch (error) {
2772
- const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2773
- if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2774
- throw error;
2775
- }
2776
- }
2777
- }
2778
- async _close(force = false) {
2779
- try {
2780
- await this.wire.sendAction('close-application', { force, ...this.identity });
2781
- }
2782
- catch (error) {
2783
- if (!error.message.includes('Remote connection has closed')) {
2784
- throw error;
2785
- }
2786
- }
2787
- }
2788
- /**
2789
- * @deprecated use Application.quit instead
2790
- * Closes the application and any child windows created by the application.
2791
- * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2792
- * @param callback - called if the method succeeds.
2793
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2794
- *
2795
- * @example
2796
- *
2797
- * ```js
2798
- * async function closeApp() {
2799
- * const app = await fin.Application.getCurrent();
2800
- * return await app.close();
2801
- * }
2802
- * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2803
- * ```
2804
- */
2805
- close(force = false) {
2806
- console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2807
- this.wire.recordAnalytic('application-close');
2808
- return this._close(force);
2809
- }
2810
- /**
2811
- * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2812
- *
2813
- * @example
2814
- *
2815
- * ```js
2816
- * async function getChildWindows() {
2817
- * const app = await fin.Application.getCurrent();
2818
- * return await app.getChildWindows();
2819
- * }
2820
- *
2821
- * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2822
- * ```
2823
- */
2824
- getChildWindows() {
2825
- return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2826
- const identityList = [];
2827
- payload.data.forEach((winName) => {
2828
- identityList.push({ uuid: this.identity.uuid, name: winName });
2829
- });
2830
- return this.windowListFromIdentityList(identityList);
2831
- });
2832
- }
2833
- /**
2834
- * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2835
- * if the application was not created from a manifest.
2836
- *
2837
- * @example
2838
- *
2839
- * ```js
2840
- * async function getManifest() {
2841
- * const app = await fin.Application.getCurrent();
2842
- * return await app.getManifest();
2843
- * }
2844
- *
2845
- * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2846
- * ```
2847
- */
2848
- getManifest() {
2849
- return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2850
- }
2851
- /**
2852
- * Retrieves UUID of the application that launches this application. Invokes the error callback
2853
- * if the application was created from a manifest.
2854
- *
2855
- * @example
2856
- *
2857
- * ```js
2858
- * async function getParentUuid() {
2859
- * const app = await fin.Application.start({
2860
- * uuid: 'app-1',
2861
- * name: 'myApp',
2862
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2863
- * autoShow: true
2864
- * });
2865
- * return await app.getParentUuid();
2866
- * }
2867
- *
2868
- * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2869
- * ```
2870
- */
2871
- getParentUuid() {
2872
- return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2873
- }
2874
- /**
2875
- * Retrieves current application's shortcut configuration.
2876
- *
2877
- * @example
2878
- *
2879
- * ```js
2880
- * async function getShortcuts() {
2881
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
2882
- * return await app.getShortcuts();
2883
- * }
2884
- * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2885
- * ```
2886
- */
2887
- getShortcuts() {
2888
- return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2889
- }
2890
- /**
2891
- * Retrieves current application's views.
2892
- * @experimental
2893
- *
2894
- * @example
2895
- *
2896
- * ```js
2897
- * async function getViews() {
2898
- * const app = await fin.Application.getCurrent();
2899
- * return await app.getViews();
2900
- * }
2901
- * getViews().then(views => console.log(views)).catch(err => console.log(err));
2902
- * ```
2903
- */
2904
- async getViews() {
2905
- const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2906
- return payload.data.map((id) => new view_1.View(this.wire, id));
2907
- }
2908
- /**
2909
- * Returns the current zoom level of the application.
2910
- *
2911
- * @example
2912
- *
2913
- * ```js
2914
- * async function getZoomLevel() {
2915
- * const app = await fin.Application.getCurrent();
2916
- * return await app.getZoomLevel();
2917
- * }
2918
- *
2919
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2920
- * ```
2921
- */
2922
- getZoomLevel() {
2923
- return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2924
- }
2925
- /**
2926
- * Returns an instance of the main Window of the application
2927
- *
2928
- * @example
2929
- *
2930
- * ```js
2931
- * async function getWindow() {
2932
- * const app = await fin.Application.start({
2933
- * uuid: 'app-1',
2934
- * name: 'myApp',
2935
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
2936
- * autoShow: true
2937
- * });
2938
- * return await app.getWindow();
2939
- * }
2940
- *
2941
- * getWindow().then(win => {
2942
- * win.showAt(0, 400);
2943
- * win.flash();
2944
- * }).catch(err => console.log(err));
2945
- * ```
2946
- */
2947
- getWindow() {
2948
- this.wire.recordAnalytic('application-get-window');
2949
- return Promise.resolve(this.window);
2950
- }
2951
- /**
2952
- * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
2953
- * @param userName - username to be passed to the RVM.
2954
- * @param appName - app name to be passed to the RVM.
2955
- *
2956
- * @example
2957
- *
2958
- * ```js
2959
- * async function registerUser() {
2960
- * const app = await fin.Application.getCurrent();
2961
- * return await app.registerUser('user', 'myApp');
2962
- * }
2963
- *
2964
- * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
2965
- * ```
2966
- */
2967
- registerUser(userName, appName) {
2968
- return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
2969
- }
2970
- /**
2971
- * Removes the application’s icon from the tray.
2972
- *
2973
- * @example
2974
- *
2975
- * ```js
2976
- * async function removeTrayIcon() {
2977
- * const app = await fin.Application.getCurrent();
2978
- * return await app.removeTrayIcon();
2979
- * }
2980
- *
2981
- * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
2982
- * ```
2983
- */
2984
- removeTrayIcon() {
2985
- return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
2986
- }
2987
- /**
2988
- * Restarts the application.
2989
- *
2990
- * @example
2991
- *
2992
- * ```js
2993
- * async function restartApp() {
2994
- * const app = await fin.Application.getCurrent();
2995
- * return await app.restart();
2996
- * }
2997
- * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
2998
- * ```
2999
- */
3000
- restart() {
3001
- return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3002
- }
3003
- /**
3004
- * DEPRECATED method to run the application.
3005
- * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3006
- *
3007
- * @example
3008
- *
3009
- * ```js
3010
- * async function run() {
3011
- * const app = await fin.Application.create({
3012
- * name: 'myApp',
3013
- * uuid: 'app-1',
3014
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3015
- * autoShow: true
3016
- * });
3017
- * await app.run();
3018
- * }
3019
- * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3020
- * ```
3021
- *
3022
- * @ignore
3023
- */
3024
- run() {
3025
- console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3026
- this.wire.recordAnalytic('application-run');
3027
- return this._run();
3028
- }
3029
- _run(opts = {}) {
3030
- return this.wire
3031
- .sendAction('run-application', {
3032
- manifestUrl: this._manifestUrl,
3033
- opts,
3034
- ...this.identity
3035
- })
3036
- .then(() => undefined);
3037
- }
3038
- /**
3039
- * Instructs the RVM to schedule one restart of the application.
3040
- *
3041
- * @example
3042
- *
3043
- * ```js
3044
- * async function scheduleRestart() {
3045
- * const app = await fin.Application.getCurrent();
3046
- * return await app.scheduleRestart();
3047
- * }
3048
- *
3049
- * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3050
- * ```
3051
- */
3052
- scheduleRestart() {
3053
- return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3054
- }
3055
- /**
3056
- * Sends a message to the RVM to upload the application's logs. On success,
3057
- * an object containing logId is returned.
3058
- *
3059
- * @example
3060
- *
3061
- * ```js
3062
- * async function sendLog() {
3063
- * const app = await fin.Application.getCurrent();
3064
- * return await app.sendApplicationLog();
3065
- * }
3066
- *
3067
- * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3068
- * ```
3069
- */
3070
- async sendApplicationLog() {
3071
- const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3072
- return payload.data;
3073
- }
3074
- /**
3075
- * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3076
- * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3077
- *
3078
- * Note: If the "name" property is omitted it defaults to "tasks".
3079
- * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3080
- *
3081
- *
3082
- * @remarks If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3083
- *
3084
- * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3085
- * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3086
- *
3087
- * Note: If the "name" property is omitted it defaults to "tasks".
3088
- *
3089
- * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3090
- * uuid or shortcut.name is changed.
3091
- *
3092
- * @example
3093
- *
3094
- * ```js
3095
- * const app = fin.Application.getCurrentSync();
3096
- * const appName = 'My App';
3097
- * const jumpListConfig = [ // array of JumpList categories
3098
- * {
3099
- * // has no name and no type so `type` is assumed to be "tasks"
3100
- * items: [ // array of JumpList items
3101
- * {
3102
- * type: 'task',
3103
- * title: `Launch ${appName}`,
3104
- * description: `Runs ${appName} with the default configuration`,
3105
- * deepLink: 'fins://path.to/app/manifest.json',
3106
- * iconPath: 'https://path.to/app/icon.ico',
3107
- * iconIndex: 0
3108
- * },
3109
- * { type: 'separator' },
3110
- * {
3111
- * type: 'task',
3112
- * title: `Restore ${appName}`,
3113
- * description: 'Restore to last configuration',
3114
- * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3115
- * iconPath: 'https://path.to/app/icon.ico',
3116
- * iconIndex: 0
3117
- * },
3118
- * ]
3119
- * },
3120
- * {
3121
- * name: 'Tools',
3122
- * items: [ // array of JumpList items
3123
- * {
3124
- * type: 'task',
3125
- * title: 'Tool A',
3126
- * description: 'Runs Tool A',
3127
- * deepLink: 'fins://path.to/tool-a/manifest.json',
3128
- * iconPath: 'https://path.to/tool-a/icon.ico',
3129
- * iconIndex: 0
3130
- * },
3131
- * {
3132
- * type: 'task',
3133
- * title: 'Tool B',
3134
- * description: 'Runs Tool B',
3135
- * deepLink: 'fins://path.to/tool-b/manifest.json',
3136
- * iconPath: 'https://path.to/tool-b/icon.ico',
3137
- * iconIndex: 0
3138
- * }]
3139
- * }
3140
- * ];
3141
- *
3142
- * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3143
- * ```
3144
- *
3145
- * To handle deeplink args:
3146
- * ```js
3147
- * function handleUseLastConfiguration() {
3148
- * // this handler is called when the app is being launched
3149
- * app.on('run-requested', event => {
3150
- * if(event.userAppConfigArgs['use-last-configuration']) {
3151
- * // your logic here
3152
- * }
3153
- * });
3154
- * // this handler is called when the app was already running when the launch was requested
3155
- * fin.desktop.main(function(args) {
3156
- * if(args && args['use-last-configuration']) {
3157
- * // your logic here
3158
- * }
3159
- * });
3160
- * }
3161
- * ```
3162
- */
3163
- async setJumpList(jumpListCategories) {
3164
- await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3165
- }
3166
- /**
3167
- * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3168
- * @param icon Image URL or base64 encoded string to be used as the icon
3169
- *
3170
- * @example
3171
- *
3172
- * ```js
3173
- * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3174
- * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3175
- * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3176
- * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3177
- * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3178
- *
3179
- * async function setTrayIcon(icon) {
3180
- * const app = await fin.Application.getCurrent();
3181
- * return await app.setTrayIcon(icon);
3182
- * }
3183
- *
3184
- * // use image url to set tray icon
3185
- * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3186
- *
3187
- * // use base64 encoded string to set tray icon
3188
- * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3189
- *
3190
- * // use a dataURL to set tray icon
3191
- * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3192
- * ```
3193
- */
3194
- setTrayIcon(icon) {
3195
- return this.wire
3196
- .sendAction('set-tray-icon', {
3197
- enabledIcon: icon,
3198
- ...this.identity
3199
- })
3200
- .then(() => undefined);
3201
- }
3202
- /**
3203
- * Set hover text for this application's system tray icon.
3204
- * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
3205
- * @param toolTip
3206
- *
3207
- * @example
3208
- *
3209
- * ```js
3210
- * const app = fin.Application.getCurrentSync();
3211
- * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3212
- *
3213
- * await app.setTrayIcon(iconUrl);
3214
- *
3215
- * await app.setTrayIconToolTip('My Application');
3216
- * ```
3217
- */
3218
- async setTrayIconToolTip(toolTip) {
3219
- await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
3220
- }
3221
- /**
3222
- * Sets new application's shortcut configuration. Windows only.
3223
- * @param config New application's shortcut configuration.
3224
- *
3225
- * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3226
- * to be able to change shortcut states.
3227
- *
3228
- * @example
3229
- *
3230
- * ```js
3231
- * async function setShortcuts(config) {
3232
- * const app = await fin.Application.getCurrent();
3233
- * return app.setShortcuts(config);
3234
- * }
3235
- *
3236
- * setShortcuts({
3237
- * desktop: true,
3238
- * startMenu: false,
3239
- * systemStartup: true
3240
- * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3241
- * ```
3242
- */
3243
- setShortcuts(config) {
3244
- return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3245
- }
3246
- /**
3247
- * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3248
- * @param queryString The new query string for this app's shortcuts.
3249
- *
3250
- * @example
3251
- *
3252
- * ```js
3253
- * const newQueryArgs = 'arg=true&arg2=false';
3254
- * const app = await fin.Application.getCurrent();
3255
- * try {
3256
- * await app.setShortcutQueryParams(newQueryArgs);
3257
- * } catch(err) {
3258
- * console.error(err)
3259
- * }
3260
- * ```
3261
- */
3262
- async setShortcutQueryParams(queryString) {
3263
- await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3264
- }
3265
- /**
3266
- * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3267
- * larger or smaller to default limits of 300% and 50% of original size, respectively.
3268
- * @param level The zoom level
3269
- *
3270
- * @example
3271
- *
3272
- * ```js
3273
- * async function setZoomLevel(number) {
3274
- * const app = await fin.Application.getCurrent();
3275
- * return await app.setZoomLevel(number);
3276
- * }
3277
- *
3278
- * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3279
- * ```
3280
- */
3281
- setZoomLevel(level) {
3282
- return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3283
- }
3284
- /**
3285
- * Sets a username to correlate with App Log Management.
3286
- * @param username Username to correlate with App's Log.
3287
- *
3288
- * @example
3289
- *
3290
- * ```js
3291
- * async function setAppLogUser() {
3292
- * const app = await fin.Application.getCurrent();
3293
- * return await app.setAppLogUsername('username');
3294
- * }
3295
- *
3296
- * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3297
- *
3298
- * ```
3299
- */
3300
- async setAppLogUsername(username) {
3301
- await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3302
- }
3303
- /**
3304
- * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3305
- * @remarks The only information currently returned is the position and dimensions.
3306
- *
3307
- * @example
3308
- *
3309
- * ```js
3310
- * async function getTrayIconInfo() {
3311
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3312
- * return await app.getTrayIconInfo();
3313
- * }
3314
- * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3315
- * ```
3316
- */
3317
- getTrayIconInfo() {
3318
- return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3319
- }
3320
- /**
3321
- * Checks if the application has an associated tray icon.
3322
- *
3323
- * @example
3324
- *
3325
- * ```js
3326
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3327
- * const hasTrayIcon = await app.hasTrayIcon();
3328
- * console.log(hasTrayIcon);
3329
- * ```
3330
- */
3331
- hasTrayIcon() {
3332
- return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3333
- }
3334
- /**
3335
- * Closes the application by terminating its process.
3336
- *
3337
- * @example
3338
- *
3339
- * ```js
3340
- * async function terminateApp() {
3341
- * const app = await fin.Application.getCurrent();
3342
- * return await app.terminate();
3343
- * }
3344
- * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3345
- * ```
3346
- */
3347
- terminate() {
3348
- return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3349
- }
3350
- /**
3351
- * Waits for a hanging application. This method can be called in response to an application
3352
- * "not-responding" to allow the application to continue and to generate another "not-responding"
3353
- * message after a certain period of time.
3354
- *
3355
- * @ignore
3356
- */
3357
- wait() {
3358
- return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3359
- }
3360
- /**
3361
- * Retrieves information about the application.
3362
- *
3363
- * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3364
- * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3365
- * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3366
- *
3367
- * @example
3368
- *
3369
- * ```js
3370
- * async function getInfo() {
3371
- * const app = await fin.Application.getCurrent();
3372
- * return await app.getInfo();
3373
- * }
3374
- *
3375
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3376
- * ```
3377
- */
3378
- getInfo() {
3379
- return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3380
- }
3381
- /**
3382
- * Retrieves all process information for entities (windows and views) associated with an application.
3383
- *
3384
- * @example
3385
- * ```js
3386
- * const app = await fin.Application.getCurrent();
3387
- * const processInfo = await app.getProcessInfo();
3388
- * ```
3389
- * @experimental
3390
- */
3391
- async getProcessInfo() {
3392
- const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3393
- return data;
3394
- }
3395
- /**
3396
- * Sets file auto download location. It's only allowed in the same application.
3397
- *
3398
- * Note: This method is restricted by default and must be enabled via
3399
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3400
- * @param downloadLocation file auto download location
3401
- *
3402
- * @throws if setting file auto download location on different applications.
3403
- * @example
3404
- *
3405
- * ```js
3406
- * const downloadLocation = 'C:\\dev\\temp';
3407
- * const app = await fin.Application.getCurrent();
3408
- * try {
3409
- * await app.setFileDownloadLocation(downloadLocation);
3410
- * console.log('File download location is set');
3411
- * } catch(err) {
3412
- * console.error(err)
3413
- * }
3414
- * ```
3415
- */
3416
- async setFileDownloadLocation(downloadLocation) {
3417
- const { name } = this.wire.me;
3418
- const entityIdentity = { uuid: this.identity.uuid, name };
3419
- await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3420
- }
3421
- /**
3422
- * Gets file auto download location. It's only allowed in the same application. If file auto download location is not set, it will return the default location.
3423
- *
3424
- * Note: This method is restricted by default and must be enabled via
3425
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3426
- *
3427
- * @throws if getting file auto download location on different applications.
3428
- * @example
3429
- *
3430
- * ```js
3431
- * const app = await fin.Application.getCurrent();
3432
- * const fileDownloadDir = await app.getFileDownloadLocation();
3433
- * ```
3434
- */
3435
- async getFileDownloadLocation() {
3436
- const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3437
- return data;
3438
- }
3439
- /**
3440
- * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3441
- * @param options
3442
- * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3443
- * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3444
- * of all possible data shapes for the entire menu, and the click handler should process
3445
- * these with a "reducer" pattern.
3446
- * @throws if the application has no tray icon set
3447
- * @throws if the system tray is currently hidden
3448
- * @example
3449
- *
3450
- * ```js
3451
- * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3452
- * const app = fin.Application.getCurrentSync();
3453
- *
3454
- * await app.setTrayIcon(iconUrl);
3455
- *
3456
- * const template = [
3457
- * {
3458
- * label: 'Menu Item 1',
3459
- * data: 'hello from item 1'
3460
- * },
3461
- * { type: 'separator' },
3462
- * {
3463
- * label: 'Menu Item 2',
3464
- * type: 'checkbox',
3465
- * checked: true,
3466
- * data: 'The user clicked the checkbox'
3467
- * },
3468
- * {
3469
- * label: 'see more',
3470
- * enabled: false,
3471
- * submenu: [
3472
- * { label: 'submenu 1', data: 'hello from submenu' }
3473
- * ]
3474
- * }
3475
- * ];
3476
- *
3477
- * app.addListener('tray-icon-clicked', (event) => {
3478
- * // right-click
3479
- * if (event.button === 2) {
3480
- * app.showTrayIconPopupMenu({ template }).then(r => {
3481
- * if (r.result === 'closed') {
3482
- * console.log('nothing happened');
3483
- * } else {
3484
- * console.log(r.data);
3485
- * }
3486
- * });
3487
- * }
3488
- * });
3489
- * ```
3490
- */
3491
- async showTrayIconPopupMenu(options) {
3492
- const { name } = this.wire.me;
3493
- const entityIdentity = { uuid: this.identity.uuid, name };
3494
- const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3495
- return payload.data;
3496
- }
3497
- /**
3498
- * Closes the tray icon menu.
3499
- *
3500
- * @throws if the application has no tray icon set
3501
- * @example
3502
- *
3503
- * ```js
3504
- * const app = fin.Application.getCurrentSync();
3505
- *
3506
- * await app.closeTrayIconPopupMenu();
3507
- * ```
3508
- */
3509
- async closeTrayIconPopupMenu() {
3510
- const { name } = this.wire.me;
3511
- const entityIdentity = { uuid: this.identity.uuid, name };
3512
- await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3513
- }
3514
- }
3515
- Instance$6.Application = Application;
2699
+ var hasRequiredInstance$1;
3516
2700
 
3517
- Object.defineProperty(Factory$7, "__esModule", { value: true });
3518
- Factory$7.ApplicationModule = void 0;
3519
- const base_1$m = base;
3520
- const validate_1$4 = validate;
3521
- const Instance_1$5 = Instance$6;
3522
- /**
3523
- * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3524
- */
3525
- class ApplicationModule extends base_1$m.Base {
3526
- /**
3527
- * Asynchronously returns an API handle for the given Application identity.
3528
- *
3529
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3530
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3531
- * for an Application throughout its entire lifecycle.
3532
- *
3533
- * @example
3534
- *
3535
- * ```js
3536
- * fin.Application.wrap({ uuid: 'testapp' })
3537
- * .then(app => app.isRunning())
3538
- * .then(running => console.log('Application is running: ' + running))
3539
- * .catch(err => console.log(err));
3540
- * ```
3541
- *
3542
- */
3543
- async wrap(identity) {
3544
- this.wire.recordAnalytic('wrap-application');
3545
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3546
- if (errorMsg) {
3547
- throw new Error(errorMsg);
3548
- }
3549
- return new Instance_1$5.Application(this.wire, identity);
3550
- }
3551
- /**
3552
- * Synchronously returns an API handle for the given Application identity.
3553
- *
3554
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3555
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3556
- * for an Aplication throughout its entire lifecycle.
3557
- *
3558
- * @example
3559
- *
3560
- * ```js
3561
- * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3562
- * await app.close();
3563
- * ```
3564
- *
3565
- */
3566
- wrapSync(identity) {
3567
- this.wire.recordAnalytic('wrap-application-sync');
3568
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
3569
- if (errorMsg) {
3570
- throw new Error(errorMsg);
3571
- }
3572
- return new Instance_1$5.Application(this.wire, identity);
3573
- }
3574
- async _create(appOptions) {
3575
- // set defaults:
3576
- if (appOptions.waitForPageLoad === undefined) {
3577
- appOptions.waitForPageLoad = false;
3578
- }
3579
- if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3580
- appOptions.autoShow = true;
3581
- }
3582
- await this.wire.sendAction('create-application', appOptions);
3583
- return this.wrap({ uuid: appOptions.uuid });
3584
- }
3585
- /**
3586
- * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3587
- *
3588
- * @example
3589
- *
3590
- * ```js
3591
- * async function createApp() {
3592
- * const app = await fin.Application.create({
3593
- * name: 'myApp',
3594
- * uuid: 'app-3',
3595
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3596
- * autoShow: true
3597
- * });
3598
- * await app.run();
3599
- * }
3600
- *
3601
- * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3602
- * ```
3603
- *
3604
- * @ignore
3605
- */
3606
- create(appOptions) {
3607
- console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3608
- this.wire.recordAnalytic('application-create');
3609
- return this._create(appOptions);
3610
- }
3611
- /**
3612
- * Creates and starts a new Application.
3613
- *
3614
- * @example
3615
- *
3616
- * ```js
3617
- * async function start() {
3618
- * return fin.Application.start({
3619
- * name: 'app-1',
3620
- * uuid: 'app-1',
3621
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3622
- * autoShow: true
3623
- * });
3624
- * }
3625
- * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3626
- * ```
3627
- *
3628
- */
3629
- async start(appOptions) {
3630
- this.wire.recordAnalytic('start-application');
3631
- const app = await this._create(appOptions);
3632
- await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3633
- return app;
3634
- }
3635
- /**
3636
- * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3637
- * Returns once the RVM is finished attempting to launch the applications.
3638
- * @param opts - Parameters that the RVM will use.
3639
- *
3640
- * @example
3641
- *
3642
- * ```js
3643
- *
3644
- * const applicationInfoArray = [
3645
- * {
3646
- * "uuid": 'App-1',
3647
- * "manifestUrl": 'http://localhost:5555/app1.json',
3648
- * },
3649
- * {
3650
- * "uuid": 'App-2',
3651
- * "manifestUrl": 'http://localhost:5555/app2.json',
3652
- * },
3653
- * {
3654
- * "uuid": 'App-3',
3655
- * "manifestUrl": 'http://localhost:5555/app3.json',
3656
- * }
3657
- * ]
3658
- *
3659
- * fin.Application.startManyManifests(applicationInfoArray)
3660
- * .then(() => {
3661
- * console.log('RVM has finished launching the application list.');
3662
- * })
3663
- * .catch((err) => {
3664
- * console.log(err);
3665
- * })
3666
- * ```
3667
- *
3668
- * @experimental
3669
- */
3670
- async startManyManifests(applications, opts) {
3671
- return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3672
- }
3673
- /**
3674
- * Asynchronously returns an Application object that represents the current application
3675
- *
3676
- * @example
3677
- *
3678
- * ```js
3679
- * async function isCurrentAppRunning () {
3680
- * const app = await fin.Application.getCurrent();
3681
- * return app.isRunning();
3682
- * }
3683
- *
3684
- * isCurrentAppRunning().then(running => {
3685
- * console.log(`Current app is running: ${running}`);
3686
- * }).catch(err => {
3687
- * console.error(err);
3688
- * });
3689
- *
3690
- * ```
3691
- */
3692
- getCurrent() {
3693
- this.wire.recordAnalytic('get-current-application');
3694
- return this.wrap({ uuid: this.wire.me.uuid });
3695
- }
3696
- /**
3697
- * Synchronously returns an Application object that represents the current application
3698
- *
3699
- * @example
3700
- *
3701
- * ```js
3702
- * async function isCurrentAppRunning () {
3703
- * const app = fin.Application.getCurrentSync();
3704
- * return app.isRunning();
3705
- * }
3706
- *
3707
- * isCurrentAppRunning().then(running => {
3708
- * console.log(`Current app is running: ${running}`);
3709
- * }).catch(err => {
3710
- * console.error(err);
3711
- * });
3712
- *
3713
- * ```
3714
- */
3715
- getCurrentSync() {
3716
- this.wire.recordAnalytic('get-current-application-sync');
3717
- return this.wrapSync({ uuid: this.wire.me.uuid });
3718
- }
3719
- /**
3720
- * Retrieves application's manifest and returns a running instance of the application.
3721
- * @param manifestUrl - The URL of app's manifest.
3722
- * @param opts - Parameters that the RVM will use.
3723
- *
3724
- * @example
3725
- *
3726
- * ```js
3727
- * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3728
- *
3729
- * // For a local manifest file:
3730
- * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3731
- * ```
3732
- */
3733
- async startFromManifest(manifestUrl, opts) {
3734
- this.wire.recordAnalytic('application-start-from-manifest');
3735
- const app = await this._createFromManifest(manifestUrl);
3736
- // @ts-expect-error using private method without warning.
3737
- await app._run(opts); // eslint-disable-line no-underscore-dangle
3738
- return app;
3739
- }
3740
- /**
3741
- * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3742
- * Retrieves application's manifest and returns a wrapped application.
3743
- * @param manifestUrl - The URL of app's manifest.
3744
- * @param callback - called if the method succeeds.
3745
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3746
- *
3747
- * @example
3748
- *
3749
- * ```js
3750
- * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3751
- * ```
3752
- * @ignore
3753
- */
3754
- createFromManifest(manifestUrl) {
3755
- console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3756
- this.wire.recordAnalytic('application-create-from-manifest');
3757
- return this._createFromManifest(manifestUrl);
3758
- }
3759
- _createFromManifest(manifestUrl) {
3760
- return this.wire
3761
- .sendAction('get-application-manifest', { manifestUrl })
3762
- .then(({ payload }) => {
3763
- const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3764
- return this.wrap({ uuid });
3765
- })
3766
- .then((app) => {
3767
- app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3768
- return app;
3769
- });
3770
- }
2701
+ function requireInstance$1 () {
2702
+ if (hasRequiredInstance$1) return Instance$6;
2703
+ hasRequiredInstance$1 = 1;
2704
+ Object.defineProperty(Instance$6, "__esModule", { value: true });
2705
+ Instance$6.Application = void 0;
2706
+ /* eslint-disable import/prefer-default-export */
2707
+ const base_1 = base;
2708
+ const window_1 = requireWindow();
2709
+ const view_1 = requireView();
2710
+ /**
2711
+ * An object representing an application. Allows the developer to create,
2712
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
2713
+ */
2714
+ class Application extends base_1.EmitterBase {
2715
+ /**
2716
+ * @internal
2717
+ */
2718
+ constructor(wire, identity) {
2719
+ super(wire, 'application', identity.uuid);
2720
+ this.identity = identity;
2721
+ this.window = new window_1._Window(this.wire, {
2722
+ uuid: this.identity.uuid,
2723
+ name: this.identity.uuid
2724
+ });
2725
+ }
2726
+ windowListFromIdentityList(identityList) {
2727
+ const windowList = [];
2728
+ identityList.forEach((identity) => {
2729
+ windowList.push(new window_1._Window(this.wire, {
2730
+ uuid: identity.uuid,
2731
+ name: identity.name
2732
+ }));
2733
+ });
2734
+ return windowList;
2735
+ }
2736
+ /**
2737
+ * Determines if the application is currently running.
2738
+ *
2739
+ * @example
2740
+ *
2741
+ * ```js
2742
+ * async function isAppRunning() {
2743
+ * const app = await fin.Application.getCurrent();
2744
+ * return await app.isRunning();
2745
+ * }
2746
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
2747
+ * ```
2748
+ */
2749
+ isRunning() {
2750
+ return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
2751
+ }
2752
+ /**
2753
+ * Closes the application and any child windows created by the application.
2754
+ * Cleans the application from state so it is no longer found in getAllApplications.
2755
+ * @param force Close will be prevented from closing when force is false and
2756
+ * ‘close-requested’ has been subscribed to for application’s main window.
2757
+ *
2758
+ * @example
2759
+ *
2760
+ * ```js
2761
+ * async function closeApp() {
2762
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
2763
+ * const app = await fin.Application.wrap({uuid: 'app2'});
2764
+ * await app.quit();
2765
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
2766
+ *
2767
+ * }
2768
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
2769
+ * ```
2770
+ */
2771
+ async quit(force = false) {
2772
+ try {
2773
+ await this._close(force);
2774
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
2775
+ }
2776
+ catch (error) {
2777
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
2778
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
2779
+ throw error;
2780
+ }
2781
+ }
2782
+ }
2783
+ async _close(force = false) {
2784
+ try {
2785
+ await this.wire.sendAction('close-application', { force, ...this.identity });
2786
+ }
2787
+ catch (error) {
2788
+ if (!error.message.includes('Remote connection has closed')) {
2789
+ throw error;
2790
+ }
2791
+ }
2792
+ }
2793
+ /**
2794
+ * @deprecated use Application.quit instead
2795
+ * Closes the application and any child windows created by the application.
2796
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
2797
+ * @param callback - called if the method succeeds.
2798
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
2799
+ *
2800
+ * @example
2801
+ *
2802
+ * ```js
2803
+ * async function closeApp() {
2804
+ * const app = await fin.Application.getCurrent();
2805
+ * return await app.close();
2806
+ * }
2807
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
2808
+ * ```
2809
+ */
2810
+ close(force = false) {
2811
+ console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
2812
+ this.wire.recordAnalytic('application-close');
2813
+ return this._close(force);
2814
+ }
2815
+ /**
2816
+ * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
2817
+ *
2818
+ * @example
2819
+ *
2820
+ * ```js
2821
+ * async function getChildWindows() {
2822
+ * const app = await fin.Application.getCurrent();
2823
+ * return await app.getChildWindows();
2824
+ * }
2825
+ *
2826
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
2827
+ * ```
2828
+ */
2829
+ getChildWindows() {
2830
+ return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
2831
+ const identityList = [];
2832
+ payload.data.forEach((winName) => {
2833
+ identityList.push({ uuid: this.identity.uuid, name: winName });
2834
+ });
2835
+ return this.windowListFromIdentityList(identityList);
2836
+ });
2837
+ }
2838
+ /**
2839
+ * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
2840
+ * if the application was not created from a manifest.
2841
+ *
2842
+ * @example
2843
+ *
2844
+ * ```js
2845
+ * async function getManifest() {
2846
+ * const app = await fin.Application.getCurrent();
2847
+ * return await app.getManifest();
2848
+ * }
2849
+ *
2850
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
2851
+ * ```
2852
+ */
2853
+ getManifest() {
2854
+ return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
2855
+ }
2856
+ /**
2857
+ * Retrieves UUID of the application that launches this application. Invokes the error callback
2858
+ * if the application was created from a manifest.
2859
+ *
2860
+ * @example
2861
+ *
2862
+ * ```js
2863
+ * async function getParentUuid() {
2864
+ * const app = await fin.Application.start({
2865
+ * uuid: 'app-1',
2866
+ * name: 'myApp',
2867
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
2868
+ * autoShow: true
2869
+ * });
2870
+ * return await app.getParentUuid();
2871
+ * }
2872
+ *
2873
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
2874
+ * ```
2875
+ */
2876
+ getParentUuid() {
2877
+ return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
2878
+ }
2879
+ /**
2880
+ * Retrieves current application's shortcut configuration.
2881
+ *
2882
+ * @example
2883
+ *
2884
+ * ```js
2885
+ * async function getShortcuts() {
2886
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
2887
+ * return await app.getShortcuts();
2888
+ * }
2889
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
2890
+ * ```
2891
+ */
2892
+ getShortcuts() {
2893
+ return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
2894
+ }
2895
+ /**
2896
+ * Retrieves current application's views.
2897
+ * @experimental
2898
+ *
2899
+ * @example
2900
+ *
2901
+ * ```js
2902
+ * async function getViews() {
2903
+ * const app = await fin.Application.getCurrent();
2904
+ * return await app.getViews();
2905
+ * }
2906
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
2907
+ * ```
2908
+ */
2909
+ async getViews() {
2910
+ const { payload } = await this.wire.sendAction('application-get-views', this.identity);
2911
+ return payload.data.map((id) => new view_1.View(this.wire, id));
2912
+ }
2913
+ /**
2914
+ * Returns the current zoom level of the application.
2915
+ *
2916
+ * @example
2917
+ *
2918
+ * ```js
2919
+ * async function getZoomLevel() {
2920
+ * const app = await fin.Application.getCurrent();
2921
+ * return await app.getZoomLevel();
2922
+ * }
2923
+ *
2924
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
2925
+ * ```
2926
+ */
2927
+ getZoomLevel() {
2928
+ return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
2929
+ }
2930
+ /**
2931
+ * Returns an instance of the main Window of the application
2932
+ *
2933
+ * @example
2934
+ *
2935
+ * ```js
2936
+ * async function getWindow() {
2937
+ * const app = await fin.Application.start({
2938
+ * uuid: 'app-1',
2939
+ * name: 'myApp',
2940
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
2941
+ * autoShow: true
2942
+ * });
2943
+ * return await app.getWindow();
2944
+ * }
2945
+ *
2946
+ * getWindow().then(win => {
2947
+ * win.showAt(0, 400);
2948
+ * win.flash();
2949
+ * }).catch(err => console.log(err));
2950
+ * ```
2951
+ */
2952
+ getWindow() {
2953
+ this.wire.recordAnalytic('application-get-window');
2954
+ return Promise.resolve(this.window);
2955
+ }
2956
+ /**
2957
+ * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
2958
+ * @param userName - username to be passed to the RVM.
2959
+ * @param appName - app name to be passed to the RVM.
2960
+ *
2961
+ * @example
2962
+ *
2963
+ * ```js
2964
+ * async function registerUser() {
2965
+ * const app = await fin.Application.getCurrent();
2966
+ * return await app.registerUser('user', 'myApp');
2967
+ * }
2968
+ *
2969
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
2970
+ * ```
2971
+ */
2972
+ registerUser(userName, appName) {
2973
+ return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
2974
+ }
2975
+ /**
2976
+ * Removes the application’s icon from the tray.
2977
+ *
2978
+ * @example
2979
+ *
2980
+ * ```js
2981
+ * async function removeTrayIcon() {
2982
+ * const app = await fin.Application.getCurrent();
2983
+ * return await app.removeTrayIcon();
2984
+ * }
2985
+ *
2986
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
2987
+ * ```
2988
+ */
2989
+ removeTrayIcon() {
2990
+ return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
2991
+ }
2992
+ /**
2993
+ * Restarts the application.
2994
+ *
2995
+ * @example
2996
+ *
2997
+ * ```js
2998
+ * async function restartApp() {
2999
+ * const app = await fin.Application.getCurrent();
3000
+ * return await app.restart();
3001
+ * }
3002
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
3003
+ * ```
3004
+ */
3005
+ restart() {
3006
+ return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3007
+ }
3008
+ /**
3009
+ * DEPRECATED method to run the application.
3010
+ * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3011
+ *
3012
+ * @example
3013
+ *
3014
+ * ```js
3015
+ * async function run() {
3016
+ * const app = await fin.Application.create({
3017
+ * name: 'myApp',
3018
+ * uuid: 'app-1',
3019
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3020
+ * autoShow: true
3021
+ * });
3022
+ * await app.run();
3023
+ * }
3024
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3025
+ * ```
3026
+ *
3027
+ * @ignore
3028
+ */
3029
+ run() {
3030
+ console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3031
+ this.wire.recordAnalytic('application-run');
3032
+ return this._run();
3033
+ }
3034
+ _run(opts = {}) {
3035
+ return this.wire
3036
+ .sendAction('run-application', {
3037
+ manifestUrl: this._manifestUrl,
3038
+ opts,
3039
+ ...this.identity
3040
+ })
3041
+ .then(() => undefined);
3042
+ }
3043
+ /**
3044
+ * Instructs the RVM to schedule one restart of the application.
3045
+ *
3046
+ * @example
3047
+ *
3048
+ * ```js
3049
+ * async function scheduleRestart() {
3050
+ * const app = await fin.Application.getCurrent();
3051
+ * return await app.scheduleRestart();
3052
+ * }
3053
+ *
3054
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3055
+ * ```
3056
+ */
3057
+ scheduleRestart() {
3058
+ return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3059
+ }
3060
+ /**
3061
+ * Sends a message to the RVM to upload the application's logs. On success,
3062
+ * an object containing logId is returned.
3063
+ *
3064
+ * @example
3065
+ *
3066
+ * ```js
3067
+ * async function sendLog() {
3068
+ * const app = await fin.Application.getCurrent();
3069
+ * return await app.sendApplicationLog();
3070
+ * }
3071
+ *
3072
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3073
+ * ```
3074
+ */
3075
+ async sendApplicationLog() {
3076
+ const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3077
+ return payload.data;
3078
+ }
3079
+ /**
3080
+ * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3081
+ * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3082
+ *
3083
+ * Note: If the "name" property is omitted it defaults to "tasks".
3084
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3085
+ *
3086
+ *
3087
+ * @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).
3088
+ *
3089
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3090
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3091
+ *
3092
+ * Note: If the "name" property is omitted it defaults to "tasks".
3093
+ *
3094
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3095
+ * uuid or shortcut.name is changed.
3096
+ *
3097
+ * @example
3098
+ *
3099
+ * ```js
3100
+ * const app = fin.Application.getCurrentSync();
3101
+ * const appName = 'My App';
3102
+ * const jumpListConfig = [ // array of JumpList categories
3103
+ * {
3104
+ * // has no name and no type so `type` is assumed to be "tasks"
3105
+ * items: [ // array of JumpList items
3106
+ * {
3107
+ * type: 'task',
3108
+ * title: `Launch ${appName}`,
3109
+ * description: `Runs ${appName} with the default configuration`,
3110
+ * deepLink: 'fins://path.to/app/manifest.json',
3111
+ * iconPath: 'https://path.to/app/icon.ico',
3112
+ * iconIndex: 0
3113
+ * },
3114
+ * { type: 'separator' },
3115
+ * {
3116
+ * type: 'task',
3117
+ * title: `Restore ${appName}`,
3118
+ * description: 'Restore to last configuration',
3119
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3120
+ * iconPath: 'https://path.to/app/icon.ico',
3121
+ * iconIndex: 0
3122
+ * },
3123
+ * ]
3124
+ * },
3125
+ * {
3126
+ * name: 'Tools',
3127
+ * items: [ // array of JumpList items
3128
+ * {
3129
+ * type: 'task',
3130
+ * title: 'Tool A',
3131
+ * description: 'Runs Tool A',
3132
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
3133
+ * iconPath: 'https://path.to/tool-a/icon.ico',
3134
+ * iconIndex: 0
3135
+ * },
3136
+ * {
3137
+ * type: 'task',
3138
+ * title: 'Tool B',
3139
+ * description: 'Runs Tool B',
3140
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
3141
+ * iconPath: 'https://path.to/tool-b/icon.ico',
3142
+ * iconIndex: 0
3143
+ * }]
3144
+ * }
3145
+ * ];
3146
+ *
3147
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3148
+ * ```
3149
+ *
3150
+ * To handle deeplink args:
3151
+ * ```js
3152
+ * function handleUseLastConfiguration() {
3153
+ * // this handler is called when the app is being launched
3154
+ * app.on('run-requested', event => {
3155
+ * if(event.userAppConfigArgs['use-last-configuration']) {
3156
+ * // your logic here
3157
+ * }
3158
+ * });
3159
+ * // this handler is called when the app was already running when the launch was requested
3160
+ * fin.desktop.main(function(args) {
3161
+ * if(args && args['use-last-configuration']) {
3162
+ * // your logic here
3163
+ * }
3164
+ * });
3165
+ * }
3166
+ * ```
3167
+ */
3168
+ async setJumpList(jumpListCategories) {
3169
+ await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3170
+ }
3171
+ /**
3172
+ * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3173
+ * @param icon Image URL or base64 encoded string to be used as the icon
3174
+ *
3175
+ * @example
3176
+ *
3177
+ * ```js
3178
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3179
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3180
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3181
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3182
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3183
+ *
3184
+ * async function setTrayIcon(icon) {
3185
+ * const app = await fin.Application.getCurrent();
3186
+ * return await app.setTrayIcon(icon);
3187
+ * }
3188
+ *
3189
+ * // use image url to set tray icon
3190
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3191
+ *
3192
+ * // use base64 encoded string to set tray icon
3193
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3194
+ *
3195
+ * // use a dataURL to set tray icon
3196
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3197
+ * ```
3198
+ */
3199
+ setTrayIcon(icon) {
3200
+ return this.wire
3201
+ .sendAction('set-tray-icon', {
3202
+ enabledIcon: icon,
3203
+ ...this.identity
3204
+ })
3205
+ .then(() => undefined);
3206
+ }
3207
+ /**
3208
+ * Set hover text for this application's system tray icon.
3209
+ * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
3210
+ * @param toolTip
3211
+ *
3212
+ * @example
3213
+ *
3214
+ * ```js
3215
+ * const app = fin.Application.getCurrentSync();
3216
+ * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3217
+ *
3218
+ * await app.setTrayIcon(iconUrl);
3219
+ *
3220
+ * await app.setTrayIconToolTip('My Application');
3221
+ * ```
3222
+ */
3223
+ async setTrayIconToolTip(toolTip) {
3224
+ await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
3225
+ }
3226
+ /**
3227
+ * Sets new application's shortcut configuration. Windows only.
3228
+ * @param config New application's shortcut configuration.
3229
+ *
3230
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3231
+ * to be able to change shortcut states.
3232
+ *
3233
+ * @example
3234
+ *
3235
+ * ```js
3236
+ * async function setShortcuts(config) {
3237
+ * const app = await fin.Application.getCurrent();
3238
+ * return app.setShortcuts(config);
3239
+ * }
3240
+ *
3241
+ * setShortcuts({
3242
+ * desktop: true,
3243
+ * startMenu: false,
3244
+ * systemStartup: true
3245
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3246
+ * ```
3247
+ */
3248
+ setShortcuts(config) {
3249
+ return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3250
+ }
3251
+ /**
3252
+ * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3253
+ * @param queryString The new query string for this app's shortcuts.
3254
+ *
3255
+ * @example
3256
+ *
3257
+ * ```js
3258
+ * const newQueryArgs = 'arg=true&arg2=false';
3259
+ * const app = await fin.Application.getCurrent();
3260
+ * try {
3261
+ * await app.setShortcutQueryParams(newQueryArgs);
3262
+ * } catch(err) {
3263
+ * console.error(err)
3264
+ * }
3265
+ * ```
3266
+ */
3267
+ async setShortcutQueryParams(queryString) {
3268
+ await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3269
+ }
3270
+ /**
3271
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3272
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
3273
+ * @param level The zoom level
3274
+ *
3275
+ * @example
3276
+ *
3277
+ * ```js
3278
+ * async function setZoomLevel(number) {
3279
+ * const app = await fin.Application.getCurrent();
3280
+ * return await app.setZoomLevel(number);
3281
+ * }
3282
+ *
3283
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3284
+ * ```
3285
+ */
3286
+ setZoomLevel(level) {
3287
+ return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3288
+ }
3289
+ /**
3290
+ * Sets a username to correlate with App Log Management.
3291
+ * @param username Username to correlate with App's Log.
3292
+ *
3293
+ * @example
3294
+ *
3295
+ * ```js
3296
+ * async function setAppLogUser() {
3297
+ * const app = await fin.Application.getCurrent();
3298
+ * return await app.setAppLogUsername('username');
3299
+ * }
3300
+ *
3301
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3302
+ *
3303
+ * ```
3304
+ */
3305
+ async setAppLogUsername(username) {
3306
+ await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3307
+ }
3308
+ /**
3309
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3310
+ * @remarks The only information currently returned is the position and dimensions.
3311
+ *
3312
+ * @example
3313
+ *
3314
+ * ```js
3315
+ * async function getTrayIconInfo() {
3316
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3317
+ * return await app.getTrayIconInfo();
3318
+ * }
3319
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3320
+ * ```
3321
+ */
3322
+ getTrayIconInfo() {
3323
+ return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3324
+ }
3325
+ /**
3326
+ * Checks if the application has an associated tray icon.
3327
+ *
3328
+ * @example
3329
+ *
3330
+ * ```js
3331
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3332
+ * const hasTrayIcon = await app.hasTrayIcon();
3333
+ * console.log(hasTrayIcon);
3334
+ * ```
3335
+ */
3336
+ hasTrayIcon() {
3337
+ return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3338
+ }
3339
+ /**
3340
+ * Closes the application by terminating its process.
3341
+ *
3342
+ * @example
3343
+ *
3344
+ * ```js
3345
+ * async function terminateApp() {
3346
+ * const app = await fin.Application.getCurrent();
3347
+ * return await app.terminate();
3348
+ * }
3349
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3350
+ * ```
3351
+ */
3352
+ terminate() {
3353
+ return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3354
+ }
3355
+ /**
3356
+ * Waits for a hanging application. This method can be called in response to an application
3357
+ * "not-responding" to allow the application to continue and to generate another "not-responding"
3358
+ * message after a certain period of time.
3359
+ *
3360
+ * @ignore
3361
+ */
3362
+ wait() {
3363
+ return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3364
+ }
3365
+ /**
3366
+ * Retrieves information about the application.
3367
+ *
3368
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3369
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3370
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3371
+ *
3372
+ * @example
3373
+ *
3374
+ * ```js
3375
+ * async function getInfo() {
3376
+ * const app = await fin.Application.getCurrent();
3377
+ * return await app.getInfo();
3378
+ * }
3379
+ *
3380
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3381
+ * ```
3382
+ */
3383
+ getInfo() {
3384
+ return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3385
+ }
3386
+ /**
3387
+ * Retrieves all process information for entities (windows and views) associated with an application.
3388
+ *
3389
+ * @example
3390
+ * ```js
3391
+ * const app = await fin.Application.getCurrent();
3392
+ * const processInfo = await app.getProcessInfo();
3393
+ * ```
3394
+ * @experimental
3395
+ */
3396
+ async getProcessInfo() {
3397
+ const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3398
+ return data;
3399
+ }
3400
+ /**
3401
+ * Sets file auto download location. It's only allowed in the same application.
3402
+ *
3403
+ * Note: This method is restricted by default and must be enabled via
3404
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3405
+ * @param downloadLocation file auto download location
3406
+ *
3407
+ * @throws if setting file auto download location on different applications.
3408
+ * @example
3409
+ *
3410
+ * ```js
3411
+ * const downloadLocation = 'C:\\dev\\temp';
3412
+ * const app = await fin.Application.getCurrent();
3413
+ * try {
3414
+ * await app.setFileDownloadLocation(downloadLocation);
3415
+ * console.log('File download location is set');
3416
+ * } catch(err) {
3417
+ * console.error(err)
3418
+ * }
3419
+ * ```
3420
+ */
3421
+ async setFileDownloadLocation(downloadLocation) {
3422
+ const { name } = this.wire.me;
3423
+ const entityIdentity = { uuid: this.identity.uuid, name };
3424
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3425
+ }
3426
+ /**
3427
+ * 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.
3428
+ *
3429
+ * Note: This method is restricted by default and must be enabled via
3430
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3431
+ *
3432
+ * @throws if getting file auto download location on different applications.
3433
+ * @example
3434
+ *
3435
+ * ```js
3436
+ * const app = await fin.Application.getCurrent();
3437
+ * const fileDownloadDir = await app.getFileDownloadLocation();
3438
+ * ```
3439
+ */
3440
+ async getFileDownloadLocation() {
3441
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3442
+ return data;
3443
+ }
3444
+ /**
3445
+ * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3446
+ * @param options
3447
+ * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3448
+ * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3449
+ * of all possible data shapes for the entire menu, and the click handler should process
3450
+ * these with a "reducer" pattern.
3451
+ * @throws if the application has no tray icon set
3452
+ * @throws if the system tray is currently hidden
3453
+ * @example
3454
+ *
3455
+ * ```js
3456
+ * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
3457
+ * const app = fin.Application.getCurrentSync();
3458
+ *
3459
+ * await app.setTrayIcon(iconUrl);
3460
+ *
3461
+ * const template = [
3462
+ * {
3463
+ * label: 'Menu Item 1',
3464
+ * data: 'hello from item 1'
3465
+ * },
3466
+ * { type: 'separator' },
3467
+ * {
3468
+ * label: 'Menu Item 2',
3469
+ * type: 'checkbox',
3470
+ * checked: true,
3471
+ * data: 'The user clicked the checkbox'
3472
+ * },
3473
+ * {
3474
+ * label: 'see more',
3475
+ * enabled: false,
3476
+ * submenu: [
3477
+ * { label: 'submenu 1', data: 'hello from submenu' }
3478
+ * ]
3479
+ * }
3480
+ * ];
3481
+ *
3482
+ * app.addListener('tray-icon-clicked', (event) => {
3483
+ * // right-click
3484
+ * if (event.button === 2) {
3485
+ * app.showTrayIconPopupMenu({ template }).then(r => {
3486
+ * if (r.result === 'closed') {
3487
+ * console.log('nothing happened');
3488
+ * } else {
3489
+ * console.log(r.data);
3490
+ * }
3491
+ * });
3492
+ * }
3493
+ * });
3494
+ * ```
3495
+ */
3496
+ async showTrayIconPopupMenu(options) {
3497
+ const { name } = this.wire.me;
3498
+ const entityIdentity = { uuid: this.identity.uuid, name };
3499
+ const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
3500
+ return payload.data;
3501
+ }
3502
+ /**
3503
+ * Closes the tray icon menu.
3504
+ *
3505
+ * @throws if the application has no tray icon set
3506
+ * @example
3507
+ *
3508
+ * ```js
3509
+ * const app = fin.Application.getCurrentSync();
3510
+ *
3511
+ * await app.closeTrayIconPopupMenu();
3512
+ * ```
3513
+ */
3514
+ async closeTrayIconPopupMenu() {
3515
+ const { name } = this.wire.me;
3516
+ const entityIdentity = { uuid: this.identity.uuid, name };
3517
+ await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
3518
+ }
3519
+ }
3520
+ Instance$6.Application = Application;
3521
+ return Instance$6;
3771
3522
  }
3772
- Factory$7.ApplicationModule = ApplicationModule;
3773
3523
 
3774
- (function (exports) {
3775
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3776
- if (k2 === undefined) k2 = k;
3777
- var desc = Object.getOwnPropertyDescriptor(m, k);
3778
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3779
- desc = { enumerable: true, get: function() { return m[k]; } };
3780
- }
3781
- Object.defineProperty(o, k2, desc);
3782
- }) : (function(o, m, k, k2) {
3783
- if (k2 === undefined) k2 = k;
3784
- o[k2] = m[k];
3785
- }));
3786
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3787
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3788
- };
3789
- Object.defineProperty(exports, "__esModule", { value: true });
3524
+ var hasRequiredFactory$1;
3525
+
3526
+ function requireFactory$1 () {
3527
+ if (hasRequiredFactory$1) return Factory$7;
3528
+ hasRequiredFactory$1 = 1;
3529
+ Object.defineProperty(Factory$7, "__esModule", { value: true });
3530
+ Factory$7.ApplicationModule = void 0;
3531
+ const base_1 = base;
3532
+ const validate_1 = validate;
3533
+ const Instance_1 = requireInstance$1();
3790
3534
  /**
3791
- * Entry points for the OpenFin `Application` API (`fin.Application`).
3792
- *
3793
- * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3794
- * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3795
- *
3796
- * These are separate code entities, and are documented separately. In the [previous version of the API documentation](https://cdn.openfin.co/docs/javascript/32.114.76.10/index.html),
3797
- * both of these were documented on the same page.
3798
- *
3799
- * @packageDocumentation
3535
+ * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
3800
3536
  */
3801
- __exportStar(Factory$7, exports);
3802
- __exportStar(Instance$6, exports);
3803
- } (application));
3537
+ class ApplicationModule extends base_1.Base {
3538
+ /**
3539
+ * Asynchronously returns an API handle for the given Application identity.
3540
+ *
3541
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3542
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3543
+ * for an Application throughout its entire lifecycle.
3544
+ *
3545
+ * @example
3546
+ *
3547
+ * ```js
3548
+ * fin.Application.wrap({ uuid: 'testapp' })
3549
+ * .then(app => app.isRunning())
3550
+ * .then(running => console.log('Application is running: ' + running))
3551
+ * .catch(err => console.log(err));
3552
+ * ```
3553
+ *
3554
+ */
3555
+ async wrap(identity) {
3556
+ this.wire.recordAnalytic('wrap-application');
3557
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
3558
+ if (errorMsg) {
3559
+ throw new Error(errorMsg);
3560
+ }
3561
+ return new Instance_1.Application(this.wire, identity);
3562
+ }
3563
+ /**
3564
+ * Synchronously returns an API handle for the given Application identity.
3565
+ *
3566
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
3567
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
3568
+ * for an Aplication throughout its entire lifecycle.
3569
+ *
3570
+ * @example
3571
+ *
3572
+ * ```js
3573
+ * const app = fin.Application.wrapSync({ uuid: 'testapp' });
3574
+ * await app.close();
3575
+ * ```
3576
+ *
3577
+ */
3578
+ wrapSync(identity) {
3579
+ this.wire.recordAnalytic('wrap-application-sync');
3580
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
3581
+ if (errorMsg) {
3582
+ throw new Error(errorMsg);
3583
+ }
3584
+ return new Instance_1.Application(this.wire, identity);
3585
+ }
3586
+ async _create(appOptions) {
3587
+ // set defaults:
3588
+ if (appOptions.waitForPageLoad === undefined) {
3589
+ appOptions.waitForPageLoad = false;
3590
+ }
3591
+ if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
3592
+ appOptions.autoShow = true;
3593
+ }
3594
+ await this.wire.sendAction('create-application', appOptions);
3595
+ return this.wrap({ uuid: appOptions.uuid });
3596
+ }
3597
+ /**
3598
+ * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
3599
+ *
3600
+ * @example
3601
+ *
3602
+ * ```js
3603
+ * async function createApp() {
3604
+ * const app = await fin.Application.create({
3605
+ * name: 'myApp',
3606
+ * uuid: 'app-3',
3607
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
3608
+ * autoShow: true
3609
+ * });
3610
+ * await app.run();
3611
+ * }
3612
+ *
3613
+ * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
3614
+ * ```
3615
+ *
3616
+ * @ignore
3617
+ */
3618
+ create(appOptions) {
3619
+ console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
3620
+ this.wire.recordAnalytic('application-create');
3621
+ return this._create(appOptions);
3622
+ }
3623
+ /**
3624
+ * Creates and starts a new Application.
3625
+ *
3626
+ * @example
3627
+ *
3628
+ * ```js
3629
+ * async function start() {
3630
+ * return fin.Application.start({
3631
+ * name: 'app-1',
3632
+ * uuid: 'app-1',
3633
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
3634
+ * autoShow: true
3635
+ * });
3636
+ * }
3637
+ * start().then(() => console.log('Application is running')).catch(err => console.log(err));
3638
+ * ```
3639
+ *
3640
+ */
3641
+ async start(appOptions) {
3642
+ this.wire.recordAnalytic('start-application');
3643
+ const app = await this._create(appOptions);
3644
+ await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
3645
+ return app;
3646
+ }
3647
+ /**
3648
+ * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
3649
+ * Returns once the RVM is finished attempting to launch the applications.
3650
+ * @param opts - Parameters that the RVM will use.
3651
+ *
3652
+ * @example
3653
+ *
3654
+ * ```js
3655
+ *
3656
+ * const applicationInfoArray = [
3657
+ * {
3658
+ * "uuid": 'App-1',
3659
+ * "manifestUrl": 'http://localhost:5555/app1.json',
3660
+ * },
3661
+ * {
3662
+ * "uuid": 'App-2',
3663
+ * "manifestUrl": 'http://localhost:5555/app2.json',
3664
+ * },
3665
+ * {
3666
+ * "uuid": 'App-3',
3667
+ * "manifestUrl": 'http://localhost:5555/app3.json',
3668
+ * }
3669
+ * ]
3670
+ *
3671
+ * fin.Application.startManyManifests(applicationInfoArray)
3672
+ * .then(() => {
3673
+ * console.log('RVM has finished launching the application list.');
3674
+ * })
3675
+ * .catch((err) => {
3676
+ * console.log(err);
3677
+ * })
3678
+ * ```
3679
+ *
3680
+ * @experimental
3681
+ */
3682
+ async startManyManifests(applications, opts) {
3683
+ return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
3684
+ }
3685
+ /**
3686
+ * Asynchronously returns an Application object that represents the current application
3687
+ *
3688
+ * @example
3689
+ *
3690
+ * ```js
3691
+ * async function isCurrentAppRunning () {
3692
+ * const app = await fin.Application.getCurrent();
3693
+ * return app.isRunning();
3694
+ * }
3695
+ *
3696
+ * isCurrentAppRunning().then(running => {
3697
+ * console.log(`Current app is running: ${running}`);
3698
+ * }).catch(err => {
3699
+ * console.error(err);
3700
+ * });
3701
+ *
3702
+ * ```
3703
+ */
3704
+ getCurrent() {
3705
+ this.wire.recordAnalytic('get-current-application');
3706
+ return this.wrap({ uuid: this.wire.me.uuid });
3707
+ }
3708
+ /**
3709
+ * Synchronously returns an Application object that represents the current application
3710
+ *
3711
+ * @example
3712
+ *
3713
+ * ```js
3714
+ * async function isCurrentAppRunning () {
3715
+ * const app = fin.Application.getCurrentSync();
3716
+ * return app.isRunning();
3717
+ * }
3718
+ *
3719
+ * isCurrentAppRunning().then(running => {
3720
+ * console.log(`Current app is running: ${running}`);
3721
+ * }).catch(err => {
3722
+ * console.error(err);
3723
+ * });
3724
+ *
3725
+ * ```
3726
+ */
3727
+ getCurrentSync() {
3728
+ this.wire.recordAnalytic('get-current-application-sync');
3729
+ return this.wrapSync({ uuid: this.wire.me.uuid });
3730
+ }
3731
+ /**
3732
+ * Retrieves application's manifest and returns a running instance of the application.
3733
+ * @param manifestUrl - The URL of app's manifest.
3734
+ * @param opts - Parameters that the RVM will use.
3735
+ *
3736
+ * @example
3737
+ *
3738
+ * ```js
3739
+ * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3740
+ *
3741
+ * // For a local manifest file:
3742
+ * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
3743
+ * ```
3744
+ */
3745
+ async startFromManifest(manifestUrl, opts) {
3746
+ this.wire.recordAnalytic('application-start-from-manifest');
3747
+ const app = await this._createFromManifest(manifestUrl);
3748
+ // @ts-expect-error using private method without warning.
3749
+ await app._run(opts); // eslint-disable-line no-underscore-dangle
3750
+ return app;
3751
+ }
3752
+ /**
3753
+ * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
3754
+ * Retrieves application's manifest and returns a wrapped application.
3755
+ * @param manifestUrl - The URL of app's manifest.
3756
+ * @param callback - called if the method succeeds.
3757
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3758
+ *
3759
+ * @example
3760
+ *
3761
+ * ```js
3762
+ * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
3763
+ * ```
3764
+ * @ignore
3765
+ */
3766
+ createFromManifest(manifestUrl) {
3767
+ console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
3768
+ this.wire.recordAnalytic('application-create-from-manifest');
3769
+ return this._createFromManifest(manifestUrl);
3770
+ }
3771
+ _createFromManifest(manifestUrl) {
3772
+ return this.wire
3773
+ .sendAction('get-application-manifest', { manifestUrl })
3774
+ .then(({ payload }) => {
3775
+ const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
3776
+ return this.wrap({ uuid });
3777
+ })
3778
+ .then((app) => {
3779
+ app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
3780
+ return app;
3781
+ });
3782
+ }
3783
+ }
3784
+ Factory$7.ApplicationModule = ApplicationModule;
3785
+ return Factory$7;
3786
+ }
3787
+
3788
+ var hasRequiredApplication;
3789
+
3790
+ function requireApplication () {
3791
+ if (hasRequiredApplication) return application;
3792
+ hasRequiredApplication = 1;
3793
+ (function (exports) {
3794
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3795
+ if (k2 === undefined) k2 = k;
3796
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3797
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3798
+ desc = { enumerable: true, get: function() { return m[k]; } };
3799
+ }
3800
+ Object.defineProperty(o, k2, desc);
3801
+ }) : (function(o, m, k, k2) {
3802
+ if (k2 === undefined) k2 = k;
3803
+ o[k2] = m[k];
3804
+ }));
3805
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
3806
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3807
+ };
3808
+ Object.defineProperty(exports, "__esModule", { value: true });
3809
+ /**
3810
+ * Entry points for the OpenFin `Application` API (`fin.Application`).
3811
+ *
3812
+ * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
3813
+ * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
3814
+ *
3815
+ * 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),
3816
+ * both of these were documented on the same page.
3817
+ *
3818
+ * @packageDocumentation
3819
+ */
3820
+ __exportStar(requireFactory$1(), exports);
3821
+ __exportStar(requireInstance$1(), exports);
3822
+ } (application));
3823
+ return application;
3824
+ }
3804
3825
 
3805
3826
  var promisifySubscription$1 = {};
3806
3827
 
@@ -3844,7 +3865,7 @@ function requireInstance () {
3844
3865
  /* eslint-disable @typescript-eslint/no-unused-vars */
3845
3866
  /* eslint-disable no-console */
3846
3867
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
3847
- const application_1 = application;
3868
+ const application_1 = requireApplication();
3848
3869
  const main_1 = main;
3849
3870
  const view_1 = requireView();
3850
3871
  const warnings_1 = warnings;
@@ -8417,9 +8438,8 @@ class ChannelProvider extends channel_1.ChannelBase {
8417
8438
  return [...__classPrivateFieldGet$d(this, _ChannelProvider_connections, "f")];
8418
8439
  }
8419
8440
  static handleClientDisconnection(channel, payload) {
8420
- if (payload?.endpointId) {
8421
- const { uuid, name, endpointId, isLocalEndpointId } = payload;
8422
- __classPrivateFieldGet$d(channel, _ChannelProvider_removeEndpoint, "f").call(channel, { uuid, name, endpointId, isLocalEndpointId });
8441
+ if (payload.endpointId) {
8442
+ __classPrivateFieldGet$d(channel, _ChannelProvider_removeEndpoint, "f").call(channel, { endpointId: payload.endpointId });
8423
8443
  }
8424
8444
  else {
8425
8445
  // this is here to support older runtimes that did not have endpointId
@@ -8589,7 +8609,9 @@ class ChannelProvider extends channel_1.ChannelBase {
8589
8609
  * ```
8590
8610
  */
8591
8611
  onDisconnection(listener) {
8592
- this.disconnectListener = listener;
8612
+ this.disconnectListener = (identity) => {
8613
+ listener(identity);
8614
+ };
8593
8615
  }
8594
8616
  /**
8595
8617
  * Destroy the channel, raises `disconnected` events on all connected channel clients.
@@ -8606,7 +8628,6 @@ class ChannelProvider extends channel_1.ChannelBase {
8606
8628
  */
8607
8629
  async destroy() {
8608
8630
  const protectedObj = __classPrivateFieldGet$d(this, _ChannelProvider_protectedObj, "f");
8609
- protectedObj.providerIdentity;
8610
8631
  __classPrivateFieldSet$c(this, _ChannelProvider_connections, [], "f");
8611
8632
  await protectedObj.close();
8612
8633
  __classPrivateFieldGet$d(this, _ChannelProvider_close, "f").call(this);
@@ -8913,7 +8934,7 @@ const base_1$i = base;
8913
8934
  const strategy_1 = strategy$3;
8914
8935
  const strategy_2 = strategy$2;
8915
8936
  const ice_manager_1 = iceManager;
8916
- const provider_1$1 = provider;
8937
+ const provider_1 = provider;
8917
8938
  const message_receiver_1 = messageReceiver;
8918
8939
  const protocol_manager_1 = protocolManager;
8919
8940
  const strategy_3 = __importDefault$6(strategy);
@@ -8935,6 +8956,13 @@ class ConnectionManager extends base_1$i.Base {
8935
8956
  _ConnectionManager_messageReceiver.set(this, void 0);
8936
8957
  _ConnectionManager_rtcConnectionManager.set(this, void 0);
8937
8958
  this.removeChannelFromProviderMap = (channelId) => {
8959
+ const providerEntry = this.providerMap.get(channelId);
8960
+ if (providerEntry) {
8961
+ const { channelName } = providerEntry.providerIdentity;
8962
+ if (this.providerChannelIdByName.get(channelName) === channelId) {
8963
+ this.providerChannelIdByName.delete(channelName);
8964
+ }
8965
+ }
8938
8966
  this.providerMap.delete(channelId);
8939
8967
  };
8940
8968
  this.onmessage = (msg) => {
@@ -8945,6 +8973,7 @@ class ConnectionManager extends base_1$i.Base {
8945
8973
  return false;
8946
8974
  };
8947
8975
  this.providerMap = new Map();
8976
+ this.providerChannelIdByName = new Map();
8948
8977
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
8949
8978
  __classPrivateFieldSet$b(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
8950
8979
  __classPrivateFieldSet$b(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
@@ -8978,14 +9007,16 @@ class ConnectionManager extends base_1$i.Base {
8978
9007
  // Should be impossible.
8979
9008
  throw new Error('failed to combine strategies');
8980
9009
  }
8981
- const channel = new provider_1$1.ChannelProvider(providerIdentity, () => provider_1$1.ChannelProvider.wireClose(this.wire, providerIdentity.channelName), strategy);
9010
+ const channel = new provider_1.ChannelProvider(providerIdentity, () => provider_1.ChannelProvider.wireClose(this.wire, providerIdentity.channelName), strategy);
8982
9011
  const key = providerIdentity.channelId;
8983
9012
  this.providerMap.set(key, {
9013
+ providerIdentity,
8984
9014
  provider: channel,
8985
9015
  strategy,
8986
9016
  supportedProtocols: ConnectionManager.getProtocolOptionsFromStrings(protocols)
8987
9017
  });
8988
- provider_1$1.ChannelProvider.setProviderRemoval(channel, this.removeChannelFromProviderMap.bind(this));
9018
+ this.providerChannelIdByName.set(providerIdentity.channelName, key);
9019
+ provider_1.ChannelProvider.setProviderRemoval(channel, this.removeChannelFromProviderMap.bind(this));
8989
9020
  return channel;
8990
9021
  }
8991
9022
  async createClientOffer(options) {
@@ -9059,6 +9090,16 @@ class ConnectionManager extends base_1$i.Base {
9059
9090
  strategy.addEndpoint(routingInfo.channelId, endpointPayload);
9060
9091
  return strategy;
9061
9092
  }
9093
+ handleClientDisconnection(eventPayload) {
9094
+ const channelId = eventPayload.channelId ?? this.providerChannelIdByName.get(eventPayload.channelName ?? '');
9095
+ if (!channelId) {
9096
+ return;
9097
+ }
9098
+ const providerEntry = this.providerMap.get(channelId);
9099
+ if (providerEntry) {
9100
+ provider_1.ChannelProvider.handleClientDisconnection(providerEntry.provider, eventPayload);
9101
+ }
9102
+ }
9062
9103
  async processChannelConnection(msg) {
9063
9104
  const { clientIdentity, providerIdentity, ackToSender, payload, offer: clientOffer } = msg.payload;
9064
9105
  if (!clientIdentity.endpointId) {
@@ -9078,7 +9119,7 @@ class ConnectionManager extends base_1$i.Base {
9078
9119
  }
9079
9120
  const { provider, strategy, supportedProtocols } = bus;
9080
9121
  try {
9081
- if (!(provider instanceof provider_1$1.ChannelProvider)) {
9122
+ if (!(provider instanceof provider_1.ChannelProvider)) {
9082
9123
  throw Error('Cannot connect to a channel client');
9083
9124
  }
9084
9125
  const offer = clientOffer ?? {
@@ -9159,7 +9200,7 @@ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateF
9159
9200
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
9160
9201
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9161
9202
  };
9162
- var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnect;
9203
+ var _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyForProvider, _Channel_readyToConnect;
9163
9204
  Object.defineProperty(channel$1, "__esModule", { value: true });
9164
9205
  channel$1.Channel = void 0;
9165
9206
  /* eslint-disable no-console */
@@ -9168,7 +9209,6 @@ const lazy_1$2 = lazy;
9168
9209
  const base_1$h = base;
9169
9210
  const client_1 = client;
9170
9211
  const connection_manager_1 = connectionManager;
9171
- const provider_1 = provider;
9172
9212
  function retryDelay(count) {
9173
9213
  const interval = 500; // base delay
9174
9214
  const steps = 10; // How many retries to do before incrementing the delay
@@ -9204,9 +9244,19 @@ class Channel extends base_1$h.EmitterBase {
9204
9244
  super(wire, 'channel');
9205
9245
  _Channel_connectionManager.set(this, void 0);
9206
9246
  _Channel_internalEmitter.set(this, new events_1$5.EventEmitter());
9247
+ // Provider-side disconnect routing setup. This must exist before first create()
9248
+ // so provider onDisconnection callbacks are wired even if connect() is never called.
9249
+ _Channel_readyForProvider.set(this, new lazy_1$2.AsyncRetryableLazy(async () => {
9250
+ // TODO: fix typing (internal)
9251
+ // @ts-expect-error
9252
+ await this.on('client-disconnected', (eventPayload) => {
9253
+ __classPrivateFieldGet$b(this, _Channel_connectionManager, "f").handleClientDisconnection(eventPayload);
9254
+ });
9255
+ }));
9207
9256
  // OpenFin API has not been injected at construction time, *must* wait for API to be ready.
9208
9257
  _Channel_readyToConnect.set(this, new lazy_1$2.AsyncRetryableLazy(async () => {
9209
9258
  await Promise.all([
9259
+ __classPrivateFieldGet$b(this, _Channel_readyForProvider, "f").getValue(),
9210
9260
  this.on('disconnected', (eventPayload) => {
9211
9261
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
9212
9262
  }),
@@ -9463,23 +9513,16 @@ class Channel extends base_1$h.EmitterBase {
9463
9513
  * ```
9464
9514
  */
9465
9515
  async create(channelName, options) {
9516
+ await __classPrivateFieldGet$b(this, _Channel_readyForProvider, "f").getValue();
9466
9517
  if (!channelName) {
9467
9518
  throw new Error('Please provide a channelName to create a channel');
9468
9519
  }
9469
9520
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
9470
- const channel = __classPrivateFieldGet$b(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9471
- // TODO: fix typing (internal)
9472
- // @ts-expect-error
9473
- this.on('client-disconnected', (eventPayload) => {
9474
- if (eventPayload.channelName === channelName) {
9475
- provider_1.ChannelProvider.handleClientDisconnection(channel, eventPayload);
9476
- }
9477
- });
9478
- return channel;
9521
+ return __classPrivateFieldGet$b(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9479
9522
  }
9480
9523
  }
9481
9524
  channel$1.Channel = Channel;
9482
- _Channel_connectionManager = new WeakMap(), _Channel_internalEmitter = new WeakMap(), _Channel_readyToConnect = new WeakMap();
9525
+ _Channel_connectionManager = new WeakMap(), _Channel_internalEmitter = new WeakMap(), _Channel_readyForProvider = new WeakMap(), _Channel_readyToConnect = new WeakMap();
9483
9526
 
9484
9527
  Object.defineProperty(interappbus, "__esModule", { value: true });
9485
9528
  interappbus.InterAppPayload = interappbus.InterApplicationBus = void 0;
@@ -17149,7 +17192,7 @@ const events_1$3 = require$$0;
17149
17192
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
17150
17193
  const index_1 = system;
17151
17194
  const index_2 = requireWindow();
17152
- const index_3 = application;
17195
+ const index_3 = requireApplication();
17153
17196
  const index_4 = interappbus;
17154
17197
  const index_5 = clipboard;
17155
17198
  const index_6 = externalApplication;