@openfin/remote-adapter 45.100.18 → 45.100.19

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