V binding for webview - a tiny cross-platform library to build modern cross-platform GUI applications.
The goal of this release is to add quality of life features for developers.
For applications that build their user interface using a node web framework, serve_dev
and serve_satic
have been integrated.
serve_dev
- for usage during development
serve_dev('ui_path') // Runs `npm run dev` in the `ui_path` and connects the webview window to it.
serve_dev('ui_path', pkg_manager: .pnpm, script: 'start') // Runs `pnpm start` in the `ui_path` and "
serve_static
- for usage in the compiled application
serve_static('ui_path') // Uses vweb to serve a UI that has been built into a static site and "
Adds a minimal example using Astro: https://github.com/ttytm/webview/tree/main/examples/astro-project
Full Changelog: https://github.com/ttytm/webview/compare/v0.6.0...v0.7.0
The release makes the module safer and more convenient to use and extends test coverage.
Generated release notes:
get_arg[T]
to parse JS args of any type by @ttytm in https://github.com/ttytm/webview/pull/29
bind_opt
and bind_opt_with_ctx
by @ttytm in https://github.com/ttytm/webview/pull/30
Full Changelog: https://github.com/ttytm/webview/compare/v0.5.0...v0.6.0
get_arg
event methodMoves towards using get_arg[T](idx int) !T
to parse JS args to V data types. It's a more uniform approach that embraces error handling and is made the libs default. E.g.:
// Use
e.get_arg[string](0) or { ... }
// Instead of
e.string(0)
e.string_opt(0) or { ... }
Marks methods like e.string()
as deprecated.
bind_opt
and bind_opt_with_ctx
webview methodsAllows to return errors to JS. E.g.:
w.bind_opt('v_fn_with_custom_error', fn (e &webview.Event) !int {
// ...
return error('my error')
})
w.bind_opt('v_fn_with_error_propagation', fn (e &webview.Event) !string {
return os.existing_path('my_inexistent_path/file.v')!
})
try {
await window.v_fn_with_error_propagation();
} catch (err) {
console.log(err); // -> path does not exist
}
Async by default and native return types for more convenience and improved type safety (https://github.com/ttytm/webview/pull/25)
// Comparison, sketching version differences and problems solved.
// v0.4.0
fn my_v_fn_called_from_js(e &Event) {
spawn fn (e &Event) {
interim_res := my_fn_with_err_potential() or { return } // Handled error, but missed returning a value to JS.
// ... further time extensive processing.
e.@return(res)
}(e.async()) // Use `async()` to return a JS result form another thread.
}
// v0.5.0
fn my_v_fn_called_from_js(e &Event) string {
interim_res := my_fn_with_err_potential() or { return '' } // Correct return type required.
// ... further time extensive processing.
return res
}
Add set_icon()
method to set the icon for a window (for now it supports Windows and Linux) (https://github.com/ttytm/webview/pull/24)
Full Changelog: https://github.com/ttytm/webview/compare/v0.4.0...v0.5.0
Introduces a new API for V an JS interoperability
Example:
// v0.3
fn my_v_func(event_id &char, raw_args &char, mut app App) {
hello_from_js_arg := json.decode([]string, unsafe { raw_args.vstring() }) or { return }[0]
app.w.result(event_id, .value, json.encode(hello_from_js_arg + ' Hello back from V!'))
}
// v0.4
fn my_v_func(e &webview.Event) {
hello_from_js_arg := e.string(0)
e.@return(hello_from_js_arg + ' Hello back from V!')
}
The goal of this release is to extend the libraries capabilities and make it simpler to use. Examples are updated and simplified as well as the documentation is updated to reflect the usage.
Full Changelog: https://github.com/ttytm/webview/compare/v0.2.1...v0.3.0