@openfin/remote-adapter 44.100.60 → 44.100.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/out/remote-adapter.js +1154 -1133
  2. package/package.json +2 -2
@@ -825,7 +825,7 @@ var __importDefault$7 = (commonjsGlobal && commonjsGlobal.__importDefault) || fu
825
825
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
826
826
  Object.defineProperty(InteropBroker$1, "__esModule", { value: true });
827
827
  InteropBroker$1.InteropBroker = void 0;
828
- const base_1$p = base;
828
+ const base_1$n = base;
829
829
  const SessionContextGroupBroker_1 = __importDefault$7(SessionContextGroupBroker$1);
830
830
  const utils_1$7 = utils$3;
831
831
  const isEqual_1$2 = __importDefault$7(require$$3);
@@ -994,7 +994,7 @@ const defaultContextGroups = [
994
994
  * ---
995
995
  *
996
996
  */
997
- class InteropBroker extends base_1$p.Base {
997
+ class InteropBroker extends base_1$n.Base {
998
998
  /**
999
999
  * @internal
1000
1000
  */
@@ -2551,11 +2551,11 @@ const handleDeprecatedWarnings = (options) => {
2551
2551
  };
2552
2552
  warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
2553
2553
 
2554
- var hasRequiredFactory$1;
2554
+ var hasRequiredFactory$2;
2555
2555
 
2556
- function requireFactory$1 () {
2557
- if (hasRequiredFactory$1) return Factory$8;
2558
- hasRequiredFactory$1 = 1;
2556
+ function requireFactory$2 () {
2557
+ if (hasRequiredFactory$2) return Factory$8;
2558
+ hasRequiredFactory$2 = 1;
2559
2559
  Object.defineProperty(Factory$8, "__esModule", { value: true });
2560
2560
  Factory$8.ViewModule = void 0;
2561
2561
  const base_1 = base;
@@ -2714,8 +2714,8 @@ var main = {};
2714
2714
 
2715
2715
  Object.defineProperty(main, "__esModule", { value: true });
2716
2716
  main.WebContents = void 0;
2717
- const base_1$o = base;
2718
- class WebContents extends base_1$o.EmitterBase {
2717
+ const base_1$m = base;
2718
+ class WebContents extends base_1$m.EmitterBase {
2719
2719
  /**
2720
2720
  * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
2721
2721
  * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
@@ -3808,1133 +3808,1154 @@ var Factory$6 = {};
3808
3808
 
3809
3809
  var Instance$5 = {};
3810
3810
 
3811
- Object.defineProperty(Instance$5, "__esModule", { value: true });
3812
- Instance$5.Application = void 0;
3813
- /* eslint-disable import/prefer-default-export */
3814
- const base_1$n = base;
3815
- const window_1$1 = requireWindow();
3816
- const view_1 = requireView();
3817
- /**
3818
- * An object representing an application. Allows the developer to create,
3819
- * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
3820
- */
3821
- class Application extends base_1$n.EmitterBase {
3822
- /**
3823
- * @internal
3824
- */
3825
- constructor(wire, identity) {
3826
- super(wire, 'application', identity.uuid);
3827
- this.identity = identity;
3828
- this.window = new window_1$1._Window(this.wire, {
3829
- uuid: this.identity.uuid,
3830
- name: this.identity.uuid
3831
- });
3832
- }
3833
- windowListFromIdentityList(identityList) {
3834
- const windowList = [];
3835
- identityList.forEach((identity) => {
3836
- windowList.push(new window_1$1._Window(this.wire, {
3837
- uuid: identity.uuid,
3838
- name: identity.name
3839
- }));
3840
- });
3841
- return windowList;
3842
- }
3843
- /**
3844
- * Determines if the application is currently running.
3845
- *
3846
- * @example
3847
- *
3848
- * ```js
3849
- * async function isAppRunning() {
3850
- * const app = await fin.Application.getCurrent();
3851
- * return await app.isRunning();
3852
- * }
3853
- * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
3854
- * ```
3855
- */
3856
- isRunning() {
3857
- return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
3858
- }
3859
- /**
3860
- * Closes the application and any child windows created by the application.
3861
- * Cleans the application from state so it is no longer found in getAllApplications.
3862
- * @param force Close will be prevented from closing when force is false and
3863
- * ‘close-requested’ has been subscribed to for application’s main window.
3864
- *
3865
- * @example
3866
- *
3867
- * ```js
3868
- * async function closeApp() {
3869
- * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
3870
- * const app = await fin.Application.wrap({uuid: 'app2'});
3871
- * await app.quit();
3872
- * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
3873
- *
3874
- * }
3875
- * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
3876
- * ```
3877
- */
3878
- async quit(force = false) {
3879
- try {
3880
- await this._close(force);
3881
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
3882
- }
3883
- catch (error) {
3884
- const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
3885
- if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
3886
- throw error;
3887
- }
3888
- }
3889
- }
3890
- async _close(force = false) {
3891
- try {
3892
- await this.wire.sendAction('close-application', { force, ...this.identity });
3893
- }
3894
- catch (error) {
3895
- if (!error.message.includes('Remote connection has closed')) {
3896
- throw error;
3897
- }
3898
- }
3899
- }
3900
- /**
3901
- * @deprecated use Application.quit instead
3902
- * Closes the application and any child windows created by the application.
3903
- * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
3904
- * @param callback - called if the method succeeds.
3905
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3906
- *
3907
- * @example
3908
- *
3909
- * ```js
3910
- * async function closeApp() {
3911
- * const app = await fin.Application.getCurrent();
3912
- * return await app.close();
3913
- * }
3914
- * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
3915
- * ```
3916
- */
3917
- close(force = false) {
3918
- console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
3919
- this.wire.sendAction('application-close', this.identity).catch((e) => {
3920
- // we do not want to expose this error, just continue if this analytics-only call fails
3921
- });
3922
- return this._close(force);
3923
- }
3924
- /**
3925
- * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
3926
- *
3927
- * @example
3928
- *
3929
- * ```js
3930
- * async function getChildWindows() {
3931
- * const app = await fin.Application.getCurrent();
3932
- * return await app.getChildWindows();
3933
- * }
3934
- *
3935
- * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
3936
- * ```
3937
- */
3938
- getChildWindows() {
3939
- return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
3940
- const identityList = [];
3941
- payload.data.forEach((winName) => {
3942
- identityList.push({ uuid: this.identity.uuid, name: winName });
3943
- });
3944
- return this.windowListFromIdentityList(identityList);
3945
- });
3946
- }
3947
- /**
3948
- * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
3949
- * if the application was not created from a manifest.
3950
- *
3951
- * @example
3952
- *
3953
- * ```js
3954
- * async function getManifest() {
3955
- * const app = await fin.Application.getCurrent();
3956
- * return await app.getManifest();
3957
- * }
3958
- *
3959
- * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
3960
- * ```
3961
- */
3962
- getManifest() {
3963
- return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
3964
- }
3965
- /**
3966
- * Retrieves UUID of the application that launches this application. Invokes the error callback
3967
- * if the application was created from a manifest.
3968
- *
3969
- * @example
3970
- *
3971
- * ```js
3972
- * async function getParentUuid() {
3973
- * const app = await fin.Application.start({
3974
- * uuid: 'app-1',
3975
- * name: 'myApp',
3976
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
3977
- * autoShow: true
3978
- * });
3979
- * return await app.getParentUuid();
3980
- * }
3981
- *
3982
- * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
3983
- * ```
3984
- */
3985
- getParentUuid() {
3986
- return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
3987
- }
3988
- /**
3989
- * Retrieves current application's shortcut configuration.
3990
- *
3991
- * @example
3992
- *
3993
- * ```js
3994
- * async function getShortcuts() {
3995
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3996
- * return await app.getShortcuts();
3997
- * }
3998
- * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
3999
- * ```
4000
- */
4001
- getShortcuts() {
4002
- return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
4003
- }
4004
- /**
4005
- * Retrieves current application's views.
4006
- * @experimental
4007
- *
4008
- * @example
4009
- *
4010
- * ```js
4011
- * async function getViews() {
4012
- * const app = await fin.Application.getCurrent();
4013
- * return await app.getViews();
4014
- * }
4015
- * getViews().then(views => console.log(views)).catch(err => console.log(err));
4016
- * ```
4017
- */
4018
- async getViews() {
4019
- const { payload } = await this.wire.sendAction('application-get-views', this.identity);
4020
- return payload.data.map((id) => new view_1.View(this.wire, id));
4021
- }
4022
- /**
4023
- * Returns the current zoom level of the application.
4024
- *
4025
- * @example
4026
- *
4027
- * ```js
4028
- * async function getZoomLevel() {
4029
- * const app = await fin.Application.getCurrent();
4030
- * return await app.getZoomLevel();
4031
- * }
4032
- *
4033
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
4034
- * ```
4035
- */
4036
- getZoomLevel() {
4037
- return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
4038
- }
4039
- /**
4040
- * Returns an instance of the main Window of the application
4041
- *
4042
- * @example
4043
- *
4044
- * ```js
4045
- * async function getWindow() {
4046
- * const app = await fin.Application.start({
4047
- * uuid: 'app-1',
4048
- * name: 'myApp',
4049
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
4050
- * autoShow: true
4051
- * });
4052
- * return await app.getWindow();
4053
- * }
4054
- *
4055
- * getWindow().then(win => {
4056
- * win.showAt(0, 400);
4057
- * win.flash();
4058
- * }).catch(err => console.log(err));
4059
- * ```
4060
- */
4061
- getWindow() {
4062
- this.wire.sendAction('application-get-window', this.identity).catch((e) => {
4063
- // we do not want to expose this error, just continue if this analytics-only call fails
4064
- });
4065
- return Promise.resolve(this.window);
4066
- }
4067
- /**
4068
- * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
4069
- * @param userName - username to be passed to the RVM.
4070
- * @param appName - app name to be passed to the RVM.
4071
- *
4072
- * @example
4073
- *
4074
- * ```js
4075
- * async function registerUser() {
4076
- * const app = await fin.Application.getCurrent();
4077
- * return await app.registerUser('user', 'myApp');
4078
- * }
4079
- *
4080
- * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
4081
- * ```
4082
- */
4083
- registerUser(userName, appName) {
4084
- return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
4085
- }
4086
- /**
4087
- * Removes the application’s icon from the tray.
4088
- *
4089
- * @example
4090
- *
4091
- * ```js
4092
- * async function removeTrayIcon() {
4093
- * const app = await fin.Application.getCurrent();
4094
- * return await app.removeTrayIcon();
4095
- * }
4096
- *
4097
- * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
4098
- * ```
4099
- */
4100
- removeTrayIcon() {
4101
- return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
4102
- }
4103
- /**
4104
- * Restarts the application.
4105
- *
4106
- * @example
4107
- *
4108
- * ```js
4109
- * async function restartApp() {
4110
- * const app = await fin.Application.getCurrent();
4111
- * return await app.restart();
4112
- * }
4113
- * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
4114
- * ```
4115
- */
4116
- restart() {
4117
- return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
4118
- }
4119
- /**
4120
- * DEPRECATED method to run the application.
4121
- * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
4122
- *
4123
- * @example
4124
- *
4125
- * ```js
4126
- * async function run() {
4127
- * const app = await fin.Application.create({
4128
- * name: 'myApp',
4129
- * uuid: 'app-1',
4130
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
4131
- * autoShow: true
4132
- * });
4133
- * await app.run();
4134
- * }
4135
- * run().then(() => console.log('Application is running')).catch(err => console.log(err));
4136
- * ```
4137
- *
4138
- * @ignore
4139
- */
4140
- run() {
4141
- console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
4142
- this.wire.sendAction('application-run', this.identity).catch((e) => {
4143
- // we do not want to expose this error, just continue if this analytics-only call fails
4144
- });
4145
- return this._run();
4146
- }
4147
- _run(opts = {}) {
4148
- return this.wire
4149
- .sendAction('run-application', {
4150
- manifestUrl: this._manifestUrl,
4151
- opts,
4152
- ...this.identity
4153
- })
4154
- .then(() => undefined);
4155
- }
4156
- /**
4157
- * Instructs the RVM to schedule one restart of the application.
4158
- *
4159
- * @example
4160
- *
4161
- * ```js
4162
- * async function scheduleRestart() {
4163
- * const app = await fin.Application.getCurrent();
4164
- * return await app.scheduleRestart();
4165
- * }
4166
- *
4167
- * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
4168
- * ```
4169
- */
4170
- scheduleRestart() {
4171
- return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
4172
- }
4173
- /**
4174
- * Sends a message to the RVM to upload the application's logs. On success,
4175
- * an object containing logId is returned.
4176
- *
4177
- * @example
4178
- *
4179
- * ```js
4180
- * async function sendLog() {
4181
- * const app = await fin.Application.getCurrent();
4182
- * return await app.sendApplicationLog();
4183
- * }
4184
- *
4185
- * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
4186
- * ```
4187
- */
4188
- async sendApplicationLog() {
4189
- const { payload } = await this.wire.sendAction('send-application-log', this.identity);
4190
- return payload.data;
4191
- }
4192
- /**
4193
- * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
4194
- * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
4195
- *
4196
- * Note: If the "name" property is omitted it defaults to "tasks".
4197
- * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
4198
- *
4199
- *
4200
- * @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).
4201
- *
4202
- * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
4203
- * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
4204
- *
4205
- * Note: If the "name" property is omitted it defaults to "tasks".
4206
- *
4207
- * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
4208
- * uuid or shortcut.name is changed.
4209
- *
4210
- * @example
4211
- *
4212
- * ```js
4213
- * const app = fin.Application.getCurrentSync();
4214
- * const appName = 'My App';
4215
- * const jumpListConfig = [ // array of JumpList categories
4216
- * {
4217
- * // has no name and no type so `type` is assumed to be "tasks"
4218
- * items: [ // array of JumpList items
4219
- * {
4220
- * type: 'task',
4221
- * title: `Launch ${appName}`,
4222
- * description: `Runs ${appName} with the default configuration`,
4223
- * deepLink: 'fins://path.to/app/manifest.json',
4224
- * iconPath: 'https://path.to/app/icon.ico',
4225
- * iconIndex: 0
4226
- * },
4227
- * { type: 'separator' },
4228
- * {
4229
- * type: 'task',
4230
- * title: `Restore ${appName}`,
4231
- * description: 'Restore to last configuration',
4232
- * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
4233
- * iconPath: 'https://path.to/app/icon.ico',
4234
- * iconIndex: 0
4235
- * },
4236
- * ]
4237
- * },
4238
- * {
4239
- * name: 'Tools',
4240
- * items: [ // array of JumpList items
4241
- * {
4242
- * type: 'task',
4243
- * title: 'Tool A',
4244
- * description: 'Runs Tool A',
4245
- * deepLink: 'fins://path.to/tool-a/manifest.json',
4246
- * iconPath: 'https://path.to/tool-a/icon.ico',
4247
- * iconIndex: 0
4248
- * },
4249
- * {
4250
- * type: 'task',
4251
- * title: 'Tool B',
4252
- * description: 'Runs Tool B',
4253
- * deepLink: 'fins://path.to/tool-b/manifest.json',
4254
- * iconPath: 'https://path.to/tool-b/icon.ico',
4255
- * iconIndex: 0
4256
- * }]
4257
- * }
4258
- * ];
4259
- *
4260
- * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
4261
- * ```
4262
- *
4263
- * To handle deeplink args:
4264
- * ```js
4265
- * function handleUseLastConfiguration() {
4266
- * // this handler is called when the app is being launched
4267
- * app.on('run-requested', event => {
4268
- * if(event.userAppConfigArgs['use-last-configuration']) {
4269
- * // your logic here
4270
- * }
4271
- * });
4272
- * // this handler is called when the app was already running when the launch was requested
4273
- * fin.desktop.main(function(args) {
4274
- * if(args && args['use-last-configuration']) {
4275
- * // your logic here
4276
- * }
4277
- * });
4278
- * }
4279
- * ```
4280
- */
4281
- async setJumpList(jumpListCategories) {
4282
- await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
4283
- }
4284
- /**
4285
- * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
4286
- * @param icon Image URL or base64 encoded string to be used as the icon
4287
- *
4288
- * @example
4289
- *
4290
- * ```js
4291
- * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
4292
- * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
4293
- * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
4294
- * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
4295
- * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
4296
- *
4297
- * async function setTrayIcon(icon) {
4298
- * const app = await fin.Application.getCurrent();
4299
- * return await app.setTrayIcon(icon);
4300
- * }
4301
- *
4302
- * // use image url to set tray icon
4303
- * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
4304
- *
4305
- * // use base64 encoded string to set tray icon
4306
- * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
4307
- *
4308
- * // use a dataURL to set tray icon
4309
- * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
4310
- * ```
4311
- */
4312
- setTrayIcon(icon) {
4313
- return this.wire
4314
- .sendAction('set-tray-icon', {
4315
- enabledIcon: icon,
4316
- ...this.identity
4317
- })
4318
- .then(() => undefined);
4319
- }
4320
- /**
4321
- * Set hover text for this application's system tray icon.
4322
- * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
4323
- * @param toolTip
4324
- *
4325
- * @example
4326
- *
4327
- * ```js
4328
- * const app = fin.Application.getCurrentSync();
4329
- * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
4330
- *
4331
- * await app.setTrayIcon(iconUrl);
4332
- *
4333
- * await app.setTrayIconToolTip('My Application');
4334
- * ```
4335
- */
4336
- async setTrayIconToolTip(toolTip) {
4337
- await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
4338
- }
4339
- /**
4340
- * Sets new application's shortcut configuration. Windows only.
4341
- * @param config New application's shortcut configuration.
4342
- *
4343
- * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
4344
- * to be able to change shortcut states.
4345
- *
4346
- * @example
4347
- *
4348
- * ```js
4349
- * async function setShortcuts(config) {
4350
- * const app = await fin.Application.getCurrent();
4351
- * return app.setShortcuts(config);
4352
- * }
4353
- *
4354
- * setShortcuts({
4355
- * desktop: true,
4356
- * startMenu: false,
4357
- * systemStartup: true
4358
- * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
4359
- * ```
4360
- */
4361
- setShortcuts(config) {
4362
- return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
4363
- }
4364
- /**
4365
- * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
4366
- * @param queryString The new query string for this app's shortcuts.
4367
- *
4368
- * @example
4369
- *
4370
- * ```js
4371
- * const newQueryArgs = 'arg=true&arg2=false';
4372
- * const app = await fin.Application.getCurrent();
4373
- * try {
4374
- * await app.setShortcutQueryParams(newQueryArgs);
4375
- * } catch(err) {
4376
- * console.error(err)
4377
- * }
4378
- * ```
4379
- */
4380
- async setShortcutQueryParams(queryString) {
4381
- await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
4382
- }
4383
- /**
4384
- * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
4385
- * larger or smaller to default limits of 300% and 50% of original size, respectively.
4386
- * @param level The zoom level
4387
- *
4388
- * @example
4389
- *
4390
- * ```js
4391
- * async function setZoomLevel(number) {
4392
- * const app = await fin.Application.getCurrent();
4393
- * return await app.setZoomLevel(number);
4394
- * }
4395
- *
4396
- * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
4397
- * ```
4398
- */
4399
- setZoomLevel(level) {
4400
- return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
4401
- }
4402
- /**
4403
- * Sets a username to correlate with App Log Management.
4404
- * @param username Username to correlate with App's Log.
4405
- *
4406
- * @example
4407
- *
4408
- * ```js
4409
- * async function setAppLogUser() {
4410
- * const app = await fin.Application.getCurrent();
4411
- * return await app.setAppLogUsername('username');
4412
- * }
4413
- *
4414
- * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
4415
- *
4416
- * ```
4417
- */
4418
- async setAppLogUsername(username) {
4419
- await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
4420
- }
4421
- /**
4422
- * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
4423
- * @remarks The only information currently returned is the position and dimensions.
4424
- *
4425
- * @example
4426
- *
4427
- * ```js
4428
- * async function getTrayIconInfo() {
4429
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
4430
- * return await app.getTrayIconInfo();
4431
- * }
4432
- * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
4433
- * ```
4434
- */
4435
- getTrayIconInfo() {
4436
- return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
4437
- }
4438
- /**
4439
- * Checks if the application has an associated tray icon.
4440
- *
4441
- * @example
4442
- *
4443
- * ```js
4444
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
4445
- * const hasTrayIcon = await app.hasTrayIcon();
4446
- * console.log(hasTrayIcon);
4447
- * ```
4448
- */
4449
- hasTrayIcon() {
4450
- return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
4451
- }
4452
- /**
4453
- * Closes the application by terminating its process.
4454
- *
4455
- * @example
4456
- *
4457
- * ```js
4458
- * async function terminateApp() {
4459
- * const app = await fin.Application.getCurrent();
4460
- * return await app.terminate();
4461
- * }
4462
- * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
4463
- * ```
4464
- */
4465
- terminate() {
4466
- return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
4467
- }
4468
- /**
4469
- * Waits for a hanging application. This method can be called in response to an application
4470
- * "not-responding" to allow the application to continue and to generate another "not-responding"
4471
- * message after a certain period of time.
4472
- *
4473
- * @ignore
4474
- */
4475
- wait() {
4476
- return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
4477
- }
4478
- /**
4479
- * Retrieves information about the application.
4480
- *
4481
- * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
4482
- * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
4483
- * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
4484
- *
4485
- * @example
4486
- *
4487
- * ```js
4488
- * async function getInfo() {
4489
- * const app = await fin.Application.getCurrent();
4490
- * return await app.getInfo();
4491
- * }
4492
- *
4493
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
4494
- * ```
4495
- */
4496
- getInfo() {
4497
- return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
4498
- }
4499
- /**
4500
- * Retrieves all process information for entities (windows and views) associated with an application.
4501
- *
4502
- * @example
4503
- * ```js
4504
- * const app = await fin.Application.getCurrent();
4505
- * const processInfo = await app.getProcessInfo();
4506
- * ```
4507
- * @experimental
4508
- */
4509
- async getProcessInfo() {
4510
- const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
4511
- return data;
4512
- }
4513
- /**
4514
- * Sets file auto download location. It's only allowed in the same application.
4515
- *
4516
- * Note: This method is restricted by default and must be enabled via
4517
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
4518
- * @param downloadLocation file auto download location
4519
- *
4520
- * @throws if setting file auto download location on different applications.
4521
- * @example
4522
- *
4523
- * ```js
4524
- * const downloadLocation = 'C:\\dev\\temp';
4525
- * const app = await fin.Application.getCurrent();
4526
- * try {
4527
- * await app.setFileDownloadLocation(downloadLocation);
4528
- * console.log('File download location is set');
4529
- * } catch(err) {
4530
- * console.error(err)
4531
- * }
4532
- * ```
4533
- */
4534
- async setFileDownloadLocation(downloadLocation) {
4535
- const { name } = this.wire.me;
4536
- const entityIdentity = { uuid: this.identity.uuid, name };
4537
- await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
4538
- }
4539
- /**
4540
- * 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.
4541
- *
4542
- * Note: This method is restricted by default and must be enabled via
4543
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
4544
- *
4545
- * @throws if getting file auto download location on different applications.
4546
- * @example
4547
- *
4548
- * ```js
4549
- * const app = await fin.Application.getCurrent();
4550
- * const fileDownloadDir = await app.getFileDownloadLocation();
4551
- * ```
4552
- */
4553
- async getFileDownloadLocation() {
4554
- const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
4555
- return data;
4556
- }
4557
- /**
4558
- * Shows a menu on the tray icon. Use with tray-icon-clicked event.
4559
- * @param options
4560
- * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
4561
- * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
4562
- * of all possible data shapes for the entire menu, and the click handler should process
4563
- * these with a "reducer" pattern.
4564
- * @throws if the application has no tray icon set
4565
- * @throws if the system tray is currently hidden
4566
- * @example
4567
- *
4568
- * ```js
4569
- * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
4570
- * const app = fin.Application.getCurrentSync();
4571
- *
4572
- * await app.setTrayIcon(iconUrl);
4573
- *
4574
- * const template = [
4575
- * {
4576
- * label: 'Menu Item 1',
4577
- * data: 'hello from item 1'
4578
- * },
4579
- * { type: 'separator' },
4580
- * {
4581
- * label: 'Menu Item 2',
4582
- * type: 'checkbox',
4583
- * checked: true,
4584
- * data: 'The user clicked the checkbox'
4585
- * },
4586
- * {
4587
- * label: 'see more',
4588
- * enabled: false,
4589
- * submenu: [
4590
- * { label: 'submenu 1', data: 'hello from submenu' }
4591
- * ]
4592
- * }
4593
- * ];
4594
- *
4595
- * app.addListener('tray-icon-clicked', (event) => {
4596
- * // right-click
4597
- * if (event.button === 2) {
4598
- * app.showTrayIconPopupMenu({ template }).then(r => {
4599
- * if (r.result === 'closed') {
4600
- * console.log('nothing happened');
4601
- * } else {
4602
- * console.log(r.data);
4603
- * }
4604
- * });
4605
- * }
4606
- * });
4607
- * ```
4608
- */
4609
- async showTrayIconPopupMenu(options) {
4610
- const { name } = this.wire.me;
4611
- const entityIdentity = { uuid: this.identity.uuid, name };
4612
- const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
4613
- return payload.data;
4614
- }
4615
- /**
4616
- * Closes the tray icon menu.
4617
- *
4618
- * @throws if the application has no tray icon set
4619
- * @example
4620
- *
4621
- * ```js
4622
- * const app = fin.Application.getCurrentSync();
4623
- *
4624
- * await app.closeTrayIconPopupMenu();
4625
- * ```
4626
- */
4627
- async closeTrayIconPopupMenu() {
4628
- const { name } = this.wire.me;
4629
- const entityIdentity = { uuid: this.identity.uuid, name };
4630
- await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
4631
- }
4632
- }
4633
- Instance$5.Application = Application;
3811
+ var hasRequiredInstance$2;
4634
3812
 
4635
- Object.defineProperty(Factory$6, "__esModule", { value: true });
4636
- Factory$6.ApplicationModule = void 0;
4637
- const base_1$m = base;
4638
- const validate_1$4 = validate;
4639
- const Instance_1$5 = Instance$5;
4640
- /**
4641
- * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
4642
- */
4643
- class ApplicationModule extends base_1$m.Base {
4644
- /**
4645
- * Asynchronously returns an API handle for the given Application identity.
4646
- *
4647
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4648
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4649
- * for an Application throughout its entire lifecycle.
4650
- *
4651
- * @example
4652
- *
4653
- * ```js
4654
- * fin.Application.wrap({ uuid: 'testapp' })
4655
- * .then(app => app.isRunning())
4656
- * .then(running => console.log('Application is running: ' + running))
4657
- * .catch(err => console.log(err));
4658
- * ```
4659
- *
4660
- */
4661
- async wrap(identity) {
4662
- this.wire.sendAction('wrap-application').catch((e) => {
4663
- // we do not want to expose this error, just continue if this analytics-only call fails
4664
- });
4665
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
4666
- if (errorMsg) {
4667
- throw new Error(errorMsg);
4668
- }
4669
- return new Instance_1$5.Application(this.wire, identity);
4670
- }
4671
- /**
4672
- * Synchronously returns an API handle for the given Application identity.
4673
- *
4674
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4675
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4676
- * for an Aplication throughout its entire lifecycle.
4677
- *
4678
- * @example
4679
- *
4680
- * ```js
4681
- * const app = fin.Application.wrapSync({ uuid: 'testapp' });
4682
- * await app.close();
4683
- * ```
4684
- *
4685
- */
4686
- wrapSync(identity) {
4687
- this.wire.sendAction('wrap-application-sync').catch((e) => {
4688
- // we do not want to expose this error, just continue if this analytics-only call fails
4689
- });
4690
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
4691
- if (errorMsg) {
4692
- throw new Error(errorMsg);
4693
- }
4694
- return new Instance_1$5.Application(this.wire, identity);
4695
- }
4696
- async _create(appOptions) {
4697
- // set defaults:
4698
- if (appOptions.waitForPageLoad === undefined) {
4699
- appOptions.waitForPageLoad = false;
4700
- }
4701
- if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
4702
- appOptions.autoShow = true;
4703
- }
4704
- await this.wire.sendAction('create-application', appOptions);
4705
- return this.wrap({ uuid: appOptions.uuid });
4706
- }
4707
- /**
4708
- * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
4709
- *
4710
- * @example
4711
- *
4712
- * ```js
4713
- * async function createApp() {
4714
- * const app = await fin.Application.create({
4715
- * name: 'myApp',
4716
- * uuid: 'app-3',
4717
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
4718
- * autoShow: true
4719
- * });
4720
- * await app.run();
4721
- * }
4722
- *
4723
- * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
4724
- * ```
4725
- *
4726
- * @ignore
4727
- */
4728
- create(appOptions) {
4729
- console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
4730
- this.wire.sendAction('application-create').catch((e) => {
4731
- // we do not want to expose this error, just continue if this analytics-only call fails
4732
- });
4733
- return this._create(appOptions);
4734
- }
4735
- /**
4736
- * Creates and starts a new Application.
4737
- *
4738
- * @example
4739
- *
4740
- * ```js
4741
- * async function start() {
4742
- * return fin.Application.start({
4743
- * name: 'app-1',
4744
- * uuid: 'app-1',
4745
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
4746
- * autoShow: true
4747
- * });
4748
- * }
4749
- * start().then(() => console.log('Application is running')).catch(err => console.log(err));
4750
- * ```
4751
- *
4752
- */
4753
- async start(appOptions) {
4754
- this.wire.sendAction('start-application').catch((e) => {
4755
- // we do not want to expose this error, just continue if this analytics-only call fails
4756
- });
4757
- const app = await this._create(appOptions);
4758
- await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
4759
- return app;
4760
- }
4761
- /**
4762
- * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
4763
- * Returns once the RVM is finished attempting to launch the applications.
4764
- * @param opts - Parameters that the RVM will use.
4765
- *
4766
- * @example
4767
- *
4768
- * ```js
4769
- *
4770
- * const applicationInfoArray = [
4771
- * {
4772
- * "uuid": 'App-1',
4773
- * "manifestUrl": 'http://localhost:5555/app1.json',
4774
- * },
4775
- * {
4776
- * "uuid": 'App-2',
4777
- * "manifestUrl": 'http://localhost:5555/app2.json',
4778
- * },
4779
- * {
4780
- * "uuid": 'App-3',
4781
- * "manifestUrl": 'http://localhost:5555/app3.json',
4782
- * }
4783
- * ]
4784
- *
4785
- * fin.Application.startManyManifests(applicationInfoArray)
4786
- * .then(() => {
4787
- * console.log('RVM has finished launching the application list.');
4788
- * })
4789
- * .catch((err) => {
4790
- * console.log(err);
4791
- * })
4792
- * ```
4793
- *
4794
- * @experimental
4795
- */
4796
- async startManyManifests(applications, opts) {
4797
- return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
4798
- }
4799
- /**
4800
- * Asynchronously returns an Application object that represents the current application
4801
- *
4802
- * @example
4803
- *
4804
- * ```js
4805
- * async function isCurrentAppRunning () {
4806
- * const app = await fin.Application.getCurrent();
4807
- * return app.isRunning();
4808
- * }
4809
- *
4810
- * isCurrentAppRunning().then(running => {
4811
- * console.log(`Current app is running: ${running}`);
4812
- * }).catch(err => {
4813
- * console.error(err);
4814
- * });
4815
- *
4816
- * ```
4817
- */
4818
- getCurrent() {
4819
- this.wire.sendAction('get-current-application').catch((e) => {
4820
- // we do not want to expose this error, just continue if this analytics-only call fails
4821
- });
4822
- return this.wrap({ uuid: this.wire.me.uuid });
4823
- }
4824
- /**
4825
- * Synchronously returns an Application object that represents the current application
4826
- *
4827
- * @example
4828
- *
4829
- * ```js
4830
- * async function isCurrentAppRunning () {
4831
- * const app = fin.Application.getCurrentSync();
4832
- * return app.isRunning();
4833
- * }
4834
- *
4835
- * isCurrentAppRunning().then(running => {
4836
- * console.log(`Current app is running: ${running}`);
4837
- * }).catch(err => {
4838
- * console.error(err);
4839
- * });
4840
- *
4841
- * ```
4842
- */
4843
- getCurrentSync() {
4844
- this.wire.sendAction('get-current-application-sync').catch((e) => {
4845
- // we do not want to expose this error, just continue if this analytics-only call fails
4846
- });
4847
- return this.wrapSync({ uuid: this.wire.me.uuid });
4848
- }
4849
- /**
4850
- * Retrieves application's manifest and returns a running instance of the application.
4851
- * @param manifestUrl - The URL of app's manifest.
4852
- * @param opts - Parameters that the RVM will use.
4853
- *
4854
- * @example
4855
- *
4856
- * ```js
4857
- * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4858
- *
4859
- * // For a local manifest file:
4860
- * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4861
- * ```
4862
- */
4863
- async startFromManifest(manifestUrl, opts) {
4864
- this.wire.sendAction('application-start-from-manifest').catch((e) => {
4865
- // we do not want to expose this error, just continue if this analytics-only call fails
4866
- });
4867
- const app = await this._createFromManifest(manifestUrl);
4868
- // @ts-expect-error using private method without warning.
4869
- await app._run(opts); // eslint-disable-line no-underscore-dangle
4870
- return app;
4871
- }
4872
- /**
4873
- * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
4874
- * Retrieves application's manifest and returns a wrapped application.
4875
- * @param manifestUrl - The URL of app's manifest.
4876
- * @param callback - called if the method succeeds.
4877
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
4878
- *
4879
- * @example
4880
- *
4881
- * ```js
4882
- * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
4883
- * ```
4884
- * @ignore
4885
- */
4886
- createFromManifest(manifestUrl) {
4887
- console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
4888
- this.wire.sendAction('application-create-from-manifest').catch((e) => {
4889
- // we do not want to expose this error, just continue if this analytics-only call fails
4890
- });
4891
- return this._createFromManifest(manifestUrl);
4892
- }
4893
- _createFromManifest(manifestUrl) {
4894
- return this.wire
4895
- .sendAction('get-application-manifest', { manifestUrl })
4896
- .then(({ payload }) => {
4897
- const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
4898
- return this.wrap({ uuid });
4899
- })
4900
- .then((app) => {
4901
- app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
4902
- return app;
4903
- });
4904
- }
3813
+ function requireInstance$2 () {
3814
+ if (hasRequiredInstance$2) return Instance$5;
3815
+ hasRequiredInstance$2 = 1;
3816
+ Object.defineProperty(Instance$5, "__esModule", { value: true });
3817
+ Instance$5.Application = void 0;
3818
+ /* eslint-disable import/prefer-default-export */
3819
+ const base_1 = base;
3820
+ const window_1 = requireWindow();
3821
+ const view_1 = requireView();
3822
+ /**
3823
+ * An object representing an application. Allows the developer to create,
3824
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
3825
+ */
3826
+ class Application extends base_1.EmitterBase {
3827
+ /**
3828
+ * @internal
3829
+ */
3830
+ constructor(wire, identity) {
3831
+ super(wire, 'application', identity.uuid);
3832
+ this.identity = identity;
3833
+ this.window = new window_1._Window(this.wire, {
3834
+ uuid: this.identity.uuid,
3835
+ name: this.identity.uuid
3836
+ });
3837
+ }
3838
+ windowListFromIdentityList(identityList) {
3839
+ const windowList = [];
3840
+ identityList.forEach((identity) => {
3841
+ windowList.push(new window_1._Window(this.wire, {
3842
+ uuid: identity.uuid,
3843
+ name: identity.name
3844
+ }));
3845
+ });
3846
+ return windowList;
3847
+ }
3848
+ /**
3849
+ * Determines if the application is currently running.
3850
+ *
3851
+ * @example
3852
+ *
3853
+ * ```js
3854
+ * async function isAppRunning() {
3855
+ * const app = await fin.Application.getCurrent();
3856
+ * return await app.isRunning();
3857
+ * }
3858
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
3859
+ * ```
3860
+ */
3861
+ isRunning() {
3862
+ return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
3863
+ }
3864
+ /**
3865
+ * Closes the application and any child windows created by the application.
3866
+ * Cleans the application from state so it is no longer found in getAllApplications.
3867
+ * @param force Close will be prevented from closing when force is false and
3868
+ * ‘close-requested’ has been subscribed to for application’s main window.
3869
+ *
3870
+ * @example
3871
+ *
3872
+ * ```js
3873
+ * async function closeApp() {
3874
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
3875
+ * const app = await fin.Application.wrap({uuid: 'app2'});
3876
+ * await app.quit();
3877
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
3878
+ *
3879
+ * }
3880
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
3881
+ * ```
3882
+ */
3883
+ async quit(force = false) {
3884
+ try {
3885
+ await this._close(force);
3886
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
3887
+ }
3888
+ catch (error) {
3889
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
3890
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
3891
+ throw error;
3892
+ }
3893
+ }
3894
+ }
3895
+ async _close(force = false) {
3896
+ try {
3897
+ await this.wire.sendAction('close-application', { force, ...this.identity });
3898
+ }
3899
+ catch (error) {
3900
+ if (!error.message.includes('Remote connection has closed')) {
3901
+ throw error;
3902
+ }
3903
+ }
3904
+ }
3905
+ /**
3906
+ * @deprecated use Application.quit instead
3907
+ * Closes the application and any child windows created by the application.
3908
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
3909
+ * @param callback - called if the method succeeds.
3910
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3911
+ *
3912
+ * @example
3913
+ *
3914
+ * ```js
3915
+ * async function closeApp() {
3916
+ * const app = await fin.Application.getCurrent();
3917
+ * return await app.close();
3918
+ * }
3919
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
3920
+ * ```
3921
+ */
3922
+ close(force = false) {
3923
+ console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
3924
+ this.wire.sendAction('application-close', this.identity).catch((e) => {
3925
+ // we do not want to expose this error, just continue if this analytics-only call fails
3926
+ });
3927
+ return this._close(force);
3928
+ }
3929
+ /**
3930
+ * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
3931
+ *
3932
+ * @example
3933
+ *
3934
+ * ```js
3935
+ * async function getChildWindows() {
3936
+ * const app = await fin.Application.getCurrent();
3937
+ * return await app.getChildWindows();
3938
+ * }
3939
+ *
3940
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
3941
+ * ```
3942
+ */
3943
+ getChildWindows() {
3944
+ return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
3945
+ const identityList = [];
3946
+ payload.data.forEach((winName) => {
3947
+ identityList.push({ uuid: this.identity.uuid, name: winName });
3948
+ });
3949
+ return this.windowListFromIdentityList(identityList);
3950
+ });
3951
+ }
3952
+ /**
3953
+ * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
3954
+ * if the application was not created from a manifest.
3955
+ *
3956
+ * @example
3957
+ *
3958
+ * ```js
3959
+ * async function getManifest() {
3960
+ * const app = await fin.Application.getCurrent();
3961
+ * return await app.getManifest();
3962
+ * }
3963
+ *
3964
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
3965
+ * ```
3966
+ */
3967
+ getManifest() {
3968
+ return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
3969
+ }
3970
+ /**
3971
+ * Retrieves UUID of the application that launches this application. Invokes the error callback
3972
+ * if the application was created from a manifest.
3973
+ *
3974
+ * @example
3975
+ *
3976
+ * ```js
3977
+ * async function getParentUuid() {
3978
+ * const app = await fin.Application.start({
3979
+ * uuid: 'app-1',
3980
+ * name: 'myApp',
3981
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
3982
+ * autoShow: true
3983
+ * });
3984
+ * return await app.getParentUuid();
3985
+ * }
3986
+ *
3987
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
3988
+ * ```
3989
+ */
3990
+ getParentUuid() {
3991
+ return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
3992
+ }
3993
+ /**
3994
+ * Retrieves current application's shortcut configuration.
3995
+ *
3996
+ * @example
3997
+ *
3998
+ * ```js
3999
+ * async function getShortcuts() {
4000
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
4001
+ * return await app.getShortcuts();
4002
+ * }
4003
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
4004
+ * ```
4005
+ */
4006
+ getShortcuts() {
4007
+ return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
4008
+ }
4009
+ /**
4010
+ * Retrieves current application's views.
4011
+ * @experimental
4012
+ *
4013
+ * @example
4014
+ *
4015
+ * ```js
4016
+ * async function getViews() {
4017
+ * const app = await fin.Application.getCurrent();
4018
+ * return await app.getViews();
4019
+ * }
4020
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
4021
+ * ```
4022
+ */
4023
+ async getViews() {
4024
+ const { payload } = await this.wire.sendAction('application-get-views', this.identity);
4025
+ return payload.data.map((id) => new view_1.View(this.wire, id));
4026
+ }
4027
+ /**
4028
+ * Returns the current zoom level of the application.
4029
+ *
4030
+ * @example
4031
+ *
4032
+ * ```js
4033
+ * async function getZoomLevel() {
4034
+ * const app = await fin.Application.getCurrent();
4035
+ * return await app.getZoomLevel();
4036
+ * }
4037
+ *
4038
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
4039
+ * ```
4040
+ */
4041
+ getZoomLevel() {
4042
+ return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
4043
+ }
4044
+ /**
4045
+ * Returns an instance of the main Window of the application
4046
+ *
4047
+ * @example
4048
+ *
4049
+ * ```js
4050
+ * async function getWindow() {
4051
+ * const app = await fin.Application.start({
4052
+ * uuid: 'app-1',
4053
+ * name: 'myApp',
4054
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
4055
+ * autoShow: true
4056
+ * });
4057
+ * return await app.getWindow();
4058
+ * }
4059
+ *
4060
+ * getWindow().then(win => {
4061
+ * win.showAt(0, 400);
4062
+ * win.flash();
4063
+ * }).catch(err => console.log(err));
4064
+ * ```
4065
+ */
4066
+ getWindow() {
4067
+ this.wire.sendAction('application-get-window', this.identity).catch((e) => {
4068
+ // we do not want to expose this error, just continue if this analytics-only call fails
4069
+ });
4070
+ return Promise.resolve(this.window);
4071
+ }
4072
+ /**
4073
+ * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
4074
+ * @param userName - username to be passed to the RVM.
4075
+ * @param appName - app name to be passed to the RVM.
4076
+ *
4077
+ * @example
4078
+ *
4079
+ * ```js
4080
+ * async function registerUser() {
4081
+ * const app = await fin.Application.getCurrent();
4082
+ * return await app.registerUser('user', 'myApp');
4083
+ * }
4084
+ *
4085
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
4086
+ * ```
4087
+ */
4088
+ registerUser(userName, appName) {
4089
+ return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
4090
+ }
4091
+ /**
4092
+ * Removes the application’s icon from the tray.
4093
+ *
4094
+ * @example
4095
+ *
4096
+ * ```js
4097
+ * async function removeTrayIcon() {
4098
+ * const app = await fin.Application.getCurrent();
4099
+ * return await app.removeTrayIcon();
4100
+ * }
4101
+ *
4102
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
4103
+ * ```
4104
+ */
4105
+ removeTrayIcon() {
4106
+ return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
4107
+ }
4108
+ /**
4109
+ * Restarts the application.
4110
+ *
4111
+ * @example
4112
+ *
4113
+ * ```js
4114
+ * async function restartApp() {
4115
+ * const app = await fin.Application.getCurrent();
4116
+ * return await app.restart();
4117
+ * }
4118
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
4119
+ * ```
4120
+ */
4121
+ restart() {
4122
+ return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
4123
+ }
4124
+ /**
4125
+ * DEPRECATED method to run the application.
4126
+ * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
4127
+ *
4128
+ * @example
4129
+ *
4130
+ * ```js
4131
+ * async function run() {
4132
+ * const app = await fin.Application.create({
4133
+ * name: 'myApp',
4134
+ * uuid: 'app-1',
4135
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
4136
+ * autoShow: true
4137
+ * });
4138
+ * await app.run();
4139
+ * }
4140
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
4141
+ * ```
4142
+ *
4143
+ * @ignore
4144
+ */
4145
+ run() {
4146
+ console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
4147
+ this.wire.sendAction('application-run', this.identity).catch((e) => {
4148
+ // we do not want to expose this error, just continue if this analytics-only call fails
4149
+ });
4150
+ return this._run();
4151
+ }
4152
+ _run(opts = {}) {
4153
+ return this.wire
4154
+ .sendAction('run-application', {
4155
+ manifestUrl: this._manifestUrl,
4156
+ opts,
4157
+ ...this.identity
4158
+ })
4159
+ .then(() => undefined);
4160
+ }
4161
+ /**
4162
+ * Instructs the RVM to schedule one restart of the application.
4163
+ *
4164
+ * @example
4165
+ *
4166
+ * ```js
4167
+ * async function scheduleRestart() {
4168
+ * const app = await fin.Application.getCurrent();
4169
+ * return await app.scheduleRestart();
4170
+ * }
4171
+ *
4172
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
4173
+ * ```
4174
+ */
4175
+ scheduleRestart() {
4176
+ return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
4177
+ }
4178
+ /**
4179
+ * Sends a message to the RVM to upload the application's logs. On success,
4180
+ * an object containing logId is returned.
4181
+ *
4182
+ * @example
4183
+ *
4184
+ * ```js
4185
+ * async function sendLog() {
4186
+ * const app = await fin.Application.getCurrent();
4187
+ * return await app.sendApplicationLog();
4188
+ * }
4189
+ *
4190
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
4191
+ * ```
4192
+ */
4193
+ async sendApplicationLog() {
4194
+ const { payload } = await this.wire.sendAction('send-application-log', this.identity);
4195
+ return payload.data;
4196
+ }
4197
+ /**
4198
+ * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
4199
+ * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
4200
+ *
4201
+ * Note: If the "name" property is omitted it defaults to "tasks".
4202
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
4203
+ *
4204
+ *
4205
+ * @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).
4206
+ *
4207
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
4208
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
4209
+ *
4210
+ * Note: If the "name" property is omitted it defaults to "tasks".
4211
+ *
4212
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
4213
+ * uuid or shortcut.name is changed.
4214
+ *
4215
+ * @example
4216
+ *
4217
+ * ```js
4218
+ * const app = fin.Application.getCurrentSync();
4219
+ * const appName = 'My App';
4220
+ * const jumpListConfig = [ // array of JumpList categories
4221
+ * {
4222
+ * // has no name and no type so `type` is assumed to be "tasks"
4223
+ * items: [ // array of JumpList items
4224
+ * {
4225
+ * type: 'task',
4226
+ * title: `Launch ${appName}`,
4227
+ * description: `Runs ${appName} with the default configuration`,
4228
+ * deepLink: 'fins://path.to/app/manifest.json',
4229
+ * iconPath: 'https://path.to/app/icon.ico',
4230
+ * iconIndex: 0
4231
+ * },
4232
+ * { type: 'separator' },
4233
+ * {
4234
+ * type: 'task',
4235
+ * title: `Restore ${appName}`,
4236
+ * description: 'Restore to last configuration',
4237
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
4238
+ * iconPath: 'https://path.to/app/icon.ico',
4239
+ * iconIndex: 0
4240
+ * },
4241
+ * ]
4242
+ * },
4243
+ * {
4244
+ * name: 'Tools',
4245
+ * items: [ // array of JumpList items
4246
+ * {
4247
+ * type: 'task',
4248
+ * title: 'Tool A',
4249
+ * description: 'Runs Tool A',
4250
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
4251
+ * iconPath: 'https://path.to/tool-a/icon.ico',
4252
+ * iconIndex: 0
4253
+ * },
4254
+ * {
4255
+ * type: 'task',
4256
+ * title: 'Tool B',
4257
+ * description: 'Runs Tool B',
4258
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
4259
+ * iconPath: 'https://path.to/tool-b/icon.ico',
4260
+ * iconIndex: 0
4261
+ * }]
4262
+ * }
4263
+ * ];
4264
+ *
4265
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
4266
+ * ```
4267
+ *
4268
+ * To handle deeplink args:
4269
+ * ```js
4270
+ * function handleUseLastConfiguration() {
4271
+ * // this handler is called when the app is being launched
4272
+ * app.on('run-requested', event => {
4273
+ * if(event.userAppConfigArgs['use-last-configuration']) {
4274
+ * // your logic here
4275
+ * }
4276
+ * });
4277
+ * // this handler is called when the app was already running when the launch was requested
4278
+ * fin.desktop.main(function(args) {
4279
+ * if(args && args['use-last-configuration']) {
4280
+ * // your logic here
4281
+ * }
4282
+ * });
4283
+ * }
4284
+ * ```
4285
+ */
4286
+ async setJumpList(jumpListCategories) {
4287
+ await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
4288
+ }
4289
+ /**
4290
+ * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
4291
+ * @param icon Image URL or base64 encoded string to be used as the icon
4292
+ *
4293
+ * @example
4294
+ *
4295
+ * ```js
4296
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
4297
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
4298
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
4299
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
4300
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
4301
+ *
4302
+ * async function setTrayIcon(icon) {
4303
+ * const app = await fin.Application.getCurrent();
4304
+ * return await app.setTrayIcon(icon);
4305
+ * }
4306
+ *
4307
+ * // use image url to set tray icon
4308
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
4309
+ *
4310
+ * // use base64 encoded string to set tray icon
4311
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
4312
+ *
4313
+ * // use a dataURL to set tray icon
4314
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
4315
+ * ```
4316
+ */
4317
+ setTrayIcon(icon) {
4318
+ return this.wire
4319
+ .sendAction('set-tray-icon', {
4320
+ enabledIcon: icon,
4321
+ ...this.identity
4322
+ })
4323
+ .then(() => undefined);
4324
+ }
4325
+ /**
4326
+ * Set hover text for this application's system tray icon.
4327
+ * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
4328
+ * @param toolTip
4329
+ *
4330
+ * @example
4331
+ *
4332
+ * ```js
4333
+ * const app = fin.Application.getCurrentSync();
4334
+ * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
4335
+ *
4336
+ * await app.setTrayIcon(iconUrl);
4337
+ *
4338
+ * await app.setTrayIconToolTip('My Application');
4339
+ * ```
4340
+ */
4341
+ async setTrayIconToolTip(toolTip) {
4342
+ await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
4343
+ }
4344
+ /**
4345
+ * Sets new application's shortcut configuration. Windows only.
4346
+ * @param config New application's shortcut configuration.
4347
+ *
4348
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
4349
+ * to be able to change shortcut states.
4350
+ *
4351
+ * @example
4352
+ *
4353
+ * ```js
4354
+ * async function setShortcuts(config) {
4355
+ * const app = await fin.Application.getCurrent();
4356
+ * return app.setShortcuts(config);
4357
+ * }
4358
+ *
4359
+ * setShortcuts({
4360
+ * desktop: true,
4361
+ * startMenu: false,
4362
+ * systemStartup: true
4363
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
4364
+ * ```
4365
+ */
4366
+ setShortcuts(config) {
4367
+ return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
4368
+ }
4369
+ /**
4370
+ * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
4371
+ * @param queryString The new query string for this app's shortcuts.
4372
+ *
4373
+ * @example
4374
+ *
4375
+ * ```js
4376
+ * const newQueryArgs = 'arg=true&arg2=false';
4377
+ * const app = await fin.Application.getCurrent();
4378
+ * try {
4379
+ * await app.setShortcutQueryParams(newQueryArgs);
4380
+ * } catch(err) {
4381
+ * console.error(err)
4382
+ * }
4383
+ * ```
4384
+ */
4385
+ async setShortcutQueryParams(queryString) {
4386
+ await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
4387
+ }
4388
+ /**
4389
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
4390
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
4391
+ * @param level The zoom level
4392
+ *
4393
+ * @example
4394
+ *
4395
+ * ```js
4396
+ * async function setZoomLevel(number) {
4397
+ * const app = await fin.Application.getCurrent();
4398
+ * return await app.setZoomLevel(number);
4399
+ * }
4400
+ *
4401
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
4402
+ * ```
4403
+ */
4404
+ setZoomLevel(level) {
4405
+ return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
4406
+ }
4407
+ /**
4408
+ * Sets a username to correlate with App Log Management.
4409
+ * @param username Username to correlate with App's Log.
4410
+ *
4411
+ * @example
4412
+ *
4413
+ * ```js
4414
+ * async function setAppLogUser() {
4415
+ * const app = await fin.Application.getCurrent();
4416
+ * return await app.setAppLogUsername('username');
4417
+ * }
4418
+ *
4419
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
4420
+ *
4421
+ * ```
4422
+ */
4423
+ async setAppLogUsername(username) {
4424
+ await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
4425
+ }
4426
+ /**
4427
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
4428
+ * @remarks The only information currently returned is the position and dimensions.
4429
+ *
4430
+ * @example
4431
+ *
4432
+ * ```js
4433
+ * async function getTrayIconInfo() {
4434
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
4435
+ * return await app.getTrayIconInfo();
4436
+ * }
4437
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
4438
+ * ```
4439
+ */
4440
+ getTrayIconInfo() {
4441
+ return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
4442
+ }
4443
+ /**
4444
+ * Checks if the application has an associated tray icon.
4445
+ *
4446
+ * @example
4447
+ *
4448
+ * ```js
4449
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
4450
+ * const hasTrayIcon = await app.hasTrayIcon();
4451
+ * console.log(hasTrayIcon);
4452
+ * ```
4453
+ */
4454
+ hasTrayIcon() {
4455
+ return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
4456
+ }
4457
+ /**
4458
+ * Closes the application by terminating its process.
4459
+ *
4460
+ * @example
4461
+ *
4462
+ * ```js
4463
+ * async function terminateApp() {
4464
+ * const app = await fin.Application.getCurrent();
4465
+ * return await app.terminate();
4466
+ * }
4467
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
4468
+ * ```
4469
+ */
4470
+ terminate() {
4471
+ return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
4472
+ }
4473
+ /**
4474
+ * Waits for a hanging application. This method can be called in response to an application
4475
+ * "not-responding" to allow the application to continue and to generate another "not-responding"
4476
+ * message after a certain period of time.
4477
+ *
4478
+ * @ignore
4479
+ */
4480
+ wait() {
4481
+ return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
4482
+ }
4483
+ /**
4484
+ * Retrieves information about the application.
4485
+ *
4486
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
4487
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
4488
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
4489
+ *
4490
+ * @example
4491
+ *
4492
+ * ```js
4493
+ * async function getInfo() {
4494
+ * const app = await fin.Application.getCurrent();
4495
+ * return await app.getInfo();
4496
+ * }
4497
+ *
4498
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
4499
+ * ```
4500
+ */
4501
+ getInfo() {
4502
+ return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
4503
+ }
4504
+ /**
4505
+ * Retrieves all process information for entities (windows and views) associated with an application.
4506
+ *
4507
+ * @example
4508
+ * ```js
4509
+ * const app = await fin.Application.getCurrent();
4510
+ * const processInfo = await app.getProcessInfo();
4511
+ * ```
4512
+ * @experimental
4513
+ */
4514
+ async getProcessInfo() {
4515
+ const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
4516
+ return data;
4517
+ }
4518
+ /**
4519
+ * Sets file auto download location. It's only allowed in the same application.
4520
+ *
4521
+ * Note: This method is restricted by default and must be enabled via
4522
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
4523
+ * @param downloadLocation file auto download location
4524
+ *
4525
+ * @throws if setting file auto download location on different applications.
4526
+ * @example
4527
+ *
4528
+ * ```js
4529
+ * const downloadLocation = 'C:\\dev\\temp';
4530
+ * const app = await fin.Application.getCurrent();
4531
+ * try {
4532
+ * await app.setFileDownloadLocation(downloadLocation);
4533
+ * console.log('File download location is set');
4534
+ * } catch(err) {
4535
+ * console.error(err)
4536
+ * }
4537
+ * ```
4538
+ */
4539
+ async setFileDownloadLocation(downloadLocation) {
4540
+ const { name } = this.wire.me;
4541
+ const entityIdentity = { uuid: this.identity.uuid, name };
4542
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
4543
+ }
4544
+ /**
4545
+ * 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.
4546
+ *
4547
+ * Note: This method is restricted by default and must be enabled via
4548
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
4549
+ *
4550
+ * @throws if getting file auto download location on different applications.
4551
+ * @example
4552
+ *
4553
+ * ```js
4554
+ * const app = await fin.Application.getCurrent();
4555
+ * const fileDownloadDir = await app.getFileDownloadLocation();
4556
+ * ```
4557
+ */
4558
+ async getFileDownloadLocation() {
4559
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
4560
+ return data;
4561
+ }
4562
+ /**
4563
+ * Shows a menu on the tray icon. Use with tray-icon-clicked event.
4564
+ * @param options
4565
+ * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
4566
+ * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
4567
+ * of all possible data shapes for the entire menu, and the click handler should process
4568
+ * these with a "reducer" pattern.
4569
+ * @throws if the application has no tray icon set
4570
+ * @throws if the system tray is currently hidden
4571
+ * @example
4572
+ *
4573
+ * ```js
4574
+ * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
4575
+ * const app = fin.Application.getCurrentSync();
4576
+ *
4577
+ * await app.setTrayIcon(iconUrl);
4578
+ *
4579
+ * const template = [
4580
+ * {
4581
+ * label: 'Menu Item 1',
4582
+ * data: 'hello from item 1'
4583
+ * },
4584
+ * { type: 'separator' },
4585
+ * {
4586
+ * label: 'Menu Item 2',
4587
+ * type: 'checkbox',
4588
+ * checked: true,
4589
+ * data: 'The user clicked the checkbox'
4590
+ * },
4591
+ * {
4592
+ * label: 'see more',
4593
+ * enabled: false,
4594
+ * submenu: [
4595
+ * { label: 'submenu 1', data: 'hello from submenu' }
4596
+ * ]
4597
+ * }
4598
+ * ];
4599
+ *
4600
+ * app.addListener('tray-icon-clicked', (event) => {
4601
+ * // right-click
4602
+ * if (event.button === 2) {
4603
+ * app.showTrayIconPopupMenu({ template }).then(r => {
4604
+ * if (r.result === 'closed') {
4605
+ * console.log('nothing happened');
4606
+ * } else {
4607
+ * console.log(r.data);
4608
+ * }
4609
+ * });
4610
+ * }
4611
+ * });
4612
+ * ```
4613
+ */
4614
+ async showTrayIconPopupMenu(options) {
4615
+ const { name } = this.wire.me;
4616
+ const entityIdentity = { uuid: this.identity.uuid, name };
4617
+ const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
4618
+ return payload.data;
4619
+ }
4620
+ /**
4621
+ * Closes the tray icon menu.
4622
+ *
4623
+ * @throws if the application has no tray icon set
4624
+ * @example
4625
+ *
4626
+ * ```js
4627
+ * const app = fin.Application.getCurrentSync();
4628
+ *
4629
+ * await app.closeTrayIconPopupMenu();
4630
+ * ```
4631
+ */
4632
+ async closeTrayIconPopupMenu() {
4633
+ const { name } = this.wire.me;
4634
+ const entityIdentity = { uuid: this.identity.uuid, name };
4635
+ await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
4636
+ }
4637
+ }
4638
+ Instance$5.Application = Application;
4639
+ return Instance$5;
4905
4640
  }
4906
- Factory$6.ApplicationModule = ApplicationModule;
4907
4641
 
4908
- (function (exports) {
4909
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4910
- if (k2 === undefined) k2 = k;
4911
- var desc = Object.getOwnPropertyDescriptor(m, k);
4912
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4913
- desc = { enumerable: true, get: function() { return m[k]; } };
4914
- }
4915
- Object.defineProperty(o, k2, desc);
4916
- }) : (function(o, m, k, k2) {
4917
- if (k2 === undefined) k2 = k;
4918
- o[k2] = m[k];
4919
- }));
4920
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
4921
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4922
- };
4923
- Object.defineProperty(exports, "__esModule", { value: true });
4642
+ var hasRequiredFactory$1;
4643
+
4644
+ function requireFactory$1 () {
4645
+ if (hasRequiredFactory$1) return Factory$6;
4646
+ hasRequiredFactory$1 = 1;
4647
+ Object.defineProperty(Factory$6, "__esModule", { value: true });
4648
+ Factory$6.ApplicationModule = void 0;
4649
+ const base_1 = base;
4650
+ const validate_1 = validate;
4651
+ const Instance_1 = requireInstance$2();
4924
4652
  /**
4925
- * Entry points for the OpenFin `Application` API (`fin.Application`).
4926
- *
4927
- * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
4928
- * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
4929
- *
4930
- * 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),
4931
- * both of these were documented on the same page.
4932
- *
4933
- * @packageDocumentation
4653
+ * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
4934
4654
  */
4935
- __exportStar(Factory$6, exports);
4936
- __exportStar(Instance$5, exports);
4937
- } (application));
4655
+ class ApplicationModule extends base_1.Base {
4656
+ /**
4657
+ * Asynchronously returns an API handle for the given Application identity.
4658
+ *
4659
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4660
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4661
+ * for an Application throughout its entire lifecycle.
4662
+ *
4663
+ * @example
4664
+ *
4665
+ * ```js
4666
+ * fin.Application.wrap({ uuid: 'testapp' })
4667
+ * .then(app => app.isRunning())
4668
+ * .then(running => console.log('Application is running: ' + running))
4669
+ * .catch(err => console.log(err));
4670
+ * ```
4671
+ *
4672
+ */
4673
+ async wrap(identity) {
4674
+ this.wire.sendAction('wrap-application').catch((e) => {
4675
+ // we do not want to expose this error, just continue if this analytics-only call fails
4676
+ });
4677
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
4678
+ if (errorMsg) {
4679
+ throw new Error(errorMsg);
4680
+ }
4681
+ return new Instance_1.Application(this.wire, identity);
4682
+ }
4683
+ /**
4684
+ * Synchronously returns an API handle for the given Application identity.
4685
+ *
4686
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4687
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4688
+ * for an Aplication throughout its entire lifecycle.
4689
+ *
4690
+ * @example
4691
+ *
4692
+ * ```js
4693
+ * const app = fin.Application.wrapSync({ uuid: 'testapp' });
4694
+ * await app.close();
4695
+ * ```
4696
+ *
4697
+ */
4698
+ wrapSync(identity) {
4699
+ this.wire.sendAction('wrap-application-sync').catch((e) => {
4700
+ // we do not want to expose this error, just continue if this analytics-only call fails
4701
+ });
4702
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
4703
+ if (errorMsg) {
4704
+ throw new Error(errorMsg);
4705
+ }
4706
+ return new Instance_1.Application(this.wire, identity);
4707
+ }
4708
+ async _create(appOptions) {
4709
+ // set defaults:
4710
+ if (appOptions.waitForPageLoad === undefined) {
4711
+ appOptions.waitForPageLoad = false;
4712
+ }
4713
+ if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
4714
+ appOptions.autoShow = true;
4715
+ }
4716
+ await this.wire.sendAction('create-application', appOptions);
4717
+ return this.wrap({ uuid: appOptions.uuid });
4718
+ }
4719
+ /**
4720
+ * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
4721
+ *
4722
+ * @example
4723
+ *
4724
+ * ```js
4725
+ * async function createApp() {
4726
+ * const app = await fin.Application.create({
4727
+ * name: 'myApp',
4728
+ * uuid: 'app-3',
4729
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
4730
+ * autoShow: true
4731
+ * });
4732
+ * await app.run();
4733
+ * }
4734
+ *
4735
+ * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
4736
+ * ```
4737
+ *
4738
+ * @ignore
4739
+ */
4740
+ create(appOptions) {
4741
+ console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
4742
+ this.wire.sendAction('application-create').catch((e) => {
4743
+ // we do not want to expose this error, just continue if this analytics-only call fails
4744
+ });
4745
+ return this._create(appOptions);
4746
+ }
4747
+ /**
4748
+ * Creates and starts a new Application.
4749
+ *
4750
+ * @example
4751
+ *
4752
+ * ```js
4753
+ * async function start() {
4754
+ * return fin.Application.start({
4755
+ * name: 'app-1',
4756
+ * uuid: 'app-1',
4757
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
4758
+ * autoShow: true
4759
+ * });
4760
+ * }
4761
+ * start().then(() => console.log('Application is running')).catch(err => console.log(err));
4762
+ * ```
4763
+ *
4764
+ */
4765
+ async start(appOptions) {
4766
+ this.wire.sendAction('start-application').catch((e) => {
4767
+ // we do not want to expose this error, just continue if this analytics-only call fails
4768
+ });
4769
+ const app = await this._create(appOptions);
4770
+ await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
4771
+ return app;
4772
+ }
4773
+ /**
4774
+ * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
4775
+ * Returns once the RVM is finished attempting to launch the applications.
4776
+ * @param opts - Parameters that the RVM will use.
4777
+ *
4778
+ * @example
4779
+ *
4780
+ * ```js
4781
+ *
4782
+ * const applicationInfoArray = [
4783
+ * {
4784
+ * "uuid": 'App-1',
4785
+ * "manifestUrl": 'http://localhost:5555/app1.json',
4786
+ * },
4787
+ * {
4788
+ * "uuid": 'App-2',
4789
+ * "manifestUrl": 'http://localhost:5555/app2.json',
4790
+ * },
4791
+ * {
4792
+ * "uuid": 'App-3',
4793
+ * "manifestUrl": 'http://localhost:5555/app3.json',
4794
+ * }
4795
+ * ]
4796
+ *
4797
+ * fin.Application.startManyManifests(applicationInfoArray)
4798
+ * .then(() => {
4799
+ * console.log('RVM has finished launching the application list.');
4800
+ * })
4801
+ * .catch((err) => {
4802
+ * console.log(err);
4803
+ * })
4804
+ * ```
4805
+ *
4806
+ * @experimental
4807
+ */
4808
+ async startManyManifests(applications, opts) {
4809
+ return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
4810
+ }
4811
+ /**
4812
+ * Asynchronously returns an Application object that represents the current application
4813
+ *
4814
+ * @example
4815
+ *
4816
+ * ```js
4817
+ * async function isCurrentAppRunning () {
4818
+ * const app = await fin.Application.getCurrent();
4819
+ * return app.isRunning();
4820
+ * }
4821
+ *
4822
+ * isCurrentAppRunning().then(running => {
4823
+ * console.log(`Current app is running: ${running}`);
4824
+ * }).catch(err => {
4825
+ * console.error(err);
4826
+ * });
4827
+ *
4828
+ * ```
4829
+ */
4830
+ getCurrent() {
4831
+ this.wire.sendAction('get-current-application').catch((e) => {
4832
+ // we do not want to expose this error, just continue if this analytics-only call fails
4833
+ });
4834
+ return this.wrap({ uuid: this.wire.me.uuid });
4835
+ }
4836
+ /**
4837
+ * Synchronously returns an Application object that represents the current application
4838
+ *
4839
+ * @example
4840
+ *
4841
+ * ```js
4842
+ * async function isCurrentAppRunning () {
4843
+ * const app = fin.Application.getCurrentSync();
4844
+ * return app.isRunning();
4845
+ * }
4846
+ *
4847
+ * isCurrentAppRunning().then(running => {
4848
+ * console.log(`Current app is running: ${running}`);
4849
+ * }).catch(err => {
4850
+ * console.error(err);
4851
+ * });
4852
+ *
4853
+ * ```
4854
+ */
4855
+ getCurrentSync() {
4856
+ this.wire.sendAction('get-current-application-sync').catch((e) => {
4857
+ // we do not want to expose this error, just continue if this analytics-only call fails
4858
+ });
4859
+ return this.wrapSync({ uuid: this.wire.me.uuid });
4860
+ }
4861
+ /**
4862
+ * Retrieves application's manifest and returns a running instance of the application.
4863
+ * @param manifestUrl - The URL of app's manifest.
4864
+ * @param opts - Parameters that the RVM will use.
4865
+ *
4866
+ * @example
4867
+ *
4868
+ * ```js
4869
+ * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4870
+ *
4871
+ * // For a local manifest file:
4872
+ * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4873
+ * ```
4874
+ */
4875
+ async startFromManifest(manifestUrl, opts) {
4876
+ this.wire.sendAction('application-start-from-manifest').catch((e) => {
4877
+ // we do not want to expose this error, just continue if this analytics-only call fails
4878
+ });
4879
+ const app = await this._createFromManifest(manifestUrl);
4880
+ // @ts-expect-error using private method without warning.
4881
+ await app._run(opts); // eslint-disable-line no-underscore-dangle
4882
+ return app;
4883
+ }
4884
+ /**
4885
+ * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
4886
+ * Retrieves application's manifest and returns a wrapped application.
4887
+ * @param manifestUrl - The URL of app's manifest.
4888
+ * @param callback - called if the method succeeds.
4889
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
4890
+ *
4891
+ * @example
4892
+ *
4893
+ * ```js
4894
+ * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
4895
+ * ```
4896
+ * @ignore
4897
+ */
4898
+ createFromManifest(manifestUrl) {
4899
+ console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
4900
+ this.wire.sendAction('application-create-from-manifest').catch((e) => {
4901
+ // we do not want to expose this error, just continue if this analytics-only call fails
4902
+ });
4903
+ return this._createFromManifest(manifestUrl);
4904
+ }
4905
+ _createFromManifest(manifestUrl) {
4906
+ return this.wire
4907
+ .sendAction('get-application-manifest', { manifestUrl })
4908
+ .then(({ payload }) => {
4909
+ const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
4910
+ return this.wrap({ uuid });
4911
+ })
4912
+ .then((app) => {
4913
+ app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
4914
+ return app;
4915
+ });
4916
+ }
4917
+ }
4918
+ Factory$6.ApplicationModule = ApplicationModule;
4919
+ return Factory$6;
4920
+ }
4921
+
4922
+ var hasRequiredApplication;
4923
+
4924
+ function requireApplication () {
4925
+ if (hasRequiredApplication) return application;
4926
+ hasRequiredApplication = 1;
4927
+ (function (exports) {
4928
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4929
+ if (k2 === undefined) k2 = k;
4930
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4931
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4932
+ desc = { enumerable: true, get: function() { return m[k]; } };
4933
+ }
4934
+ Object.defineProperty(o, k2, desc);
4935
+ }) : (function(o, m, k, k2) {
4936
+ if (k2 === undefined) k2 = k;
4937
+ o[k2] = m[k];
4938
+ }));
4939
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
4940
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4941
+ };
4942
+ Object.defineProperty(exports, "__esModule", { value: true });
4943
+ /**
4944
+ * Entry points for the OpenFin `Application` API (`fin.Application`).
4945
+ *
4946
+ * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
4947
+ * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
4948
+ *
4949
+ * 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),
4950
+ * both of these were documented on the same page.
4951
+ *
4952
+ * @packageDocumentation
4953
+ */
4954
+ __exportStar(requireFactory$1(), exports);
4955
+ __exportStar(requireInstance$2(), exports);
4956
+ } (application));
4957
+ return application;
4958
+ }
4938
4959
 
4939
4960
  var promisifySubscription$1 = {};
4940
4961
 
@@ -4978,7 +4999,7 @@ function requireInstance$1 () {
4978
4999
  /* eslint-disable @typescript-eslint/no-unused-vars */
4979
5000
  /* eslint-disable no-console */
4980
5001
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
4981
- const application_1 = application;
5002
+ const application_1 = requireApplication();
4982
5003
  const main_1 = main;
4983
5004
  const view_1 = requireView();
4984
5005
  const warnings_1 = warnings;
@@ -7101,7 +7122,7 @@ function requireView () {
7101
7122
  *
7102
7123
  * @packageDocumentation
7103
7124
  */
7104
- __exportStar(requireFactory$1(), exports);
7125
+ __exportStar(requireFactory$2(), exports);
7105
7126
  __exportStar(requireInstance(), exports);
7106
7127
  } (view));
7107
7128
  return view;
@@ -17875,7 +17896,7 @@ const events_1 = require$$0;
17875
17896
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
17876
17897
  const index_1 = system;
17877
17898
  const index_2 = requireWindow();
17878
- const index_3 = application;
17899
+ const index_3 = requireApplication();
17879
17900
  const index_4 = interappbus;
17880
17901
  const index_5 = clipboard;
17881
17902
  const index_6 = externalApplication;