@openfin/remote-adapter 40.104.3 → 40.104.4

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