@openfin/remote-adapter 41.100.116 → 41.100.118

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