From 8aa4e6316d2d82edba98824583175c5f946d32a4 Mon Sep 17 00:00:00 2001
From: licui
Date: Wed, 30 Jan 2019 15:33:08 -0500
Subject: [PATCH] Add missing API functions in Window
---
types/openfin/index.d.ts | 40 ++++++++++++++++++++++++++++++++--
types/openfin/openfin-tests.ts | 24 ++++++++++++++++++++
2 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts
index 559a6318b3..5d2cd28742 100644
--- a/types/openfin/index.d.ts
+++ b/types/openfin/index.d.ts
@@ -66,12 +66,14 @@ declare namespace fin {
type RuntimeInfo = import('./_v2/api/system/runtime-info').RuntimeInfo;
type RVMInfo = import('./_v2/api/system/rvm').RVMInfo;
type WindowDetail = import('./_v2/api/system/window').WindowDetail;
- type WindowInfo = import('./_v2/api/system/window').WindowInfo;
+ type SystemWindowInfo = import('./_v2/api/system/window').WindowInfo;
type AnchorType = import('./_v2/api/window/anchor-type').AnchorType;
type Bounds = import('./_v2/api/window/bounds').default;
type Transition = import('./_v2/api/window/transition').Transition;
type TransitionOptions = import('./_v2/api/window/transition').TransitionOptions;
type WindowOption = import('./_v2/api/window/windowOption').WindowOption;
+ type WindowInfo = import('./_v2/api/window/window').WindowInfo;
+ type FrameInfo = import('./_v2/api/window/window').FrameInfo;
const desktop: OpenFinDesktop;
@@ -574,7 +576,7 @@ declare namespace fin {
/**
* Retrieves an array of data (name, ids, bounds) for all application windows.
*/
- getAllWindows(callback?: (windowInfoList: WindowInfo[]) => void, errorCallback?: (reason: string) => void): void;
+ getAllWindows(callback?: (windowInfoList: SystemWindowInfo[]) => void, errorCallback?: (reason: string) => void): void;
/**
* Returns information about the app asset.
*/
@@ -825,6 +827,11 @@ declare namespace fin {
* @param Close will be prevented from closing when force is false and 'close-requested' has been subscribed to for application's main window.
*/
close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Executes Javascript on the window, restricted to windows you own or windows owned by applications you have created.
+ * @param code JavaScript code to be executed on the window.
+ */
+ executeJavaScript(code: string, callback?: () => void, errorCallback?: (reason: string) => void): void;
/**
* Prevents a user from changing a window's size/position when using the window's frame.
* 'disabled-frame-bounds-changing' is generated at the start of and during a user move/size operation.
@@ -849,6 +856,11 @@ declare namespace fin {
* Gives focus to the window.
*/
focus(callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Retrieves an array of frame info objects representing the main frame and any
+ * iframes that are currently on the page.
+ */
+ getAllFrames(callback?: (frames: FrameInfo[]) => void, errorCallback?: (reason: string) => void): void;
/**
* Gets the current bounds (top, left, width, height) of the window.
*/
@@ -858,6 +870,10 @@ declare namespace fin {
* Please note that calling window is included in the result array.
*/
getGroup(callback?: (group: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Gets an information object for the window.
+ */
+ getInfo(callback?: (info: WindowInfo) => void, errorCallback?: (reason: string) => void): void;
/**
* Gets the current settings of the window.
*/
@@ -910,6 +926,22 @@ declare namespace fin {
* Moves the window to a specified location.
*/
moveTo(left: number, top: number, callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Navigates the window to a specified URL.
+ */
+ navigate(url: string, callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Navigates the window back one page.
+ */
+ navigateBack(callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Navigates the window forward one page.
+ */
+ navigateForward(callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Reloads the window current page.
+ */
+ reload(ignoreCacheopt?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void;
/**
* Removes a previously registered event listener from the specified event.
*/
@@ -962,6 +994,10 @@ declare namespace fin {
* Stops the taskbar icon from flashing.
*/
stopFlashing(callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Stops any current navigation the window is performing.
+ */
+ stopNavigation(callback?: () => void, errorCallback?: (reason: string) => void): void;
/**
* Updates the window using the passed options
*/
diff --git a/types/openfin/openfin-tests.ts b/types/openfin/openfin-tests.ts
index 134139ce2e..d1b8ebe32d 100644
--- a/types/openfin/openfin-tests.ts
+++ b/types/openfin/openfin-tests.ts
@@ -736,6 +736,8 @@ function test_window() {
finWindow.bringToFront();
// close
finWindow.close();
+ // executeJavaScript
+ finWindow.executeJavaScript("console.log('Hello world');");
// disableFrame
finWindow.disableFrame();
// enableFrame
@@ -744,10 +746,22 @@ function test_window() {
finWindow.flash();
// focus
finWindow.focus();
+ // getAllFrames
+ finWindow.getAllFrames(frames => {
+ console.log(`name: ${frames[0].name} uuid: ${frames[0].uuid}`);
+ });
// getBounds
finWindow.getBounds(bounds => {
console.log(`top: ${bounds.top} left: ${bounds.left} height: ${bounds.height} width: ${bounds.width}`);
});
+ // getGroups
+ finWindow.getGroup(windowGroup => {
+ console.log(`There are a total of ${windowGroup.length} windows in this group.`);
+ });
+ // getInfo
+ finWindow.getInfo(info => {
+ console.log(`Window title: ${info.title}`);
+ });
// getOptions
finWindow.getOptions(options => {
console.log(options);
@@ -830,6 +844,14 @@ function test_window() {
finWindow.moveBy(10, 10);
// moveTo
finWindow.moveTo(100, 200);
+ // navigate
+ finWindow.navigate("https://openfin.co");
+ // navigateBack
+ finWindow.navigateBack();
+ // navigateForward
+ finWindow.navigateForward();
+ // reload
+ finWindow.reload();
// removeEventListener
finWindow.removeEventListener("bounds-changed", event => {
console.log(event);
@@ -852,6 +874,8 @@ function test_window() {
finWindow.showAt(10, 10, false);
// stopFlashing
finWindow.stopFlashing();
+ // stopNavigation
+ finWindow.stopNavigation();
// updateOptions
finWindow.updateOptions({
frame: false,