@openfin/remote-adapter 40.105.7 → 40.105.8

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