v-webui
v-webui copied to clipboard
Use any web browser as GUI, with V in the backend and modern web technologies in the frontend.
V-WebUI
Features · Installation · Usage · Documentation · WebUI
WebUI is not a web-server solution or a framework, but it allows you to use any web browser as a GUI, with your preferred language in the backend and HTML5 in the frontend. All in a lightweight portable lib.
Features
- Parent library written in pure C
- Fully Independent (No need for any third-party runtimes)
- Lightweight ~200 Kb & Small memory footprint
- Fast binary communication protocol between WebUI and the browser (Instead of JSON)
- One header file
- Multi-platform & Multi-Browser
- Using private profile for safety
Installation
v install https://github.com/webui-dev/v-webui
Usage
After the installation, prepare the WebUI library for usage.
# Linux / macOs
~/.vmodules/vwebui/setup.vsh
# Windows PowerShell
v run %USERPROFILE%/.vmodules/vwebui/setup.vsh
[!TIP] On Windows it is recommended to use GCC or Clang to compile a WebUI V program. TCC is currently not working due to missing header files. You can use the
-ccflag to specify a custom compiler. E.g.:v -cc gcc run .
Example
import vwebui as ui
const html = '<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
background: linear-gradient(to left, #36265a, #654da9);
color: AliceBlue;
font: 16px sans-serif;
text-align: center;
}
</style>
<script src="webui.js"></script>
</head>
<body>
<h1>Thanks for using WebUI!</h1>
<button onclick="webui.my_v_func()">Call V!</button>
</body>
</html>'
fn my_v_func(e &ui.Event) voidptr {
println('Hello From V!')
return ui.no_result
}
w := ui.new_window()
w.bind('my_v_func', my_v_func)
w.show(html)!
ui.wait()
Find more examples in the examples/ directory.
Documentation
- Online Documentation (WIP)
[!NOTE] Until our Online Documentation is finished, you can referrer to
src/lib.vor use V's builtinv doc -comments vwebui.srcfor the latest overview of exported and commented functions.
-
To use WebUI's debug build in your V-WebUI application, add the
-d webui_logflag. E.g.:v -d webui_log run examples/call_v_from_js.v -
Run tests locally:
VJOBS=1 v -stats test tests/
Supported Web Browsers
| Browser | Windows | macOS | Linux |
|---|---|---|---|
| Mozilla Firefox | ✔️ | ✔️ | ✔️ |
| Google Chrome | ✔️ | ✔️ | ✔️ |
| Microsoft Edge | ✔️ | ✔️ | ✔️ |
| Chromium | ✔️ | ✔️ | ✔️ |
| Yandex | ✔️ | ✔️ | ✔️ |
| Brave | ✔️ | ✔️ | ✔️ |
| Vivaldi | ✔️ | ✔️ | ✔️ |
| Epic | ✔️ | ✔️ | not available |
| Apple Safari | not available | coming soon | not available |
| Opera | coming soon | coming soon | coming soon |
License
Licensed under the MIT License.