@openfin/core 33.76.31 → 33.76.36

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 (116) hide show
  1. package/openfin-core-33.76.36.tgz +0 -0
  2. package/package.json +1 -1
  3. package/src/OpenFin.d.ts +27 -16
  4. package/src/api/application/Factory.d.ts +148 -100
  5. package/src/api/application/Factory.js +148 -100
  6. package/src/api/application/Instance.d.ts +477 -106
  7. package/src/api/application/Instance.js +474 -106
  8. package/src/api/application/index.d.ts +9 -0
  9. package/src/api/application/index.js +9 -0
  10. package/src/api/base.d.ts +69 -0
  11. package/src/api/base.js +69 -0
  12. package/src/api/clipboard/index.d.ts +111 -31
  13. package/src/api/clipboard/index.js +111 -31
  14. package/src/api/events/application.d.ts +12 -0
  15. package/src/api/events/application.js +12 -0
  16. package/src/api/events/channel.d.ts +5 -0
  17. package/src/api/events/channel.js +5 -0
  18. package/src/api/events/externalApplication.d.ts +5 -0
  19. package/src/api/events/externalApplication.js +5 -0
  20. package/src/api/events/frame.d.ts +5 -0
  21. package/src/api/events/globalHotkey.d.ts +5 -0
  22. package/src/api/events/platform.d.ts +9 -1
  23. package/src/api/events/platform.js +8 -0
  24. package/src/api/events/system.d.ts +13 -0
  25. package/src/api/events/system.js +13 -0
  26. package/src/api/events/view.d.ts +19 -9
  27. package/src/api/events/view.js +10 -0
  28. package/src/api/events/webcontents.d.ts +21 -10
  29. package/src/api/events/webcontents.js +11 -0
  30. package/src/api/events/window.d.ts +70 -1
  31. package/src/api/events/window.js +10 -0
  32. package/src/api/external-application/Factory.d.ts +16 -9
  33. package/src/api/external-application/Factory.js +16 -9
  34. package/src/api/external-application/Instance.d.ts +40 -32
  35. package/src/api/external-application/Instance.js +40 -32
  36. package/src/api/external-application/index.d.ts +9 -0
  37. package/src/api/external-application/index.js +9 -0
  38. package/src/api/fin.d.ts +3 -0
  39. package/src/api/fin.js +3 -0
  40. package/src/api/frame/Factory.d.ts +30 -13
  41. package/src/api/frame/Factory.js +30 -13
  42. package/src/api/frame/Instance.d.ts +51 -38
  43. package/src/api/frame/Instance.js +51 -38
  44. package/src/api/frame/index.d.ts +11 -0
  45. package/src/api/frame/index.js +11 -0
  46. package/src/api/global-hotkey/index.d.ts +81 -13
  47. package/src/api/global-hotkey/index.js +81 -13
  48. package/src/api/interappbus/channel/channel.d.ts +257 -0
  49. package/src/api/interappbus/channel/channel.js +257 -0
  50. package/src/api/interappbus/channel/channels-docs.d.ts +59 -57
  51. package/src/api/interappbus/channel/channels-docs.js +71 -68
  52. package/src/api/interappbus/channel/client.d.ts +93 -0
  53. package/src/api/interappbus/channel/client.js +93 -1
  54. package/src/api/interappbus/channel/index.d.ts +164 -0
  55. package/src/api/interappbus/channel/index.js +165 -1
  56. package/src/api/interappbus/channel/provider.d.ts +172 -0
  57. package/src/api/interappbus/channel/provider.js +172 -0
  58. package/src/api/interappbus/index.d.ts +55 -20
  59. package/src/api/interappbus/index.js +55 -20
  60. package/src/api/interop/Factory.d.ts +30 -10
  61. package/src/api/interop/Factory.js +30 -10
  62. package/src/api/interop/InteropBroker.d.ts +298 -70
  63. package/src/api/interop/InteropBroker.js +298 -70
  64. package/src/api/interop/InteropClient.d.ts +286 -62
  65. package/src/api/interop/InteropClient.js +286 -62
  66. package/src/api/interop/SessionContextGroupClient.d.ts +2 -2
  67. package/src/api/interop/SessionContextGroupClient.js +2 -2
  68. package/src/api/interop/fdc3/documentationStub.d.ts +14 -0
  69. package/src/api/interop/fdc3/documentationStub.js +17 -0
  70. package/src/api/interop/fdc3/fdc3-1.2.d.ts +31 -34
  71. package/src/api/interop/fdc3/fdc3-1.2.js +31 -34
  72. package/src/api/interop/fdc3/fdc3-2.0.d.ts +48 -51
  73. package/src/api/interop/fdc3/fdc3-2.0.js +48 -51
  74. package/src/api/interop/index.d.ts +8 -0
  75. package/src/api/interop/index.js +8 -0
  76. package/src/api/platform/Factory.d.ts +121 -65
  77. package/src/api/platform/Factory.js +122 -66
  78. package/src/api/platform/Instance.d.ts +551 -48
  79. package/src/api/platform/Instance.js +551 -49
  80. package/src/api/platform/index.d.ts +9 -0
  81. package/src/api/platform/index.js +9 -0
  82. package/src/api/platform/layout/Factory.d.ts +53 -76
  83. package/src/api/platform/layout/Factory.js +53 -76
  84. package/src/api/platform/layout/Instance.d.ts +158 -23
  85. package/src/api/platform/layout/Instance.js +118 -20
  86. package/src/api/platform/layout/entities/layout-entities.d.ts +222 -30
  87. package/src/api/platform/layout/entities/layout-entities.js +222 -30
  88. package/src/api/platform/layout/index.d.ts +9 -0
  89. package/src/api/platform/layout/index.js +9 -0
  90. package/src/api/platform/provider.d.ts +398 -51
  91. package/src/api/snapshot-source/Factory.d.ts +33 -18
  92. package/src/api/snapshot-source/Factory.js +33 -18
  93. package/src/api/snapshot-source/Instance.d.ts +30 -8
  94. package/src/api/snapshot-source/Instance.js +30 -8
  95. package/src/api/snapshot-source/index.d.ts +9 -0
  96. package/src/api/snapshot-source/index.js +9 -0
  97. package/src/api/system/index.d.ts +1137 -186
  98. package/src/api/system/index.js +1142 -186
  99. package/src/api/view/Factory.d.ts +54 -16
  100. package/src/api/view/Factory.js +54 -16
  101. package/src/api/view/Instance.d.ts +330 -216
  102. package/src/api/view/Instance.js +331 -217
  103. package/src/api/view/index.d.ts +9 -0
  104. package/src/api/view/index.js +9 -0
  105. package/src/api/webcontents/main.d.ts +890 -0
  106. package/src/api/webcontents/main.js +890 -0
  107. package/src/api/window/Factory.d.ts +67 -16
  108. package/src/api/window/Factory.js +67 -16
  109. package/src/api/window/Instance.d.ts +824 -316
  110. package/src/api/window/Instance.js +822 -320
  111. package/src/api/window/index.d.ts +11 -0
  112. package/src/api/window/index.js +11 -0
  113. package/src/namespaces.d.ts +1 -0
  114. package/src/namespaces.js +3 -1
  115. package/src/shapes/protocol.d.ts +4 -0
  116. package/openfin-core-33.76.31.tgz +0 -0
@@ -478,27 +478,27 @@ this animation onto the end of the animation queue.
478
478
  * @property { number } bottom Get the application bottom bound
479
479
  */
480
480
  /**
481
- * @classdesc A basic window that wraps a native HTML window. Provides more fine-grained
481
+ * A basic window that wraps a native HTML window. Provides more fine-grained
482
482
  * control over the window state such as the ability to minimize, maximize, restore, etc.
483
483
  * By default a window does not show upon instantiation; instead the window's show() method
484
484
  * must be invoked manually. The new window appears in the same process as the parent window.
485
- * It has the ability to listen for <a href="tutorial-Window.EventEmitter.html">window specific events</a>.
486
- * @class
487
- * @alias Window
488
- * @hideconstructor
485
+ * It has the ability to listen for {@link OpenFin.WindowEvents window specific events}.
489
486
  */
490
487
  // The window.Window name is taken
491
488
  class _Window extends main_1.WebContents {
489
+ /**
490
+ * @internal
491
+ */
492
492
  constructor(wire, identity) {
493
493
  super(wire, identity, 'window');
494
494
  this.identity = identity;
495
495
  }
496
496
  /**
497
497
  * Adds a listener to the end of the listeners array for the specified event.
498
- * @param { string | symbol } eventType - The type of the event.
499
- * @param { Function } listener - Called whenever an event of the specified type occurs.
500
- * @param { SubOptions } [options] - Option to support event timestamps.
501
- * @return {Promise.<this>}
498
+ * @param eventType - The type of the event.
499
+ * @param listener - Called whenever an event of the specified type occurs.
500
+ * @param options - Option to support event timestamps.
501
+ *
502
502
  * @function addListener
503
503
  * @memberof Window
504
504
  * @instance
@@ -506,10 +506,10 @@ class _Window extends main_1.WebContents {
506
506
  */
507
507
  /**
508
508
  * Adds a listener to the end of the listeners array for the specified event.
509
- * @param { string | symbol } eventType - The type of the event.
510
- * @param { Function } listener - Called whenever an event of the specified type occurs.
511
- * @param { SubOptions } [options] - Option to support event timestamps.
512
- * @return {Promise.<this>}
509
+ * @param eventType - The type of the event.
510
+ * @param listener - Called whenever an event of the specified type occurs.
511
+ * @param options - Option to support event timestamps.
512
+ *
513
513
  * @function on
514
514
  * @memberof Window
515
515
  * @instance
@@ -517,10 +517,10 @@ class _Window extends main_1.WebContents {
517
517
  */
518
518
  /**
519
519
  * Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.
520
- * @param { string | symbol } eventType - The type of the event.
521
- * @param { Function } listener - The callback function.
522
- * @param { SubOptions } [options] - Option to support event timestamps.
523
- * @return {Promise.<this>}
520
+ * @param eventType - The type of the event.
521
+ * @param listener - The callback function.
522
+ * @param options - Option to support event timestamps.
523
+ *
524
524
  * @function once
525
525
  * @memberof Window
526
526
  * @instance
@@ -528,10 +528,10 @@ class _Window extends main_1.WebContents {
528
528
  */
529
529
  /**
530
530
  * Adds a listener to the beginning of the listeners array for the specified event.
531
- * @param { string | symbol } eventType - The type of the event.
532
- * @param { Function } listener - The callback function.
533
- * @param { SubOptions } [options] - Option to support event timestamps.
534
- * @return {Promise.<this>}
531
+ * @param eventType - The type of the event.
532
+ * @param listener - The callback function.
533
+ * @param options - Option to support event timestamps.
534
+ *
535
535
  * @function prependListener
536
536
  * @memberof Window
537
537
  * @instance
@@ -540,10 +540,10 @@ class _Window extends main_1.WebContents {
540
540
  /**
541
541
  * Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.
542
542
  * The listener is added to the beginning of the listeners array.
543
- * @param { string | symbol } eventType - The type of the event.
544
- * @param { Function } listener - The callback function.
545
- * @param { SubOptions } [options] - Option to support event timestamps.
546
- * @return {Promise.<this>}
543
+ * @param eventType - The type of the event.
544
+ * @param listener - The callback function.
545
+ * @param options - Option to support event timestamps.
546
+ *
547
547
  * @function prependOnceListener
548
548
  * @memberof Window
549
549
  * @instance
@@ -552,10 +552,10 @@ class _Window extends main_1.WebContents {
552
552
  /**
553
553
  * Remove a listener from the listener array for the specified event.
554
554
  * Caution: Calling this method changes the array indices in the listener array behind the listener.
555
- * @param { string | symbol } eventType - The type of the event.
556
- * @param { Function } listener - The callback function.
557
- * @param { SubOptions } [options] - Option to support event timestamps.
558
- * @return {Promise.<this>}
555
+ * @param eventType - The type of the event.
556
+ * @param listener - The callback function.
557
+ * @param options - Option to support event timestamps.
558
+ *
559
559
  * @function removeListener
560
560
  * @memberof Window
561
561
  * @instance
@@ -563,181 +563,13 @@ class _Window extends main_1.WebContents {
563
563
  */
564
564
  /**
565
565
  * Removes all listeners, or those of the specified event.
566
- * @param { string | symbol } [eventType] - The type of the event.
567
- * @return {Promise.<this>}
566
+ * @param eventType - The type of the event.
567
+ *
568
568
  * @function removeAllListeners
569
569
  * @memberof Window
570
570
  * @instance
571
571
  * @tutorial Window.EventEmitter
572
572
  */
573
- /**
574
- * Gets a base64 encoded image of the window or a part of it.
575
- * @function capturePage
576
- * @param { CapturePageOptions } [options] options for capturePage call.
577
- * @return {Promise.<string>}
578
- * @memberof Window
579
- * @instance
580
- * @tutorial Window.capturePage
581
- */
582
- /**
583
- * Executes Javascript on the window, restricted to windows you own or windows owned by
584
- * applications you have created.
585
- * @param { string } code JavaScript code to be executed on the window.
586
- * @function executeJavaScript
587
- * @memberOf Window
588
- * @instance
589
- * @return {Promise.<void>}
590
- * @tutorial Window.executeJavaScript
591
- */
592
- /**
593
- * Gives focus to the window.
594
- * @return {Promise.<void>}
595
- * @function focus
596
- * @emits focused
597
- * @memberOf Window
598
- * @instance
599
- * @tutorial Window.focus
600
- */
601
- /**
602
- * Returns the zoom level of the window.
603
- * @function getZoomLevel
604
- * @memberOf Window
605
- * @instance
606
- * @return {Promise.<number>}
607
- * @tutorial Window.getZoomLevel
608
- */
609
- /**
610
- * Sets the zoom level of the window.
611
- * @param { number } level The zoom level
612
- * @function setZoomLevel
613
- * @memberOf Window
614
- * @instance
615
- * @return {Promise.<void>}
616
- * @tutorial Window.setZoomLevel
617
- */
618
- /**
619
- * Find and highlight text on a page.
620
- * @param { string } searchTerm Term to find in page
621
- * @param { FindInPageOptions } options Search options
622
- * @function findInPage
623
- * @memberOf Window
624
- * @instance
625
- * @return {Promise.<number>}
626
- * @tutorial Window.findInPage
627
- */
628
- /**
629
- * Stops any findInPage call with the provided action.
630
- * @param {string} action
631
- * Action to execute when stopping a find in page:<br>
632
- * "clearSelection" - Clear the selection.<br>
633
- * "keepSelection" - Translate the selection into a normal selection.<br>
634
- * "activateSelection" - Focus and click the selection node.<br>
635
- * @function stopFindInPage
636
- * @memberOf Window
637
- * @instance
638
- * @return {Promise.<void>}
639
- * @tutorial Window.stopFindInPage
640
- */
641
- /**
642
- * Navigates the window to a specified URL. The url must contain the protocol prefix such as http:// or https://.
643
- * @param {string} url - The URL to navigate the window to.
644
- * @function navigate
645
- * @memberOf Window
646
- * @instance
647
- * @return {Promise.<void>}
648
- * @tutorial Window.navigate
649
- */
650
- /**
651
- * Navigates the window back one page.
652
- * @function navigateBack
653
- * @memberOf Window
654
- * @instance
655
- * @return {Promise.<void>}
656
- * @tutorial Window.navigateBack
657
- */
658
- /**
659
- * Navigates the window forward one page.
660
- * @function navigateForward
661
- * @memberOf Window
662
- * @instance
663
- * @return {Promise.<void>}
664
- * @tutorial Window.navigateForward
665
- */
666
- /**
667
- * Stops any current navigation the window is performing.
668
- * @function stopNavigation
669
- * @memberOf Window
670
- * @instance
671
- * @return {Promise.<void>}
672
- * @tutorial Window.stopNavigation
673
- */
674
- /**
675
- * Reloads the window current page
676
- * @function reload
677
- * @memberOf Window
678
- * @instance
679
- * @return {Promise.<void>}
680
- * @tutorial Window.reload
681
- */
682
- /**
683
- * Prints the window's web page
684
- * @param { PrintOptions } [options] Printer Options
685
- * @function print
686
- * @memberOf Window
687
- * @instance
688
- * @return {Promise.<void>}
689
- * @tutorial Window.print
690
- */
691
- /**
692
- * Returns an array with all system printers
693
- * @deprecated use System.getPrinters instead
694
- * @function getPrinters
695
- * @memberOf Window
696
- * @instance
697
- * @return { Promise.Array.<PrinterInfo> }
698
- * @tutorial Window.getPrinters
699
- */
700
- /**
701
- * Retrieves the process information associated with a window.
702
- * @function getProcessInfo
703
- * @memberOf Window
704
- * @instance
705
- * @return {Promise.<EntityProcessDetails>}
706
- * @tutorial Window.getProcessInfo
707
- */
708
- /**
709
- * Retrieves information on all Shared Workers.
710
- * @function getSharedWorkers
711
- * @memberOf Window
712
- * @instance
713
- * @return {Promise.Array.<SharedWorkerInfo>}
714
- * @tutorial Window.getSharedWorkers
715
- */
716
- /**
717
- * Opens the developer tools for the shared worker context.
718
- * @function inspectSharedWorker
719
- * @memberOf Window
720
- * @instance
721
- * @return {Promise.<void>}
722
- * @tutorial Window.inspectSharedWorker
723
- */
724
- /**
725
- * Inspects the shared worker based on its ID.
726
- * @param { string } workerId - The id of the shared worker.
727
- * @function inspectSharedWorkerById
728
- * @memberOf Window
729
- * @instance
730
- * @return {Promise.<void>}
731
- * @tutorial Window.inspectSharedWorkerById
732
- */
733
- /**
734
- * Opens the developer tools for the service worker context.
735
- * @function inspectServiceWorker
736
- * @memberOf Window
737
- * @instance
738
- * @return {Promise.<void>}
739
- * @tutorial Window.inspectServiceWorker
740
- */
741
573
  // create a new window
742
574
  createWindow(options) {
743
575
  this.wire.sendAction('window-create-window', this.identity).catch((e) => {
@@ -811,16 +643,44 @@ class _Window extends main_1.WebContents {
811
643
  /**
812
644
  * Retrieves an array of frame info objects representing the main frame and any
813
645
  * iframes that are currently on the page.
814
- * @return {Promise.<Array<FrameInfo>>}
815
- * @tutorial Window.getAllFrames
646
+ *
647
+ * @example
648
+ * ```js
649
+ * async function getAllFrames() {
650
+ * const app = await fin.Application.start({
651
+ * name: 'myApp',
652
+ * uuid: 'app-1',
653
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getAllFrames.html',
654
+ * autoShow: true
655
+ * });
656
+ * const win = await app.getWindow();
657
+ * return await win.getAllFrames();
658
+ * }
659
+ *
660
+ * getAllFrames().then(framesInfo => console.log(framesInfo)).catch(err => console.log(err));
661
+ * ```
816
662
  */
817
663
  getAllFrames() {
818
664
  return this.wire.sendAction('get-all-frames', this.identity).then(({ payload }) => payload.data);
819
665
  }
820
666
  /**
821
667
  * Gets the current bounds (top, bottom, right, left, width, height) of the window.
822
- * @return {Promise.<Bounds>}
823
- * @tutorial Window.getBounds
668
+ *
669
+ * @example
670
+ * ```js
671
+ * async function getBounds() {
672
+ * const app = await fin.Application.start({
673
+ * name: 'myApp',
674
+ * uuid: 'app-3',
675
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getBounds.html',
676
+ * autoShow: true
677
+ * });
678
+ * const win = await app.getWindow();
679
+ * return await win.getBounds();
680
+ * }
681
+ *
682
+ * getBounds().then(bounds => console.log(bounds)).catch(err => console.log(err));
683
+ * ```
824
684
  */
825
685
  getBounds() {
826
686
  return this.wire
@@ -829,34 +689,106 @@ class _Window extends main_1.WebContents {
829
689
  }
830
690
  /**
831
691
  * Centers the window on its current screen.
832
- * @return {Promise.<void>}
833
- * @tutorial Window.center
692
+ *
693
+ * @remarks Does not have an effect on minimized or maximized windows.
694
+ *
695
+ * @example
696
+ * ```js
697
+ * async function centerWindow() {
698
+ * const app = await fin.Application.start({
699
+ * name: 'myApp',
700
+ * uuid: 'app-1',
701
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.center.html',
702
+ * autoShow: true
703
+ * });
704
+ * const win = await app.getWindow();
705
+ * return await win.center();
706
+ * }
707
+ *
708
+ * centerWindow().then(() => console.log('Window centered')).catch(err => console.log(err));
709
+ * ```
710
+ *
834
711
  */
835
712
  center() {
836
713
  return this.wire.sendAction('center-window', this.identity).then(() => undefined);
837
714
  }
838
715
  /**
839
716
  * Removes focus from the window.
840
- * @return {Promise.<void>}
841
- * @tutorial Window.blur
717
+ *
718
+ * @example
719
+ * ```js
720
+ * async function blurWindow() {
721
+ * const app = await fin.Application.start({
722
+ * name: 'myApp',
723
+ * uuid: 'app-1',
724
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.blur.html',
725
+ * autoShow: true
726
+ * });
727
+ * const win = await app.getWindow();
728
+ * return await win.blur();
729
+ * }
730
+ *
731
+ * blurWindow().then(() => console.log('Blured Window')).catch(err => console.log(err));
732
+ * ```
842
733
  */
843
734
  blur() {
844
735
  return this.wire.sendAction('blur-window', this.identity).then(() => undefined);
845
736
  }
846
737
  /**
847
738
  * Brings the window to the front of the window stack.
848
- * @return {Promise.<void>}
849
- * @tutorial Window.bringToFront
739
+ *
740
+ * @example
741
+ * ```js
742
+ * async function BringWindowToFront() {
743
+ * const app = await fin.Application.start({
744
+ * name: 'myApp',
745
+ * uuid: 'app-1',
746
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.bringToFront.html',
747
+ * autoShow: true
748
+ * });
749
+ * const win = await app.getWindow();
750
+ * return await win.bringToFront();
751
+ * }
752
+ *
753
+ * BringWindowToFront().then(() => console.log('Window is in the front')).catch(err => console.log(err));
754
+ * ```
850
755
  */
851
756
  bringToFront() {
852
757
  return this.wire.sendAction('bring-window-to-front', this.identity).then(() => undefined);
853
758
  }
854
759
  /**
855
760
  * Performs the specified window transitions.
856
- * @param {Transition} transitions - Describes the animations to perform. See the tutorial.
857
- * @param {TransitionOptions} options - Options for the animation. See the tutorial.
858
- * @return {Promise.<void>}
859
- * @tutorial Window.animate
761
+ * @param transitions - Describes the animations to perform. See the tutorial.
762
+ * @param options - Options for the animation. See the tutorial.
763
+ *
764
+ * @example
765
+ * ```
766
+ * async function animateWindow() {
767
+ * const transitions = {
768
+ * opacity: {
769
+ * opacity: 0.7,
770
+ * duration: 500
771
+ * },
772
+ * position: {
773
+ * top: 100,
774
+ * left: 100,
775
+ * duration: 500,
776
+ * relative: true
777
+ * }
778
+ * };
779
+ * const options = {
780
+ * interrupt: true,
781
+ * tween: 'ease-in'
782
+ * };
783
+ *
784
+ * const win = await fin.Window.getCurrent();
785
+ * return win.animate(transitions, options);
786
+ * }
787
+ *
788
+ * animateWindow()
789
+ * .then(() => console.log('Animation done'))
790
+ * .catch(err => console.error(err));
791
+ * ```
860
792
  */
861
793
  animate(transitions, options) {
862
794
  return this.wire
@@ -869,18 +801,46 @@ class _Window extends main_1.WebContents {
869
801
  }
870
802
  /**
871
803
  * Hides the window.
872
- * @return {Promise.<void>}
873
- * @tutorial Window.hide
804
+ *
805
+ * @example
806
+ * ```js
807
+ * async function hideWindow() {
808
+ * const app = await fin.Application.start({
809
+ * name: 'myApp',
810
+ * uuid: 'app-1',
811
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.hide.html',
812
+ * autoShow: true
813
+ * });
814
+ * const win = await app.getWindow();
815
+ * return await win.hide();
816
+ * }
817
+ *
818
+ * hideWindow().then(() => console.log('Window is hidden')).catch(err => console.log(err));
819
+ * ```
874
820
  */
875
821
  hide() {
876
822
  return this.wire.sendAction('hide-window', this.identity).then(() => undefined);
877
823
  }
878
824
  /**
879
825
  * closes the window application
880
- * @param { boolean } [force = false] Close will be prevented from closing when force is false and
826
+ * @param force Close will be prevented from closing when force is false and
881
827
  * ‘close-requested’ has been subscribed to for application’s main window.
882
- * @return {Promise.<void>}
883
- * @tutorial Window.close
828
+ *
829
+ * @example
830
+ * ```js
831
+ * async function closeWindow() {
832
+ * const app = await fin.Application.start({
833
+ * name: 'myApp',
834
+ * uuid: 'app-3',
835
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.close.html',
836
+ * autoShow: true
837
+ * });
838
+ * const win = await app.getWindow();
839
+ * return await win.close();
840
+ * }
841
+ *
842
+ * closeWindow().then(() => console.log('Window closed')).catch(err => console.log(err));
843
+ * ```
884
844
  */
885
845
  close(force = false) {
886
846
  return this.wire.sendAction('close-window', { force, ...this.identity }).then(() => {
@@ -893,9 +853,24 @@ class _Window extends main_1.WebContents {
893
853
  }
894
854
  /**
895
855
  * Returns the native OS level Id.
896
- * In Windows, it will return the Windows [handle](https://docs.microsoft.com/en-us/windows/desktop/WinProg/windows-data-types#HWND).
897
- * @return {Promise.<string>}
898
- * @tutorial Window.getNativeId
856
+ *
857
+ * @remarks In Windows, it will return the Windows [handle](https://docs.microsoft.com/en-us/windows/desktop/WinProg/windows-data-types#HWND).
858
+ *
859
+ * @example
860
+ * ```js
861
+ * async function getWindowNativeId() {
862
+ * const app = await fin.Application.start({
863
+ * name: 'myApp',
864
+ * uuid: 'app-3',
865
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getNativeId.html',
866
+ * autoShow: true
867
+ * });
868
+ * const win = await app.getWindow();
869
+ * return await win.getNativeId();
870
+ * }
871
+ *
872
+ * getWindowNativeId().then(nativeId => console.log(nativeId)).catch(err => console.log(err));
873
+ * ```
899
874
  */
900
875
  getNativeId() {
901
876
  return this.wire.sendAction('get-window-native-id', this.identity).then(({ payload }) => payload.data);
@@ -903,15 +878,22 @@ class _Window extends main_1.WebContents {
903
878
  /**
904
879
  * Retrieves window's attached views.
905
880
  * @experimental
906
- * @return {Promise.Array.<View>}
907
- * @tutorial Window.getCurrentViews
881
+ *
882
+ * @example
883
+ * ```js
884
+ * const win = fin.Window.getCurrentSync();
885
+ *
886
+ * win.getCurrentViews()
887
+ * .then(views => console.log(views))
888
+ * .catch(console.error);
889
+ * ```
908
890
  */
909
891
  async getCurrentViews() {
910
892
  const { payload } = await this.wire.sendAction('window-get-views', this.identity);
911
893
  return payload.data.map((id) => new view_1.View(this.wire, id));
912
894
  }
913
- /*
914
- * @deprecated Use {@link Window.disableUserMovement} instead.
895
+ /**
896
+ * @deprecated Use {@link Window._Window.disableUserMovement} instead.
915
897
  */
916
898
  disableFrame() {
917
899
  console.warn('Function is deprecated; use disableUserMovement instead.');
@@ -919,14 +901,28 @@ class _Window extends main_1.WebContents {
919
901
  }
920
902
  /**
921
903
  * Prevents a user from changing a window's size/position when using the window's frame.
922
- * @return {Promise.<void>}
923
- * @tutorial Window.disableUserMovement
904
+ *
905
+ * @example
906
+ * ```js
907
+ * async function disableUserMovement() {
908
+ * const app = await fin.Application.start({
909
+ * name: 'myApp',
910
+ * uuid: 'app-3',
911
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.disableFrame.html',
912
+ * autoShow: true
913
+ * });
914
+ * const win = await app.getWindow();
915
+ * return await win.disableUserMovement();
916
+ * }
917
+ *
918
+ * disableUserMovement().then(() => console.log('Window is disabled')).catch(err => console.log(err));
919
+ * ```
924
920
  */
925
921
  disableUserMovement() {
926
922
  return this.wire.sendAction('disable-window-frame', this.identity).then(() => undefined);
927
923
  }
928
- /*
929
- * @deprecated Use {@link Window.enableUserMovement} instead.
924
+ /**
925
+ * @deprecated Use {@link Window._Window.enableUserMovement} instead.
930
926
  */
931
927
  enableFrame() {
932
928
  console.warn('Function is deprecated; use enableUserMovement instead.');
@@ -934,40 +930,104 @@ class _Window extends main_1.WebContents {
934
930
  }
935
931
  /**
936
932
  * Re-enables user changes to a window's size/position when using the window's frame.
937
- * @return {Promise.<void>}
938
- * @tutorial Window.enableUserMovement
933
+ *
934
+ * @example
935
+ * ```js
936
+ * async function enableUserMovement() {
937
+ * const app = await fin.Application.start({
938
+ * name: 'myApp',
939
+ * uuid: 'app-3',
940
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.enableFrame.html',
941
+ * autoShow: true
942
+ * });
943
+ * const win = await app.getWindow();
944
+ * return await win.enableUserMovement();
945
+ * }
946
+ *
947
+ * enableUserMovement().then(() => console.log('Window is enabled')).catch(err => console.log(err));
948
+ * ```
939
949
  */
940
950
  enableUserMovement() {
941
951
  return this.wire.sendAction('enable-window-frame', this.identity).then(() => undefined);
942
952
  }
943
953
  /**
944
954
  * Flashes the window’s frame and taskbar icon until stopFlashing is called or until a focus event is fired.
945
- * @return {Promise.<void>}
946
- * @tutorial Window.flash
955
+ *
956
+ * @remarks On macOS flash only works on inactive windows.
957
+ * @example
958
+ * ```js
959
+ * async function windowFlash() {
960
+ * const app = await fin.Application.start({
961
+ * name: 'myApp',
962
+ * uuid: 'app-1',
963
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.flash.html',
964
+ * autoShow: true
965
+ * });
966
+ * const win = await app.getWindow();
967
+ * return await win.flash();
968
+ * }
969
+ *
970
+ * windowFlash().then(() => console.log('Window flashing')).catch(err => console.log(err));
971
+ * ```
947
972
  */
948
973
  flash() {
949
974
  return this.wire.sendAction('flash-window', this.identity).then(() => undefined);
950
975
  }
951
976
  /**
952
977
  * Stops the taskbar icon from flashing.
953
- * @return {Promise.<void>}
954
- * @tutorial Window.stopFlashing
978
+ *
979
+ * @example
980
+ * ```js
981
+ * async function stopWindowFlashing() {
982
+ * const app = await fin.Application.start({
983
+ * name: 'myApp',
984
+ * uuid: 'app-1',
985
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.stopFlashing.html',
986
+ * autoShow: true
987
+ * });
988
+ * const win = await app.getWindow();
989
+ * return await win.stopFlashing();
990
+ * }
991
+ *
992
+ * stopWindowFlashing().then(() => console.log('Application window flashing')).catch(err => console.log(err));
993
+ * ```
955
994
  */
956
995
  stopFlashing() {
957
996
  return this.wire.sendAction('stop-flash-window', this.identity).then(() => undefined);
958
997
  }
959
998
  /**
960
999
  * Gets an information object for the window.
961
- * @return {Promise.<WindowInfo>}
962
- * @tutorial Window.getInfo
1000
+ *
1001
+ * @example
1002
+ * ```js
1003
+ * async function getInfo() {
1004
+ * const app = await fin.Application.start({
1005
+ * name: 'myApp',
1006
+ * uuid: 'app-1',
1007
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getInfo.html',
1008
+ * autoShow: true
1009
+ * });
1010
+ * const win = await app.getWindow();
1011
+ * return await win.getInfo();
1012
+ * }
1013
+ *
1014
+ * getInfo().then(info => console.log(info)).catch(err => console.log(err));
1015
+ * ```
963
1016
  */
964
1017
  getInfo() {
965
1018
  return this.wire.sendAction('get-window-info', this.identity).then(({ payload }) => payload.data);
966
1019
  }
967
1020
  /**
968
1021
  * Retrieves the window's Layout
969
- * @return {Promise.<Layout>}
970
- * @tutorial Window.getLayout
1022
+ *
1023
+ * @example
1024
+ * ```js
1025
+ * //get the current window
1026
+ * const window = await fin.Window.getCurrent();
1027
+ *
1028
+ * //get the layout for the window
1029
+ * const layout = await window.getLayout();
1030
+ * ```
971
1031
  * @experimental
972
1032
  */
973
1033
  async getLayout() {
@@ -982,16 +1042,44 @@ class _Window extends main_1.WebContents {
982
1042
  }
983
1043
  /**
984
1044
  * Gets the current settings of the window.
985
- * @return {Promise.<any>}
986
- * @tutorial Window.getOptions
1045
+ *
1046
+ * @example
1047
+ * ```js
1048
+ * async function getWindowOptions() {
1049
+ * const app = await fin.Application.start({
1050
+ * name: 'myApp',
1051
+ * uuid: 'app-1',
1052
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getOptions.html',
1053
+ * autoShow: true
1054
+ * });
1055
+ * const win = await app.getWindow();
1056
+ * return await win.getOptions();
1057
+ * }
1058
+ *
1059
+ * getWindowOptions().then(opts => console.log(opts)).catch(err => console.log(err));
1060
+ * ```
987
1061
  */
988
1062
  getOptions() {
989
1063
  return this.wire.sendAction('get-window-options', this.identity).then(({ payload }) => payload.data);
990
1064
  }
991
1065
  /**
992
1066
  * Gets the parent application.
993
- * @return {Promise.<Application>}
994
- * @tutorial Window.getParentApplication
1067
+ *
1068
+ * @example
1069
+ * ```js
1070
+ * async function getParentApplication() {
1071
+ * const app = await fin.Application.start({
1072
+ * name: 'myApp',
1073
+ * uuid: 'app-1',
1074
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getParentApplication.html',
1075
+ * autoShow: true
1076
+ * });
1077
+ * const win = await app.getWindow();
1078
+ * return await win.getParentApplication();
1079
+ * }
1080
+ *
1081
+ * getParentApplication().then(parentApplication => console.log(parentApplication)).catch(err => console.log(err));
1082
+ * ```
995
1083
  */
996
1084
  getParentApplication() {
997
1085
  this.wire.sendAction('window-get-parent-application', this.identity).catch((e) => {
@@ -1001,8 +1089,22 @@ class _Window extends main_1.WebContents {
1001
1089
  }
1002
1090
  /**
1003
1091
  * Gets the parent window.
1004
- * @return {Promise.<_Window>}
1005
- * @tutorial Window.getParentWindow
1092
+ *
1093
+ * @example
1094
+ * ```js
1095
+ * async function getParentWindow() {
1096
+ * const app = await fin.Application.start({
1097
+ * name: 'myApp',
1098
+ * uuid: 'app-1',
1099
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getParentWindow.html',
1100
+ * autoShow: true
1101
+ * });
1102
+ * const win = await app.getWindow();
1103
+ * return await win.getParentWindow();
1104
+ * }
1105
+ *
1106
+ * getParentWindow().then(parentWindow => console.log(parentWindow)).catch(err => console.log(err));
1107
+ * ```
1006
1108
  */
1007
1109
  getParentWindow() {
1008
1110
  this.wire.sendAction('window-get-parent-window', this.identity).catch((e) => {
@@ -1013,9 +1115,9 @@ class _Window extends main_1.WebContents {
1013
1115
  /**
1014
1116
  * ***DEPRECATED - please use Window.capturePage.***
1015
1117
  * Gets a base64 encoded PNG image of the window or just part a of it.
1016
- * @param { Area } [area] The area of the window to be captured.
1118
+ * @param area The area of the window to be captured.
1017
1119
  * Omitting it will capture the whole visible window.
1018
- * @return {Promise.<string>}
1120
+ *
1019
1121
  * @tutorial Window.capturePage
1020
1122
  */
1021
1123
  async getSnapshot(area) {
@@ -1026,8 +1128,22 @@ class _Window extends main_1.WebContents {
1026
1128
  }
1027
1129
  /**
1028
1130
  * Gets the current state ("minimized", "maximized", or "normal") of the window.
1029
- * @return {Promise.<string>}
1030
- * @tutorial Window.getState
1131
+ *
1132
+ * @example
1133
+ * ```js
1134
+ * async function getWindowState() {
1135
+ * const app = await fin.Application.start({
1136
+ * name: 'myApp',
1137
+ * uuid: 'app-1',
1138
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getState.html',
1139
+ * autoShow: true
1140
+ * });
1141
+ * const win = await app.getWindow();
1142
+ * return await win.getState();
1143
+ * }
1144
+ *
1145
+ * getWindowState().then(winState => console.log(winState)).catch(err => console.log(err));
1146
+ * ```
1031
1147
  */
1032
1148
  getState() {
1033
1149
  return this.wire.sendAction('get-window-state', this.identity).then(({ payload }) => payload.data);
@@ -1039,8 +1155,62 @@ class _Window extends main_1.WebContents {
1039
1155
  * you would get from calling [window.open()](https://developer.mozilla.org/en-US/docs/Web/API/Window/open) in a standard web context.
1040
1156
  * The target window needs to be in the same application as the requesting window
1041
1157
  * as well as comply with [same-origin](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) policy requirements.
1042
- * @return {object}
1043
- * @tutorial Window.getWebWindow
1158
+ *
1159
+ * @example
1160
+ * Injecting content into an empty window:
1161
+ *
1162
+ * ```js
1163
+ * (async ()=> {
1164
+ * try {
1165
+ * const winName = `child-window-${Date.now()}`;
1166
+ * const win = await fin.Window.create({
1167
+ * name: winName,
1168
+ * url: 'about:blank'
1169
+ * });
1170
+ * win.getWebWindow().document.write('<h1>Hello World</h1>');
1171
+ * } catch (err) {
1172
+ * console.error(err);
1173
+ * }
1174
+ * })();
1175
+ * ```
1176
+ *
1177
+ * Cloning DOM elements from the parent window (in this example we clone an `h3` element from the parent window):
1178
+ * ```js
1179
+ * (async ()=> {
1180
+ * try {
1181
+ * const currentWindow = await fin.Window.getCurrent();
1182
+ * const parentWindow = await currentWindow.getParentWindow();
1183
+ * const clonedH3 = parentWindow.getWebWindow().document.querySelector('h3').cloneNode(true);
1184
+ * document.body.append(clonedH3);
1185
+ *
1186
+ * } catch (err) {
1187
+ * console.error(err);
1188
+ * }
1189
+ * })();
1190
+ * ```
1191
+ *
1192
+ * Rendering on a child window via a library (in this example we are using the [lit-html](https://lit-html.polymer-project.org/)
1193
+ * template library to render content on a blank child window. You are not going to be able to copy paste this example without
1194
+ * configuring the project correctly but this would demonstrate some templating options available):
1195
+ * ```js
1196
+ * (async ()=> {
1197
+ * try {
1198
+ * const win = await fin.Window.create({
1199
+ * name: `child-window-${Date.now()}`,
1200
+ * url: 'about:blank'
1201
+ * });
1202
+ * const template = html`
1203
+ * <div>
1204
+ * <span>Click here: </span>
1205
+ * <button @click=${()=> console.log('Hello World!')}>log to the console</button>
1206
+ * </div>`;
1207
+ * render(template, win.getWebWindow().document.body);
1208
+ *
1209
+ * } catch (err) {
1210
+ * console.error(err);
1211
+ * }
1212
+ * })();
1213
+ * ```
1044
1214
  */
1045
1215
  getWebWindow() {
1046
1216
  this.wire.sendAction('window-get-web-window', this.identity).catch((e) => {
@@ -1050,8 +1220,13 @@ class _Window extends main_1.WebContents {
1050
1220
  }
1051
1221
  /**
1052
1222
  * Determines if the window is a main window.
1053
- * @return {boolean}
1054
- * @tutorial Window.isMainWindow
1223
+ *
1224
+ * @example
1225
+ * ```js
1226
+ * const wnd = fin.Window.getCurrentSync();
1227
+ * const isMainWnd = wnd.isMainWindow();
1228
+ * console.log('Is this a main window? ' + isMainWnd);
1229
+ * ```
1055
1230
  */
1056
1231
  isMainWindow() {
1057
1232
  this.wire.sendAction('window-is-main-window', this.identity).catch((e) => {
@@ -1061,34 +1236,88 @@ class _Window extends main_1.WebContents {
1061
1236
  }
1062
1237
  /**
1063
1238
  * Determines if the window is currently showing.
1064
- * @return {Promise.<boolean>}
1065
- * @tutorial Window.isShowing
1239
+ *
1240
+ * @example
1241
+ * ```js
1242
+ * async function isWindowShowing() {
1243
+ * const app = await fin.Application.start({
1244
+ * name: 'myApp',
1245
+ * uuid: 'app-1',
1246
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.isShowing.html',
1247
+ * autoShow: true
1248
+ * });
1249
+ * const win = await app.getWindow();
1250
+ * return await win.isShowing();
1251
+ * }
1252
+ *
1253
+ * isWindowShowing().then(bool => console.log(bool)).catch(err => console.log(err));
1254
+ * ```
1066
1255
  */
1067
1256
  isShowing() {
1068
1257
  return this.wire.sendAction('is-window-showing', this.identity).then(({ payload }) => payload.data);
1069
1258
  }
1070
1259
  /**
1071
1260
  * Maximizes the window
1072
- * @return {Promise.<void>}
1073
- * @tutorial Window.maximize
1261
+ *
1262
+ * @example
1263
+ * ```js
1264
+ * async function maxWindow() {
1265
+ * const app = await fin.Application.start({
1266
+ * name: 'myApp',
1267
+ * uuid: 'app-1',
1268
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.maximize.html',
1269
+ * autoShow: true
1270
+ * });
1271
+ * const win = await app.getWindow();
1272
+ * return await win.maximize();
1273
+ * }
1274
+ *
1275
+ * maxWindow().then(() => console.log('Maximized window')).catch(err => console.log(err));
1276
+ * ```
1074
1277
  */
1075
1278
  maximize() {
1076
1279
  return this.wire.sendAction('maximize-window', this.identity).then(() => undefined);
1077
1280
  }
1078
1281
  /**
1079
1282
  * Minimizes the window.
1080
- * @return {Promise.<void>}
1081
- * @tutorial Window.minimize
1283
+ *
1284
+ * @example
1285
+ * ```js
1286
+ * async function minWindow() {
1287
+ * const win = await fin.Window.getCurrent();
1288
+ * return await win.minimize();
1289
+ * }
1290
+ *
1291
+ * minWindow().then(() => console.log('Minimized window')).catch(err => console.log(err));
1292
+ * ```
1082
1293
  */
1083
1294
  minimize() {
1084
1295
  return this.wire.sendAction('minimize-window', this.identity).then(() => undefined);
1085
1296
  }
1086
1297
  /**
1087
1298
  * Moves the window by a specified amount.
1088
- * @param { number } deltaLeft The change in the left position of the window
1089
- * @param { number } deltaTop The change in the top position of the window
1090
- * @return {Promise.<void>}
1091
- * @tutorial Window.moveBy
1299
+ * @param deltaLeft The change in the left position of the window
1300
+ * @param deltaTop The change in the top position of the window
1301
+ *
1302
+ * @example
1303
+ * ```js
1304
+ * async function createWin() {
1305
+ * const app = await fin.Application.start({
1306
+ * name: 'myApp',
1307
+ * uuid: 'app-1',
1308
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.moveBy.html',
1309
+ * autoShow: true
1310
+ * });
1311
+ * return await app.getWindow();
1312
+ * }
1313
+ *
1314
+ * async function moveBy(left, top) {
1315
+ * const win = await createWin();
1316
+ * return await win.moveBy(left, top);
1317
+ * }
1318
+ *
1319
+ * moveBy(580, 300).then(() => console.log('Moved')).catch(err => console.log(err));
1320
+ * ```
1092
1321
  */
1093
1322
  moveBy(deltaLeft, deltaTop) {
1094
1323
  return this.wire
@@ -1101,10 +1330,28 @@ class _Window extends main_1.WebContents {
1101
1330
  }
1102
1331
  /**
1103
1332
  * Moves the window to a specified location.
1104
- * @param { number } left The left position of the window
1105
- * @param { number } top The top position of the window
1106
- * @return {Promise.<void>}
1107
- * @tutorial Window.moveTo
1333
+ * @param left The left position of the window
1334
+ * @param top The top position of the window
1335
+ *
1336
+ * @example
1337
+ * ```js
1338
+ * async function createWin() {
1339
+ * const app = await fin.Application.start({
1340
+ * name: 'myApp',
1341
+ * uuid: 'app-1',
1342
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.moveTo.html',
1343
+ * autoShow: true
1344
+ * });
1345
+ * return await app.getWindow();
1346
+ * }
1347
+ *
1348
+ * async function moveTo(left, top) {
1349
+ * const win = await createWin();
1350
+ * return await win.moveTo(left, top)
1351
+ * }
1352
+ *
1353
+ * moveTo(580, 300).then(() => console.log('Moved')).catch(err => console.log(err))
1354
+ * ```
1108
1355
  */
1109
1356
  moveTo(left, top) {
1110
1357
  return this.wire
@@ -1117,13 +1364,31 @@ class _Window extends main_1.WebContents {
1117
1364
  }
1118
1365
  /**
1119
1366
  * Resizes the window by a specified amount.
1120
- * @param { number } deltaWidth The change in the width of the window
1121
- * @param { number } deltaHeight The change in the height of the window
1122
- * @param { AnchorType } anchor Specifies a corner to remain fixed during the resize.
1367
+ * @param deltaWidth The change in the width of the window
1368
+ * @param deltaHeight The change in the height of the window
1369
+ * @param anchor Specifies a corner to remain fixed during the resize.
1123
1370
  * Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right".
1124
1371
  * If undefined, the default is "top-left"
1125
- * @return {Promise.<void>}
1126
- * @tutorial Window.resizeBy
1372
+ *
1373
+ * @example
1374
+ * ```js
1375
+ * async function createWin() {
1376
+ * const app = await fin.Application.start({
1377
+ * name: 'myApp',
1378
+ * uuid: 'app-1',
1379
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.resizeBy.html',
1380
+ * autoShow: true
1381
+ * });
1382
+ * return await app.getWindow();
1383
+ * }
1384
+ *
1385
+ * async function resizeBy(left, top, anchor) {
1386
+ * const win = await createWin();
1387
+ * return await win.resizeBy(left, top, anchor)
1388
+ * }
1389
+ *
1390
+ * resizeBy(580, 300, 'top-right').then(() => console.log('Resized')).catch(err => console.log(err));
1391
+ * ```
1127
1392
  */
1128
1393
  resizeBy(deltaWidth, deltaHeight, anchor) {
1129
1394
  return this.wire
@@ -1137,13 +1402,31 @@ class _Window extends main_1.WebContents {
1137
1402
  }
1138
1403
  /**
1139
1404
  * Resizes the window to the specified dimensions.
1140
- * @param { number } width The change in the width of the window
1141
- * @param { number } height The change in the height of the window
1142
- * @param { AnchorType } anchor Specifies a corner to remain fixed during the resize.
1405
+ * @param width The change in the width of the window
1406
+ * @param height The change in the height of the window
1407
+ * @param anchor Specifies a corner to remain fixed during the resize.
1143
1408
  * Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right".
1144
1409
  * If undefined, the default is "top-left"
1145
- * @return {Promise.<void>}
1146
- * @tutorial Window.resizeTo
1410
+ *
1411
+ * @example
1412
+ * ```js
1413
+ * async function createWin() {
1414
+ * const app = await fin.Application.start({
1415
+ * name: 'myApp',
1416
+ * uuid: 'app-1',
1417
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.resizeTo.html',
1418
+ * autoShow: true
1419
+ * });
1420
+ * return await app.getWindow();
1421
+ * }
1422
+ *
1423
+ * async function resizeTo(left, top, anchor) {
1424
+ * const win = await createWin();
1425
+ * return await win.resizeTo(left, top, anchor);
1426
+ * }
1427
+ *
1428
+ * resizeTo(580, 300, 'top-left').then(() => console.log('Resized')).catch(err => console.log(err));
1429
+ * ```
1147
1430
  */
1148
1431
  resizeTo(width, height, anchor) {
1149
1432
  return this.wire
@@ -1157,16 +1440,52 @@ class _Window extends main_1.WebContents {
1157
1440
  }
1158
1441
  /**
1159
1442
  * Restores the window to its normal state (i.e., unminimized, unmaximized).
1160
- * @return {Promise.<void>}
1161
- * @tutorial Window.restore
1443
+ *
1444
+ * @example
1445
+ * ```js
1446
+ * async function createWin() {
1447
+ * const app = await fin.Application.start({
1448
+ * name: 'myApp',
1449
+ * uuid: 'app-1',
1450
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.restore.html',
1451
+ * autoShow: true
1452
+ * });
1453
+ * return await app.getWindow();
1454
+ * }
1455
+ *
1456
+ * async function restore() {
1457
+ * const win = await createWin();
1458
+ * return await win.restore();
1459
+ * }
1460
+ *
1461
+ * restore().then(() => console.log('Restored')).catch(err => console.log(err));
1462
+ * ```
1162
1463
  */
1163
1464
  restore() {
1164
1465
  return this.wire.sendAction('restore-window', this.identity).then(() => undefined);
1165
1466
  }
1166
1467
  /**
1167
1468
  * Will bring the window to the front of the entire stack and give it focus.
1168
- * @return {Promise.<void>}
1169
- * @tutorial Window.setAsForeground
1469
+ *
1470
+ * @example
1471
+ * ```js
1472
+ * async function createWin() {
1473
+ * const app = await fin.Application.start({
1474
+ * name: 'myApp',
1475
+ * uuid: 'app-1',
1476
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setAsForeground.html',
1477
+ * autoShow: true
1478
+ * });
1479
+ * return await app.getWindow();
1480
+ * }
1481
+ *
1482
+ * async function setAsForeground() {
1483
+ * const win = await createWin();
1484
+ * return await win.setAsForeground()
1485
+ * }
1486
+ *
1487
+ * setAsForeground().then(() => console.log('In the foreground')).catch(err => console.log(err));
1488
+ * ```
1170
1489
  */
1171
1490
  setAsForeground() {
1172
1491
  return this.wire.sendAction('set-foreground-window', this.identity).then(() => undefined);
@@ -1174,18 +1493,59 @@ class _Window extends main_1.WebContents {
1174
1493
  /**
1175
1494
  * Sets the window's size and position.
1176
1495
  * @property { Bounds } bounds This is a * @type {string} name - name of the window.object that holds the propertys of
1177
- * @return {Promise.<void>}
1178
- * @tutorial Window.setBounds
1496
+ *
1497
+ * @example
1498
+ * ```js
1499
+ * async function createWin() {
1500
+ * const app = await fin.Application.start({
1501
+ * name: 'myApp',
1502
+ * uuid: 'app-1',
1503
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setBounds.html',
1504
+ * autoShow: true
1505
+ * });
1506
+ * return await app.getWindow();
1507
+ * }
1508
+ *
1509
+ * async function setBounds(bounds) {
1510
+ * const win = await createWin();
1511
+ * return await win.setBounds(bounds);
1512
+ * }
1513
+ *
1514
+ * setBounds({
1515
+ * height: 100,
1516
+ * width: 200,
1517
+ * top: 400,
1518
+ * left: 400
1519
+ * }).then(() => console.log('Bounds set to window')).catch(err => console.log(err));
1520
+ * ```
1179
1521
  */
1180
1522
  setBounds(bounds) {
1181
1523
  return this.wire.sendAction('set-window-bounds', { ...bounds, ...this.identity }).then(() => undefined);
1182
1524
  }
1183
1525
  /**
1184
1526
  * Shows the window if it is hidden.
1185
- * @param { boolean } [force = false] Show will be prevented from showing when force is false and
1527
+ * @param force Show will be prevented from showing when force is false and
1186
1528
  * ‘show-requested’ has been subscribed to for application’s main window.
1187
- * @return {Promise.<void>}
1188
- * @tutorial Window.show
1529
+ *
1530
+ * @example
1531
+ * ```js
1532
+ * async function createWin() {
1533
+ * const app = await fin.Application.start({
1534
+ * name: 'myApp',
1535
+ * uuid: 'app-1',
1536
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.show.html',
1537
+ * autoShow: false
1538
+ * });
1539
+ * return await app.getWindow();
1540
+ * }
1541
+ *
1542
+ * async function show() {
1543
+ * const win = await createWin();
1544
+ * return await win.show()
1545
+ * }
1546
+ *
1547
+ * show().then(() => console.log('Showing')).catch(err => console.log(err));
1548
+ * ```
1189
1549
  */
1190
1550
  show(force = false) {
1191
1551
  return this.wire.sendAction('show-window', { force, ...this.identity }).then(() => undefined);
@@ -1194,12 +1554,30 @@ class _Window extends main_1.WebContents {
1194
1554
  * Shows the window if it is hidden at the specified location.
1195
1555
  * If the toggle parameter is set to true, the window will
1196
1556
  * alternate between showing and hiding.
1197
- * @param { number } left The left position of the window
1198
- * @param { number } top The right position of the window
1199
- * @param { boolean } force Show will be prevented from closing when force is false and
1557
+ * @param left The left position of the window
1558
+ * @param top The right position of the window
1559
+ * @param force Show will be prevented from closing when force is false and
1200
1560
  * ‘show-requested’ has been subscribed to for application’s main window
1201
- * @return {Promise.<void>}
1202
- * @tutorial Window.showAt
1561
+ *
1562
+ * @example
1563
+ * ```js
1564
+ * async function createWin() {
1565
+ * const app = await fin.Application.start({
1566
+ * name: 'myApp',
1567
+ * uuid: 'app-1',
1568
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.showAt.html',
1569
+ * autoShow: true
1570
+ * });
1571
+ * return await app.getWindow();
1572
+ * }
1573
+ *
1574
+ * async function showAt(left, top) {
1575
+ * const win = await createWin();
1576
+ * return await win.showAt(left, top)
1577
+ * }
1578
+ *
1579
+ * showAt(580, 300).then(() => console.log('Showing at')).catch(err => console.log(err));
1580
+ * ```
1203
1581
  */
1204
1582
  showAt(left, top, force = false) {
1205
1583
  return this.wire
@@ -1213,25 +1591,41 @@ class _Window extends main_1.WebContents {
1213
1591
  }
1214
1592
  /**
1215
1593
  * Shows the Chromium Developer Tools
1216
- * @return {Promise.<void>}
1594
+ *
1217
1595
  * @tutorial Window.showDeveloperTools
1218
1596
  */
1219
1597
  /**
1220
1598
  * Updates the window using the passed options.
1221
- * Values that are objects are deep-merged, overwriting only the values that are provided.
1222
- * @param {*} options Changes a window's options that were defined upon creation. See tutorial
1223
- * @return {Promise.<void>}
1224
- * @tutorial Window.updateOptions
1599
+ *
1600
+ * @remarks Values that are objects are deep-merged, overwriting only the values that are provided.
1601
+ * @param options Changes a window's options that were defined upon creation. See tutorial
1602
+ *
1603
+ * @example
1604
+ * ```js
1605
+ * async function updateOptions() {
1606
+ * const win = await fin.Window.getCurrent();
1607
+ * return win.updateOptions({maxWidth: 100});
1608
+ * }
1609
+ * updateOptions().then(() => console.log('options is updated')).catch(err => console.error(err));
1610
+ * ```
1225
1611
  */
1226
1612
  updateOptions(options) {
1227
1613
  return this.wire.sendAction('update-window-options', { options, ...this.identity }).then(() => undefined);
1228
1614
  }
1229
1615
  /**
1230
1616
  * Provides credentials to authentication requests
1231
- * @param { string } userName userName to provide to the authentication challenge
1232
- * @param { string } password password to provide to the authentication challenge
1233
- * @return {Promise.<void>}
1234
- * @tutorial Window.authenticate
1617
+ * @param userName userName to provide to the authentication challenge
1618
+ * @param password password to provide to the authentication challenge
1619
+ *
1620
+ * @example
1621
+ * ```js
1622
+ * fin.Application.wrap({uuid: 'OpenfinPOC'}).then(app => {
1623
+ * app.on('window-auth-requested', evt => {
1624
+ * let win = fin.Window.wrap({ uuid: evt.uuid, name: evt.name});
1625
+ * win.authenticate('userName', 'P@assw0rd').then(()=> console.log('authenticated')).catch(err => console.log(err));
1626
+ * });
1627
+ * });
1628
+ * ```
1235
1629
  */
1236
1630
  authenticate(userName, password) {
1237
1631
  return this.wire
@@ -1261,13 +1655,79 @@ class _Window extends main_1.WebContents {
1261
1655
  * @property {* | undefined} [data] - The data property of the menu item clicked by the user. Only defined if result was `clicked`.
1262
1656
  */
1263
1657
  /**
1264
- * Shows a menu on the window. Returns a promise that resolves when the user has either selected an item or closed the menu. (This may take longer than other apis).
1658
+ * Shows a menu on the window.
1659
+ *
1660
+ * @remarks Returns a promise that resolves when the user has either selected an item or closed the menu. (This may take longer than other apis).
1265
1661
  * Resolves to an object with `{result: 'clicked', data }` where data is the data field on the menu item clicked, or `{result 'closed'}` when the user doesn't select anything.
1266
1662
  * Calling this method will close previously opened menus.
1267
1663
  * @experimental
1268
- * @param {ShowPopupMenuOptions} options
1269
- * @return {Promise<MenuResult>}
1270
- * @tutorial Window.showPopupMenu
1664
+ * @param options
1665
+ *
1666
+ * @example
1667
+ * This could be used to show a drop down menu over views in a platform window:
1668
+ * ```js
1669
+ * const template = [
1670
+ * {
1671
+ * label: 'Menu Item 1',
1672
+ * data: 'hello from item 1'
1673
+ * },
1674
+ * { type: 'separator' },
1675
+ * {
1676
+ * label: 'Menu Item 2',
1677
+ * type: 'checkbox',
1678
+ * checked: true,
1679
+ * data: 'The user clicked the checkbox'
1680
+ * },
1681
+ * {
1682
+ * label: 'see more',
1683
+ * enabled: false,
1684
+ * submenu: [
1685
+ * { label: 'submenu 1', data: 'hello from submenu' }
1686
+ * ]
1687
+ * }
1688
+ * ]
1689
+ * fin.me.showPopupMenu({ template }).then(r => {
1690
+ * if (r.result === 'closed') {
1691
+ * console.log('nothing happened');
1692
+ * } else {
1693
+ * console.log(r.data)
1694
+ * }
1695
+ * })
1696
+ * ```
1697
+ *
1698
+ * Overriding the built in context menu (ote that this can be done per element or document wide):
1699
+ * ```js
1700
+ * document.addEventListener('contextmenu', e => {
1701
+ * e.preventDefault();
1702
+ * const template = [
1703
+ * {
1704
+ * label: 'Menu Item 1',
1705
+ * data: 'hello from item 1'
1706
+ * },
1707
+ * { type: 'separator' },
1708
+ * {
1709
+ * label: 'Menu Item 2',
1710
+ * type: 'checkbox',
1711
+ * checked: true,
1712
+ * data: 'The user clicked the checkbox'
1713
+ * },
1714
+ * {
1715
+ * label: 'see more',
1716
+ * enabled: false,
1717
+ * submenu: [
1718
+ * { label: 'submenu 1', data: 'hello from submenu' }
1719
+ * ]
1720
+ * }
1721
+ * ]
1722
+ * fin.me.showPopupMenu({ template, x: e.x, y: e.y }).then(r => {
1723
+ * if (r.result === 'closed') {
1724
+ * console.log('nothing happened');
1725
+ * } else {
1726
+ * console.log(r.data)
1727
+ * }
1728
+ * })
1729
+ * })
1730
+ * ```
1271
1731
  */
1272
1732
  async showPopupMenu(options) {
1273
1733
  const { payload } = await this.wire.sendAction('show-popup-menu', { options, ...this.identity });
@@ -1276,8 +1736,17 @@ class _Window extends main_1.WebContents {
1276
1736
  /**
1277
1737
  * Closes the window's popup menu, if one exists.
1278
1738
  * @experimental
1279
- * @return {Promise<void>}
1280
- * @tutorial Window.closePopupMenu
1739
+ *
1740
+ * @remarks Only one popup menu will ever be showing at a time. Calling `showPopupMenu` will automatically close
1741
+ * any existing popup menu.
1742
+ *
1743
+ *
1744
+ * @example
1745
+ * This could be used to close a popup menu if the user's mouse leaves an element for example.
1746
+ *
1747
+ * ```js
1748
+ * await fin.me.closePopupMenu();
1749
+ * ```
1281
1750
  */
1282
1751
  async closePopupMenu() {
1283
1752
  return this.wire.sendAction('close-popup-menu', { ...this.identity }).then(() => undefined);
@@ -1306,19 +1775,17 @@ class _Window extends main_1.WebContents {
1306
1775
  * @property {* | undefined} [data] - Data passed to `dispatchPopupResult`.
1307
1776
  */
1308
1777
  /**
1309
- * Shows a popup window. If this window currently has a popup open, closes it.
1310
- * @function showPopupWindow
1311
- * @memberOf Window
1312
- * @instance
1313
- * @param {PopupOptions} options
1314
- * @return {Promise<PopupResult>}
1315
- * @tutorial Window.showPopupWindow
1316
- */
1317
- /**
1318
- * Dispatch a result to the caller of `showPopupWindow`. If this window isn't currently being shown as a popup, this call will silently fail.
1319
- * @param {*} data Serializable data to send to the caller window.
1320
- * @return {Promise<void>}
1321
- * @tutorial Window.dispatchPopupResult
1778
+ * Dispatch a result to the caller of `showPopupWindow`.
1779
+ *
1780
+ * @remarks If this window isn't currently being shown as a popup, this call will silently fail.
1781
+ * @param data Serializable data to send to the caller window.
1782
+ *
1783
+ * @example
1784
+ * ```js
1785
+ * await fin.me.dispatchPopupResult({
1786
+ * foo: 'bar'
1787
+ * });
1788
+ * ```
1322
1789
  */
1323
1790
  async dispatchPopupResult(data) {
1324
1791
  this.wire.sendAction('window-dispatch-popup-result', this.identity).catch((e) => {
@@ -1330,7 +1797,42 @@ class _Window extends main_1.WebContents {
1330
1797
  * Prints the contents of the window.
1331
1798
  *
1332
1799
  * @param options Configuration for the print task.
1333
- * @tutorial Window.print
1800
+ * @remarks When `silent` is set to `true`, the API will pick the system's default printer if deviceName is empty
1801
+ * and the default settings for printing.
1802
+ *
1803
+ * Use the CSS style `page-break-before: always;` to force print to a new page.
1804
+ *
1805
+ * @example
1806
+ * ```js
1807
+ * const win = fin.Window.getCurrentSync();
1808
+ *
1809
+ * win.print({ silent: false, deviceName: 'system-printer-name' }).then(() => {
1810
+ * console.log('print call has been sent to the system');
1811
+ * });
1812
+ * ```
1813
+ *
1814
+ * If a window has embedded views, those views will not print by default. To print a window's contents including embedded views,
1815
+ * use the `content` option:
1816
+ *
1817
+ * ```js
1818
+ * const win = fin.Window.getCurrentSync();
1819
+ *
1820
+ * // Print embedded views
1821
+ * win.print({ content: 'views' });
1822
+ *
1823
+ * // Print screenshot of current window
1824
+ * win.print({ content: 'screenshot' })
1825
+ * ```
1826
+ *
1827
+ * When `content` is set to `views`, the embedded views in the platform window will be concatenated and printed as
1828
+ * individual pages. If `includeSelf` is set to `true`, the platform window itself will be printed as the first
1829
+ * page - be aware that this page will *not* include the embedded views - it will only include the contents of
1830
+ * the platform window itself (e.g. tab stacks), with blank spaces where the view contents would be embedded.
1831
+ *
1832
+ * Due to a known issue, view contents that are not visible at the time `print` is called will not appear when
1833
+ * printing `contents: views`. This includes views that are obscured behind other active UI elements.
1834
+ *
1835
+ * To print the views embedded in their page context, set `content` to `screenshot`.
1334
1836
  */
1335
1837
  async print(options = { content: 'self' }) {
1336
1838
  switch (options.content) {