Merge pull request #32393 from licui3936/task/RUN_4957_some_functions_types_missing

Task/run 4957 some functions types missing
This commit is contained in:
Benjamin Lichtman
2019-01-22 13:55:41 -08:00
committed by GitHub
2 changed files with 115 additions and 0 deletions
+63
View File
@@ -62,6 +62,7 @@ declare namespace fin {
type ProcessInfo = import('./_v2/api/system/process').ProcessInfo;
type ProxyInfo = import('./_v2/api/system/proxy').ProxyInfo;
type RegistryInfo = import('./_v2/api/system/registry-info').RegistryInfo;
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;
@@ -77,6 +78,7 @@ declare namespace fin {
main(f: () => any): void;
Application: OpenFinApplicationStatic;
ExternalApp: OpenFinExternalApplicationStatic;
GlobalHotkey: OpenFinGlobalHotkey;
InterApplicationBus: OpenFinInterApplicationBus;
Notification: OpenFinNotificationStatic;
System: OpenFinSystem;
@@ -311,6 +313,45 @@ declare namespace fin {
errorCallback?: (reason: string, error: ErrorInfo) => void): void;
}
/**
* GlobalHotkey
* The Global Hotkey allows the registration and unregistration of given hotkeys at the OS level, meaning a Window/Application will receive the events regardless of focused state.
*/
interface OpenFinGlobalHotkey {
/**
* Registers an event listener on the specified event.
*/
addEventListener(
type: OpenFinGlobalHotkeyEventType,
listener: (event: GlobalHotkeyEvent) => void,
callback?: () => void,
errorCallback?: (reason: string, error: ErrorInfo) => void): void;
/**
* Checks if a given hotkey has been registered
*/
isRegistered(hotkey: string, callback?: (registered: boolean) => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
/**
* Registers a global hotkey with the operating system.
*/
register(hotkey: string, listener: () => void, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
/**
* Removes a previously registered event listener from the specified event.
*/
removeEventListener(
type: OpenFinGlobalHotkeyEventType,
listener: (event: GlobalHotkeyEvent) => void,
callback?: () => void,
errorCallback?: (reason: string, error: ErrorInfo) => void): void;
/**
* Unregisters a global hotkey with the operating system.
*/
unregister(hotkey: string, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
/**
* Unregisters all global hotkeys for the current application.
*/
unregisterAll(callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
}
/**
* InterApplicationBus
* A messaging bus that allows for pub/sub messaging between different applications.
@@ -581,6 +622,10 @@ declare namespace fin {
* Retrieves the Proxy settings.
*/
getProxySettings(callback?: (proxy: ProxyInfo) => void, errorCallback?: (reason: string) => void): void;
/**
* Returns information about the running Runtime in an object.
*/
getRuntimeInfo(callback?: (rvmInfo: RuntimeInfo) => void, errorCallback?: (reason: string) => void): void;
/**
* Returns information about the running RVM in an object.
*/
@@ -977,6 +1022,21 @@ declare namespace fin {
uuid: string;
}
interface GlobalHotkeyEvent {
topic: string;
type: OpenFinGlobalHotkeyEventType;
/**
* The Identity that has just registered the hotkey
*/
identity: {
name: string;
uuid: string;
parentFrame: string;
entityType: string;
},
hotkey: string;
}
interface DesktopIconClickedEvent {
mouse: {
/**
@@ -1206,6 +1266,9 @@ declare namespace fin {
type OpenFinExternalApplicationEventType = "connected"
| "disconnected";
type OpenFinGlobalHotkeyEventType = "registered"
| "unregistered";
type OpenFinSystemEventType = "application-closed"
| "application-crashed"
| "application-created"
+52
View File
@@ -164,6 +164,51 @@ function test_external_application() {
}, err => console.log(err));
}
function test_global_hot_key() {
// addEventListener
fin.desktop.GlobalHotkey.addEventListener('registered', (event) => {
console.log(` window ${event.identity.name} has registered ${event.hotkey}`, event);
}, () => {
console.log('The registration was successful');
}, (reason, err) => {
console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`);
});
// isRegister
const hotkey = 'CommandOrControl+X';
fin.desktop.GlobalHotkey.isRegistered(hotkey, registered => {
console.log(`hotkey ${hotkey} is registered ? ${registered}`);
}, (reason, err) => {
console.log('Error unregistering the hotkey', err);
});
// register
fin.desktop.GlobalHotkey.register(hotkey, () => {
console.log(`${hotkey} pressed`);
}, () => {
console.log('Success');
}, (reason, err) => {
console.log('Error registering the hotkey', err);
});
// removeEventListener
const previousCallback = () => { };
fin.desktop.GlobalHotkey.removeEventListener('registered', previousCallback, () => {
console.log('The unregistration was successful');
}, (reason, err) => {
console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`);
});
// unregister
fin.desktop.GlobalHotkey.unregister(hotkey, () => {
console.log('Success');
}, (reason, err) => {
console.log('Error unregistering the hotkey', err);
});
// unregisterAll
fin.desktop.GlobalHotkey.unregisterAll(() => {
console.log('Success');
}, (reason, err) => {
console.log('Error unregistering all hotkeys for this application', err);
});
}
function test_inter_application_bus() {
// addSubscribeListener
fin.desktop.InterApplicationBus.addSubscribeListener((uuid, topic, name) => {
@@ -376,6 +421,13 @@ function test_system() {
fin.desktop.System.getProxySettings(proxy => {
console.log(proxy);
});
// getRuntimeInfo
fin.desktop.System.getRuntimeInfo(runtimeInfoObject => {
console.log("Runtime version:", runtimeInfoObject.version);
console.log("Runtime architecture:", runtimeInfoObject["architecture"]);
}, err => {
console.log("Failed to get runtime info, error message:", err);
});
// getRvmInfo
fin.desktop.System.getRvmInfo(rvmInfoObject => {
console.log("RVM version:", rvmInfoObject.version);