File: bridge/README.md
WebUI Bridge
The WebUI Bridge connects the UI (Web Browser) with the backend application through WebSocket. This bridge is written in TypeScript, and it needs to be transpiled to JavaScript using ESBuild to produce webui.js, then converted to C header using the Node script js2c.js to generate webui_bridge.h.
Windows
- Install Python
- Install Node.js
- cd
webui\bridge npm install esbuild.\node_modules\.bin\esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=.\ .\webui.tsnode js2c.js
Windows PowerShell
- cd
webui\bridge build.bat- If you get running scripts is disabled on this
system error. Then runSet-ExecutionPolicy RemoteSignedto enable script execution. After done, you can roll back by runningSet-ExecutionPolicy Restricted
Linux
- Install Python
- Install Node.js
- cd
webui/bridge npm install esbuild./node_modules/.bin/esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=./ ./webui.tsnode js2c.js
Linux Bash
- cd
webui\bridge - sh
./build.sh
macOS
- Install Python
- Install Node.js
- cd
webui/bridge npm install esbuild./node_modules/.bin/esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=./ ./webui.tsnode js2c.js
macOS Bash
- cd
webui\bridge - sh
./build.sh
File: examples/C/react/README.md
React WebUI Example
This is a basic example of how to use WebUI with React to generate a portable single executable program. WebUI will run the internal web server and use any installed web browser as GUI to show the React UI.
A simple Python script vfs.py is used to generate vfs.h to embed the whole react's build folder into the portable single executable program.
The generated VFS serves exact file paths only; directory index fallback/redirect is handled by WebUI core.
How to use it?
- Run script
build_reactto re-build the React project and compile the C file
How to create a React WebUI project from scratch?
- Run
npx create-react-app my-react-appto create a React app using NPM - Add
<script src="webui.js"></script>intopublic/index.htmlto connect UI with the backend - Run
python vfs.py "./my-react-app/build" "vfs.h"to embed the build folder - Now, use any C compiler to compile
main.cinto a portable executable program
Other backend languages examples:
- Coming soon...
File: examples/C/text-editor/README.md
WebUI C - Text Editor
This text editor is a lightweight and portable example written in C using WebUI as the GUI library.
Windows
sh# GCC mingw32-makeLinux
sh# GCC make # Clang make CC=clangmacOS
shmake
File: examples/C/README.md
WebUI C Examples
Examples of how to create a WebUI application in C.
C Examples
The only requirement to build the examples is a C compiler.
minimal: Creates a minimal WebUI application.call_c_from_js: Calls C from JavaScript.call_js_from_c: Calls JavaScript from C.serve_a_folder: Use WebUI to serve a folder that contains.html,.css,.js, or.tsfiles.custom_web_server: Use your preferred web server like NGINX/Apache... with WebUI to serve a folder.chatgpt_api: Calls ChatGPT API from C.frameless: Frameless window example.public_network_access: Allows network access to external devices.react: React + WebUI example.virtual_file_system: Embeds files using a virtual file system.test_index_redirect: Tests index fallback and custom entry behavior for/,/sub, and/sub/foo.web_app_multi_client: Multiple clients example.
To build an example, cd into its directory and run the make command.
Windows
sh# GCC mingw32-make # MSVC nmakeLinux
sh# GCC make # Clang make CC=clangmacOS
shmake
Additional Examples
text-editor: A lightweight and portable text editor written in C using WebUI as the GUI library.
File: examples/C++/README.md
WebUI C++ Examples
Examples of how to create a WebUI application in C++.
The only requirement to build the examples is a a C++11 compiler.
minimal: Creates a minimal WebUI application.call_cpp_from_js: Calls C++ from JavaScript.call_js_from_cpp: Calls JavaScript from C++ using class methods and member-function bind.serve_a_folder: Uses WebUI to serve a folder with multiple files (class-based example using member-function bind).virtual_file_system: Embeds files using a virtual file system.test_index_redirect: Tests index fallback and custom entry behavior for/,/sub, and/sub/foo.
To build an example, cd into its directory and run the make command.
Windows
sh# G++ mingw32-make # MSVC nmakeLinux
sh# G++ make # Clang make CXX=clangmacOS
shmake
File: src/civetweb/README.md
Changes currently required when updating the submodule to ensure full direct interoperability for wrappers:
Prevent warnings for e.g.
mallocandsnprintfusage outside civetweb.diff+ // Disable All Warnings + #ifdef _MSC_VER + #pragma warning(push, 0) + #pragma warning(disable: 4996) + #elif defined(__clang__) + #pragma clang system_header + #elif defined(__GNUC__) + #pragma GCC system_header + #endif /* Copyright (c) 2013-2024 the Civetweb developers
File: src/webview/README.md
1. `WebView2.h`
- Go to https://www.nuget.org/packages/microsoft.web.webview2.
- Download the
.nupkgfile. - Rename it to
.zip. - Extract the archive.
- Copy the file
microsoft.web.webview2.x.x.xxxx.xx\build\native\include\WebView2.h. - Paste
WebView2.hinto this folder (webui\src\webview).
2. `EventToken.h`
- Go to https://learn.microsoft.com/en-us/windows/apps/windows-sdk/downloads.
- Download and install the Windows SDK.
- Copy
C:\Program Files (x86)\Windows Kits\10\Include\10.x.xxxx.x\winrt\EventToken.h. - Paste
EventToken.hinto this folder (webui\src\webview).
3. Prevent warnings
Add the following snippet at the top of WebView2.h:
// Disable all warnings (WebUI)
#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(disable: 4996)
#elif defined(__clang__)
#pragma clang system_header
#elif defined(__GNUC__)
#pragma GCC system_header
#endif