Update existing examples

This commit is contained in:
Fabio Massaioli 2025-02-25 03:33:15 +01:00
commit cdb4045542
8 changed files with 53 additions and 76 deletions

View file

@ -2,10 +2,10 @@
This example demonstrates how to generate bindings for your application.
To generate bindings, run `wails3 generate bindings -b -d assets/bindings` in this directory.
To generate bindings, run `wails3 generate bindings -clean -b -d assets/bindings` in this directory.
See more options by running `wails3 generate bindings --help`.
## Notes
- The bindings generator is still a work in progress and is subject to change.
- The generated code uses `wails.CallByID` by default. This is the most secure and quickest way to call a function. In a future release, we will look at generating `wails.CallByName` too.
- The generated code uses `wails.CallByID` by default. This is the most robust way to call a function.

View file

@ -9,7 +9,7 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
import {Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create} from "/wails/runtime.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
@ -18,36 +18,31 @@ import * as data$0 from "./data/models.js";
/**
* GetPerson returns a person with the given name.
* @param {string} name
* @returns {Promise<data$0.Person> & { cancel(): void }}
* @returns {$CancellablePromise<data$0.Person>}
*/
export function GetPerson(name) {
let $resultPromise = /** @type {any} */($Call.ByID(2952413357, name));
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
return $Call.ByID(2952413357, name).then(/** @type {($result: any) => any} */(($result) => {
return $$createType0($result);
}));
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
/**
* Greet greets a person
* @param {string} name
* @param {number[]} counts
* @returns {Promise<string> & { cancel(): void }}
* @returns {$CancellablePromise<string>}
*/
export function Greet(name, ...counts) {
let $resultPromise = /** @type {any} */($Call.ByID(1411160069, name, counts));
return $resultPromise;
return $Call.ByID(1411160069, name, counts);
}
/**
* GreetPerson greets a person
* @param {data$0.Person} person
* @returns {Promise<string> & { cancel(): void }}
* @returns {$CancellablePromise<string>}
*/
export function GreetPerson(person) {
let $resultPromise = /** @type {any} */($Call.ByID(4021313248, person));
return $resultPromise;
return $Call.ByID(4021313248, person);
}
// Private type creation functions

View file

@ -4,7 +4,7 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
import {Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create} from "/wails/runtime.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
@ -12,9 +12,8 @@ import * as $models from "./models.js";
/**
* @param {string} s
* @returns {Promise<$models.Hashes> & { cancel(): void }}
* @returns {$CancellablePromise<$models.Hashes>}
*/
export function Generate(s) {
let $resultPromise = /** @type {any} */($Call.ByID(1123907498, s));
return $resultPromise;
return $Call.ByID(1123907498, s);
}

View file

@ -4,44 +4,40 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
import {Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create} from "/wails/runtime.js";
/**
* Delete deletes the key from the store. If AutoSave is true, the store is saved to disk.
* @param {string} key
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Delete(key) {
let $resultPromise = /** @type {any} */($Call.ByID(1029952841, key));
return $resultPromise;
return $Call.ByID(1029952841, key);
}
/**
* Get returns the value for the given key. If key is empty, the entire store is returned.
* @param {string} key
* @returns {Promise<any> & { cancel(): void }}
* @returns {$CancellablePromise<any>}
*/
export function Get(key) {
let $resultPromise = /** @type {any} */($Call.ByID(3017738442, key));
return $resultPromise;
return $Call.ByID(3017738442, key);
}
/**
* Save saves the store to disk
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Save() {
let $resultPromise = /** @type {any} */($Call.ByID(840897339));
return $resultPromise;
return $Call.ByID(840897339);
}
/**
* Set sets the value for the given key. If AutoSave is true, the store is saved to disk.
* @param {string} key
* @param {any} value
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Set(key, value) {
let $resultPromise = /** @type {any} */($Call.ByID(2329265830, key, value));
return $resultPromise;
return $Call.ByID(2329265830, key, value);
}

View file

@ -4,7 +4,7 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
import {Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create} from "/wails/runtime.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
@ -13,48 +13,43 @@ import * as slog$0 from "../../../../../../../log/slog/models.js";
/**
* @param {string} message
* @param {any[]} args
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Debug(message, ...args) {
let $resultPromise = /** @type {any} */($Call.ByID(1384012895, message, args));
return $resultPromise;
return $Call.ByID(1384012895, message, args);
}
/**
* @param {string} message
* @param {any[]} args
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Error(message, ...args) {
let $resultPromise = /** @type {any} */($Call.ByID(1324251502, message, args));
return $resultPromise;
return $Call.ByID(1324251502, message, args);
}
/**
* @param {string} message
* @param {any[]} args
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Info(message, ...args) {
let $resultPromise = /** @type {any} */($Call.ByID(3712350036, message, args));
return $resultPromise;
return $Call.ByID(3712350036, message, args);
}
/**
* @param {slog$0.Level} level
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function SetLogLevel(level) {
let $resultPromise = /** @type {any} */($Call.ByID(2521579448, level));
return $resultPromise;
return $Call.ByID(2521579448, level);
}
/**
* @param {string} message
* @param {any[]} args
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Warning(message, ...args) {
let $resultPromise = /** @type {any} */($Call.ByID(2902024404, message, args));
return $resultPromise;
return $Call.ByID(2902024404, message, args);
}

View file

@ -4,47 +4,41 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
import {Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create} from "/wails/runtime.js";
/**
* @returns {Promise<string> & { cancel(): void }}
* @returns {$CancellablePromise<string>}
*/
export function Close() {
let $resultPromise = /** @type {any} */($Call.ByID(1888105376));
return $resultPromise;
return $Call.ByID(1888105376);
}
/**
* @param {string} query
* @param {any[]} args
* @returns {Promise<void> & { cancel(): void }}
* @returns {$CancellablePromise<void>}
*/
export function Execute(query, ...args) {
let $resultPromise = /** @type {any} */($Call.ByID(3811930203, query, args));
return $resultPromise;
return $Call.ByID(3811930203, query, args);
}
/**
* @param {string} dbPath
* @returns {Promise<string> & { cancel(): void }}
* @returns {$CancellablePromise<string>}
*/
export function Open(dbPath) {
let $resultPromise = /** @type {any} */($Call.ByID(2012175612, dbPath));
return $resultPromise;
return $Call.ByID(2012175612, dbPath);
}
/**
* @param {string} query
* @param {any[]} args
* @returns {Promise<{ [_: string]: any }[]> & { cancel(): void }}
* @returns {$CancellablePromise<{ [_: string]: any }[]>}
*/
export function Select(query, ...args) {
let $resultPromise = /** @type {any} */($Call.ByID(2472933124, query, args));
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
return $Call.ByID(2472933124, query, args).then(/** @type {($result: any) => any} */(($result) => {
return $$createType1($result);
}));
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
// Private type creation functions

View file

@ -48,11 +48,7 @@
let results = document.getElementById("sqlresults");
results.innerHTML = "";
if (!isSelect) {
let message = "Query executed successfully";
if (result.length > 0) {
message += " - " + result;
}
results.innerHTML = message;
results.innerHTML = "Query executed successfully";
return;
}
if (result.length === 0) {
@ -78,6 +74,8 @@
}
results.appendChild(table);
}).catch((err) => {
// Log error for debugging
console.error(err);
// Put error in results
document.getElementById("sqlresults").innerHTML = "<p class='error-message'>" + err + "</p>";
});

File diff suppressed because one or more lines are too long