@openfin/core 38.81.49 → 38.81.51

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.
package/out/mock.js CHANGED
@@ -706,11 +706,11 @@ const handleDeprecatedWarnings = (options) => {
706
706
  };
707
707
  warnings.handleDeprecatedWarnings = handleDeprecatedWarnings;
708
708
 
709
- var hasRequiredFactory$2;
709
+ var hasRequiredFactory$3;
710
710
 
711
- function requireFactory$2 () {
712
- if (hasRequiredFactory$2) return Factory$6;
713
- hasRequiredFactory$2 = 1;
711
+ function requireFactory$3 () {
712
+ if (hasRequiredFactory$3) return Factory$6;
713
+ hasRequiredFactory$3 = 1;
714
714
  Object.defineProperty(Factory$6, "__esModule", { value: true });
715
715
  Factory$6.ViewModule = void 0;
716
716
  const base_1 = base;
@@ -1587,8 +1587,8 @@ var main = {};
1587
1587
 
1588
1588
  Object.defineProperty(main, "__esModule", { value: true });
1589
1589
  main.WebContents = void 0;
1590
- const base_1$l = base;
1591
- class WebContents extends base_1$l.EmitterBase {
1590
+ const base_1$j = base;
1591
+ class WebContents extends base_1$j.EmitterBase {
1592
1592
  /**
1593
1593
  * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1594
1594
  * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
@@ -2654,11 +2654,11 @@ class WebContents extends base_1$l.EmitterBase {
2654
2654
  }
2655
2655
  main.WebContents = WebContents;
2656
2656
 
2657
- var hasRequiredInstance$1;
2657
+ var hasRequiredInstance$2;
2658
2658
 
2659
- function requireInstance$1 () {
2660
- if (hasRequiredInstance$1) return Instance$5;
2661
- hasRequiredInstance$1 = 1;
2659
+ function requireInstance$2 () {
2660
+ if (hasRequiredInstance$2) return Instance$5;
2661
+ hasRequiredInstance$2 = 1;
2662
2662
  var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2663
2663
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2664
2664
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -3253,1120 +3253,1141 @@ function requireView () {
3253
3253
  *
3254
3254
  * @packageDocumentation
3255
3255
  */
3256
- __exportStar(requireFactory$2(), exports);
3257
- __exportStar(requireInstance$1(), exports);
3256
+ __exportStar(requireFactory$3(), exports);
3257
+ __exportStar(requireInstance$2(), exports);
3258
3258
  } (view));
3259
3259
  return view;
3260
3260
  }
3261
3261
 
3262
- Object.defineProperty(Instance$6, "__esModule", { value: true });
3263
- Instance$6.Application = void 0;
3264
- /* eslint-disable import/prefer-default-export */
3265
- const base_1$k = base;
3266
- const window_1$1 = requireWindow();
3267
- const view_1 = requireView();
3268
- /**
3269
- * An object representing an application. Allows the developer to create,
3270
- * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
3271
- */
3272
- class Application extends base_1$k.EmitterBase {
3273
- /**
3274
- * @internal
3275
- */
3276
- constructor(wire, identity) {
3277
- super(wire, 'application', identity.uuid);
3278
- this.identity = identity;
3279
- this.window = new window_1$1._Window(this.wire, {
3280
- uuid: this.identity.uuid,
3281
- name: this.identity.uuid
3282
- });
3283
- }
3284
- windowListFromIdentityList(identityList) {
3285
- const windowList = [];
3286
- identityList.forEach((identity) => {
3287
- windowList.push(new window_1$1._Window(this.wire, {
3288
- uuid: identity.uuid,
3289
- name: identity.name
3290
- }));
3291
- });
3292
- return windowList;
3293
- }
3294
- /**
3295
- * Determines if the application is currently running.
3296
- *
3297
- * @example
3298
- *
3299
- * ```js
3300
- * async function isAppRunning() {
3301
- * const app = await fin.Application.getCurrent();
3302
- * return await app.isRunning();
3303
- * }
3304
- * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
3305
- * ```
3306
- */
3307
- isRunning() {
3308
- return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
3309
- }
3310
- /**
3311
- * Closes the application and any child windows created by the application.
3312
- * Cleans the application from state so it is no longer found in getAllApplications.
3313
- * @param force Close will be prevented from closing when force is false and
3314
- * ‘close-requested’ has been subscribed to for application’s main window.
3315
- *
3316
- * @example
3317
- *
3318
- * ```js
3319
- * async function closeApp() {
3320
- * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
3321
- * const app = await fin.Application.wrap({uuid: 'app2'});
3322
- * await app.quit();
3323
- * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
3324
- *
3325
- * }
3326
- * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
3327
- * ```
3328
- */
3329
- async quit(force = false) {
3330
- try {
3331
- await this._close(force);
3332
- await this.wire.sendAction('destroy-application', { force, ...this.identity });
3333
- }
3334
- catch (error) {
3335
- const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
3336
- if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
3337
- throw error;
3338
- }
3339
- }
3340
- }
3341
- async _close(force = false) {
3342
- try {
3343
- await this.wire.sendAction('close-application', { force, ...this.identity });
3344
- }
3345
- catch (error) {
3346
- if (!error.message.includes('Remote connection has closed')) {
3347
- throw error;
3348
- }
3349
- }
3350
- }
3351
- /**
3352
- * @deprecated use Application.quit instead
3353
- * Closes the application and any child windows created by the application.
3354
- * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
3355
- * @param callback - called if the method succeeds.
3356
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3357
- *
3358
- * @example
3359
- *
3360
- * ```js
3361
- * async function closeApp() {
3362
- * const app = await fin.Application.getCurrent();
3363
- * return await app.close();
3364
- * }
3365
- * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
3366
- * ```
3367
- */
3368
- close(force = false) {
3369
- console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
3370
- this.wire.sendAction('application-close', this.identity).catch((e) => {
3371
- // we do not want to expose this error, just continue if this analytics-only call fails
3372
- });
3373
- return this._close(force);
3374
- }
3375
- /**
3376
- * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
3377
- *
3378
- * @example
3379
- *
3380
- * ```js
3381
- * async function getChildWindows() {
3382
- * const app = await fin.Application.getCurrent();
3383
- * return await app.getChildWindows();
3384
- * }
3385
- *
3386
- * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
3387
- * ```
3388
- */
3389
- getChildWindows() {
3390
- return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
3391
- const identityList = [];
3392
- payload.data.forEach((winName) => {
3393
- identityList.push({ uuid: this.identity.uuid, name: winName });
3394
- });
3395
- return this.windowListFromIdentityList(identityList);
3396
- });
3397
- }
3398
- /**
3399
- * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
3400
- * if the application was not created from a manifest.
3401
- *
3402
- * @example
3403
- *
3404
- * ```js
3405
- * async function getManifest() {
3406
- * const app = await fin.Application.getCurrent();
3407
- * return await app.getManifest();
3408
- * }
3409
- *
3410
- * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
3411
- * ```
3412
- */
3413
- getManifest() {
3414
- return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
3415
- }
3416
- /**
3417
- * Retrieves UUID of the application that launches this application. Invokes the error callback
3418
- * if the application was created from a manifest.
3419
- *
3420
- * @example
3421
- *
3422
- * ```js
3423
- * async function getParentUuid() {
3424
- * const app = await fin.Application.start({
3425
- * uuid: 'app-1',
3426
- * name: 'myApp',
3427
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
3428
- * autoShow: true
3429
- * });
3430
- * return await app.getParentUuid();
3431
- * }
3432
- *
3433
- * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
3434
- * ```
3435
- */
3436
- getParentUuid() {
3437
- return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
3438
- }
3439
- /**
3440
- * Retrieves current application's shortcut configuration.
3441
- *
3442
- * @example
3443
- *
3444
- * ```js
3445
- * async function getShortcuts() {
3446
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3447
- * return await app.getShortcuts();
3448
- * }
3449
- * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
3450
- * ```
3451
- */
3452
- getShortcuts() {
3453
- return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
3454
- }
3455
- /**
3456
- * Retrieves current application's views.
3457
- * @experimental
3458
- *
3459
- * @example
3460
- *
3461
- * ```js
3462
- * async function getViews() {
3463
- * const app = await fin.Application.getCurrent();
3464
- * return await app.getViews();
3465
- * }
3466
- * getViews().then(views => console.log(views)).catch(err => console.log(err));
3467
- * ```
3468
- */
3469
- async getViews() {
3470
- const { payload } = await this.wire.sendAction('application-get-views', this.identity);
3471
- return payload.data.map((id) => new view_1.View(this.wire, id));
3472
- }
3473
- /**
3474
- * Returns the current zoom level of the application.
3475
- *
3476
- * @example
3477
- *
3478
- * ```js
3479
- * async function getZoomLevel() {
3480
- * const app = await fin.Application.getCurrent();
3481
- * return await app.getZoomLevel();
3482
- * }
3483
- *
3484
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
3485
- * ```
3486
- */
3487
- getZoomLevel() {
3488
- return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
3489
- }
3490
- /**
3491
- * Returns an instance of the main Window of the application
3492
- *
3493
- * @example
3494
- *
3495
- * ```js
3496
- * async function getWindow() {
3497
- * const app = await fin.Application.start({
3498
- * uuid: 'app-1',
3499
- * name: 'myApp',
3500
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
3501
- * autoShow: true
3502
- * });
3503
- * return await app.getWindow();
3504
- * }
3505
- *
3506
- * getWindow().then(win => {
3507
- * win.showAt(0, 400);
3508
- * win.flash();
3509
- * }).catch(err => console.log(err));
3510
- * ```
3511
- */
3512
- getWindow() {
3513
- this.wire.sendAction('application-get-window', this.identity).catch((e) => {
3514
- // we do not want to expose this error, just continue if this analytics-only call fails
3515
- });
3516
- return Promise.resolve(this.window);
3517
- }
3518
- /**
3519
- * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
3520
- * @param userName - username to be passed to the RVM.
3521
- * @param appName - app name to be passed to the RVM.
3522
- *
3523
- * @example
3524
- *
3525
- * ```js
3526
- * async function registerUser() {
3527
- * const app = await fin.Application.getCurrent();
3528
- * return await app.registerUser('user', 'myApp');
3529
- * }
3530
- *
3531
- * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
3532
- * ```
3533
- */
3534
- registerUser(userName, appName) {
3535
- return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
3536
- }
3537
- /**
3538
- * Removes the application’s icon from the tray.
3539
- *
3540
- * @example
3541
- *
3542
- * ```js
3543
- * async function removeTrayIcon() {
3544
- * const app = await fin.Application.getCurrent();
3545
- * return await app.removeTrayIcon();
3546
- * }
3547
- *
3548
- * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
3549
- * ```
3550
- */
3551
- removeTrayIcon() {
3552
- return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
3553
- }
3554
- /**
3555
- * Restarts the application.
3556
- *
3557
- * @example
3558
- *
3559
- * ```js
3560
- * async function restartApp() {
3561
- * const app = await fin.Application.getCurrent();
3562
- * return await app.restart();
3563
- * }
3564
- * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
3565
- * ```
3566
- */
3567
- restart() {
3568
- return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3569
- }
3570
- /**
3571
- * DEPRECATED method to run the application.
3572
- * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3573
- *
3574
- * @example
3575
- *
3576
- * ```js
3577
- * async function run() {
3578
- * const app = await fin.Application.create({
3579
- * name: 'myApp',
3580
- * uuid: 'app-1',
3581
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3582
- * autoShow: true
3583
- * });
3584
- * await app.run();
3585
- * }
3586
- * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3587
- * ```
3588
- *
3589
- * @ignore
3590
- */
3591
- run() {
3592
- console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3593
- this.wire.sendAction('application-run', this.identity).catch((e) => {
3594
- // we do not want to expose this error, just continue if this analytics-only call fails
3595
- });
3596
- return this._run();
3597
- }
3598
- _run(opts = {}) {
3599
- return this.wire
3600
- .sendAction('run-application', {
3601
- manifestUrl: this._manifestUrl,
3602
- opts,
3603
- ...this.identity
3604
- })
3605
- .then(() => undefined);
3606
- }
3607
- /**
3608
- * Instructs the RVM to schedule one restart of the application.
3609
- *
3610
- * @example
3611
- *
3612
- * ```js
3613
- * async function scheduleRestart() {
3614
- * const app = await fin.Application.getCurrent();
3615
- * return await app.scheduleRestart();
3616
- * }
3617
- *
3618
- * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3619
- * ```
3620
- */
3621
- scheduleRestart() {
3622
- return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3623
- }
3624
- /**
3625
- * Sends a message to the RVM to upload the application's logs. On success,
3626
- * an object containing logId is returned.
3627
- *
3628
- * @example
3629
- *
3630
- * ```js
3631
- * async function sendLog() {
3632
- * const app = await fin.Application.getCurrent();
3633
- * return await app.sendApplicationLog();
3634
- * }
3635
- *
3636
- * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3637
- * ```
3638
- */
3639
- async sendApplicationLog() {
3640
- const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3641
- return payload.data;
3642
- }
3643
- /**
3644
- * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3645
- * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3646
- *
3647
- * Note: If the "name" property is omitted it defaults to "tasks".
3648
- * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3649
- *
3650
- *
3651
- * @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).
3652
- *
3653
- * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3654
- * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3655
- *
3656
- * Note: If the "name" property is omitted it defaults to "tasks".
3657
- *
3658
- * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3659
- * uuid or shortcut.name is changed.
3660
- *
3661
- * @example
3662
- *
3663
- * ```js
3664
- * const app = fin.Application.getCurrentSync();
3665
- * const appName = 'My App';
3666
- * const jumpListConfig = [ // array of JumpList categories
3667
- * {
3668
- * // has no name and no type so `type` is assumed to be "tasks"
3669
- * items: [ // array of JumpList items
3670
- * {
3671
- * type: 'task',
3672
- * title: `Launch ${appName}`,
3673
- * description: `Runs ${appName} with the default configuration`,
3674
- * deepLink: 'fins://path.to/app/manifest.json',
3675
- * iconPath: 'https://path.to/app/icon.ico',
3676
- * iconIndex: 0
3677
- * },
3678
- * { type: 'separator' },
3679
- * {
3680
- * type: 'task',
3681
- * title: `Restore ${appName}`,
3682
- * description: 'Restore to last configuration',
3683
- * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3684
- * iconPath: 'https://path.to/app/icon.ico',
3685
- * iconIndex: 0
3686
- * },
3687
- * ]
3688
- * },
3689
- * {
3690
- * name: 'Tools',
3691
- * items: [ // array of JumpList items
3692
- * {
3693
- * type: 'task',
3694
- * title: 'Tool A',
3695
- * description: 'Runs Tool A',
3696
- * deepLink: 'fins://path.to/tool-a/manifest.json',
3697
- * iconPath: 'https://path.to/tool-a/icon.ico',
3698
- * iconIndex: 0
3699
- * },
3700
- * {
3701
- * type: 'task',
3702
- * title: 'Tool B',
3703
- * description: 'Runs Tool B',
3704
- * deepLink: 'fins://path.to/tool-b/manifest.json',
3705
- * iconPath: 'https://path.to/tool-b/icon.ico',
3706
- * iconIndex: 0
3707
- * }]
3708
- * }
3709
- * ];
3710
- *
3711
- * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3712
- * ```
3713
- *
3714
- * To handle deeplink args:
3715
- * ```js
3716
- * function handleUseLastConfiguration() {
3717
- * // this handler is called when the app is being launched
3718
- * app.on('run-requested', event => {
3719
- * if(event.userAppConfigArgs['use-last-configuration']) {
3720
- * // your logic here
3721
- * }
3722
- * });
3723
- * // this handler is called when the app was already running when the launch was requested
3724
- * fin.desktop.main(function(args) {
3725
- * if(args && args['use-last-configuration']) {
3726
- * // your logic here
3727
- * }
3728
- * });
3729
- * }
3730
- * ```
3731
- */
3732
- async setJumpList(jumpListCategories) {
3733
- await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3734
- }
3735
- /**
3736
- * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3737
- * @param icon Image URL or base64 encoded string to be used as the icon
3738
- *
3739
- * @example
3740
- *
3741
- * ```js
3742
- * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3743
- * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3744
- * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3745
- * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3746
- * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3747
- *
3748
- * async function setTrayIcon(icon) {
3749
- * const app = await fin.Application.getCurrent();
3750
- * return await app.setTrayIcon(icon);
3751
- * }
3752
- *
3753
- * // use image url to set tray icon
3754
- * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3755
- *
3756
- * // use base64 encoded string to set tray icon
3757
- * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3758
- *
3759
- * // use a dataURL to set tray icon
3760
- * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3761
- * ```
3762
- */
3763
- setTrayIcon(icon) {
3764
- return this.wire
3765
- .sendAction('set-tray-icon', {
3766
- enabledIcon: icon,
3767
- ...this.identity
3768
- })
3769
- .then(() => undefined);
3770
- }
3771
- /**
3772
- * Sets new application's shortcut configuration. Windows only.
3773
- * @param config New application's shortcut configuration.
3774
- *
3775
- * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3776
- * to be able to change shortcut states.
3777
- *
3778
- * @example
3779
- *
3780
- * ```js
3781
- * async function setShortcuts(config) {
3782
- * const app = await fin.Application.getCurrent();
3783
- * return app.setShortcuts(config);
3784
- * }
3785
- *
3786
- * setShortcuts({
3787
- * desktop: true,
3788
- * startMenu: false,
3789
- * systemStartup: true
3790
- * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3791
- * ```
3792
- */
3793
- setShortcuts(config) {
3794
- return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3795
- }
3796
- /**
3797
- * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3798
- * @param queryString The new query string for this app's shortcuts.
3799
- *
3800
- * @example
3801
- *
3802
- * ```js
3803
- * const newQueryArgs = 'arg=true&arg2=false';
3804
- * const app = await fin.Application.getCurrent();
3805
- * try {
3806
- * await app.setShortcutQueryParams(newQueryArgs);
3807
- * } catch(err) {
3808
- * console.error(err)
3809
- * }
3810
- * ```
3811
- */
3812
- async setShortcutQueryParams(queryString) {
3813
- await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3814
- }
3815
- /**
3816
- * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3817
- * larger or smaller to default limits of 300% and 50% of original size, respectively.
3818
- * @param level The zoom level
3819
- *
3820
- * @example
3821
- *
3822
- * ```js
3823
- * async function setZoomLevel(number) {
3824
- * const app = await fin.Application.getCurrent();
3825
- * return await app.setZoomLevel(number);
3826
- * }
3827
- *
3828
- * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3829
- * ```
3830
- */
3831
- setZoomLevel(level) {
3832
- return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3833
- }
3834
- /**
3835
- * Sets a username to correlate with App Log Management.
3836
- * @param username Username to correlate with App's Log.
3837
- *
3838
- * @example
3839
- *
3840
- * ```js
3841
- * async function setAppLogUser() {
3842
- * const app = await fin.Application.getCurrent();
3843
- * return await app.setAppLogUsername('username');
3844
- * }
3845
- *
3846
- * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3847
- *
3848
- * ```
3849
- */
3850
- async setAppLogUsername(username) {
3851
- await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3852
- }
3853
- /**
3854
- * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3855
- * @remarks The only information currently returned is the position and dimensions.
3856
- *
3857
- * @example
3858
- *
3859
- * ```js
3860
- * async function getTrayIconInfo() {
3861
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3862
- * return await app.getTrayIconInfo();
3863
- * }
3864
- * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3865
- * ```
3866
- */
3867
- getTrayIconInfo() {
3868
- return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3869
- }
3870
- /**
3871
- * Checks if the application has an associated tray icon.
3872
- *
3873
- * @example
3874
- *
3875
- * ```js
3876
- * const app = await fin.Application.wrap({ uuid: 'testapp' });
3877
- * const hasTrayIcon = await app.hasTrayIcon();
3878
- * console.log(hasTrayIcon);
3879
- * ```
3880
- */
3881
- hasTrayIcon() {
3882
- return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3883
- }
3884
- /**
3885
- * Closes the application by terminating its process.
3886
- *
3887
- * @example
3888
- *
3889
- * ```js
3890
- * async function terminateApp() {
3891
- * const app = await fin.Application.getCurrent();
3892
- * return await app.terminate();
3893
- * }
3894
- * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3895
- * ```
3896
- */
3897
- terminate() {
3898
- return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3899
- }
3900
- /**
3901
- * Waits for a hanging application. This method can be called in response to an application
3902
- * "not-responding" to allow the application to continue and to generate another "not-responding"
3903
- * message after a certain period of time.
3904
- *
3905
- * @ignore
3906
- */
3907
- wait() {
3908
- return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3909
- }
3910
- /**
3911
- * Retrieves information about the application.
3912
- *
3913
- * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3914
- * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3915
- * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3916
- *
3917
- * @example
3918
- *
3919
- * ```js
3920
- * async function getInfo() {
3921
- * const app = await fin.Application.getCurrent();
3922
- * return await app.getInfo();
3923
- * }
3924
- *
3925
- * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3926
- * ```
3927
- */
3928
- getInfo() {
3929
- return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3930
- }
3931
- /**
3932
- * Retrieves all process information for entities (windows and views) associated with an application.
3933
- *
3934
- * @example
3935
- * ```js
3936
- * const app = await fin.Application.getCurrent();
3937
- * const processInfo = await app.getProcessInfo();
3938
- * ```
3939
- * @experimental
3940
- */
3941
- async getProcessInfo() {
3942
- const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3943
- return data;
3944
- }
3945
- /**
3946
- * Sets file auto download location. It's only allowed in the same application.
3947
- *
3948
- * Note: This method is restricted by default and must be enabled via
3949
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3950
- * @param downloadLocation file auto download location
3951
- *
3952
- * @throws if setting file auto download location on different applications.
3953
- * @example
3954
- *
3955
- * ```js
3956
- * const downloadLocation = 'C:\\dev\\temp';
3957
- * const app = await fin.Application.getCurrent();
3958
- * try {
3959
- * await app.setFileDownloadLocation(downloadLocation);
3960
- * console.log('File download location is set');
3961
- * } catch(err) {
3962
- * console.error(err)
3963
- * }
3964
- * ```
3965
- */
3966
- async setFileDownloadLocation(downloadLocation) {
3967
- const { name } = this.wire.me;
3968
- const entityIdentity = { uuid: this.identity.uuid, name };
3969
- await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3970
- }
3971
- /**
3972
- * 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.
3973
- *
3974
- * Note: This method is restricted by default and must be enabled via
3975
- * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3976
- *
3977
- * @throws if getting file auto download location on different applications.
3978
- * @example
3979
- *
3980
- * ```js
3981
- * const app = await fin.Application.getCurrent();
3982
- * const fileDownloadDir = await app.getFileDownloadLocation();
3983
- * ```
3984
- */
3985
- async getFileDownloadLocation() {
3986
- const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3987
- return data;
3988
- }
3989
- /**
3990
- * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3991
- * @param options
3992
- * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3993
- * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3994
- * of all possible data shapes for the entire menu, and the click handler should process
3995
- * these with a "reducer" pattern.
3996
- * @throws if the application has no tray icon set
3997
- * @throws if the system tray is currently hidden
3998
- * @example
3999
- *
4000
- * ```js
4001
- * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
4002
- * const app = fin.Application.getCurrentSync();
4003
- *
4004
- * await app.setTrayIcon(iconUrl);
4005
- *
4006
- * const template = [
4007
- * {
4008
- * label: 'Menu Item 1',
4009
- * data: 'hello from item 1'
4010
- * },
4011
- * { type: 'separator' },
4012
- * {
4013
- * label: 'Menu Item 2',
4014
- * type: 'checkbox',
4015
- * checked: true,
4016
- * data: 'The user clicked the checkbox'
4017
- * },
4018
- * {
4019
- * label: 'see more',
4020
- * enabled: false,
4021
- * submenu: [
4022
- * { label: 'submenu 1', data: 'hello from submenu' }
4023
- * ]
4024
- * }
4025
- * ];
4026
- *
4027
- * app.addListener('tray-icon-clicked', (event) => {
4028
- * // right-click
4029
- * if (event.button === 2) {
4030
- * app.showTrayIconPopupMenu({ template }).then(r => {
4031
- * if (r.result === 'closed') {
4032
- * console.log('nothing happened');
4033
- * } else {
4034
- * console.log(r.data);
4035
- * }
4036
- * });
4037
- * }
4038
- * });
4039
- * ```
4040
- */
4041
- async showTrayIconPopupMenu(options) {
4042
- const { name } = this.wire.me;
4043
- const entityIdentity = { uuid: this.identity.uuid, name };
4044
- const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
4045
- return payload.data;
4046
- }
4047
- /**
4048
- * Closes the tray icon menu.
4049
- *
4050
- * @throws if the application has no tray icon set
4051
- * @example
4052
- *
4053
- * ```js
4054
- * const app = fin.Application.getCurrentSync();
4055
- *
4056
- * await app.closeTrayIconPopupMenu();
4057
- * ```
4058
- */
4059
- async closeTrayIconPopupMenu() {
4060
- const { name } = this.wire.me;
4061
- const entityIdentity = { uuid: this.identity.uuid, name };
4062
- await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
4063
- }
4064
- }
4065
- Instance$6.Application = Application;
3262
+ var hasRequiredInstance$1;
4066
3263
 
4067
- Object.defineProperty(Factory$7, "__esModule", { value: true });
4068
- Factory$7.ApplicationModule = void 0;
4069
- const base_1$j = base;
4070
- const validate_1$4 = validate;
4071
- const Instance_1$5 = Instance$6;
4072
- /**
4073
- * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
4074
- */
4075
- class ApplicationModule extends base_1$j.Base {
4076
- /**
4077
- * Asynchronously returns an API handle for the given Application identity.
4078
- *
4079
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4080
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4081
- * for an Application throughout its entire lifecycle.
4082
- *
4083
- * @example
4084
- *
4085
- * ```js
4086
- * fin.Application.wrap({ uuid: 'testapp' })
4087
- * .then(app => app.isRunning())
4088
- * .then(running => console.log('Application is running: ' + running))
4089
- * .catch(err => console.log(err));
4090
- * ```
4091
- *
4092
- */
4093
- async wrap(identity) {
4094
- this.wire.sendAction('wrap-application').catch((e) => {
4095
- // we do not want to expose this error, just continue if this analytics-only call fails
4096
- });
4097
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
4098
- if (errorMsg) {
4099
- throw new Error(errorMsg);
4100
- }
4101
- return new Instance_1$5.Application(this.wire, identity);
4102
- }
4103
- /**
4104
- * Synchronously returns an API handle for the given Application identity.
4105
- *
4106
- * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4107
- * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4108
- * for an Aplication throughout its entire lifecycle.
4109
- *
4110
- * @example
4111
- *
4112
- * ```js
4113
- * const app = fin.Application.wrapSync({ uuid: 'testapp' });
4114
- * await app.close();
4115
- * ```
4116
- *
4117
- */
4118
- wrapSync(identity) {
4119
- this.wire.sendAction('wrap-application-sync').catch((e) => {
4120
- // we do not want to expose this error, just continue if this analytics-only call fails
4121
- });
4122
- const errorMsg = (0, validate_1$4.validateIdentity)(identity);
4123
- if (errorMsg) {
4124
- throw new Error(errorMsg);
4125
- }
4126
- return new Instance_1$5.Application(this.wire, identity);
4127
- }
4128
- async _create(appOptions) {
4129
- // set defaults:
4130
- if (appOptions.waitForPageLoad === undefined) {
4131
- appOptions.waitForPageLoad = false;
4132
- }
4133
- if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
4134
- appOptions.autoShow = true;
4135
- }
4136
- await this.wire.sendAction('create-application', appOptions);
4137
- return this.wrap({ uuid: appOptions.uuid });
4138
- }
4139
- /**
4140
- * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
4141
- *
4142
- * @example
4143
- *
4144
- * ```js
4145
- * async function createApp() {
4146
- * const app = await fin.Application.create({
4147
- * name: 'myApp',
4148
- * uuid: 'app-3',
4149
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
4150
- * autoShow: true
4151
- * });
4152
- * await app.run();
4153
- * }
4154
- *
4155
- * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
4156
- * ```
4157
- *
4158
- * @ignore
4159
- */
4160
- create(appOptions) {
4161
- console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
4162
- this.wire.sendAction('application-create').catch((e) => {
4163
- // we do not want to expose this error, just continue if this analytics-only call fails
4164
- });
4165
- return this._create(appOptions);
4166
- }
4167
- /**
4168
- * Creates and starts a new Application.
4169
- *
4170
- * @example
4171
- *
4172
- * ```js
4173
- * async function start() {
4174
- * return fin.Application.start({
4175
- * name: 'app-1',
4176
- * uuid: 'app-1',
4177
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
4178
- * autoShow: true
4179
- * });
4180
- * }
4181
- * start().then(() => console.log('Application is running')).catch(err => console.log(err));
4182
- * ```
4183
- *
4184
- */
4185
- async start(appOptions) {
4186
- this.wire.sendAction('start-application').catch((e) => {
4187
- // we do not want to expose this error, just continue if this analytics-only call fails
4188
- });
4189
- const app = await this._create(appOptions);
4190
- await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
4191
- return app;
4192
- }
4193
- /**
4194
- * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
4195
- * Returns once the RVM is finished attempting to launch the applications.
4196
- * @param opts - Parameters that the RVM will use.
4197
- *
4198
- * @example
4199
- *
4200
- * ```js
4201
- *
4202
- * const applicationInfoArray = [
4203
- * {
4204
- * "uuid": 'App-1',
4205
- * "manifestUrl": 'http://localhost:5555/app1.json',
4206
- * },
4207
- * {
4208
- * "uuid": 'App-2',
4209
- * "manifestUrl": 'http://localhost:5555/app2.json',
4210
- * },
4211
- * {
4212
- * "uuid": 'App-3',
4213
- * "manifestUrl": 'http://localhost:5555/app3.json',
4214
- * }
4215
- * ]
4216
- *
4217
- * fin.Application.startManyManifests(applicationInfoArray)
4218
- * .then(() => {
4219
- * console.log('RVM has finished launching the application list.');
4220
- * })
4221
- * .catch((err) => {
4222
- * console.log(err);
4223
- * })
4224
- * ```
4225
- *
4226
- * @experimental
4227
- */
4228
- async startManyManifests(applications, opts) {
4229
- return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
4230
- }
4231
- /**
4232
- * Asynchronously returns an Application object that represents the current application
4233
- *
4234
- * @example
4235
- *
4236
- * ```js
4237
- * async function isCurrentAppRunning () {
4238
- * const app = await fin.Application.getCurrent();
4239
- * return app.isRunning();
4240
- * }
4241
- *
4242
- * isCurrentAppRunning().then(running => {
4243
- * console.log(`Current app is running: ${running}`);
4244
- * }).catch(err => {
4245
- * console.error(err);
4246
- * });
4247
- *
4248
- * ```
4249
- */
4250
- getCurrent() {
4251
- this.wire.sendAction('get-current-application').catch((e) => {
4252
- // we do not want to expose this error, just continue if this analytics-only call fails
4253
- });
4254
- return this.wrap({ uuid: this.wire.me.uuid });
4255
- }
4256
- /**
4257
- * Synchronously returns an Application object that represents the current application
4258
- *
4259
- * @example
4260
- *
4261
- * ```js
4262
- * async function isCurrentAppRunning () {
4263
- * const app = fin.Application.getCurrentSync();
4264
- * return app.isRunning();
4265
- * }
4266
- *
4267
- * isCurrentAppRunning().then(running => {
4268
- * console.log(`Current app is running: ${running}`);
4269
- * }).catch(err => {
4270
- * console.error(err);
4271
- * });
4272
- *
4273
- * ```
4274
- */
4275
- getCurrentSync() {
4276
- this.wire.sendAction('get-current-application-sync').catch((e) => {
4277
- // we do not want to expose this error, just continue if this analytics-only call fails
4278
- });
4279
- return this.wrapSync({ uuid: this.wire.me.uuid });
4280
- }
4281
- /**
4282
- * Retrieves application's manifest and returns a running instance of the application.
4283
- * @param manifestUrl - The URL of app's manifest.
4284
- * @param opts - Parameters that the RVM will use.
4285
- *
4286
- * @example
4287
- *
4288
- * ```js
4289
- * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4290
- *
4291
- * // For a local manifest file:
4292
- * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4293
- * ```
4294
- */
4295
- async startFromManifest(manifestUrl, opts) {
4296
- this.wire.sendAction('application-start-from-manifest').catch((e) => {
4297
- // we do not want to expose this error, just continue if this analytics-only call fails
4298
- });
4299
- const app = await this._createFromManifest(manifestUrl);
4300
- // @ts-expect-error using private method without warning.
4301
- await app._run(opts); // eslint-disable-line no-underscore-dangle
4302
- return app;
4303
- }
4304
- /**
4305
- * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
4306
- * Retrieves application's manifest and returns a wrapped application.
4307
- * @param manifestUrl - The URL of app's manifest.
4308
- * @param callback - called if the method succeeds.
4309
- * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
4310
- *
4311
- * @example
4312
- *
4313
- * ```js
4314
- * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
4315
- * ```
4316
- * @ignore
4317
- */
4318
- createFromManifest(manifestUrl) {
4319
- console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
4320
- this.wire.sendAction('application-create-from-manifest').catch((e) => {
4321
- // we do not want to expose this error, just continue if this analytics-only call fails
4322
- });
4323
- return this._createFromManifest(manifestUrl);
4324
- }
4325
- _createFromManifest(manifestUrl) {
4326
- return this.wire
4327
- .sendAction('get-application-manifest', { manifestUrl })
4328
- .then(({ payload }) => {
4329
- const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
4330
- return this.wrap({ uuid });
4331
- })
4332
- .then((app) => {
4333
- app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
4334
- return app;
4335
- });
4336
- }
3264
+ function requireInstance$1 () {
3265
+ if (hasRequiredInstance$1) return Instance$6;
3266
+ hasRequiredInstance$1 = 1;
3267
+ Object.defineProperty(Instance$6, "__esModule", { value: true });
3268
+ Instance$6.Application = void 0;
3269
+ /* eslint-disable import/prefer-default-export */
3270
+ const base_1 = base;
3271
+ const window_1 = requireWindow();
3272
+ const view_1 = requireView();
3273
+ /**
3274
+ * An object representing an application. Allows the developer to create,
3275
+ * execute, show/close an application as well as listen to {@link OpenFin.ApplicationEvents application events}.
3276
+ */
3277
+ class Application extends base_1.EmitterBase {
3278
+ /**
3279
+ * @internal
3280
+ */
3281
+ constructor(wire, identity) {
3282
+ super(wire, 'application', identity.uuid);
3283
+ this.identity = identity;
3284
+ this.window = new window_1._Window(this.wire, {
3285
+ uuid: this.identity.uuid,
3286
+ name: this.identity.uuid
3287
+ });
3288
+ }
3289
+ windowListFromIdentityList(identityList) {
3290
+ const windowList = [];
3291
+ identityList.forEach((identity) => {
3292
+ windowList.push(new window_1._Window(this.wire, {
3293
+ uuid: identity.uuid,
3294
+ name: identity.name
3295
+ }));
3296
+ });
3297
+ return windowList;
3298
+ }
3299
+ /**
3300
+ * Determines if the application is currently running.
3301
+ *
3302
+ * @example
3303
+ *
3304
+ * ```js
3305
+ * async function isAppRunning() {
3306
+ * const app = await fin.Application.getCurrent();
3307
+ * return await app.isRunning();
3308
+ * }
3309
+ * isAppRunning().then(running => console.log(`Current app is running: ${running}`)).catch(err => console.log(err));
3310
+ * ```
3311
+ */
3312
+ isRunning() {
3313
+ return this.wire.sendAction('is-application-running', this.identity).then(({ payload }) => payload.data);
3314
+ }
3315
+ /**
3316
+ * Closes the application and any child windows created by the application.
3317
+ * Cleans the application from state so it is no longer found in getAllApplications.
3318
+ * @param force Close will be prevented from closing when force is false and
3319
+ * ‘close-requested’ has been subscribed to for application’s main window.
3320
+ *
3321
+ * @example
3322
+ *
3323
+ * ```js
3324
+ * async function closeApp() {
3325
+ * const allApps1 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}, {uuid: 'app2', isRunning: true}]
3326
+ * const app = await fin.Application.wrap({uuid: 'app2'});
3327
+ * await app.quit();
3328
+ * const allApps2 = await fin.System.getAllApplications(); //[{uuid: 'app1', isRunning: true}]
3329
+ *
3330
+ * }
3331
+ * closeApp().then(() => console.log('Application quit')).catch(err => console.log(err));
3332
+ * ```
3333
+ */
3334
+ async quit(force = false) {
3335
+ try {
3336
+ await this._close(force);
3337
+ await this.wire.sendAction('destroy-application', { force, ...this.identity });
3338
+ }
3339
+ catch (error) {
3340
+ const acceptableErrors = ['Remote connection has closed', 'Could not locate the requested application'];
3341
+ if (!acceptableErrors.some((msg) => error.message.includes(msg))) {
3342
+ throw error;
3343
+ }
3344
+ }
3345
+ }
3346
+ async _close(force = false) {
3347
+ try {
3348
+ await this.wire.sendAction('close-application', { force, ...this.identity });
3349
+ }
3350
+ catch (error) {
3351
+ if (!error.message.includes('Remote connection has closed')) {
3352
+ throw error;
3353
+ }
3354
+ }
3355
+ }
3356
+ /**
3357
+ * @deprecated use Application.quit instead
3358
+ * Closes the application and any child windows created by the application.
3359
+ * @param force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.
3360
+ * @param callback - called if the method succeeds.
3361
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
3362
+ *
3363
+ * @example
3364
+ *
3365
+ * ```js
3366
+ * async function closeApp() {
3367
+ * const app = await fin.Application.getCurrent();
3368
+ * return await app.close();
3369
+ * }
3370
+ * closeApp().then(() => console.log('Application closed')).catch(err => console.log(err));
3371
+ * ```
3372
+ */
3373
+ close(force = false) {
3374
+ console.warn('Deprecation Warning: Application.close is deprecated Please use Application.quit');
3375
+ this.wire.sendAction('application-close', this.identity).catch((e) => {
3376
+ // we do not want to expose this error, just continue if this analytics-only call fails
3377
+ });
3378
+ return this._close(force);
3379
+ }
3380
+ /**
3381
+ * Retrieves an array of wrapped fin.Windows for each of the application’s child windows.
3382
+ *
3383
+ * @example
3384
+ *
3385
+ * ```js
3386
+ * async function getChildWindows() {
3387
+ * const app = await fin.Application.getCurrent();
3388
+ * return await app.getChildWindows();
3389
+ * }
3390
+ *
3391
+ * getChildWindows().then(children => console.log(children)).catch(err => console.log(err));
3392
+ * ```
3393
+ */
3394
+ getChildWindows() {
3395
+ return this.wire.sendAction('get-child-windows', this.identity).then(({ payload }) => {
3396
+ const identityList = [];
3397
+ payload.data.forEach((winName) => {
3398
+ identityList.push({ uuid: this.identity.uuid, name: winName });
3399
+ });
3400
+ return this.windowListFromIdentityList(identityList);
3401
+ });
3402
+ }
3403
+ /**
3404
+ * Retrieves the JSON manifest that was used to create the application. Invokes the error callback
3405
+ * if the application was not created from a manifest.
3406
+ *
3407
+ * @example
3408
+ *
3409
+ * ```js
3410
+ * async function getManifest() {
3411
+ * const app = await fin.Application.getCurrent();
3412
+ * return await app.getManifest();
3413
+ * }
3414
+ *
3415
+ * getManifest().then(manifest => console.log(manifest)).catch(err => console.log(err));
3416
+ * ```
3417
+ */
3418
+ getManifest() {
3419
+ return this.wire.sendAction('get-application-manifest', this.identity).then(({ payload }) => payload.data);
3420
+ }
3421
+ /**
3422
+ * Retrieves UUID of the application that launches this application. Invokes the error callback
3423
+ * if the application was created from a manifest.
3424
+ *
3425
+ * @example
3426
+ *
3427
+ * ```js
3428
+ * async function getParentUuid() {
3429
+ * const app = await fin.Application.start({
3430
+ * uuid: 'app-1',
3431
+ * name: 'myApp',
3432
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getParentUuid.html',
3433
+ * autoShow: true
3434
+ * });
3435
+ * return await app.getParentUuid();
3436
+ * }
3437
+ *
3438
+ * getParentUuid().then(parentUuid => console.log(parentUuid)).catch(err => console.log(err));
3439
+ * ```
3440
+ */
3441
+ getParentUuid() {
3442
+ return this.wire.sendAction('get-parent-application', this.identity).then(({ payload }) => payload.data);
3443
+ }
3444
+ /**
3445
+ * Retrieves current application's shortcut configuration.
3446
+ *
3447
+ * @example
3448
+ *
3449
+ * ```js
3450
+ * async function getShortcuts() {
3451
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3452
+ * return await app.getShortcuts();
3453
+ * }
3454
+ * getShortcuts().then(config => console.log(config)).catch(err => console.log(err));
3455
+ * ```
3456
+ */
3457
+ getShortcuts() {
3458
+ return this.wire.sendAction('get-shortcuts', this.identity).then(({ payload }) => payload.data);
3459
+ }
3460
+ /**
3461
+ * Retrieves current application's views.
3462
+ * @experimental
3463
+ *
3464
+ * @example
3465
+ *
3466
+ * ```js
3467
+ * async function getViews() {
3468
+ * const app = await fin.Application.getCurrent();
3469
+ * return await app.getViews();
3470
+ * }
3471
+ * getViews().then(views => console.log(views)).catch(err => console.log(err));
3472
+ * ```
3473
+ */
3474
+ async getViews() {
3475
+ const { payload } = await this.wire.sendAction('application-get-views', this.identity);
3476
+ return payload.data.map((id) => new view_1.View(this.wire, id));
3477
+ }
3478
+ /**
3479
+ * Returns the current zoom level of the application.
3480
+ *
3481
+ * @example
3482
+ *
3483
+ * ```js
3484
+ * async function getZoomLevel() {
3485
+ * const app = await fin.Application.getCurrent();
3486
+ * return await app.getZoomLevel();
3487
+ * }
3488
+ *
3489
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
3490
+ * ```
3491
+ */
3492
+ getZoomLevel() {
3493
+ return this.wire.sendAction('get-application-zoom-level', this.identity).then(({ payload }) => payload.data);
3494
+ }
3495
+ /**
3496
+ * Returns an instance of the main Window of the application
3497
+ *
3498
+ * @example
3499
+ *
3500
+ * ```js
3501
+ * async function getWindow() {
3502
+ * const app = await fin.Application.start({
3503
+ * uuid: 'app-1',
3504
+ * name: 'myApp',
3505
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.getWindow.html',
3506
+ * autoShow: true
3507
+ * });
3508
+ * return await app.getWindow();
3509
+ * }
3510
+ *
3511
+ * getWindow().then(win => {
3512
+ * win.showAt(0, 400);
3513
+ * win.flash();
3514
+ * }).catch(err => console.log(err));
3515
+ * ```
3516
+ */
3517
+ getWindow() {
3518
+ this.wire.sendAction('application-get-window', this.identity).catch((e) => {
3519
+ // we do not want to expose this error, just continue if this analytics-only call fails
3520
+ });
3521
+ return Promise.resolve(this.window);
3522
+ }
3523
+ /**
3524
+ * Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
3525
+ * @param userName - username to be passed to the RVM.
3526
+ * @param appName - app name to be passed to the RVM.
3527
+ *
3528
+ * @example
3529
+ *
3530
+ * ```js
3531
+ * async function registerUser() {
3532
+ * const app = await fin.Application.getCurrent();
3533
+ * return await app.registerUser('user', 'myApp');
3534
+ * }
3535
+ *
3536
+ * registerUser().then(() => console.log('Successfully registered the user')).catch(err => console.log(err));
3537
+ * ```
3538
+ */
3539
+ registerUser(userName, appName) {
3540
+ return this.wire.sendAction('register-user', { userName, appName, ...this.identity }).then(() => undefined);
3541
+ }
3542
+ /**
3543
+ * Removes the application’s icon from the tray.
3544
+ *
3545
+ * @example
3546
+ *
3547
+ * ```js
3548
+ * async function removeTrayIcon() {
3549
+ * const app = await fin.Application.getCurrent();
3550
+ * return await app.removeTrayIcon();
3551
+ * }
3552
+ *
3553
+ * removeTrayIcon().then(() => console.log('Removed the tray icon.')).catch(err => console.log(err));
3554
+ * ```
3555
+ */
3556
+ removeTrayIcon() {
3557
+ return this.wire.sendAction('remove-tray-icon', this.identity).then(() => undefined);
3558
+ }
3559
+ /**
3560
+ * Restarts the application.
3561
+ *
3562
+ * @example
3563
+ *
3564
+ * ```js
3565
+ * async function restartApp() {
3566
+ * const app = await fin.Application.getCurrent();
3567
+ * return await app.restart();
3568
+ * }
3569
+ * restartApp().then(() => console.log('Application restarted')).catch(err => console.log(err));
3570
+ * ```
3571
+ */
3572
+ restart() {
3573
+ return this.wire.sendAction('restart-application', this.identity).then(() => undefined);
3574
+ }
3575
+ /**
3576
+ * DEPRECATED method to run the application.
3577
+ * Needed when starting application via {@link Application.create}, but NOT needed when starting via {@link Application.start}.
3578
+ *
3579
+ * @example
3580
+ *
3581
+ * ```js
3582
+ * async function run() {
3583
+ * const app = await fin.Application.create({
3584
+ * name: 'myApp',
3585
+ * uuid: 'app-1',
3586
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.run.html',
3587
+ * autoShow: true
3588
+ * });
3589
+ * await app.run();
3590
+ * }
3591
+ * run().then(() => console.log('Application is running')).catch(err => console.log(err));
3592
+ * ```
3593
+ *
3594
+ * @ignore
3595
+ */
3596
+ run() {
3597
+ console.warn('Deprecation Warning: Application.run is deprecated Please use fin.Application.start');
3598
+ this.wire.sendAction('application-run', this.identity).catch((e) => {
3599
+ // we do not want to expose this error, just continue if this analytics-only call fails
3600
+ });
3601
+ return this._run();
3602
+ }
3603
+ _run(opts = {}) {
3604
+ return this.wire
3605
+ .sendAction('run-application', {
3606
+ manifestUrl: this._manifestUrl,
3607
+ opts,
3608
+ ...this.identity
3609
+ })
3610
+ .then(() => undefined);
3611
+ }
3612
+ /**
3613
+ * Instructs the RVM to schedule one restart of the application.
3614
+ *
3615
+ * @example
3616
+ *
3617
+ * ```js
3618
+ * async function scheduleRestart() {
3619
+ * const app = await fin.Application.getCurrent();
3620
+ * return await app.scheduleRestart();
3621
+ * }
3622
+ *
3623
+ * scheduleRestart().then(() => console.log('Application is scheduled to restart')).catch(err => console.log(err));
3624
+ * ```
3625
+ */
3626
+ scheduleRestart() {
3627
+ return this.wire.sendAction('relaunch-on-close', this.identity).then(() => undefined);
3628
+ }
3629
+ /**
3630
+ * Sends a message to the RVM to upload the application's logs. On success,
3631
+ * an object containing logId is returned.
3632
+ *
3633
+ * @example
3634
+ *
3635
+ * ```js
3636
+ * async function sendLog() {
3637
+ * const app = await fin.Application.getCurrent();
3638
+ * return await app.sendApplicationLog();
3639
+ * }
3640
+ *
3641
+ * sendLog().then(info => console.log(info.logId)).catch(err => console.log(err));
3642
+ * ```
3643
+ */
3644
+ async sendApplicationLog() {
3645
+ const { payload } = await this.wire.sendAction('send-application-log', this.identity);
3646
+ return payload.data;
3647
+ }
3648
+ /**
3649
+ * Sets or removes a custom JumpList for the application. Only applicable in Windows OS.
3650
+ * If categories is null the previously set custom JumpList (if any) will be replaced by the standard JumpList for the app (managed by Windows).
3651
+ *
3652
+ * Note: If the "name" property is omitted it defaults to "tasks".
3653
+ * @param jumpListCategories An array of JumpList Categories to populate. If null, remove any existing JumpList configuration and set to Windows default.
3654
+ *
3655
+ *
3656
+ * @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).
3657
+ *
3658
+ * The bottommost item in the jumplist will always be an item pointing to the current app. Its name is taken from the manifest's
3659
+ * **` shortcut.name `** and uses **` shortcut.company `** as a fallback. Clicking that item will launch the app from its current manifest.
3660
+ *
3661
+ * Note: If the "name" property is omitted it defaults to "tasks".
3662
+ *
3663
+ * Note: Window OS caches jumplists icons, therefore an icon change might only be visible after the cache is removed or the
3664
+ * uuid or shortcut.name is changed.
3665
+ *
3666
+ * @example
3667
+ *
3668
+ * ```js
3669
+ * const app = fin.Application.getCurrentSync();
3670
+ * const appName = 'My App';
3671
+ * const jumpListConfig = [ // array of JumpList categories
3672
+ * {
3673
+ * // has no name and no type so `type` is assumed to be "tasks"
3674
+ * items: [ // array of JumpList items
3675
+ * {
3676
+ * type: 'task',
3677
+ * title: `Launch ${appName}`,
3678
+ * description: `Runs ${appName} with the default configuration`,
3679
+ * deepLink: 'fins://path.to/app/manifest.json',
3680
+ * iconPath: 'https://path.to/app/icon.ico',
3681
+ * iconIndex: 0
3682
+ * },
3683
+ * { type: 'separator' },
3684
+ * {
3685
+ * type: 'task',
3686
+ * title: `Restore ${appName}`,
3687
+ * description: 'Restore to last configuration',
3688
+ * deepLink: 'fins://path.to/app/manifest.json?$$use-last-configuration=true',
3689
+ * iconPath: 'https://path.to/app/icon.ico',
3690
+ * iconIndex: 0
3691
+ * },
3692
+ * ]
3693
+ * },
3694
+ * {
3695
+ * name: 'Tools',
3696
+ * items: [ // array of JumpList items
3697
+ * {
3698
+ * type: 'task',
3699
+ * title: 'Tool A',
3700
+ * description: 'Runs Tool A',
3701
+ * deepLink: 'fins://path.to/tool-a/manifest.json',
3702
+ * iconPath: 'https://path.to/tool-a/icon.ico',
3703
+ * iconIndex: 0
3704
+ * },
3705
+ * {
3706
+ * type: 'task',
3707
+ * title: 'Tool B',
3708
+ * description: 'Runs Tool B',
3709
+ * deepLink: 'fins://path.to/tool-b/manifest.json',
3710
+ * iconPath: 'https://path.to/tool-b/icon.ico',
3711
+ * iconIndex: 0
3712
+ * }]
3713
+ * }
3714
+ * ];
3715
+ *
3716
+ * app.setJumpList(jumpListConfig).then(() => console.log('JumpList applied')).catch(e => console.log(`JumpList failed to apply: ${e.toString()}`));
3717
+ * ```
3718
+ *
3719
+ * To handle deeplink args:
3720
+ * ```js
3721
+ * function handleUseLastConfiguration() {
3722
+ * // this handler is called when the app is being launched
3723
+ * app.on('run-requested', event => {
3724
+ * if(event.userAppConfigArgs['use-last-configuration']) {
3725
+ * // your logic here
3726
+ * }
3727
+ * });
3728
+ * // this handler is called when the app was already running when the launch was requested
3729
+ * fin.desktop.main(function(args) {
3730
+ * if(args && args['use-last-configuration']) {
3731
+ * // your logic here
3732
+ * }
3733
+ * });
3734
+ * }
3735
+ * ```
3736
+ */
3737
+ async setJumpList(jumpListCategories) {
3738
+ await this.wire.sendAction('set-jump-list', { config: jumpListCategories, ...this.identity });
3739
+ }
3740
+ /**
3741
+ * Adds a customizable icon in the system tray. To listen for a click on the icon use the `tray-icon-clicked` event.
3742
+ * @param icon Image URL or base64 encoded string to be used as the icon
3743
+ *
3744
+ * @example
3745
+ *
3746
+ * ```js
3747
+ * const imageUrl = "http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png";
3748
+ * const base64EncodedImage = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\
3749
+ * ///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII";
3750
+ * const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DH\
3751
+ * xgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
3752
+ *
3753
+ * async function setTrayIcon(icon) {
3754
+ * const app = await fin.Application.getCurrent();
3755
+ * return await app.setTrayIcon(icon);
3756
+ * }
3757
+ *
3758
+ * // use image url to set tray icon
3759
+ * setTrayIcon(imageUrl).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3760
+ *
3761
+ * // use base64 encoded string to set tray icon
3762
+ * setTrayIcon(base64EncodedImage).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3763
+ *
3764
+ * // use a dataURL to set tray icon
3765
+ * setTrayIcon(dataURL).then(() => console.log('Setting tray icon')).catch(err => console.log(err));
3766
+ * ```
3767
+ */
3768
+ setTrayIcon(icon) {
3769
+ return this.wire
3770
+ .sendAction('set-tray-icon', {
3771
+ enabledIcon: icon,
3772
+ ...this.identity
3773
+ })
3774
+ .then(() => undefined);
3775
+ }
3776
+ /**
3777
+ * Sets new application's shortcut configuration. Windows only.
3778
+ * @param config New application's shortcut configuration.
3779
+ *
3780
+ * @remarks Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest
3781
+ * to be able to change shortcut states.
3782
+ *
3783
+ * @example
3784
+ *
3785
+ * ```js
3786
+ * async function setShortcuts(config) {
3787
+ * const app = await fin.Application.getCurrent();
3788
+ * return app.setShortcuts(config);
3789
+ * }
3790
+ *
3791
+ * setShortcuts({
3792
+ * desktop: true,
3793
+ * startMenu: false,
3794
+ * systemStartup: true
3795
+ * }).then(() => console.log('Shortcuts are set.')).catch(err => console.log(err));
3796
+ * ```
3797
+ */
3798
+ setShortcuts(config) {
3799
+ return this.wire.sendAction('set-shortcuts', { data: config, ...this.identity }).then(() => undefined);
3800
+ }
3801
+ /**
3802
+ * Sets the query string in all shortcuts for this app. Requires RVM 5.5+.
3803
+ * @param queryString The new query string for this app's shortcuts.
3804
+ *
3805
+ * @example
3806
+ *
3807
+ * ```js
3808
+ * const newQueryArgs = 'arg=true&arg2=false';
3809
+ * const app = await fin.Application.getCurrent();
3810
+ * try {
3811
+ * await app.setShortcutQueryParams(newQueryArgs);
3812
+ * } catch(err) {
3813
+ * console.error(err)
3814
+ * }
3815
+ * ```
3816
+ */
3817
+ async setShortcutQueryParams(queryString) {
3818
+ await this.wire.sendAction('set-shortcut-query-args', { data: queryString, ...this.identity });
3819
+ }
3820
+ /**
3821
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
3822
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
3823
+ * @param level The zoom level
3824
+ *
3825
+ * @example
3826
+ *
3827
+ * ```js
3828
+ * async function setZoomLevel(number) {
3829
+ * const app = await fin.Application.getCurrent();
3830
+ * return await app.setZoomLevel(number);
3831
+ * }
3832
+ *
3833
+ * setZoomLevel(5).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
3834
+ * ```
3835
+ */
3836
+ setZoomLevel(level) {
3837
+ return this.wire.sendAction('set-application-zoom-level', { level, ...this.identity }).then(() => undefined);
3838
+ }
3839
+ /**
3840
+ * Sets a username to correlate with App Log Management.
3841
+ * @param username Username to correlate with App's Log.
3842
+ *
3843
+ * @example
3844
+ *
3845
+ * ```js
3846
+ * async function setAppLogUser() {
3847
+ * const app = await fin.Application.getCurrent();
3848
+ * return await app.setAppLogUsername('username');
3849
+ * }
3850
+ *
3851
+ * setAppLogUser().then(() => console.log('Success')).catch(err => console.log(err));
3852
+ *
3853
+ * ```
3854
+ */
3855
+ async setAppLogUsername(username) {
3856
+ await this.wire.sendAction('set-app-log-username', { data: username, ...this.identity });
3857
+ }
3858
+ /**
3859
+ * Retrieves information about the system tray. If the system tray is not set, it will throw an error message.
3860
+ * @remarks The only information currently returned is the position and dimensions.
3861
+ *
3862
+ * @example
3863
+ *
3864
+ * ```js
3865
+ * async function getTrayIconInfo() {
3866
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3867
+ * return await app.getTrayIconInfo();
3868
+ * }
3869
+ * getTrayIconInfo().then(info => console.log(info)).catch(err => console.log(err));
3870
+ * ```
3871
+ */
3872
+ getTrayIconInfo() {
3873
+ return this.wire.sendAction('get-tray-icon-info', this.identity).then(({ payload }) => payload.data);
3874
+ }
3875
+ /**
3876
+ * Checks if the application has an associated tray icon.
3877
+ *
3878
+ * @example
3879
+ *
3880
+ * ```js
3881
+ * const app = await fin.Application.wrap({ uuid: 'testapp' });
3882
+ * const hasTrayIcon = await app.hasTrayIcon();
3883
+ * console.log(hasTrayIcon);
3884
+ * ```
3885
+ */
3886
+ hasTrayIcon() {
3887
+ return this.wire.sendAction('has-tray-icon', this.identity).then(({ payload }) => payload.data);
3888
+ }
3889
+ /**
3890
+ * Closes the application by terminating its process.
3891
+ *
3892
+ * @example
3893
+ *
3894
+ * ```js
3895
+ * async function terminateApp() {
3896
+ * const app = await fin.Application.getCurrent();
3897
+ * return await app.terminate();
3898
+ * }
3899
+ * terminateApp().then(() => console.log('Application terminated')).catch(err => console.log(err));
3900
+ * ```
3901
+ */
3902
+ terminate() {
3903
+ return this.wire.sendAction('terminate-application', this.identity).then(() => undefined);
3904
+ }
3905
+ /**
3906
+ * Waits for a hanging application. This method can be called in response to an application
3907
+ * "not-responding" to allow the application to continue and to generate another "not-responding"
3908
+ * message after a certain period of time.
3909
+ *
3910
+ * @ignore
3911
+ */
3912
+ wait() {
3913
+ return this.wire.sendAction('wait-for-hung-application', this.identity).then(() => undefined);
3914
+ }
3915
+ /**
3916
+ * Retrieves information about the application.
3917
+ *
3918
+ * @remarks If the application was not launched from a manifest, the call will return the closest parent application `manifest`
3919
+ * and `manifestUrl`. `initialOptions` shows the parameters used when launched programmatically, or the `startup_app` options
3920
+ * if launched from manifest. The `parentUuid` will be the uuid of the immediate parent (if applicable).
3921
+ *
3922
+ * @example
3923
+ *
3924
+ * ```js
3925
+ * async function getInfo() {
3926
+ * const app = await fin.Application.getCurrent();
3927
+ * return await app.getInfo();
3928
+ * }
3929
+ *
3930
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
3931
+ * ```
3932
+ */
3933
+ getInfo() {
3934
+ return this.wire.sendAction('get-info', this.identity).then(({ payload }) => payload.data);
3935
+ }
3936
+ /**
3937
+ * Retrieves all process information for entities (windows and views) associated with an application.
3938
+ *
3939
+ * @example
3940
+ * ```js
3941
+ * const app = await fin.Application.getCurrent();
3942
+ * const processInfo = await app.getProcessInfo();
3943
+ * ```
3944
+ * @experimental
3945
+ */
3946
+ async getProcessInfo() {
3947
+ const { payload: { data } } = await this.wire.sendAction('application-get-process-info', this.identity);
3948
+ return data;
3949
+ }
3950
+ /**
3951
+ * Sets file auto download location. It's only allowed in the same application.
3952
+ *
3953
+ * Note: This method is restricted by default and must be enabled via
3954
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3955
+ * @param downloadLocation file auto download location
3956
+ *
3957
+ * @throws if setting file auto download location on different applications.
3958
+ * @example
3959
+ *
3960
+ * ```js
3961
+ * const downloadLocation = 'C:\\dev\\temp';
3962
+ * const app = await fin.Application.getCurrent();
3963
+ * try {
3964
+ * await app.setFileDownloadLocation(downloadLocation);
3965
+ * console.log('File download location is set');
3966
+ * } catch(err) {
3967
+ * console.error(err)
3968
+ * }
3969
+ * ```
3970
+ */
3971
+ async setFileDownloadLocation(downloadLocation) {
3972
+ const { name } = this.wire.me;
3973
+ const entityIdentity = { uuid: this.identity.uuid, name };
3974
+ await this.wire.sendAction('set-file-download-location', { ...entityIdentity, downloadLocation });
3975
+ }
3976
+ /**
3977
+ * 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.
3978
+ *
3979
+ * Note: This method is restricted by default and must be enabled via
3980
+ * <a href="https://developers.openfin.co/docs/api-security">API security settings</a>.
3981
+ *
3982
+ * @throws if getting file auto download location on different applications.
3983
+ * @example
3984
+ *
3985
+ * ```js
3986
+ * const app = await fin.Application.getCurrent();
3987
+ * const fileDownloadDir = await app.getFileDownloadLocation();
3988
+ * ```
3989
+ */
3990
+ async getFileDownloadLocation() {
3991
+ const { payload: { data } } = await this.wire.sendAction('get-file-download-location', this.identity);
3992
+ return data;
3993
+ }
3994
+ /**
3995
+ * Shows a menu on the tray icon. Use with tray-icon-clicked event.
3996
+ * @param options
3997
+ * @typeParam Data User-defined shape for data returned upon menu item click. Should be a
3998
+ * [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
3999
+ * of all possible data shapes for the entire menu, and the click handler should process
4000
+ * these with a "reducer" pattern.
4001
+ * @throws if the application has no tray icon set
4002
+ * @throws if the system tray is currently hidden
4003
+ * @example
4004
+ *
4005
+ * ```js
4006
+ * const iconUrl = 'http://cdn.openfin.co/assets/testing/icons/circled-digit-one.png';
4007
+ * const app = fin.Application.getCurrentSync();
4008
+ *
4009
+ * await app.setTrayIcon(iconUrl);
4010
+ *
4011
+ * const template = [
4012
+ * {
4013
+ * label: 'Menu Item 1',
4014
+ * data: 'hello from item 1'
4015
+ * },
4016
+ * { type: 'separator' },
4017
+ * {
4018
+ * label: 'Menu Item 2',
4019
+ * type: 'checkbox',
4020
+ * checked: true,
4021
+ * data: 'The user clicked the checkbox'
4022
+ * },
4023
+ * {
4024
+ * label: 'see more',
4025
+ * enabled: false,
4026
+ * submenu: [
4027
+ * { label: 'submenu 1', data: 'hello from submenu' }
4028
+ * ]
4029
+ * }
4030
+ * ];
4031
+ *
4032
+ * app.addListener('tray-icon-clicked', (event) => {
4033
+ * // right-click
4034
+ * if (event.button === 2) {
4035
+ * app.showTrayIconPopupMenu({ template }).then(r => {
4036
+ * if (r.result === 'closed') {
4037
+ * console.log('nothing happened');
4038
+ * } else {
4039
+ * console.log(r.data);
4040
+ * }
4041
+ * });
4042
+ * }
4043
+ * });
4044
+ * ```
4045
+ */
4046
+ async showTrayIconPopupMenu(options) {
4047
+ const { name } = this.wire.me;
4048
+ const entityIdentity = { uuid: this.identity.uuid, name };
4049
+ const { payload } = await this.wire.sendAction('show-tray-icon-popup-menu', { ...entityIdentity, options });
4050
+ return payload.data;
4051
+ }
4052
+ /**
4053
+ * Closes the tray icon menu.
4054
+ *
4055
+ * @throws if the application has no tray icon set
4056
+ * @example
4057
+ *
4058
+ * ```js
4059
+ * const app = fin.Application.getCurrentSync();
4060
+ *
4061
+ * await app.closeTrayIconPopupMenu();
4062
+ * ```
4063
+ */
4064
+ async closeTrayIconPopupMenu() {
4065
+ const { name } = this.wire.me;
4066
+ const entityIdentity = { uuid: this.identity.uuid, name };
4067
+ await this.wire.sendAction('close-tray-icon-popup-menu', { ...entityIdentity });
4068
+ }
4069
+ }
4070
+ Instance$6.Application = Application;
4071
+ return Instance$6;
4337
4072
  }
4338
- Factory$7.ApplicationModule = ApplicationModule;
4339
4073
 
4340
- (function (exports) {
4341
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4342
- if (k2 === undefined) k2 = k;
4343
- var desc = Object.getOwnPropertyDescriptor(m, k);
4344
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4345
- desc = { enumerable: true, get: function() { return m[k]; } };
4346
- }
4347
- Object.defineProperty(o, k2, desc);
4348
- }) : (function(o, m, k, k2) {
4349
- if (k2 === undefined) k2 = k;
4350
- o[k2] = m[k];
4351
- }));
4352
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
4353
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4354
- };
4355
- Object.defineProperty(exports, "__esModule", { value: true });
4074
+ var hasRequiredFactory$2;
4075
+
4076
+ function requireFactory$2 () {
4077
+ if (hasRequiredFactory$2) return Factory$7;
4078
+ hasRequiredFactory$2 = 1;
4079
+ Object.defineProperty(Factory$7, "__esModule", { value: true });
4080
+ Factory$7.ApplicationModule = void 0;
4081
+ const base_1 = base;
4082
+ const validate_1 = validate;
4083
+ const Instance_1 = requireInstance$1();
4356
4084
  /**
4357
- * Entry points for the OpenFin `Application` API (`fin.Application`).
4358
- *
4359
- * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
4360
- * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
4361
- *
4362
- * 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),
4363
- * both of these were documented on the same page.
4364
- *
4365
- * @packageDocumentation
4085
+ * Static namespace for OpenFin API methods that interact with the {@link Application} class, available under `fin.Application`.
4366
4086
  */
4367
- __exportStar(Factory$7, exports);
4368
- __exportStar(Instance$6, exports);
4369
- } (application));
4087
+ class ApplicationModule extends base_1.Base {
4088
+ /**
4089
+ * Asynchronously returns an API handle for the given Application identity.
4090
+ *
4091
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4092
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4093
+ * for an Application throughout its entire lifecycle.
4094
+ *
4095
+ * @example
4096
+ *
4097
+ * ```js
4098
+ * fin.Application.wrap({ uuid: 'testapp' })
4099
+ * .then(app => app.isRunning())
4100
+ * .then(running => console.log('Application is running: ' + running))
4101
+ * .catch(err => console.log(err));
4102
+ * ```
4103
+ *
4104
+ */
4105
+ async wrap(identity) {
4106
+ this.wire.sendAction('wrap-application').catch((e) => {
4107
+ // we do not want to expose this error, just continue if this analytics-only call fails
4108
+ });
4109
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
4110
+ if (errorMsg) {
4111
+ throw new Error(errorMsg);
4112
+ }
4113
+ return new Instance_1.Application(this.wire, identity);
4114
+ }
4115
+ /**
4116
+ * Synchronously returns an API handle for the given Application identity.
4117
+ *
4118
+ * @remarks Wrapping an Application identity that does not yet exist will *not* throw an error, and instead
4119
+ * returns a stub object that cannot yet perform rendering tasks. This can be useful for plumbing eventing
4120
+ * for an Aplication throughout its entire lifecycle.
4121
+ *
4122
+ * @example
4123
+ *
4124
+ * ```js
4125
+ * const app = fin.Application.wrapSync({ uuid: 'testapp' });
4126
+ * await app.close();
4127
+ * ```
4128
+ *
4129
+ */
4130
+ wrapSync(identity) {
4131
+ this.wire.sendAction('wrap-application-sync').catch((e) => {
4132
+ // we do not want to expose this error, just continue if this analytics-only call fails
4133
+ });
4134
+ const errorMsg = (0, validate_1.validateIdentity)(identity);
4135
+ if (errorMsg) {
4136
+ throw new Error(errorMsg);
4137
+ }
4138
+ return new Instance_1.Application(this.wire, identity);
4139
+ }
4140
+ async _create(appOptions) {
4141
+ // set defaults:
4142
+ if (appOptions.waitForPageLoad === undefined) {
4143
+ appOptions.waitForPageLoad = false;
4144
+ }
4145
+ if (appOptions.autoShow === undefined && appOptions.isPlatformController === undefined) {
4146
+ appOptions.autoShow = true;
4147
+ }
4148
+ await this.wire.sendAction('create-application', appOptions);
4149
+ return this.wrap({ uuid: appOptions.uuid });
4150
+ }
4151
+ /**
4152
+ * DEPRECATED method to create a new Application. Use {@link Application.ApplicationModule.start Application.start} instead.
4153
+ *
4154
+ * @example
4155
+ *
4156
+ * ```js
4157
+ * async function createApp() {
4158
+ * const app = await fin.Application.create({
4159
+ * name: 'myApp',
4160
+ * uuid: 'app-3',
4161
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.create.html',
4162
+ * autoShow: true
4163
+ * });
4164
+ * await app.run();
4165
+ * }
4166
+ *
4167
+ * createApp().then(() => console.log('Application is created')).catch(err => console.log(err));
4168
+ * ```
4169
+ *
4170
+ * @ignore
4171
+ */
4172
+ create(appOptions) {
4173
+ console.warn('Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start');
4174
+ this.wire.sendAction('application-create').catch((e) => {
4175
+ // we do not want to expose this error, just continue if this analytics-only call fails
4176
+ });
4177
+ return this._create(appOptions);
4178
+ }
4179
+ /**
4180
+ * Creates and starts a new Application.
4181
+ *
4182
+ * @example
4183
+ *
4184
+ * ```js
4185
+ * async function start() {
4186
+ * return fin.Application.start({
4187
+ * name: 'app-1',
4188
+ * uuid: 'app-1',
4189
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Application.start.html',
4190
+ * autoShow: true
4191
+ * });
4192
+ * }
4193
+ * start().then(() => console.log('Application is running')).catch(err => console.log(err));
4194
+ * ```
4195
+ *
4196
+ */
4197
+ async start(appOptions) {
4198
+ this.wire.sendAction('start-application').catch((e) => {
4199
+ // we do not want to expose this error, just continue if this analytics-only call fails
4200
+ });
4201
+ const app = await this._create(appOptions);
4202
+ await this.wire.sendAction('run-application', { uuid: appOptions.uuid });
4203
+ return app;
4204
+ }
4205
+ /**
4206
+ * Asynchronously starts a batch of applications given an array of application identifiers and manifestUrls.
4207
+ * Returns once the RVM is finished attempting to launch the applications.
4208
+ * @param opts - Parameters that the RVM will use.
4209
+ *
4210
+ * @example
4211
+ *
4212
+ * ```js
4213
+ *
4214
+ * const applicationInfoArray = [
4215
+ * {
4216
+ * "uuid": 'App-1',
4217
+ * "manifestUrl": 'http://localhost:5555/app1.json',
4218
+ * },
4219
+ * {
4220
+ * "uuid": 'App-2',
4221
+ * "manifestUrl": 'http://localhost:5555/app2.json',
4222
+ * },
4223
+ * {
4224
+ * "uuid": 'App-3',
4225
+ * "manifestUrl": 'http://localhost:5555/app3.json',
4226
+ * }
4227
+ * ]
4228
+ *
4229
+ * fin.Application.startManyManifests(applicationInfoArray)
4230
+ * .then(() => {
4231
+ * console.log('RVM has finished launching the application list.');
4232
+ * })
4233
+ * .catch((err) => {
4234
+ * console.log(err);
4235
+ * })
4236
+ * ```
4237
+ *
4238
+ * @experimental
4239
+ */
4240
+ async startManyManifests(applications, opts) {
4241
+ return this.wire.sendAction('run-applications', { applications, opts }).then(() => undefined);
4242
+ }
4243
+ /**
4244
+ * Asynchronously returns an Application object that represents the current application
4245
+ *
4246
+ * @example
4247
+ *
4248
+ * ```js
4249
+ * async function isCurrentAppRunning () {
4250
+ * const app = await fin.Application.getCurrent();
4251
+ * return app.isRunning();
4252
+ * }
4253
+ *
4254
+ * isCurrentAppRunning().then(running => {
4255
+ * console.log(`Current app is running: ${running}`);
4256
+ * }).catch(err => {
4257
+ * console.error(err);
4258
+ * });
4259
+ *
4260
+ * ```
4261
+ */
4262
+ getCurrent() {
4263
+ this.wire.sendAction('get-current-application').catch((e) => {
4264
+ // we do not want to expose this error, just continue if this analytics-only call fails
4265
+ });
4266
+ return this.wrap({ uuid: this.wire.me.uuid });
4267
+ }
4268
+ /**
4269
+ * Synchronously returns an Application object that represents the current application
4270
+ *
4271
+ * @example
4272
+ *
4273
+ * ```js
4274
+ * async function isCurrentAppRunning () {
4275
+ * const app = fin.Application.getCurrentSync();
4276
+ * return app.isRunning();
4277
+ * }
4278
+ *
4279
+ * isCurrentAppRunning().then(running => {
4280
+ * console.log(`Current app is running: ${running}`);
4281
+ * }).catch(err => {
4282
+ * console.error(err);
4283
+ * });
4284
+ *
4285
+ * ```
4286
+ */
4287
+ getCurrentSync() {
4288
+ this.wire.sendAction('get-current-application-sync').catch((e) => {
4289
+ // we do not want to expose this error, just continue if this analytics-only call fails
4290
+ });
4291
+ return this.wrapSync({ uuid: this.wire.me.uuid });
4292
+ }
4293
+ /**
4294
+ * Retrieves application's manifest and returns a running instance of the application.
4295
+ * @param manifestUrl - The URL of app's manifest.
4296
+ * @param opts - Parameters that the RVM will use.
4297
+ *
4298
+ * @example
4299
+ *
4300
+ * ```js
4301
+ * fin.Application.startFromManifest('http://localhost:5555/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4302
+ *
4303
+ * // For a local manifest file:
4304
+ * fin.Application.startFromManifest('file:///C:/somefolder/app.json').then(app => console.log('App is running')).catch(err => console.log(err));
4305
+ * ```
4306
+ */
4307
+ async startFromManifest(manifestUrl, opts) {
4308
+ this.wire.sendAction('application-start-from-manifest').catch((e) => {
4309
+ // we do not want to expose this error, just continue if this analytics-only call fails
4310
+ });
4311
+ const app = await this._createFromManifest(manifestUrl);
4312
+ // @ts-expect-error using private method without warning.
4313
+ await app._run(opts); // eslint-disable-line no-underscore-dangle
4314
+ return app;
4315
+ }
4316
+ /**
4317
+ * @deprecated Use {@link Application.ApplicationModule.startFromManifest Application.startFromManifest} instead.
4318
+ * Retrieves application's manifest and returns a wrapped application.
4319
+ * @param manifestUrl - The URL of app's manifest.
4320
+ * @param callback - called if the method succeeds.
4321
+ * @param errorCallback - called if the method fails. The reason for failure is passed as an argument.
4322
+ *
4323
+ * @example
4324
+ *
4325
+ * ```js
4326
+ * fin.Application.createFromManifest('http://localhost:5555/app.json').then(app => console.log(app)).catch(err => console.log(err));
4327
+ * ```
4328
+ * @ignore
4329
+ */
4330
+ createFromManifest(manifestUrl) {
4331
+ console.warn('Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest');
4332
+ this.wire.sendAction('application-create-from-manifest').catch((e) => {
4333
+ // we do not want to expose this error, just continue if this analytics-only call fails
4334
+ });
4335
+ return this._createFromManifest(manifestUrl);
4336
+ }
4337
+ _createFromManifest(manifestUrl) {
4338
+ return this.wire
4339
+ .sendAction('get-application-manifest', { manifestUrl })
4340
+ .then(({ payload }) => {
4341
+ const uuid = payload.data.platform ? payload.data.platform.uuid : payload.data.startup_app.uuid;
4342
+ return this.wrap({ uuid });
4343
+ })
4344
+ .then((app) => {
4345
+ app._manifestUrl = manifestUrl; // eslint-disable-line no-underscore-dangle
4346
+ return app;
4347
+ });
4348
+ }
4349
+ }
4350
+ Factory$7.ApplicationModule = ApplicationModule;
4351
+ return Factory$7;
4352
+ }
4353
+
4354
+ var hasRequiredApplication;
4355
+
4356
+ function requireApplication () {
4357
+ if (hasRequiredApplication) return application;
4358
+ hasRequiredApplication = 1;
4359
+ (function (exports) {
4360
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4361
+ if (k2 === undefined) k2 = k;
4362
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4363
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4364
+ desc = { enumerable: true, get: function() { return m[k]; } };
4365
+ }
4366
+ Object.defineProperty(o, k2, desc);
4367
+ }) : (function(o, m, k, k2) {
4368
+ if (k2 === undefined) k2 = k;
4369
+ o[k2] = m[k];
4370
+ }));
4371
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
4372
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4373
+ };
4374
+ Object.defineProperty(exports, "__esModule", { value: true });
4375
+ /**
4376
+ * Entry points for the OpenFin `Application` API (`fin.Application`).
4377
+ *
4378
+ * * {@link ApplicationModule} contains static members of the `Application` API, accessible through `fin.Application`.
4379
+ * * {@link Application} describes an instance of an OpenFin Application, e.g. as returned by `fin.Application.getCurrent`.
4380
+ *
4381
+ * 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),
4382
+ * both of these were documented on the same page.
4383
+ *
4384
+ * @packageDocumentation
4385
+ */
4386
+ __exportStar(requireFactory$2(), exports);
4387
+ __exportStar(requireInstance$1(), exports);
4388
+ } (application));
4389
+ return application;
4390
+ }
4370
4391
 
4371
4392
  var promisifySubscription$1 = {};
4372
4393
 
@@ -4410,7 +4431,7 @@ function requireInstance () {
4410
4431
  /* eslint-disable @typescript-eslint/no-unused-vars */
4411
4432
  /* eslint-disable no-console */
4412
4433
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
4413
- const application_1 = application;
4434
+ const application_1 = requireApplication();
4414
4435
  const main_1 = main;
4415
4436
  const view_1 = requireView();
4416
4437
  const warnings_1 = warnings;
@@ -4880,7 +4901,7 @@ function requireInstance () {
4880
4901
  // don't expose
4881
4902
  });
4882
4903
  const opts = await this.getOptions();
4883
- if (!opts.layout || !opts.layoutSnapshot) {
4904
+ if (!opts.layout && !opts.layoutSnapshot) {
4884
4905
  throw new Error('Window does not have a Layout');
4885
4906
  }
4886
4907
  return this.fin.Platform.Layout.wrap(layoutIdentity ?? this.identity);
@@ -15400,14 +15421,11 @@ function requireFdc31_2 () {
15400
15421
  this.wire.sendAction('fdc3-get-info').catch((e) => {
15401
15422
  // we do not want to expose this error, just continue if this analytics-only call fails
15402
15423
  });
15403
- // @ts-expect-error
15404
- const { uuid, fdc3InteropApi } = fin.__internal_.initialOptions;
15405
- // @ts-expect-error
15406
- const runtimeVersion = fin.desktop.getVersion();
15424
+ const version = this.wire.environment.getAdapterVersionSync();
15407
15425
  return {
15408
- fdc3Version: fdc3InteropApi,
15409
- provider: `openfin-${uuid}`,
15410
- providerVersion: runtimeVersion
15426
+ providerVersion: version,
15427
+ provider: `openfin-${this.wire.me.uuid}`,
15428
+ fdc3Version: '1.2'
15411
15429
  };
15412
15430
  }
15413
15431
  }
@@ -16852,7 +16870,7 @@ const events_1$3 = require$$0;
16852
16870
  // Import from the file rather than the directory in case someone consuming types is using module resolution other than "node"
16853
16871
  const index_1 = system;
16854
16872
  const index_2 = requireWindow();
16855
- const index_3 = application;
16873
+ const index_3 = requireApplication();
16856
16874
  const index_4 = interappbus;
16857
16875
  const index_5 = clipboard;
16858
16876
  const index_6 = externalApplication;
@@ -17251,6 +17269,9 @@ class MockEnvironment {
17251
17269
  this.type = 'other';
17252
17270
  this.childViews = true;
17253
17271
  }
17272
+ getAdapterVersionSync() {
17273
+ throw new Error(me_1.environmentUnsupportedMessage);
17274
+ }
17254
17275
  async getInteropInfo() {
17255
17276
  throw new Error(me_1.environmentUnsupportedMessage);
17256
17277
  }