@openfin/remote-adapter 40.104.8 → 40.105.3

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 +1159 -1138
  2. package/package.json +2 -2
@@ -469,9 +469,9 @@ var __classPrivateFieldGet$e = (commonjsGlobal && commonjsGlobal.__classPrivateF
469
469
  };
470
470
  var _SessionContextGroupClient_clientPromise;
471
471
  Object.defineProperty(SessionContextGroupClient$1, "__esModule", { value: true });
472
- const base_1$l = base;
472
+ const base_1$j = base;
473
473
  const utils_1$2 = utils$3;
474
- class SessionContextGroupClient extends base_1$l.Base {
474
+ class SessionContextGroupClient extends base_1$j.Base {
475
475
  constructor(wire, client, id) {
476
476
  super(wire);
477
477
  _SessionContextGroupClient_clientPromise.set(this, void 0);
@@ -2358,11 +2358,11 @@ function overrideFromComposables(...overrides) {
2358
2358
  commonUtils.overrideFromComposables = overrideFromComposables;
2359
2359
  commonUtils.default = { isValidPresetType };
2360
2360
 
2361
- var hasRequiredFactory$2;
2361
+ var hasRequiredFactory$3;
2362
2362
 
2363
- function requireFactory$2 () {
2364
- if (hasRequiredFactory$2) return Factory$8;
2365
- hasRequiredFactory$2 = 1;
2363
+ function requireFactory$3 () {
2364
+ if (hasRequiredFactory$3) return Factory$8;
2365
+ hasRequiredFactory$3 = 1;
2366
2366
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
2367
2367
  return (mod && mod.__esModule) ? mod : { "default": mod };
2368
2368
  };
@@ -2493,7 +2493,7 @@ function requireInterop () {
2493
2493
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2494
2494
  };
2495
2495
  Object.defineProperty(exports, "__esModule", { value: true });
2496
- __exportStar(requireFactory$2(), exports);
2496
+ __exportStar(requireFactory$3(), exports);
2497
2497
  __exportStar(requireInteropClient(), exports);
2498
2498
  __exportStar(requireInteropBroker(), exports);
2499
2499
  } (interop));
@@ -4714,11 +4714,11 @@ const handleDeprecatedWarnings = (options) => {
4714
4714
  };
4715
4715
  warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
4716
4716
 
4717
- var hasRequiredFactory$1;
4717
+ var hasRequiredFactory$2;
4718
4718
 
4719
- function requireFactory$1 () {
4720
- if (hasRequiredFactory$1) return Factory$7;
4721
- hasRequiredFactory$1 = 1;
4719
+ function requireFactory$2 () {
4720
+ if (hasRequiredFactory$2) return Factory$7;
4721
+ hasRequiredFactory$2 = 1;
4722
4722
  Object.defineProperty(Factory$7, "__esModule", { value: true });
4723
4723
  Factory$7.ViewModule = void 0;
4724
4724
  const base_1 = base;
@@ -4877,8 +4877,8 @@ var main = {};
4877
4877
 
4878
4878
  Object.defineProperty(main, "__esModule", { value: true });
4879
4879
  main.WebContents = void 0;
4880
- const base_1$k = base;
4881
- class WebContents extends base_1$k.EmitterBase {
4880
+ const base_1$i = base;
4881
+ class WebContents extends base_1$i.EmitterBase {
4882
4882
  /**
4883
4883
  * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
4884
4884
  * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
@@ -5971,1133 +5971,1154 @@ var Factory$5 = {};
5971
5971
 
5972
5972
  var Instance$5 = {};
5973
5973
 
5974
- Object.defineProperty(Instance$5, "__esModule", { value: true });
5975
- Instance$5.Application = void 0;
5976
- /* eslint-disable import/prefer-default-export */
5977
- const base_1$j = base;
5978
- const window_1$1 = requireWindow();
5979
- const view_1 = requireView();
5980
- /**
5981
- * An object representing an application. Allows the developer to create,
5982
- * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
5983
- */
5984
- class Application extends base_1$j.EmitterBase {
5985
- /**
5986
- * @internal
5987
- */
5988
- constructor(wire, identity) {
5989
- super(wire, 'application', identity.uuid);
5990
- this.identity = identity;
5991
- this.window = new window_1$1._Window(this.wire, {
5992
- uuid: this.identity.uuid,
5993
- name: this.identity.uuid
5994
- });
5995
- }
5996
- windowListFromIdentityList(identityList) {
5997
- const windowList = [];
5998
- identityList.forEach((identity) => {
5999
- windowList.push(new window_1$1._Window(this.wire, {
6000
- uuid: identity.uuid,
6001
- name: identity.name
6002
- }));
6003
- });
6004
- return windowList;
6005
- }
6006
- /**
6007
- * Determines if the application is currently running.
6008
- *
6009
- * @example
6010
- *
6011
- * ```js
6012
- * async function isAppRunning() {
6013
- * const app = await fin.Application.getCurrent();
6014
- * return await app.isRunning();
6015
- * }
6016
- * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
6017
- * ```
6018
- */
6019
- isRunning() {
6020
- return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
6021
- }
6022
- /**
6023
- * Closes the application and any child windows created by the application.
6024
- * Cleans the application from state so it is no longer found in getAllApplications.
6025
- * @param force Close will be prevented from closing when force is false and
6026
- * ‘close-requested’ has been subscribed to for application’s main window.
6027
- *
6028
- * @example
6029
- *
6030
- * ```js
6031
- * async function closeApp() {
6032
- * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
6033
- * const app = await fin.Application.wrap({uuid: 'app2'});
6034
- * await app.quit();
6035
- * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
6036
- *
6037
- * }
6038
- * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
6039
- * ```
6040
- */
6041
- async quit(force = false) {
6042
- try {
6043
- await this._close(force);
6044
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
6045
- }
6046
- catch (error) {
6047
- const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
6048
- if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
6049
- throw error;
6050
- }
6051
- }
6052
- }
6053
- async _close(force = false) {
6054
- try {
6055
- await this.wire.sendAction('close-application', { force, ...this.identity });
6056
- }
6057
- catch (error) {
6058
- if (!error.message.includes('Remote connection has closed')) {
6059
- throw error;
6060
- }
6061
- }
6062
- }
6063
- /**
6064
- * @deprecated use Application.quit instead
6065
- * Closes the application and any child windows created by the application.
6066
- * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
6067
- * @param callback - called if the method succeeds.
6068
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
6069
- *
6070
- * @example
6071
- *
6072
- * ```js
6073
- * async function closeApp() {
6074
- * const app = await fin.Application.getCurrent();
6075
- * return await app.close();
6076
- * }
6077
- * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
6078
- * ```
6079
- */
6080
- close(force = false) {
6081
- console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
6082
- this.wire.sendAction('application-close', this.identity).catch((e) => {
6083
- // we do not want to expose this error, just continue if this analytics-only call fails
6084
- });
6085
- return this._close(force);
6086
- }
6087
- /**
6088
- * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
6089
- *
6090
- * @example
6091
- *
6092
- * ```js
6093
- * async function getChildWindows() {
6094
- * const app = await fin.Application.getCurrent();
6095
- * return await app.getChildWindows();
6096
- * }
6097
- *
6098
- * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
6099
- * ```
6100
- */
6101
- getChildWindows() {
6102
- return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
6103
- const identityList = [];
6104
- payload.data.forEach((winName) => {
6105
- identityList.push({ uuid: this.identity.uuid, name: winName });
6106
- });
6107
- return this.windowListFromIdentityList(identityList);
6108
- });
6109
- }
6110
- /**
6111
- * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
6112
- * if the application was not created from a manifest.
6113
- *
6114
- * @example
6115
- *
6116
- * ```js
6117
- * async function getManifest() {
6118
- * const app = await fin.Application.getCurrent();
6119
- * return await app.getManifest();
6120
- * }
6121
- *
6122
- * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
6123
- * ```
6124
- */
6125
- getManifest() {
6126
- return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
6127
- }
6128
- /**
6129
- * Retrieves UUID of the application that launches this application. Invokes the error callback
6130
- * if the application was created from a manifest.
6131
- *
6132
- * @example
6133
- *
6134
- * ```js
6135
- * async function getParentUuid() {
6136
- * const app = await fin.Application.start({
6137
- * uuid: 'app-1',
6138
- * name: 'myApp',
6139
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
6140
- * autoShow: true
6141
- * });
6142
- * return await app.getParentUuid();
6143
- * }
6144
- *
6145
- * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
6146
- * ```
6147
- */
6148
- getParentUuid() {
6149
- return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
6150
- }
6151
- /**
6152
- * Retrieves current application's shortcut configuration.
6153
- *
6154
- * @example
6155
- *
6156
- * ```js
6157
- * async function getShortcuts() {
6158
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
6159
- * return await app.getShortcuts();
6160
- * }
6161
- * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
6162
- * ```
6163
- */
6164
- getShortcuts() {
6165
- return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
6166
- }
6167
- /**
6168
- * Retrieves current application's views.
6169
- * @experimental
6170
- *
6171
- * @example
6172
- *
6173
- * ```js
6174
- * async function getViews() {
6175
- * const app = await fin.Application.getCurrent();
6176
- * return await app.getViews();
6177
- * }
6178
- * getViews().then(views => console.log(views)).catch(err => console.log(err));
6179
- * ```
6180
- */
6181
- async getViews() {
6182
- const { payload } = await this.wire.sendAction('application-get-views', this.identity);
6183
- return payload.data.map((id) => new view_1.View(this.wire, id));
6184
- }
6185
- /**
6186
- * Returns the current zoom level of the application.
6187
- *
6188
- * @example
6189
- *
6190
- * ```js
6191
- * async function getZoomLevel() {
6192
- * const app = await fin.Application.getCurrent();
6193
- * return await app.getZoomLevel();
6194
- * }
6195
- *
6196
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
6197
- * ```
6198
- */
6199
- getZoomLevel() {
6200
- return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
6201
- }
6202
- /**
6203
- * Returns an instance of the main Window of the application
6204
- *
6205
- * @example
6206
- *
6207
- * ```js
6208
- * async function getWindow() {
6209
- * const app = await fin.Application.start({
6210
- * uuid: 'app-1',
6211
- * name: 'myApp',
6212
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
6213
- * autoShow: true
6214
- * });
6215
- * return await app.getWindow();
6216
- * }
6217
- *
6218
- * getWindow().then(win => {
6219
- * win.showAt(0, 400);
6220
- * win.flash();
6221
- * }).catch(err => console.log(err));
6222
- * ```
6223
- */
6224
- getWindow() {
6225
- this.wire.sendAction('application-get-window', this.identity).catch((e) => {
6226
- // we do not want to expose this error, just continue if this analytics-only call fails
6227
- });
6228
- return Promise.resolve(this.window);
6229
- }
6230
- /**
6231
- * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
6232
- * @param userName - username to be passed to the RVM.
6233
- * @param appName - app name to be passed to the RVM.
6234
- *
6235
- * @example
6236
- *
6237
- * ```js
6238
- * async function registerUser() {
6239
- * const app = await fin.Application.getCurrent();
6240
- * return await app.registerUser('user', 'myApp');
6241
- * }
6242
- *
6243
- * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
6244
- * ```
6245
- */
6246
- registerUser(userName, appName) {
6247
- return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
6248
- }
6249
- /**
6250
- * Removes the application’s icon from the tray.
6251
- *
6252
- * @example
6253
- *
6254
- * ```js
6255
- * async function removeTrayIcon() {
6256
- * const app = await fin.Application.getCurrent();
6257
- * return await app.removeTrayIcon();
6258
- * }
6259
- *
6260
- * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
6261
- * ```
6262
- */
6263
- removeTrayIcon() {
6264
- return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
6265
- }
6266
- /**
6267
- * Restarts the application.
6268
- *
6269
- * @example
6270
- *
6271
- * ```js
6272
- * async function restartApp() {
6273
- * const app = await fin.Application.getCurrent();
6274
- * return await app.restart();
6275
- * }
6276
- * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
6277
- * ```
6278
- */
6279
- restart() {
6280
- return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
6281
- }
6282
- /**
6283
- * DEPRECATED method to run the application.
6284
- * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
6285
- *
6286
- * @example
6287
- *
6288
- * ```js
6289
- * async function run() {
6290
- * const app = await fin.Application.create({
6291
- * name: 'myApp',
6292
- * uuid: 'app-1',
6293
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
6294
- * autoShow: true
6295
- * });
6296
- * await app.run();
6297
- * }
6298
- * run().then(() => console.log('Application is running')).catch(err => console.log(err));
6299
- * ```
6300
- *
6301
- * @ignore
6302
- */
6303
- run() {
6304
- console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
6305
- this.wire.sendAction('application-run', this.identity).catch((e) => {
6306
- // we do not want to expose this error, just continue if this analytics-only call fails
6307
- });
6308
- return this._run();
6309
- }
6310
- _run(opts = {}) {
6311
- return this.wire
6312
- .sendAction('run-application', {
6313
- manifestUrl: this._manifestUrl,
6314
- opts,
6315
- ...this.identity
6316
- })
6317
- .then(() => undefined);
6318
- }
6319
- /**
6320
- * Instructs the RVM to schedule one restart of the application.
6321
- *
6322
- * @example
6323
- *
6324
- * ```js
6325
- * async function scheduleRestart() {
6326
- * const app = await fin.Application.getCurrent();
6327
- * return await app.scheduleRestart();
6328
- * }
6329
- *
6330
- * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
6331
- * ```
6332
- */
6333
- scheduleRestart() {
6334
- return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
6335
- }
6336
- /**
6337
- * Sends a message to the RVM to upload the application's logs. On success,
6338
- * an object containing logId is returned.
6339
- *
6340
- * @example
6341
- *
6342
- * ```js
6343
- * async function sendLog() {
6344
- * const app = await fin.Application.getCurrent();
6345
- * return await app.sendApplicationLog();
6346
- * }
6347
- *
6348
- * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
6349
- * ```
6350
- */
6351
- async sendApplicationLog() {
6352
- const { payload } = await this.wire.sendAction('send-application-log', this.identity);
6353
- return payload.data;
6354
- }
6355
- /**
6356
- * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
6357
- * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
6358
- *
6359
- * Note: If the "name" property is omitted it defaults to "tasks".
6360
- * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
6361
- *
6362
- *
6363
- * @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).
6364
- *
6365
- * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
6366
- * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
6367
- *
6368
- * Note: If the "name" property is omitted it defaults to "tasks".
6369
- *
6370
- * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
6371
- * uuid or shortcut.name is changed.
6372
- *
6373
- * @example
6374
- *
6375
- * ```js
6376
- * const app = fin.Application.getCurrentSync();
6377
- * const appName = 'My App';
6378
- * const jumpListConfig = [ // array of JumpList categories
6379
- * {
6380
- * // has no name and no type so `type` is assumed to be "tasks"
6381
- * items: [ // array of JumpList items
6382
- * {
6383
- * type: 'task',
6384
- * title: `Launch ${appName}`,
6385
- * description: `Runs ${appName} with the default configuration`,
6386
- * deepLink: 'fins://path.to/app/manifest.json',
6387
- * iconPath: 'https://path.to/app/icon.ico',
6388
- * iconIndex: 0
6389
- * },
6390
- * { type: 'separator' },
6391
- * {
6392
- * type: 'task',
6393
- * title: `Restore ${appName}`,
6394
- * description: 'Restore to last configuration',
6395
- * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
6396
- * iconPath: 'https://path.to/app/icon.ico',
6397
- * iconIndex: 0
6398
- * },
6399
- * ]
6400
- * },
6401
- * {
6402
- * name: 'Tools',
6403
- * items: [ // array of JumpList items
6404
- * {
6405
- * type: 'task',
6406
- * title: 'Tool A',
6407
- * description: 'Runs Tool A',
6408
- * deepLink: 'fins://path.to/tool-a/manifest.json',
6409
- * iconPath: 'https://path.to/tool-a/icon.ico',
6410
- * iconIndex: 0
6411
- * },
6412
- * {
6413
- * type: 'task',
6414
- * title: 'Tool B',
6415
- * description: 'Runs Tool B',
6416
- * deepLink: 'fins://path.to/tool-b/manifest.json',
6417
- * iconPath: 'https://path.to/tool-b/icon.ico',
6418
- * iconIndex: 0
6419
- * }]
6420
- * }
6421
- * ];
6422
- *
6423
- * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
6424
- * ```
6425
- *
6426
- * To handle deeplink args:
6427
- * ```js
6428
- * function handleUseLastConfiguration() {
6429
- * // this handler is called when the app is being launched
6430
- * app.on('run-requested', event => {
6431
- * if(event.userAppConfigArgs['use-last-configuration']) {
6432
- * // your logic here
6433
- * }
6434
- * });
6435
- * // this handler is called when the app was already running when the launch was requested
6436
- * fin.desktop.main(function(args) {
6437
- * if(args && args['use-last-configuration']) {
6438
- * // your logic here
6439
- * }
6440
- * });
6441
- * }
6442
- * ```
6443
- */
6444
- async setJumpList(jumpListCategories) {
6445
- await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
6446
- }
6447
- /**
6448
- * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
6449
- * @param icon Image URL or base64 encoded string to be used as the icon
6450
- *
6451
- * @example
6452
- *
6453
- * ```js
6454
- * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
6455
- * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
6456
- * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
6457
- * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
6458
- * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
6459
- *
6460
- * async function setTrayIcon(icon) {
6461
- * const app = await fin.Application.getCurrent();
6462
- * return await app.setTrayIcon(icon);
6463
- * }
6464
- *
6465
- * // use image url to set tray icon
6466
- * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
6467
- *
6468
- * // use base64 encoded string to set tray icon
6469
- * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
6470
- *
6471
- * // use a dataURL to set tray icon
6472
- * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
6473
- * ```
6474
- */
6475
- setTrayIcon(icon) {
6476
- return this.wire
6477
- .sendAction('set-tray-icon', {
6478
- enabledIcon: icon,
6479
- ...this.identity
6480
- })
6481
- .then(() => undefined);
6482
- }
6483
- /**
6484
- * Set hover text for this application's system tray icon.
6485
- * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
6486
- * @param toolTip
6487
- *
6488
- * @example
6489
- *
6490
- * ```js
6491
- * const app = fin.Application.getCurrentSync();
6492
- * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
6493
- *
6494
- * await app.setTrayIcon(iconUrl);
6495
- *
6496
- * await app.setTrayIconToolTip('My Application');
6497
- * ```
6498
- */
6499
- async setTrayIconToolTip(toolTip) {
6500
- await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
6501
- }
6502
- /**
6503
- * Sets new application's shortcut configuration. Windows only.
6504
- * @param config New application's shortcut configuration.
6505
- *
6506
- * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
6507
- * to be able to change shortcut states.
6508
- *
6509
- * @example
6510
- *
6511
- * ```js
6512
- * async function setShortcuts(config) {
6513
- * const app = await fin.Application.getCurrent();
6514
- * return app.setShortcuts(config);
6515
- * }
6516
- *
6517
- * setShortcuts({
6518
- * desktop: true,
6519
- * startMenu: false,
6520
- * systemStartup: true
6521
- * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
6522
- * ```
6523
- */
6524
- setShortcuts(config) {
6525
- return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
6526
- }
6527
- /**
6528
- * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
6529
- * @param queryString The new query string for this app's shortcuts.
6530
- *
6531
- * @example
6532
- *
6533
- * ```js
6534
- * const newQueryArgs = 'arg=true&arg2=false';
6535
- * const app = await fin.Application.getCurrent();
6536
- * try {
6537
- * await app.setShortcutQueryParams(newQueryArgs);
6538
- * } catch(err) {
6539
- * console.error(err)
6540
- * }
6541
- * ```
6542
- */
6543
- async setShortcutQueryParams(queryString) {
6544
- await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
6545
- }
6546
- /**
6547
- * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
6548
- * larger or smaller to default limits of 300% and 50% of original size, respectively.
6549
- * @param level The zoom level
6550
- *
6551
- * @example
6552
- *
6553
- * ```js
6554
- * async function setZoomLevel(number) {
6555
- * const app = await fin.Application.getCurrent();
6556
- * return await app.setZoomLevel(number);
6557
- * }
6558
- *
6559
- * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
6560
- * ```
6561
- */
6562
- setZoomLevel(level) {
6563
- return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
6564
- }
6565
- /**
6566
- * Sets a username to correlate with App Log Management.
6567
- * @param username Username to correlate with App's Log.
6568
- *
6569
- * @example
6570
- *
6571
- * ```js
6572
- * async function setAppLogUser() {
6573
- * const app = await fin.Application.getCurrent();
6574
- * return await app.setAppLogUsername('username');
6575
- * }
6576
- *
6577
- * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
6578
- *
6579
- * ```
6580
- */
6581
- async setAppLogUsername(username) {
6582
- await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
6583
- }
6584
- /**
6585
- * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
6586
- * @remarks The only information currently returned is the position and dimensions.
6587
- *
6588
- * @example
6589
- *
6590
- * ```js
6591
- * async function getTrayIconInfo() {
6592
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
6593
- * return await app.getTrayIconInfo();
6594
- * }
6595
- * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
6596
- * ```
6597
- */
6598
- getTrayIconInfo() {
6599
- return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
6600
- }
6601
- /**
6602
- * Checks if the application has an associated tray icon.
6603
- *
6604
- * @example
6605
- *
6606
- * ```js
6607
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
6608
- * const hasTrayIcon = await app.hasTrayIcon();
6609
- * console.log(hasTrayIcon);
6610
- * ```
6611
- */
6612
- hasTrayIcon() {
6613
- return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
6614
- }
6615
- /**
6616
- * Closes the application by terminating its process.
6617
- *
6618
- * @example
6619
- *
6620
- * ```js
6621
- * async function terminateApp() {
6622
- * const app = await fin.Application.getCurrent();
6623
- * return await app.terminate();
6624
- * }
6625
- * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
6626
- * ```
6627
- */
6628
- terminate() {
6629
- return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
6630
- }
6631
- /**
6632
- * Waits for a hanging application. This method can be called in response to an application
6633
- * "not-responding" to allow the application to continue and to generate another "not-responding"
6634
- * message after a certain period of time.
6635
- *
6636
- * @ignore
6637
- */
6638
- wait() {
6639
- return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
6640
- }
6641
- /**
6642
- * Retrieves information about the application.
6643
- *
6644
- * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
6645
- * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
6646
- * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
6647
- *
6648
- * @example
6649
- *
6650
- * ```js
6651
- * async function getInfo() {
6652
- * const app = await fin.Application.getCurrent();
6653
- * return await app.getInfo();
6654
- * }
6655
- *
6656
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
6657
- * ```
6658
- */
6659
- getInfo() {
6660
- return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
6661
- }
6662
- /**
6663
- * Retrieves all process information for entities (windows and views) associated with an application.
6664
- *
6665
- * @example
6666
- * ```js
6667
- * const app = await fin.Application.getCurrent();
6668
- * const processInfo = await app.getProcessInfo();
6669
- * ```
6670
- * @experimental
6671
- */
6672
- async getProcessInfo() {
6673
- const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
6674
- return data;
6675
- }
6676
- /**
6677
- * Sets file auto download location. It's only allowed in the same application.
6678
- *
6679
- * Note: This method is restricted by default and must be enabled via
6680
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
6681
- * @param downloadLocation file auto download location
6682
- *
6683
- * @throws if setting file auto download location on different applications.
6684
- * @example
6685
- *
6686
- * ```js
6687
- * const downloadLocation = 'C:\\dev\\temp';
6688
- * const app = await fin.Application.getCurrent();
6689
- * try {
6690
- * await app.setFileDownloadLocation(downloadLocation);
6691
- * console.log('File download location is set');
6692
- * } catch(err) {
6693
- * console.error(err)
6694
- * }
6695
- * ```
6696
- */
6697
- async setFileDownloadLocation(downloadLocation) {
6698
- const { name } = this.wire.me;
6699
- const entityIdentity = { uuid: this.identity.uuid, name };
6700
- await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
6701
- }
6702
- /**
6703
- * 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.
6704
- *
6705
- * Note: This method is restricted by default and must be enabled via
6706
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
6707
- *
6708
- * @throws if getting file auto download location on different applications.
6709
- * @example
6710
- *
6711
- * ```js
6712
- * const app = await fin.Application.getCurrent();
6713
- * const fileDownloadDir = await app.getFileDownloadLocation();
6714
- * ```
6715
- */
6716
- async getFileDownloadLocation() {
6717
- const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
6718
- return data;
6719
- }
6720
- /**
6721
- * Shows a menu on the tray icon. Use with tray-icon-clicked event.
6722
- * @param options
6723
- * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
6724
- * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
6725
- * of all possible data shapes for the entire menu, and the click handler should process
6726
- * these with a "reducer" pattern.
6727
- * @throws if the application has no tray icon set
6728
- * @throws if the system tray is currently hidden
6729
- * @example
6730
- *
6731
- * ```js
6732
- * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
6733
- * const app = fin.Application.getCurrentSync();
6734
- *
6735
- * await app.setTrayIcon(iconUrl);
6736
- *
6737
- * const template = [
6738
- * {
6739
- * label: 'Menu Item 1',
6740
- * data: 'hello from item 1'
6741
- * },
6742
- * { type: 'separator' },
6743
- * {
6744
- * label: 'Menu Item 2',
6745
- * type: 'checkbox',
6746
- * checked: true,
6747
- * data: 'The user clicked the checkbox'
6748
- * },
6749
- * {
6750
- * label: 'see more',
6751
- * enabled: false,
6752
- * submenu: [
6753
- * { label: 'submenu 1', data: 'hello from submenu' }
6754
- * ]
6755
- * }
6756
- * ];
6757
- *
6758
- * app.addListener('tray-icon-clicked', (event) => {
6759
- * // right-click
6760
- * if (event.button === 2) {
6761
- * app.showTrayIconPopupMenu({ template }).then(r => {
6762
- * if (r.result === 'closed') {
6763
- * console.log('nothing happened');
6764
- * } else {
6765
- * console.log(r.data);
6766
- * }
6767
- * });
6768
- * }
6769
- * });
6770
- * ```
6771
- */
6772
- async showTrayIconPopupMenu(options) {
6773
- const { name } = this.wire.me;
6774
- const entityIdentity = { uuid: this.identity.uuid, name };
6775
- const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
6776
- return payload.data;
6777
- }
6778
- /**
6779
- * Closes the tray icon menu.
6780
- *
6781
- * @throws if the application has no tray icon set
6782
- * @example
6783
- *
6784
- * ```js
6785
- * const app = fin.Application.getCurrentSync();
6786
- *
6787
- * await app.closeTrayIconPopupMenu();
6788
- * ```
6789
- */
6790
- async closeTrayIconPopupMenu() {
6791
- const { name } = this.wire.me;
6792
- const entityIdentity = { uuid: this.identity.uuid, name };
6793
- await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
6794
- }
6795
- }
6796
- Instance$5.Application = Application;
5974
+ var hasRequiredInstance$2;
6797
5975
 
6798
- Object.defineProperty(Factory$5, "__esModule", { value: true });
6799
- Factory$5.ApplicationModule = void 0;
6800
- const base_1$i = base;
6801
- const validate_1$4 = validate;
6802
- const Instance_1$5 = Instance$5;
6803
- /**
6804
- * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
6805
- */
6806
- class ApplicationModule extends base_1$i.Base {
6807
- /**
6808
- * Asynchronously returns an API handle for the given Application identity.
6809
- *
6810
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
6811
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
6812
- * for an Application throughout its entire lifecycle.
6813
- *
6814
- * @example
6815
- *
6816
- * ```js
6817
- * fin.Application.wrap({ uuid: 'testapp' })
6818
- * .then(app => app.isRunning())
6819
- * .then(running => console.log('Application is running: ' + running))
6820
- * .catch(err => console.log(err));
6821
- * ```
6822
- *
6823
- */
6824
- async wrap(identity) {
6825
- this.wire.sendAction('wrap-application').catch((e) => {
6826
- // we do not want to expose this error, just continue if this analytics-only call fails
6827
- });
6828
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
6829
- if (errorMsg) {
6830
- throw new Error(errorMsg);
6831
- }
6832
- return new Instance_1$5.Application(this.wire, identity);
6833
- }
6834
- /**
6835
- * Synchronously returns an API handle for the given Application identity.
6836
- *
6837
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
6838
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
6839
- * for an Aplication throughout its entire lifecycle.
6840
- *
6841
- * @example
6842
- *
6843
- * ```js
6844
- * const app = fin.Application.wrapSync({ uuid: 'testapp' });
6845
- * await app.close();
6846
- * ```
6847
- *
6848
- */
6849
- wrapSync(identity) {
6850
- this.wire.sendAction('wrap-application-sync').catch((e) => {
6851
- // we do not want to expose this error, just continue if this analytics-only call fails
6852
- });
6853
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
6854
- if (errorMsg) {
6855
- throw new Error(errorMsg);
6856
- }
6857
- return new Instance_1$5.Application(this.wire, identity);
6858
- }
6859
- async _create(appOptions) {
6860
- // set defaults:
6861
- if (appOptions.waitForPageLoad === undefined) {
6862
- appOptions.waitForPageLoad = false;
6863
- }
6864
- if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
6865
- appOptions.autoShow = true;
6866
- }
6867
- await this.wire.sendAction('create-application', appOptions);
6868
- return this.wrap({ uuid: appOptions.uuid });
6869
- }
6870
- /**
6871
- * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
6872
- *
6873
- * @example
6874
- *
6875
- * ```js
6876
- * async function createApp() {
6877
- * const app = await fin.Application.create({
6878
- * name: 'myApp',
6879
- * uuid: 'app-3',
6880
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
6881
- * autoShow: true
6882
- * });
6883
- * await app.run();
6884
- * }
6885
- *
6886
- * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
6887
- * ```
6888
- *
6889
- * @ignore
6890
- */
6891
- create(appOptions) {
6892
- console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
6893
- this.wire.sendAction('application-create').catch((e) => {
6894
- // we do not want to expose this error, just continue if this analytics-only call fails
6895
- });
6896
- return this._create(appOptions);
6897
- }
6898
- /**
6899
- * Creates and starts a new Application.
6900
- *
6901
- * @example
6902
- *
6903
- * ```js
6904
- * async function start() {
6905
- * return fin.Application.start({
6906
- * name: 'app-1',
6907
- * uuid: 'app-1',
6908
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
6909
- * autoShow: true
6910
- * });
6911
- * }
6912
- * start().then(() => console.log('Application is running')).catch(err => console.log(err));
6913
- * ```
6914
- *
6915
- */
6916
- async start(appOptions) {
6917
- this.wire.sendAction('start-application').catch((e) => {
6918
- // we do not want to expose this error, just continue if this analytics-only call fails
6919
- });
6920
- const app = await this._create(appOptions);
6921
- await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
6922
- return app;
6923
- }
6924
- /**
6925
- * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
6926
- * Returns once the RVM is finished attempting to launch the applications.
6927
- * @param opts - Parameters that the RVM will use.
6928
- *
6929
- * @example
6930
- *
6931
- * ```js
6932
- *
6933
- * const applicationInfoArray = [
6934
- * {
6935
- * "uuid": 'App-1',
6936
- * "manifestUrl": 'http://localhost:5555/app1.json',
6937
- * },
6938
- * {
6939
- * "uuid": 'App-2',
6940
- * "manifestUrl": 'http://localhost:5555/app2.json',
6941
- * },
6942
- * {
6943
- * "uuid": 'App-3',
6944
- * "manifestUrl": 'http://localhost:5555/app3.json',
6945
- * }
6946
- * ]
6947
- *
6948
- * fin.Application.startManyManifests(applicationInfoArray)
6949
- * .then(() => {
6950
- * console.log('RVM has finished launching the application list.');
6951
- * })
6952
- * .catch((err) => {
6953
- * console.log(err);
6954
- * })
6955
- * ```
6956
- *
6957
- * @experimental
6958
- */
6959
- async startManyManifests(applications, opts) {
6960
- return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
6961
- }
6962
- /**
6963
- * Asynchronously returns an Application object that represents the current application
6964
- *
6965
- * @example
6966
- *
6967
- * ```js
6968
- * async function isCurrentAppRunning () {
6969
- * const app = await fin.Application.getCurrent();
6970
- * return app.isRunning();
6971
- * }
6972
- *
6973
- * isCurrentAppRunning().then(running => {
6974
- * console.log(`Current app is running: ${running}`);
6975
- * }).catch(err => {
6976
- * console.error(err);
6977
- * });
6978
- *
6979
- * ```
6980
- */
6981
- getCurrent() {
6982
- this.wire.sendAction('get-current-application').catch((e) => {
6983
- // we do not want to expose this error, just continue if this analytics-only call fails
6984
- });
6985
- return this.wrap({ uuid: this.wire.me.uuid });
6986
- }
6987
- /**
6988
- * Synchronously returns an Application object that represents the current application
6989
- *
6990
- * @example
6991
- *
6992
- * ```js
6993
- * async function isCurrentAppRunning () {
6994
- * const app = fin.Application.getCurrentSync();
6995
- * return app.isRunning();
6996
- * }
6997
- *
6998
- * isCurrentAppRunning().then(running => {
6999
- * console.log(`Current app is running: ${running}`);
7000
- * }).catch(err => {
7001
- * console.error(err);
7002
- * });
7003
- *
7004
- * ```
7005
- */
7006
- getCurrentSync() {
7007
- this.wire.sendAction('get-current-application-sync').catch((e) => {
7008
- // we do not want to expose this error, just continue if this analytics-only call fails
7009
- });
7010
- return this.wrapSync({ uuid: this.wire.me.uuid });
7011
- }
7012
- /**
7013
- * Retrieves application's manifest and returns a running instance of the application.
7014
- * @param manifestUrl - The URL of app's manifest.
7015
- * @param opts - Parameters that the RVM will use.
7016
- *
7017
- * @example
7018
- *
7019
- * ```js
7020
- * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
7021
- *
7022
- * // For a local manifest file:
7023
- * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
7024
- * ```
7025
- */
7026
- async startFromManifest(manifestUrl, opts) {
7027
- this.wire.sendAction('application-start-from-manifest').catch((e) => {
7028
- // we do not want to expose this error, just continue if this analytics-only call fails
7029
- });
7030
- const app = await this._createFromManifest(manifestUrl);
7031
- // @ts-expect-error using private method without warning.
7032
- await app._run(opts); // eslint-disable-line no-underscore-dangle
7033
- return app;
7034
- }
7035
- /**
7036
- * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
7037
- * Retrieves application's manifest and returns a wrapped application.
7038
- * @param manifestUrl - The URL of app's manifest.
7039
- * @param callback - called if the method succeeds.
7040
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
7041
- *
7042
- * @example
7043
- *
7044
- * ```js
7045
- * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
7046
- * ```
7047
- * @ignore
7048
- */
7049
- createFromManifest(manifestUrl) {
7050
- console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
7051
- this.wire.sendAction('application-create-from-manifest').catch((e) => {
7052
- // we do not want to expose this error, just continue if this analytics-only call fails
7053
- });
7054
- return this._createFromManifest(manifestUrl);
7055
- }
7056
- _createFromManifest(manifestUrl) {
7057
- return this.wire
7058
- .sendAction('get-application-manifest', { manifestUrl })
7059
- .then(({ payload }) => {
7060
- const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
7061
- return this.wrap({ uuid });
7062
- })
7063
- .then((app) => {
7064
- app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
7065
- return app;
7066
- });
7067
- }
5976
+ function requireInstance$2 () {
5977
+ if (hasRequiredInstance$2) return Instance$5;
5978
+ hasRequiredInstance$2 = 1;
5979
+ Object.defineProperty(Instance$5, "__esModule", { value: true });
5980
+ Instance$5.Application = void 0;
5981
+ /* eslint-disable import/prefer-default-export */
5982
+ const base_1 = base;
5983
+ const window_1 = requireWindow();
5984
+ const view_1 = requireView();
5985
+ /**
5986
+ * An object representing an application. Allows the developer to create,
5987
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
5988
+ */
5989
+ class Application extends base_1.EmitterBase {
5990
+ /**
5991
+ * @internal
5992
+ */
5993
+ constructor(wire, identity) {
5994
+ super(wire, 'application', identity.uuid);
5995
+ this.identity = identity;
5996
+ this.window = new window_1._Window(this.wire, {
5997
+ uuid: this.identity.uuid,
5998
+ name: this.identity.uuid
5999
+ });
6000
+ }
6001
+ windowListFromIdentityList(identityList) {
6002
+ const windowList = [];
6003
+ identityList.forEach((identity) => {
6004
+ windowList.push(new window_1._Window(this.wire, {
6005
+ uuid: identity.uuid,
6006
+ name: identity.name
6007
+ }));
6008
+ });
6009
+ return windowList;
6010
+ }
6011
+ /**
6012
+ * Determines if the application is currently running.
6013
+ *
6014
+ * @example
6015
+ *
6016
+ * ```js
6017
+ * async function isAppRunning() {
6018
+ * const app = await fin.Application.getCurrent();
6019
+ * return await app.isRunning();
6020
+ * }
6021
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
6022
+ * ```
6023
+ */
6024
+ isRunning() {
6025
+ return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
6026
+ }
6027
+ /**
6028
+ * Closes the application and any child windows created by the application.
6029
+ * Cleans the application from state so it is no longer found in getAllApplications.
6030
+ * @param force Close will be prevented from closing when force is false and
6031
+ * ‘close-requested’ has been subscribed to for application’s main window.
6032
+ *
6033
+ * @example
6034
+ *
6035
+ * ```js
6036
+ * async function closeApp() {
6037
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
6038
+ * const app = await fin.Application.wrap({uuid: 'app2'});
6039
+ * await app.quit();
6040
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
6041
+ *
6042
+ * }
6043
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
6044
+ * ```
6045
+ */
6046
+ async quit(force = false) {
6047
+ try {
6048
+ await this._close(force);
6049
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
6050
+ }
6051
+ catch (error) {
6052
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
6053
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
6054
+ throw error;
6055
+ }
6056
+ }
6057
+ }
6058
+ async _close(force = false) {
6059
+ try {
6060
+ await this.wire.sendAction('close-application', { force, ...this.identity });
6061
+ }
6062
+ catch (error) {
6063
+ if (!error.message.includes('Remote connection has closed')) {
6064
+ throw error;
6065
+ }
6066
+ }
6067
+ }
6068
+ /**
6069
+ * @deprecated use Application.quit instead
6070
+ * Closes the application and any child windows created by the application.
6071
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
6072
+ * @param callback - called if the method succeeds.
6073
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
6074
+ *
6075
+ * @example
6076
+ *
6077
+ * ```js
6078
+ * async function closeApp() {
6079
+ * const app = await fin.Application.getCurrent();
6080
+ * return await app.close();
6081
+ * }
6082
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
6083
+ * ```
6084
+ */
6085
+ close(force = false) {
6086
+ console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
6087
+ this.wire.sendAction('application-close', this.identity).catch((e) => {
6088
+ // we do not want to expose this error, just continue if this analytics-only call fails
6089
+ });
6090
+ return this._close(force);
6091
+ }
6092
+ /**
6093
+ * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
6094
+ *
6095
+ * @example
6096
+ *
6097
+ * ```js
6098
+ * async function getChildWindows() {
6099
+ * const app = await fin.Application.getCurrent();
6100
+ * return await app.getChildWindows();
6101
+ * }
6102
+ *
6103
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
6104
+ * ```
6105
+ */
6106
+ getChildWindows() {
6107
+ return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
6108
+ const identityList = [];
6109
+ payload.data.forEach((winName) => {
6110
+ identityList.push({ uuid: this.identity.uuid, name: winName });
6111
+ });
6112
+ return this.windowListFromIdentityList(identityList);
6113
+ });
6114
+ }
6115
+ /**
6116
+ * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
6117
+ * if the application was not created from a manifest.
6118
+ *
6119
+ * @example
6120
+ *
6121
+ * ```js
6122
+ * async function getManifest() {
6123
+ * const app = await fin.Application.getCurrent();
6124
+ * return await app.getManifest();
6125
+ * }
6126
+ *
6127
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
6128
+ * ```
6129
+ */
6130
+ getManifest() {
6131
+ return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
6132
+ }
6133
+ /**
6134
+ * Retrieves UUID of the application that launches this application. Invokes the error callback
6135
+ * if the application was created from a manifest.
6136
+ *
6137
+ * @example
6138
+ *
6139
+ * ```js
6140
+ * async function getParentUuid() {
6141
+ * const app = await fin.Application.start({
6142
+ * uuid: 'app-1',
6143
+ * name: 'myApp',
6144
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
6145
+ * autoShow: true
6146
+ * });
6147
+ * return await app.getParentUuid();
6148
+ * }
6149
+ *
6150
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
6151
+ * ```
6152
+ */
6153
+ getParentUuid() {
6154
+ return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
6155
+ }
6156
+ /**
6157
+ * Retrieves current application's shortcut configuration.
6158
+ *
6159
+ * @example
6160
+ *
6161
+ * ```js
6162
+ * async function getShortcuts() {
6163
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
6164
+ * return await app.getShortcuts();
6165
+ * }
6166
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
6167
+ * ```
6168
+ */
6169
+ getShortcuts() {
6170
+ return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
6171
+ }
6172
+ /**
6173
+ * Retrieves current application's views.
6174
+ * @experimental
6175
+ *
6176
+ * @example
6177
+ *
6178
+ * ```js
6179
+ * async function getViews() {
6180
+ * const app = await fin.Application.getCurrent();
6181
+ * return await app.getViews();
6182
+ * }
6183
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
6184
+ * ```
6185
+ */
6186
+ async getViews() {
6187
+ const { payload } = await this.wire.sendAction('application-get-views', this.identity);
6188
+ return payload.data.map((id) => new view_1.View(this.wire, id));
6189
+ }
6190
+ /**
6191
+ * Returns the current zoom level of the application.
6192
+ *
6193
+ * @example
6194
+ *
6195
+ * ```js
6196
+ * async function getZoomLevel() {
6197
+ * const app = await fin.Application.getCurrent();
6198
+ * return await app.getZoomLevel();
6199
+ * }
6200
+ *
6201
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
6202
+ * ```
6203
+ */
6204
+ getZoomLevel() {
6205
+ return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
6206
+ }
6207
+ /**
6208
+ * Returns an instance of the main Window of the application
6209
+ *
6210
+ * @example
6211
+ *
6212
+ * ```js
6213
+ * async function getWindow() {
6214
+ * const app = await fin.Application.start({
6215
+ * uuid: 'app-1',
6216
+ * name: 'myApp',
6217
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
6218
+ * autoShow: true
6219
+ * });
6220
+ * return await app.getWindow();
6221
+ * }
6222
+ *
6223
+ * getWindow().then(win => {
6224
+ * win.showAt(0, 400);
6225
+ * win.flash();
6226
+ * }).catch(err => console.log(err));
6227
+ * ```
6228
+ */
6229
+ getWindow() {
6230
+ this.wire.sendAction('application-get-window', this.identity).catch((e) => {
6231
+ // we do not want to expose this error, just continue if this analytics-only call fails
6232
+ });
6233
+ return Promise.resolve(this.window);
6234
+ }
6235
+ /**
6236
+ * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
6237
+ * @param userName - username to be passed to the RVM.
6238
+ * @param appName - app name to be passed to the RVM.
6239
+ *
6240
+ * @example
6241
+ *
6242
+ * ```js
6243
+ * async function registerUser() {
6244
+ * const app = await fin.Application.getCurrent();
6245
+ * return await app.registerUser('user', 'myApp');
6246
+ * }
6247
+ *
6248
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
6249
+ * ```
6250
+ */
6251
+ registerUser(userName, appName) {
6252
+ return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
6253
+ }
6254
+ /**
6255
+ * Removes the application’s icon from the tray.
6256
+ *
6257
+ * @example
6258
+ *
6259
+ * ```js
6260
+ * async function removeTrayIcon() {
6261
+ * const app = await fin.Application.getCurrent();
6262
+ * return await app.removeTrayIcon();
6263
+ * }
6264
+ *
6265
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
6266
+ * ```
6267
+ */
6268
+ removeTrayIcon() {
6269
+ return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
6270
+ }
6271
+ /**
6272
+ * Restarts the application.
6273
+ *
6274
+ * @example
6275
+ *
6276
+ * ```js
6277
+ * async function restartApp() {
6278
+ * const app = await fin.Application.getCurrent();
6279
+ * return await app.restart();
6280
+ * }
6281
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
6282
+ * ```
6283
+ */
6284
+ restart() {
6285
+ return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
6286
+ }
6287
+ /**
6288
+ * DEPRECATED method to run the application.
6289
+ * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
6290
+ *
6291
+ * @example
6292
+ *
6293
+ * ```js
6294
+ * async function run() {
6295
+ * const app = await fin.Application.create({
6296
+ * name: 'myApp',
6297
+ * uuid: 'app-1',
6298
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
6299
+ * autoShow: true
6300
+ * });
6301
+ * await app.run();
6302
+ * }
6303
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
6304
+ * ```
6305
+ *
6306
+ * @ignore
6307
+ */
6308
+ run() {
6309
+ console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
6310
+ this.wire.sendAction('application-run', this.identity).catch((e) => {
6311
+ // we do not want to expose this error, just continue if this analytics-only call fails
6312
+ });
6313
+ return this._run();
6314
+ }
6315
+ _run(opts = {}) {
6316
+ return this.wire
6317
+ .sendAction('run-application', {
6318
+ manifestUrl: this._manifestUrl,
6319
+ opts,
6320
+ ...this.identity
6321
+ })
6322
+ .then(() => undefined);
6323
+ }
6324
+ /**
6325
+ * Instructs the RVM to schedule one restart of the application.
6326
+ *
6327
+ * @example
6328
+ *
6329
+ * ```js
6330
+ * async function scheduleRestart() {
6331
+ * const app = await fin.Application.getCurrent();
6332
+ * return await app.scheduleRestart();
6333
+ * }
6334
+ *
6335
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
6336
+ * ```
6337
+ */
6338
+ scheduleRestart() {
6339
+ return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
6340
+ }
6341
+ /**
6342
+ * Sends a message to the RVM to upload the application's logs. On success,
6343
+ * an object containing logId is returned.
6344
+ *
6345
+ * @example
6346
+ *
6347
+ * ```js
6348
+ * async function sendLog() {
6349
+ * const app = await fin.Application.getCurrent();
6350
+ * return await app.sendApplicationLog();
6351
+ * }
6352
+ *
6353
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
6354
+ * ```
6355
+ */
6356
+ async sendApplicationLog() {
6357
+ const { payload } = await this.wire.sendAction('send-application-log', this.identity);
6358
+ return payload.data;
6359
+ }
6360
+ /**
6361
+ * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
6362
+ * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
6363
+ *
6364
+ * Note: If the "name" property is omitted it defaults to "tasks".
6365
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
6366
+ *
6367
+ *
6368
+ * @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).
6369
+ *
6370
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
6371
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
6372
+ *
6373
+ * Note: If the "name" property is omitted it defaults to "tasks".
6374
+ *
6375
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
6376
+ * uuid or shortcut.name is changed.
6377
+ *
6378
+ * @example
6379
+ *
6380
+ * ```js
6381
+ * const app = fin.Application.getCurrentSync();
6382
+ * const appName = 'My App';
6383
+ * const jumpListConfig = [ // array of JumpList categories
6384
+ * {
6385
+ * // has no name and no type so `type` is assumed to be "tasks"
6386
+ * items: [ // array of JumpList items
6387
+ * {
6388
+ * type: 'task',
6389
+ * title: `Launch ${appName}`,
6390
+ * description: `Runs ${appName} with the default configuration`,
6391
+ * deepLink: 'fins://path.to/app/manifest.json',
6392
+ * iconPath: 'https://path.to/app/icon.ico',
6393
+ * iconIndex: 0
6394
+ * },
6395
+ * { type: 'separator' },
6396
+ * {
6397
+ * type: 'task',
6398
+ * title: `Restore ${appName}`,
6399
+ * description: 'Restore to last configuration',
6400
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
6401
+ * iconPath: 'https://path.to/app/icon.ico',
6402
+ * iconIndex: 0
6403
+ * },
6404
+ * ]
6405
+ * },
6406
+ * {
6407
+ * name: 'Tools',
6408
+ * items: [ // array of JumpList items
6409
+ * {
6410
+ * type: 'task',
6411
+ * title: 'Tool A',
6412
+ * description: 'Runs Tool A',
6413
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
6414
+ * iconPath: 'https://path.to/tool-a/icon.ico',
6415
+ * iconIndex: 0
6416
+ * },
6417
+ * {
6418
+ * type: 'task',
6419
+ * title: 'Tool B',
6420
+ * description: 'Runs Tool B',
6421
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
6422
+ * iconPath: 'https://path.to/tool-b/icon.ico',
6423
+ * iconIndex: 0
6424
+ * }]
6425
+ * }
6426
+ * ];
6427
+ *
6428
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
6429
+ * ```
6430
+ *
6431
+ * To handle deeplink args:
6432
+ * ```js
6433
+ * function handleUseLastConfiguration() {
6434
+ * // this handler is called when the app is being launched
6435
+ * app.on('run-requested', event => {
6436
+ * if(event.userAppConfigArgs['use-last-configuration']) {
6437
+ * // your logic here
6438
+ * }
6439
+ * });
6440
+ * // this handler is called when the app was already running when the launch was requested
6441
+ * fin.desktop.main(function(args) {
6442
+ * if(args && args['use-last-configuration']) {
6443
+ * // your logic here
6444
+ * }
6445
+ * });
6446
+ * }
6447
+ * ```
6448
+ */
6449
+ async setJumpList(jumpListCategories) {
6450
+ await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
6451
+ }
6452
+ /**
6453
+ * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
6454
+ * @param icon Image URL or base64 encoded string to be used as the icon
6455
+ *
6456
+ * @example
6457
+ *
6458
+ * ```js
6459
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
6460
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
6461
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
6462
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
6463
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
6464
+ *
6465
+ * async function setTrayIcon(icon) {
6466
+ * const app = await fin.Application.getCurrent();
6467
+ * return await app.setTrayIcon(icon);
6468
+ * }
6469
+ *
6470
+ * // use image url to set tray icon
6471
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
6472
+ *
6473
+ * // use base64 encoded string to set tray icon
6474
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
6475
+ *
6476
+ * // use a dataURL to set tray icon
6477
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
6478
+ * ```
6479
+ */
6480
+ setTrayIcon(icon) {
6481
+ return this.wire
6482
+ .sendAction('set-tray-icon', {
6483
+ enabledIcon: icon,
6484
+ ...this.identity
6485
+ })
6486
+ .then(() => undefined);
6487
+ }
6488
+ /**
6489
+ * Set hover text for this application's system tray icon.
6490
+ * Note: Application must first set a tray icon with {@link Application.setTrayIcon}.
6491
+ * @param toolTip
6492
+ *
6493
+ * @example
6494
+ *
6495
+ * ```js
6496
+ * const app = fin.Application.getCurrentSync();
6497
+ * const iconUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
6498
+ *
6499
+ * await app.setTrayIcon(iconUrl);
6500
+ *
6501
+ * await app.setTrayIconToolTip('My Application');
6502
+ * ```
6503
+ */
6504
+ async setTrayIconToolTip(toolTip) {
6505
+ await this.wire.sendAction('set-tray-icon-tooltip', { ...this.identity, toolTip });
6506
+ }
6507
+ /**
6508
+ * Sets new application's shortcut configuration. Windows only.
6509
+ * @param config New application's shortcut configuration.
6510
+ *
6511
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
6512
+ * to be able to change shortcut states.
6513
+ *
6514
+ * @example
6515
+ *
6516
+ * ```js
6517
+ * async function setShortcuts(config) {
6518
+ * const app = await fin.Application.getCurrent();
6519
+ * return app.setShortcuts(config);
6520
+ * }
6521
+ *
6522
+ * setShortcuts({
6523
+ * desktop: true,
6524
+ * startMenu: false,
6525
+ * systemStartup: true
6526
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
6527
+ * ```
6528
+ */
6529
+ setShortcuts(config) {
6530
+ return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
6531
+ }
6532
+ /**
6533
+ * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
6534
+ * @param queryString The new query string for this app's shortcuts.
6535
+ *
6536
+ * @example
6537
+ *
6538
+ * ```js
6539
+ * const newQueryArgs = 'arg=true&arg2=false';
6540
+ * const app = await fin.Application.getCurrent();
6541
+ * try {
6542
+ * await app.setShortcutQueryParams(newQueryArgs);
6543
+ * } catch(err) {
6544
+ * console.error(err)
6545
+ * }
6546
+ * ```
6547
+ */
6548
+ async setShortcutQueryParams(queryString) {
6549
+ await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
6550
+ }
6551
+ /**
6552
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
6553
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
6554
+ * @param level The zoom level
6555
+ *
6556
+ * @example
6557
+ *
6558
+ * ```js
6559
+ * async function setZoomLevel(number) {
6560
+ * const app = await fin.Application.getCurrent();
6561
+ * return await app.setZoomLevel(number);
6562
+ * }
6563
+ *
6564
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
6565
+ * ```
6566
+ */
6567
+ setZoomLevel(level) {
6568
+ return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
6569
+ }
6570
+ /**
6571
+ * Sets a username to correlate with App Log Management.
6572
+ * @param username Username to correlate with App's Log.
6573
+ *
6574
+ * @example
6575
+ *
6576
+ * ```js
6577
+ * async function setAppLogUser() {
6578
+ * const app = await fin.Application.getCurrent();
6579
+ * return await app.setAppLogUsername('username');
6580
+ * }
6581
+ *
6582
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
6583
+ *
6584
+ * ```
6585
+ */
6586
+ async setAppLogUsername(username) {
6587
+ await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
6588
+ }
6589
+ /**
6590
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
6591
+ * @remarks The only information currently returned is the position and dimensions.
6592
+ *
6593
+ * @example
6594
+ *
6595
+ * ```js
6596
+ * async function getTrayIconInfo() {
6597
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
6598
+ * return await app.getTrayIconInfo();
6599
+ * }
6600
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
6601
+ * ```
6602
+ */
6603
+ getTrayIconInfo() {
6604
+ return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
6605
+ }
6606
+ /**
6607
+ * Checks if the application has an associated tray icon.
6608
+ *
6609
+ * @example
6610
+ *
6611
+ * ```js
6612
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
6613
+ * const hasTrayIcon = await app.hasTrayIcon();
6614
+ * console.log(hasTrayIcon);
6615
+ * ```
6616
+ */
6617
+ hasTrayIcon() {
6618
+ return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
6619
+ }
6620
+ /**
6621
+ * Closes the application by terminating its process.
6622
+ *
6623
+ * @example
6624
+ *
6625
+ * ```js
6626
+ * async function terminateApp() {
6627
+ * const app = await fin.Application.getCurrent();
6628
+ * return await app.terminate();
6629
+ * }
6630
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
6631
+ * ```
6632
+ */
6633
+ terminate() {
6634
+ return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
6635
+ }
6636
+ /**
6637
+ * Waits for a hanging application. This method can be called in response to an application
6638
+ * "not-responding" to allow the application to continue and to generate another "not-responding"
6639
+ * message after a certain period of time.
6640
+ *
6641
+ * @ignore
6642
+ */
6643
+ wait() {
6644
+ return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
6645
+ }
6646
+ /**
6647
+ * Retrieves information about the application.
6648
+ *
6649
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
6650
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
6651
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
6652
+ *
6653
+ * @example
6654
+ *
6655
+ * ```js
6656
+ * async function getInfo() {
6657
+ * const app = await fin.Application.getCurrent();
6658
+ * return await app.getInfo();
6659
+ * }
6660
+ *
6661
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
6662
+ * ```
6663
+ */
6664
+ getInfo() {
6665
+ return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
6666
+ }
6667
+ /**
6668
+ * Retrieves all process information for entities (windows and views) associated with an application.
6669
+ *
6670
+ * @example
6671
+ * ```js
6672
+ * const app = await fin.Application.getCurrent();
6673
+ * const processInfo = await app.getProcessInfo();
6674
+ * ```
6675
+ * @experimental
6676
+ */
6677
+ async getProcessInfo() {
6678
+ const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
6679
+ return data;
6680
+ }
6681
+ /**
6682
+ * Sets file auto download location. It's only allowed in the same application.
6683
+ *
6684
+ * Note: This method is restricted by default and must be enabled via
6685
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
6686
+ * @param downloadLocation file auto download location
6687
+ *
6688
+ * @throws if setting file auto download location on different applications.
6689
+ * @example
6690
+ *
6691
+ * ```js
6692
+ * const downloadLocation = 'C:\\dev\\temp';
6693
+ * const app = await fin.Application.getCurrent();
6694
+ * try {
6695
+ * await app.setFileDownloadLocation(downloadLocation);
6696
+ * console.log('File download location is set');
6697
+ * } catch(err) {
6698
+ * console.error(err)
6699
+ * }
6700
+ * ```
6701
+ */
6702
+ async setFileDownloadLocation(downloadLocation) {
6703
+ const { name } = this.wire.me;
6704
+ const entityIdentity = { uuid: this.identity.uuid, name };
6705
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
6706
+ }
6707
+ /**
6708
+ * 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.
6709
+ *
6710
+ * Note: This method is restricted by default and must be enabled via
6711
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
6712
+ *
6713
+ * @throws if getting file auto download location on different applications.
6714
+ * @example
6715
+ *
6716
+ * ```js
6717
+ * const app = await fin.Application.getCurrent();
6718
+ * const fileDownloadDir = await app.getFileDownloadLocation();
6719
+ * ```
6720
+ */
6721
+ async getFileDownloadLocation() {
6722
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
6723
+ return data;
6724
+ }
6725
+ /**
6726
+ * Shows a menu on the tray icon. Use with tray-icon-clicked event.
6727
+ * @param options
6728
+ * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
6729
+ * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
6730
+ * of all possible data shapes for the entire menu, and the click handler should process
6731
+ * these with a "reducer" pattern.
6732
+ * @throws if the application has no tray icon set
6733
+ * @throws if the system tray is currently hidden
6734
+ * @example
6735
+ *
6736
+ * ```js
6737
+ * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
6738
+ * const app = fin.Application.getCurrentSync();
6739
+ *
6740
+ * await app.setTrayIcon(iconUrl);
6741
+ *
6742
+ * const template = [
6743
+ * {
6744
+ * label: 'Menu Item 1',
6745
+ * data: 'hello from item 1'
6746
+ * },
6747
+ * { type: 'separator' },
6748
+ * {
6749
+ * label: 'Menu Item 2',
6750
+ * type: 'checkbox',
6751
+ * checked: true,
6752
+ * data: 'The user clicked the checkbox'
6753
+ * },
6754
+ * {
6755
+ * label: 'see more',
6756
+ * enabled: false,
6757
+ * submenu: [
6758
+ * { label: 'submenu 1', data: 'hello from submenu' }
6759
+ * ]
6760
+ * }
6761
+ * ];
6762
+ *
6763
+ * app.addListener('tray-icon-clicked', (event) => {
6764
+ * // right-click
6765
+ * if (event.button === 2) {
6766
+ * app.showTrayIconPopupMenu({ template }).then(r => {
6767
+ * if (r.result === 'closed') {
6768
+ * console.log('nothing happened');
6769
+ * } else {
6770
+ * console.log(r.data);
6771
+ * }
6772
+ * });
6773
+ * }
6774
+ * });
6775
+ * ```
6776
+ */
6777
+ async showTrayIconPopupMenu(options) {
6778
+ const { name } = this.wire.me;
6779
+ const entityIdentity = { uuid: this.identity.uuid, name };
6780
+ const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
6781
+ return payload.data;
6782
+ }
6783
+ /**
6784
+ * Closes the tray icon menu.
6785
+ *
6786
+ * @throws if the application has no tray icon set
6787
+ * @example
6788
+ *
6789
+ * ```js
6790
+ * const app = fin.Application.getCurrentSync();
6791
+ *
6792
+ * await app.closeTrayIconPopupMenu();
6793
+ * ```
6794
+ */
6795
+ async closeTrayIconPopupMenu() {
6796
+ const { name } = this.wire.me;
6797
+ const entityIdentity = { uuid: this.identity.uuid, name };
6798
+ await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
6799
+ }
6800
+ }
6801
+ Instance$5.Application = Application;
6802
+ return Instance$5;
7068
6803
  }
7069
- Factory$5.ApplicationModule = ApplicationModule;
7070
6804
 
7071
- (function (exports) {
7072
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7073
- if (k2 === undefined) k2 = k;
7074
- var desc = Object.getOwnPropertyDescriptor(m, k);
7075
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7076
- desc = { enumerable: true, get: function() { return m[k]; } };
7077
- }
7078
- Object.defineProperty(o, k2, desc);
7079
- }) : (function(o, m, k, k2) {
7080
- if (k2 === undefined) k2 = k;
7081
- o[k2] = m[k];
7082
- }));
7083
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
7084
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
7085
- };
7086
- Object.defineProperty(exports, "__esModule", { value: true });
6805
+ var hasRequiredFactory$1;
6806
+
6807
+ function requireFactory$1 () {
6808
+ if (hasRequiredFactory$1) return Factory$5;
6809
+ hasRequiredFactory$1 = 1;
6810
+ Object.defineProperty(Factory$5, "__esModule", { value: true });
6811
+ Factory$5.ApplicationModule = void 0;
6812
+ const base_1 = base;
6813
+ const validate_1 = validate;
6814
+ const Instance_1 = requireInstance$2();
7087
6815
  /**
7088
- * Entry points for the OpenFin `Application` API (`fin.Application`).
7089
- *
7090
- * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
7091
- * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
7092
- *
7093
- * 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),
7094
- * both of these were documented on the same page.
7095
- *
7096
- * @packageDocumentation
6816
+ * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
7097
6817
  */
7098
- __exportStar(Factory$5, exports);
7099
- __exportStar(Instance$5, exports);
7100
- } (application));
6818
+ class ApplicationModule extends base_1.Base {
6819
+ /**
6820
+ * Asynchronously returns an API handle for the given Application identity.
6821
+ *
6822
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
6823
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
6824
+ * for an Application throughout its entire lifecycle.
6825
+ *
6826
+ * @example
6827
+ *
6828
+ * ```js
6829
+ * fin.Application.wrap({ uuid: 'testapp' })
6830
+ * .then(app => app.isRunning())
6831
+ * .then(running => console.log('Application is running: ' + running))
6832
+ * .catch(err => console.log(err));
6833
+ * ```
6834
+ *
6835
+ */
6836
+ async wrap(identity) {
6837
+ this.wire.sendAction('wrap-application').catch((e) => {
6838
+ // we do not want to expose this error, just continue if this analytics-only call fails
6839
+ });
6840
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
6841
+ if (errorMsg) {
6842
+ throw new Error(errorMsg);
6843
+ }
6844
+ return new Instance_1.Application(this.wire, identity);
6845
+ }
6846
+ /**
6847
+ * Synchronously returns an API handle for the given Application identity.
6848
+ *
6849
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
6850
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
6851
+ * for an Aplication throughout its entire lifecycle.
6852
+ *
6853
+ * @example
6854
+ *
6855
+ * ```js
6856
+ * const app = fin.Application.wrapSync({ uuid: 'testapp' });
6857
+ * await app.close();
6858
+ * ```
6859
+ *
6860
+ */
6861
+ wrapSync(identity) {
6862
+ this.wire.sendAction('wrap-application-sync').catch((e) => {
6863
+ // we do not want to expose this error, just continue if this analytics-only call fails
6864
+ });
6865
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
6866
+ if (errorMsg) {
6867
+ throw new Error(errorMsg);
6868
+ }
6869
+ return new Instance_1.Application(this.wire, identity);
6870
+ }
6871
+ async _create(appOptions) {
6872
+ // set defaults:
6873
+ if (appOptions.waitForPageLoad === undefined) {
6874
+ appOptions.waitForPageLoad = false;
6875
+ }
6876
+ if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
6877
+ appOptions.autoShow = true;
6878
+ }
6879
+ await this.wire.sendAction('create-application', appOptions);
6880
+ return this.wrap({ uuid: appOptions.uuid });
6881
+ }
6882
+ /**
6883
+ * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
6884
+ *
6885
+ * @example
6886
+ *
6887
+ * ```js
6888
+ * async function createApp() {
6889
+ * const app = await fin.Application.create({
6890
+ * name: 'myApp',
6891
+ * uuid: 'app-3',
6892
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
6893
+ * autoShow: true
6894
+ * });
6895
+ * await app.run();
6896
+ * }
6897
+ *
6898
+ * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
6899
+ * ```
6900
+ *
6901
+ * @ignore
6902
+ */
6903
+ create(appOptions) {
6904
+ console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
6905
+ this.wire.sendAction('application-create').catch((e) => {
6906
+ // we do not want to expose this error, just continue if this analytics-only call fails
6907
+ });
6908
+ return this._create(appOptions);
6909
+ }
6910
+ /**
6911
+ * Creates and starts a new Application.
6912
+ *
6913
+ * @example
6914
+ *
6915
+ * ```js
6916
+ * async function start() {
6917
+ * return fin.Application.start({
6918
+ * name: 'app-1',
6919
+ * uuid: 'app-1',
6920
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
6921
+ * autoShow: true
6922
+ * });
6923
+ * }
6924
+ * start().then(() => console.log('Application is running')).catch(err => console.log(err));
6925
+ * ```
6926
+ *
6927
+ */
6928
+ async start(appOptions) {
6929
+ this.wire.sendAction('start-application').catch((e) => {
6930
+ // we do not want to expose this error, just continue if this analytics-only call fails
6931
+ });
6932
+ const app = await this._create(appOptions);
6933
+ await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
6934
+ return app;
6935
+ }
6936
+ /**
6937
+ * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
6938
+ * Returns once the RVM is finished attempting to launch the applications.
6939
+ * @param opts - Parameters that the RVM will use.
6940
+ *
6941
+ * @example
6942
+ *
6943
+ * ```js
6944
+ *
6945
+ * const applicationInfoArray = [
6946
+ * {
6947
+ * "uuid": 'App-1',
6948
+ * "manifestUrl": 'http://localhost:5555/app1.json',
6949
+ * },
6950
+ * {
6951
+ * "uuid": 'App-2',
6952
+ * "manifestUrl": 'http://localhost:5555/app2.json',
6953
+ * },
6954
+ * {
6955
+ * "uuid": 'App-3',
6956
+ * "manifestUrl": 'http://localhost:5555/app3.json',
6957
+ * }
6958
+ * ]
6959
+ *
6960
+ * fin.Application.startManyManifests(applicationInfoArray)
6961
+ * .then(() => {
6962
+ * console.log('RVM has finished launching the application list.');
6963
+ * })
6964
+ * .catch((err) => {
6965
+ * console.log(err);
6966
+ * })
6967
+ * ```
6968
+ *
6969
+ * @experimental
6970
+ */
6971
+ async startManyManifests(applications, opts) {
6972
+ return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
6973
+ }
6974
+ /**
6975
+ * Asynchronously returns an Application object that represents the current application
6976
+ *
6977
+ * @example
6978
+ *
6979
+ * ```js
6980
+ * async function isCurrentAppRunning () {
6981
+ * const app = await fin.Application.getCurrent();
6982
+ * return app.isRunning();
6983
+ * }
6984
+ *
6985
+ * isCurrentAppRunning().then(running => {
6986
+ * console.log(`Current app is running: ${running}`);
6987
+ * }).catch(err => {
6988
+ * console.error(err);
6989
+ * });
6990
+ *
6991
+ * ```
6992
+ */
6993
+ getCurrent() {
6994
+ this.wire.sendAction('get-current-application').catch((e) => {
6995
+ // we do not want to expose this error, just continue if this analytics-only call fails
6996
+ });
6997
+ return this.wrap({ uuid: this.wire.me.uuid });
6998
+ }
6999
+ /**
7000
+ * Synchronously returns an Application object that represents the current application
7001
+ *
7002
+ * @example
7003
+ *
7004
+ * ```js
7005
+ * async function isCurrentAppRunning () {
7006
+ * const app = fin.Application.getCurrentSync();
7007
+ * return app.isRunning();
7008
+ * }
7009
+ *
7010
+ * isCurrentAppRunning().then(running => {
7011
+ * console.log(`Current app is running: ${running}`);
7012
+ * }).catch(err => {
7013
+ * console.error(err);
7014
+ * });
7015
+ *
7016
+ * ```
7017
+ */
7018
+ getCurrentSync() {
7019
+ this.wire.sendAction('get-current-application-sync').catch((e) => {
7020
+ // we do not want to expose this error, just continue if this analytics-only call fails
7021
+ });
7022
+ return this.wrapSync({ uuid: this.wire.me.uuid });
7023
+ }
7024
+ /**
7025
+ * Retrieves application's manifest and returns a running instance of the application.
7026
+ * @param manifestUrl - The URL of app's manifest.
7027
+ * @param opts - Parameters that the RVM will use.
7028
+ *
7029
+ * @example
7030
+ *
7031
+ * ```js
7032
+ * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
7033
+ *
7034
+ * // For a local manifest file:
7035
+ * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
7036
+ * ```
7037
+ */
7038
+ async startFromManifest(manifestUrl, opts) {
7039
+ this.wire.sendAction('application-start-from-manifest').catch((e) => {
7040
+ // we do not want to expose this error, just continue if this analytics-only call fails
7041
+ });
7042
+ const app = await this._createFromManifest(manifestUrl);
7043
+ // @ts-expect-error using private method without warning.
7044
+ await app._run(opts); // eslint-disable-line no-underscore-dangle
7045
+ return app;
7046
+ }
7047
+ /**
7048
+ * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
7049
+ * Retrieves application's manifest and returns a wrapped application.
7050
+ * @param manifestUrl - The URL of app's manifest.
7051
+ * @param callback - called if the method succeeds.
7052
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
7053
+ *
7054
+ * @example
7055
+ *
7056
+ * ```js
7057
+ * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
7058
+ * ```
7059
+ * @ignore
7060
+ */
7061
+ createFromManifest(manifestUrl) {
7062
+ console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
7063
+ this.wire.sendAction('application-create-from-manifest').catch((e) => {
7064
+ // we do not want to expose this error, just continue if this analytics-only call fails
7065
+ });
7066
+ return this._createFromManifest(manifestUrl);
7067
+ }
7068
+ _createFromManifest(manifestUrl) {
7069
+ return this.wire
7070
+ .sendAction('get-application-manifest', { manifestUrl })
7071
+ .then(({ payload }) => {
7072
+ const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
7073
+ return this.wrap({ uuid });
7074
+ })
7075
+ .then((app) => {
7076
+ app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
7077
+ return app;
7078
+ });
7079
+ }
7080
+ }
7081
+ Factory$5.ApplicationModule = ApplicationModule;
7082
+ return Factory$5;
7083
+ }
7084
+
7085
+ var hasRequiredApplication;
7086
+
7087
+ function requireApplication () {
7088
+ if (hasRequiredApplication) return application;
7089
+ hasRequiredApplication = 1;
7090
+ (function (exports) {
7091
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7092
+ if (k2 === undefined) k2 = k;
7093
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7094
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7095
+ desc = { enumerable: true, get: function() { return m[k]; } };
7096
+ }
7097
+ Object.defineProperty(o, k2, desc);
7098
+ }) : (function(o, m, k, k2) {
7099
+ if (k2 === undefined) k2 = k;
7100
+ o[k2] = m[k];
7101
+ }));
7102
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
7103
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
7104
+ };
7105
+ Object.defineProperty(exports, "__esModule", { value: true });
7106
+ /**
7107
+ * Entry points for the OpenFin `Application` API (`fin.Application`).
7108
+ *
7109
+ * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
7110
+ * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
7111
+ *
7112
+ * 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),
7113
+ * both of these were documented on the same page.
7114
+ *
7115
+ * @packageDocumentation
7116
+ */
7117
+ __exportStar(requireFactory$1(), exports);
7118
+ __exportStar(requireInstance$2(), exports);
7119
+ } (application));
7120
+ return application;
7121
+ }
7101
7122
 
7102
7123
  var promisifySubscription$1 = {};
7103
7124
 
@@ -7141,7 +7162,7 @@ function requireInstance$1 () {
7141
7162
  /* eslint-disable @typescript-eslint/no-unused-vars */
7142
7163
  /* eslint-disable no-console */
7143
7164
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
7144
- const application_1 = application;
7165
+ const application_1 = requireApplication();
7145
7166
  const main_1 = main;
7146
7167
  const view_1 = requireView();
7147
7168
  const warnings_1 = warnings;
@@ -9168,7 +9189,7 @@ function requireView () {
9168
9189
  *
9169
9190
  * @packageDocumentation
9170
9191
  */
9171
- __exportStar(requireFactory$1(), exports);
9192
+ __exportStar(requireFactory$2(), exports);
9172
9193
  __exportStar(requireInstance(), exports);
9173
9194
  } (view));
9174
9195
  return view;
@@ -17520,7 +17541,7 @@ const events_1 = require$$0$1;
17520
17541
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
17521
17542
  const index_1 = system;
17522
17543
  const index_2 = requireWindow();
17523
- const index_3 = application;
17544
+ const index_3 = requireApplication();
17524
17545
  const index_4 = interappbus;
17525
17546
  const index_5 = clipboard;
17526
17547
  const index_6 = externalApplication;