@openfin/core 33.76.27 → 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.
- package/openfin-core-33.76.36.tgz +0 -0
- package/package.json +1 -1
- package/src/OpenFin.d.ts +27 -16
- package/src/api/application/Factory.d.ts +148 -100
- package/src/api/application/Factory.js +148 -100
- package/src/api/application/Instance.d.ts +477 -106
- package/src/api/application/Instance.js +474 -106
- package/src/api/application/index.d.ts +9 -0
- package/src/api/application/index.js +9 -0
- package/src/api/base.d.ts +69 -0
- package/src/api/base.js +69 -0
- package/src/api/clipboard/index.d.ts +111 -31
- package/src/api/clipboard/index.js +111 -31
- package/src/api/events/application.d.ts +12 -0
- package/src/api/events/application.js +12 -0
- package/src/api/events/channel.d.ts +5 -0
- package/src/api/events/channel.js +5 -0
- package/src/api/events/externalApplication.d.ts +5 -0
- package/src/api/events/externalApplication.js +5 -0
- package/src/api/events/frame.d.ts +5 -0
- package/src/api/events/globalHotkey.d.ts +5 -0
- package/src/api/events/platform.d.ts +9 -1
- package/src/api/events/platform.js +8 -0
- package/src/api/events/system.d.ts +13 -0
- package/src/api/events/system.js +13 -0
- package/src/api/events/view.d.ts +19 -9
- package/src/api/events/view.js +10 -0
- package/src/api/events/webcontents.d.ts +21 -10
- package/src/api/events/webcontents.js +11 -0
- package/src/api/events/window.d.ts +70 -1
- package/src/api/events/window.js +10 -0
- package/src/api/external-application/Factory.d.ts +16 -9
- package/src/api/external-application/Factory.js +16 -9
- package/src/api/external-application/Instance.d.ts +40 -32
- package/src/api/external-application/Instance.js +40 -32
- package/src/api/external-application/index.d.ts +9 -0
- package/src/api/external-application/index.js +9 -0
- package/src/api/fin.d.ts +3 -0
- package/src/api/fin.js +3 -0
- package/src/api/frame/Factory.d.ts +30 -13
- package/src/api/frame/Factory.js +30 -13
- package/src/api/frame/Instance.d.ts +51 -38
- package/src/api/frame/Instance.js +51 -38
- package/src/api/frame/index.d.ts +11 -0
- package/src/api/frame/index.js +11 -0
- package/src/api/global-hotkey/index.d.ts +81 -13
- package/src/api/global-hotkey/index.js +81 -13
- package/src/api/interappbus/channel/channel.d.ts +257 -0
- package/src/api/interappbus/channel/channel.js +257 -0
- package/src/api/interappbus/channel/channels-docs.d.ts +59 -57
- package/src/api/interappbus/channel/channels-docs.js +71 -68
- package/src/api/interappbus/channel/client.d.ts +93 -0
- package/src/api/interappbus/channel/client.js +93 -1
- package/src/api/interappbus/channel/index.d.ts +164 -0
- package/src/api/interappbus/channel/index.js +165 -1
- package/src/api/interappbus/channel/provider.d.ts +172 -0
- package/src/api/interappbus/channel/provider.js +172 -0
- package/src/api/interappbus/index.d.ts +55 -20
- package/src/api/interappbus/index.js +55 -20
- package/src/api/interop/Factory.d.ts +30 -10
- package/src/api/interop/Factory.js +30 -10
- package/src/api/interop/InteropBroker.d.ts +298 -70
- package/src/api/interop/InteropBroker.js +298 -70
- package/src/api/interop/InteropClient.d.ts +286 -62
- package/src/api/interop/InteropClient.js +286 -62
- package/src/api/interop/SessionContextGroupClient.d.ts +2 -2
- package/src/api/interop/SessionContextGroupClient.js +2 -2
- package/src/api/interop/fdc3/documentationStub.d.ts +14 -0
- package/src/api/interop/fdc3/documentationStub.js +17 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +31 -34
- package/src/api/interop/fdc3/fdc3-1.2.js +31 -34
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +48 -51
- package/src/api/interop/fdc3/fdc3-2.0.js +48 -51
- package/src/api/interop/index.d.ts +8 -0
- package/src/api/interop/index.js +8 -0
- package/src/api/platform/Factory.d.ts +121 -65
- package/src/api/platform/Factory.js +122 -66
- package/src/api/platform/Instance.d.ts +551 -48
- package/src/api/platform/Instance.js +551 -49
- package/src/api/platform/index.d.ts +9 -0
- package/src/api/platform/index.js +9 -0
- package/src/api/platform/layout/Factory.d.ts +53 -76
- package/src/api/platform/layout/Factory.js +53 -76
- package/src/api/platform/layout/Instance.d.ts +158 -23
- package/src/api/platform/layout/Instance.js +118 -20
- package/src/api/platform/layout/entities/layout-entities.d.ts +222 -30
- package/src/api/platform/layout/entities/layout-entities.js +222 -30
- package/src/api/platform/layout/index.d.ts +9 -0
- package/src/api/platform/layout/index.js +9 -0
- package/src/api/platform/provider.d.ts +398 -51
- package/src/api/snapshot-source/Factory.d.ts +33 -18
- package/src/api/snapshot-source/Factory.js +33 -18
- package/src/api/snapshot-source/Instance.d.ts +30 -8
- package/src/api/snapshot-source/Instance.js +30 -8
- package/src/api/snapshot-source/index.d.ts +9 -0
- package/src/api/snapshot-source/index.js +9 -0
- package/src/api/system/index.d.ts +1137 -186
- package/src/api/system/index.js +1142 -186
- package/src/api/view/Factory.d.ts +54 -16
- package/src/api/view/Factory.js +54 -16
- package/src/api/view/Instance.d.ts +330 -216
- package/src/api/view/Instance.js +331 -217
- package/src/api/view/index.d.ts +9 -0
- package/src/api/view/index.js +9 -0
- package/src/api/webcontents/main.d.ts +890 -0
- package/src/api/webcontents/main.js +890 -0
- package/src/api/window/Factory.d.ts +67 -16
- package/src/api/window/Factory.js +67 -16
- package/src/api/window/Instance.d.ts +824 -316
- package/src/api/window/Instance.js +822 -320
- package/src/api/window/index.d.ts +11 -0
- package/src/api/window/index.js +11 -0
- package/src/namespaces.d.ts +1 -0
- package/src/namespaces.js +3 -1
- package/src/shapes/protocol.d.ts +4 -0
- package/openfin-core-33.76.27.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
|
-
*
|
|
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
|
|
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
|
|
499
|
-
* @param
|
|
500
|
-
* @param
|
|
501
|
-
*
|
|
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
|
|
510
|
-
* @param
|
|
511
|
-
* @param
|
|
512
|
-
*
|
|
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
|
|
521
|
-
* @param
|
|
522
|
-
* @param
|
|
523
|
-
*
|
|
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
|
|
532
|
-
* @param
|
|
533
|
-
* @param
|
|
534
|
-
*
|
|
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
|
|
544
|
-
* @param
|
|
545
|
-
* @param
|
|
546
|
-
*
|
|
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
|
|
556
|
-
* @param
|
|
557
|
-
* @param
|
|
558
|
-
*
|
|
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
|
|
567
|
-
*
|
|
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
|
-
*
|
|
815
|
-
* @
|
|
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
|
-
*
|
|
823
|
-
* @
|
|
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
|
-
*
|
|
833
|
-
* @
|
|
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
|
-
*
|
|
841
|
-
* @
|
|
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
|
-
*
|
|
849
|
-
* @
|
|
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
|
|
857
|
-
* @param
|
|
858
|
-
*
|
|
859
|
-
* @
|
|
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
|
-
*
|
|
873
|
-
* @
|
|
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
|
|
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
|
-
*
|
|
883
|
-
* @
|
|
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
|
-
*
|
|
897
|
-
* @return
|
|
898
|
-
*
|
|
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
|
-
*
|
|
907
|
-
* @
|
|
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
|
-
*
|
|
923
|
-
* @
|
|
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
|
-
*
|
|
938
|
-
* @
|
|
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
|
-
*
|
|
946
|
-
* @
|
|
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
|
-
*
|
|
954
|
-
* @
|
|
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
|
-
*
|
|
962
|
-
* @
|
|
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
|
-
*
|
|
970
|
-
* @
|
|
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
|
-
*
|
|
986
|
-
* @
|
|
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
|
-
*
|
|
994
|
-
* @
|
|
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
|
-
*
|
|
1005
|
-
* @
|
|
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
|
|
1118
|
+
* @param area The area of the window to be captured.
|
|
1017
1119
|
* Omitting it will capture the whole visible window.
|
|
1018
|
-
*
|
|
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
|
-
*
|
|
1030
|
-
* @
|
|
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
|
-
*
|
|
1043
|
-
* @
|
|
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
|
-
*
|
|
1054
|
-
* @
|
|
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
|
-
*
|
|
1065
|
-
* @
|
|
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
|
-
*
|
|
1073
|
-
* @
|
|
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
|
-
*
|
|
1081
|
-
* @
|
|
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
|
|
1089
|
-
* @param
|
|
1090
|
-
*
|
|
1091
|
-
* @
|
|
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
|
|
1105
|
-
* @param
|
|
1106
|
-
*
|
|
1107
|
-
* @
|
|
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
|
|
1121
|
-
* @param
|
|
1122
|
-
* @param
|
|
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
|
-
*
|
|
1126
|
-
* @
|
|
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
|
|
1141
|
-
* @param
|
|
1142
|
-
* @param
|
|
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
|
-
*
|
|
1146
|
-
* @
|
|
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
|
-
*
|
|
1161
|
-
* @
|
|
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
|
-
*
|
|
1169
|
-
* @
|
|
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
|
-
*
|
|
1178
|
-
* @
|
|
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
|
|
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
|
-
*
|
|
1188
|
-
* @
|
|
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
|
|
1198
|
-
* @param
|
|
1199
|
-
* @param
|
|
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
|
-
*
|
|
1202
|
-
* @
|
|
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
|
-
*
|
|
1594
|
+
*
|
|
1217
1595
|
* @tutorial Window.showDeveloperTools
|
|
1218
1596
|
*/
|
|
1219
1597
|
/**
|
|
1220
1598
|
* Updates the window using the passed options.
|
|
1221
|
-
*
|
|
1222
|
-
* @
|
|
1223
|
-
* @
|
|
1224
|
-
*
|
|
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
|
|
1232
|
-
* @param
|
|
1233
|
-
*
|
|
1234
|
-
* @
|
|
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.
|
|
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
|
|
1269
|
-
*
|
|
1270
|
-
* @
|
|
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
|
-
*
|
|
1280
|
-
* @
|
|
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
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
* @
|
|
1312
|
-
* @
|
|
1313
|
-
*
|
|
1314
|
-
* @
|
|
1315
|
-
*
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
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
|
-
* @
|
|
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) {
|