feat: add runtime typings

This commit is contained in:
Lea Anthony
2019-10-06 13:36:20 +11:00
parent 12ff0f8c97
commit dc5a68acce
3 changed files with 38 additions and 6 deletions

View File

@@ -61,9 +61,9 @@ function Emit(eventName) {
* the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE
*
* @export
* @param {*} eventName
* @param {*} timeInMilliseconds
* @param {*} callback
* @param {string} eventName
* @param {number} timeInMilliseconds
* @param {function} callback
*/
function Heartbeat(eventName, timeInMilliseconds, callback) {
window.wails.Events.Heartbeat(eventName, timeInMilliseconds, callback);

View File

@@ -1,8 +1,9 @@
{
"name": "@wailsapp/runtime",
"version": "1.0.2",
"version": "1.0.5",
"description": "Wails Javascript runtime library",
"main": "main.js",
"types": "runtime.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -20,5 +21,8 @@
"bugs": {
"url": "https://github.com/wailsapp/wails/issues"
},
"homepage": "https://github.com/wailsapp/wails#readme"
}
"homepage": "https://github.com/wailsapp/wails#readme",
"devDependencies": {
"dts-gen": "^0.5.8"
}
}

28
runtime/js/runtime/runtime.d.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
export = wailsapp__runtime;
declare const wailsapp__runtime: {
Browser: {
OpenFile(filename: string): Promise<any>;
OpenURL(url: string): Promise<any>;
};
Events: {
Acknowledge(eventName: string): void;
Emit(eventName: string): void;
Heartbeat(eventName: string, timeInMilliseconds: number, callback: () => void): void;
On(eventName: string, callback: () => void): void;
OnMultiple(eventName: string, callback: () => void, maxCallbacks: number): void;
Once(eventName: string, callback: () => void): void;
};
Init: {
Init(callback: () => void): void;
};
Log: {
Debug(message: string): void;
Error(message: string): void;
Fatal(message: string): void;
Info(message: string): void;
Warning(message: string): void;
};
};