Compare commits

...

940 Commits
2.3.0 ... main

Author SHA1 Message Date
Albert
9dd20b5c98 Update frameless example 2025-03-25 16:12:31 -04:00
Albert
65fd9a8800 Fix out of screen 2025-03-25 16:10:59 -04:00
Albert
3c03d4f45c Fix GCC Warning - ICoreWebView2Controller 2025-03-19 12:20:50 -04:00
Albert
1f80350564 Win32 - Safer WM_EXITSIZEMOVE 2025-03-19 10:54:03 -04:00
Albert
4c8fc25b2d Fix zig warning - Win32 LONG 2025-03-18 19:10:36 -04:00
Albert
b59ddf1c0c Fix zig warning - Win32 LPVOID 2025-03-18 19:02:25 -04:00
Albert
5fafc9b6b6 Improve webkit-app-region precision 2025-03-18 19:00:16 -04:00
Albert
995f1ab25f Frameless + Transparent Screenshot 2025-03-18 17:58:21 -04:00
Albert
d274723ec6 Updating frameless example 2025-03-18 17:46:56 -04:00
Albert
9430e57040 New API - webui_set_transparent 2025-03-18 17:45:34 -04:00
Albert
78b163c350 Win32 - Up WebView Controller Version 2025-03-18 13:52:42 -04:00
Albert
af455d38ee webui_set_center - Linux 2025-03-17 17:22:04 -04:00
Albert
5c52beebfb Fix macOS Build 2025-03-17 15:03:42 -04:00
Albert
ea5e9a57fc Adding webui_set_resizable (macOS) - Not Tested 2025-03-17 14:54:47 -04:00
Albert
c50fcdf5da Adding webui_set_resizable (Linux) 2025-03-17 14:38:13 -04:00
Albert
433dcc25e0 Internal flags rename 2025-03-17 14:07:15 -04:00
Albert
c66b71a98c Renaming webui_wv_set_frameless to webui_set_frameless 2025-03-17 14:01:51 -04:00
Albert
f21f4f14e1 Adding webui_set_resizable (Win32) 2025-03-17 13:59:10 -04:00
Albert
84758f6742 Adding webui_set_center 2025-03-17 13:14:24 -04:00
Hassan DRAGA
aec0f654ba Frameless Example (Not complete) 2025-03-16 00:59:47 -04:00
Hassan DRAGA
ed3aae5790 New webui_minimize and webui_maximize (Not complete) 2025-03-16 00:59:02 -04:00
Hassan DRAGA
d2b40ee7e6 Minor tab spaces cleaning 2025-03-15 23:49:06 -04:00
Hassan DRAGA
25c7e3f16c hwnd check before use 2025-03-15 23:11:21 -04:00
Hassan DRAGA
361237669b macOS frameless window 2025-03-15 18:55:31 -04:00
Hassan DRAGA
c6d5b58352 Custom webkit-app-region implementation 2025-03-15 18:29:28 -04:00
Hassan DRAGA
7e257de1b0 Linux GTK Frameless 2025-03-15 16:13:10 -04:00
Hassan DRAGA
16aec7e181 Renaming webui_wv_set_headless to webui_wv_set_frameless 2025-03-15 15:56:59 -04:00
Hassan DRAGA
5415b19b5f
Merge pull request #570 from eliemichel/patch-2
Fix `WEBUI_STR_CAT_STATIC` on Windows
2025-03-15 15:13:52 -04:00
Hassan DRAGA
c9baba76b7
Merge pull request #568 from eliemichel/patch-1
Remove "index" argument from get_count()
2025-03-15 14:19:37 -04:00
Elie Michel
f4b9043288
Fix WEBUI_STR_CAT_STATIC on Windows
`strcat_s` expects the total destination size as second argument, contrary to `strncat`.
2025-03-15 13:07:28 +01:00
Elie Michel
facd97c107
Remove "index" argument from get_count()
Argument is not used, I suspect it ended up here as part of an abusive copy-paste!
2025-03-15 12:30:42 +01:00
Albert
223608479b macOS - Fix Quick Close WebView 2025-03-14 13:41:53 -04:00
Albert
305070eeb1 macOS - Fix missing symbol build 2025-03-14 12:43:57 -04:00
Albert
7d310a7c1f Fix macOS Build 2025-03-14 12:36:45 -04:00
Albert
d58e04ff05 Safer webui_clean 2025-03-14 12:13:00 -04:00
Albert
1b2f7b637b Fix macOS CPU usage 2025-03-14 12:05:24 -04:00
Albert
dacbfcd257 macOS - Adding _webui_macos_wv_start 2025-03-14 12:00:56 -04:00
Albert
b1595c766c macOS WebView adding exit Timer 2025-03-14 11:37:59 -04:00
Albert
130a26cc21 Remove Linux Tests 2025-03-12 13:35:26 -04:00
Albert
8bf01b0d3e Removing Tests 2025-03-12 13:28:34 -04:00
Albert
3a959d0402 Fix new lib name in macOS 2025-03-12 13:12:50 -04:00
Albert
6cca39ecac Rename examples lib name (Linux and macOS) 2025-03-12 12:42:02 -04:00
Albert
e019f00fad Rename lib name 2025-03-12 11:55:17 -04:00
Albert
fcd903d424 Merge branch 'main' of https://github.com/webui-dev/webui 2025-03-12 10:41:50 -04:00
Showns
6b61f311c8
Merge pull request #306 from iacore/patch-1
fix: add linux dynamic library "lib" prefix
2025-03-12 10:40:03 -04:00
Albert
7dddb64d92 New API - webui_wv_set_headless 2025-03-11 15:09:13 -04:00
Albert
bf1c8ada92 Fix minor warnings 2025-03-11 15:06:20 -04:00
Albert
e558709118 _webui_custom_browser_exist - macOS 2025-03-11 11:51:46 -04:00
Albert
b6457c88bb _webui_custom_browser_exist - Linux 2025-03-11 11:48:01 -04:00
Albert
8d9c6b275b Fix missing Ini _webui_custom_browser_exist 2025-03-11 11:47:25 -04:00
Albert
5ac66da94b _webui_custom_browser_exist - Windows Implementation
We still need macOS and Linux Implementation.
2025-03-10 18:28:37 -04:00
Albert
92324edf6f Adding new API webui_set_browser_folder 2025-03-10 17:50:58 -04:00
Albert
9926908e4b Up to Beta 4 2025-03-10 10:14:39 -04:00
Albert
fd716ddcac C++ - Adding memcpy and win32_get_hwnd 2025-03-07 16:04:21 -05:00
Albert
ef5df7f28c Adding webui_win32_get_hwnd 2025-03-07 11:30:59 -05:00
Albert
5d497e3b83 Merge branch 'main' of https://github.com/webui-dev/webui 2025-03-05 15:49:45 -05:00
Albert
02328acc6d Readme (Organizing Commands) 2025-03-05 15:49:18 -05:00
Showns
b4ce0284ae
Merge pull request #560 from webui-dev/0_14_0
break change: support zig `0.14.0`
2025-03-05 14:31:30 -05:00
Albert
61444bfaa7 Fix Firefox UI
Fix https://github.com/webui-dev/webui/issues/550
2025-03-05 12:47:49 -05:00
jinzhongjia
70b6689106 break change: support zig 0.14.0
Since then, 0.13.0 and previous versions cannot be supported
2025-03-06 00:13:44 +08:00
Albert
7b661f142b Updating Civetweb 2025-03-04 16:19:16 -05:00
Albert
72039fa0ca WebView - Fix Linux CPU Usage 2025-03-04 13:04:14 -05:00
Albert
bd2611ba60 Updating Readme - Adding App Build CMDs 2025-02-28 10:48:33 -05:00
Albert
93ec28addb Fix long-wait when WebView not available 2025-02-27 18:27:36 -05:00
Albert
52c1777c77 Mutex WebView Loop (Linux and macOS) 2025-02-27 17:27:39 -05:00
Albert
3734f9fe9f Adding internal _webui_webview_update 2025-02-27 16:49:39 -05:00
Albert
fb29c6cac4 Switch from Global Mutex to Window Mutex 2025-02-27 16:11:13 -05:00
Albert
18b5d14f8e Rename Mutex Var 2025-02-27 15:21:44 -05:00
Albert
f4e327208f Rename Mutex Macros 2025-02-27 15:18:01 -05:00
Showns
8c58fcb973
Merge pull request #559 from redking00/main
Fix #543
2025-02-27 13:50:25 -05:00
redking00
8f5a306574 Fix https://github.com/webui-dev/webui/issues/543 2025-02-27 18:20:45 +00:00
Albert
e92f9b7824 Enable All Workflows 2025-02-25 17:18:10 -05:00
Albert
c386758414 Enable Arch Linux Workflow 2025-02-25 17:16:02 -05:00
Albert
0f8925e358 Fix Arch Linux Clang 2025-02-25 17:15:02 -05:00
Albert
44971f9bca Fix RedHat Clang 2025-02-25 17:07:17 -05:00
Albert
8fa1fdb89d Adding OpenSSL to RedHat 2025-02-25 16:41:13 -05:00
Albert
cdebbfee0a Enabling RedHat Workflow 2025-02-25 16:33:56 -05:00
Albert
bf94687089 Updating RedHat Workflow 2025-02-25 16:33:12 -05:00
Albert
36676f68ff Fix Arch Linux Workspace Permission 2025-02-25 16:25:19 -05:00
Albert
56f1e4eb2b Fix Arch Linux Git Workspace 2025-02-25 16:17:29 -05:00
Albert
553e65e218 Fix Arch Linux Artifact 2025-02-25 16:11:01 -05:00
Albert
d9af5b2c17 Adding Arch Linux Artifact 2025-02-25 15:25:06 -05:00
Albert
27c877f73f Remove Arch Linux Examples Test 2025-02-25 15:18:38 -05:00
Albert
c9c7562496 Fix Arch Linux Git 2025-02-25 15:18:20 -05:00
Albert
1594f9e40d Test Docker Host Files Access 2025-02-25 15:11:45 -05:00
Albert
133da5072b Test Arch Linux Docker 2025-02-25 15:06:16 -05:00
Showns
8eb49857c1
Merge pull request #555 from webui-dev/zig_master
fix: zig master change
2025-02-25 14:51:02 -05:00
Albert
6c299e49ed Temporary Disable Workflow 2025-02-25 14:49:47 -05:00
Albert
ad869075d2 Adding Arch Linux WorkFlow 2025-02-25 14:46:29 -05:00
Albert
0d8ed71a8a Temporary Disable Workflow 2025-02-25 14:45:08 -05:00
jinzhongjia
c512af1e6c fxi: zig master change 2025-02-23 16:47:35 +08:00
Albert
63284fe2a7 Removing Linux RedHat Build 2025-02-18 09:14:27 -05:00
Albert
f2961585e2 Adding Linux RedHat Build 2025-02-14 17:19:16 -05:00
Albert
fb5c2ab616 Adding webui_interface_get_context
* Note: Wrappers does not need to implement any `webui_interface_xx` APIs if not needed by the wrapper.
2025-02-14 16:45:58 -05:00
Albert
c52ac5fc4a Adding C++ set_context 2025-02-14 16:34:12 -05:00
Albert
3ff8742f3e Adding webui_memcpy
* This can help wrappers like Bun
2025-02-11 17:21:52 -05:00
Albert
27088bd5d2 Adding webui_set_context and webui_get_context
* webui_set_context
* webui_get_context

Inf: https://github.com/webui-dev/webui/issues/551
2025-02-11 11:26:13 -05:00
Albert
8a7ea878b5 webui_set_custom_parameters - Ignore default parameters 2025-02-10 14:35:02 -05:00
Albert
2d3a68ebea webui.js - Adding allowNavigation
More inf: https://github.com/webui-dev/webui/issues/541
2025-02-06 15:04:55 -05:00
Albert
1eb06bb0c7 Fix show_browser
https://github.com/webui-dev/zig-webui/issues/79
2025-02-06 12:22:19 -05:00
Albert
ddc94db8db New Example - ChatGPT HTTPS API in C 2025-01-31 17:00:59 -05:00
Albert
0268c3723b Update date from 2024 to 2025 2025-01-30 15:52:24 -05:00
Albert
7f60505709 Fix internal _webui_external_file_handler 2025-01-28 12:43:23 -05:00
Albert
f412473dca Downgrade Linux Workflows GCC from v14 to v11 (Prefix) 2025-01-27 12:57:29 -05:00
Albert
728cd8370d Downgrade Linux Workflows GCC from v14 to v11 2025-01-27 12:55:13 -05:00
Albert
0a088943d5 Linux Workflows - Disable Test (Temporary) 2025-01-27 12:54:38 -05:00
Albert
cdda40df5f Downgrade Linux Workflows from 24.01 to 22.04 2025-01-27 12:43:01 -05:00
Albert
2adfee2e04 Up Linux Workflows from 20.01 to 22.04 2025-01-27 12:28:35 -05:00
Albert
c05a18a2f4 Update Linux workflows 2025-01-27 12:16:27 -05:00
Albert
9e68b911ae Update Civetweb 2025-01-27 11:56:46 -05:00
Albert
5486cb4e9c Fix strcat warnings 2025-01-27 11:44:24 -05:00
Albert
2e9d65d2bc Fix strncat buffer size 2025-01-27 11:01:11 -05:00
Albert
c9087c35b1 Adding webui_interface_set_response_file_handler 2025-01-24 16:56:25 -05:00
Showns
4dcf4ce07c
Merge pull request #544 from guimaai/main
Fix csv_size size
2025-01-23 09:11:06 -05:00
guimaai
e0b09e3a49 Fix csv_size size 2025-01-19 01:33:33 +08:00
Showns
d7a87ed6f9
Merge pull request #542 from createc-uk/createc/c++_missing_return_values
Add missing returns to c++ interface
2025-01-16 11:45:23 -05:00
Shaun
737ee76cbc Upped CMakeLists.txt CXX version to c++17 for std::string_view 2025-01-16 15:53:56 +00:00
Shaun
b6f70527be Added missing returns and removed some whitespace in c++ interface 2025-01-16 15:52:05 +00:00
Showns
c9abbc9cdb
Merge pull request #538 from JackBoosY/jack/update-cmake
Update CMakeLists
2025-01-07 09:21:37 -05:00
jyu49
d695c5b8fc Remove duplicate define 2025-01-06 13:25:59 +08:00
jyu49
d757120977 Update CMakeLists 2025-01-06 13:23:56 +08:00
Albert
0ff3b1351b Adding Interfaces 2024-12-20 11:31:26 -05:00
Albert
41497e1a52 Fix double all-events in Bind interface 2024-12-20 10:50:39 -05:00
Albert
ef18fdc772 Fix Multi Window Script
Ref: https://github.com/webui-dev/deno-webui/issues/70
2024-12-19 12:41:56 -05:00
Albert
09128cefb0 Update macOS Obj-C Buffer Size 2024-12-04 16:43:58 -05:00
Albert
0f4cf1a4b8 Fix GNU Makefile - CreateProcess failed
process_begin: CreateProcess(NULL, uname, ...) failed.
GNUmakefile:30: pipe: No error
process_begin: CreateProcess(NULL, uname, ...) failed.
GNUmakefile:111: pipe: No error
process_begin: CreateProcess(NULL, uname, ...) failed.
GNUmakefile:144: pipe: No error
2024-11-29 14:41:46 -05:00
Albert
734f00aaac CI - Remove macOS x64 Examples Build 2024-11-22 18:07:05 -05:00
Albert
3c9137eef5 CI - Fix IF Syntax (macOS) 2024-11-22 18:02:58 -05:00
Albert
6511bc56d8 CI - Remove macOS OpenSSL Build 2024-11-22 17:52:02 -05:00
Albert
2a5a449900 CI - Fix IF Syntax (macOS) 2024-11-22 17:40:08 -05:00
Albert
a3ea3619ee CI - Fix IF Syntax (macOS) 2024-11-22 17:36:51 -05:00
Albert
a509155eaf CI - Fix OpenSSL Path (macOS) 2024-11-22 17:34:49 -05:00
Albert
9d2b80d3b3 Fix Clang Buffer Warning 2024-11-22 17:34:16 -05:00
Albert
e67788ad70 CI - Fix x64 OpenSSL (MacOS) 2024-11-22 17:27:14 -05:00
Albert
9814a18e0a Fix Strcat Warning 2024-11-22 17:26:45 -05:00
Albert
7189093a5d CI - Adding x64 OpenSSL for macOS 2024-11-22 17:17:08 -05:00
Albert
7156f6a1e2 CI - Adding ARCH_TARGET (macOS) 2024-11-22 16:43:51 -05:00
Albert
4a67f91554 Adding ARCH_TARGET x64 (macOS) 2024-11-22 16:36:30 -05:00
Albert
e01fb64666 Fix macOS WebView CPU Usage 2024-11-22 15:40:28 -05:00
Albert
984de15efa Fix Linux WebView CPU Usage 2024-11-22 15:38:58 -05:00
Albert
3084ff3e26 Fix Windows WebView CPU Usage 2024-11-22 15:33:05 -05:00
Albert
2a406f5276 Fix C++ GNU Makefiles 2024-11-22 11:51:00 -05:00
Albert
8fc3d1a39a Rename -lole32 (Lowercase) 2024-11-22 11:13:40 -05:00
Albert
89a54eb621 Fix C++ missing Returns 2024-11-22 10:15:59 -05:00
Albert
39628742aa Updating React Example Style 2024-11-22 10:05:20 -05:00
Albert
f59d0463e0 Making Show() waiting for connection + token 2024-11-21 13:15:02 -05:00
Albert
6e7b0dacb2 Adding React example 2024-11-20 16:59:51 -05:00
Albert
be972b50a4 Adding use_cookies comments 2024-11-20 16:19:31 -05:00
Albert
ed77621974 Bridge - Delay disconnection warning 2024-11-20 12:29:59 -05:00
Albert
e8863a06c1 Updating Civetweb 2024-11-19 14:27:56 -05:00
Albert
09cfb561d1 Allow set_custom_parameters to clean old params 2024-11-19 11:15:46 -05:00
Albert
5273ef3925 Fix internal mem alloc (Mem debug print improvement) 2024-11-19 10:34:27 -05:00
Albert
dc82dabf3b Merge branch 'main' of https://github.com/webui-dev/webui 2024-11-19 10:10:59 -05:00
Albert
39095cea86 Fix webui_set_custom_parameters 2024-11-19 09:43:23 -05:00
John
a44283b04d
scm: Print webui logs in debug mode (#527) 2024-11-19 23:30:30 +09:00
John
5a710c29ce
scm: Support dependency debug building (#526) 2024-11-19 23:28:45 +09:00
John
387bebe2c1
Drop Zig 0.11.0 support (#525)
* scm: Update to beta 3 in `build.zig.zon`

* scm: Drop Zig 0.11.0 support

* scm: Make shared library PIC
2024-11-19 22:57:11 +09:00
Albert
72ae4703aa Embedded HTML Div alert when connection is lost 2024-11-18 16:57:10 -05:00
Hassan DRAGA
12dee8bab7 Up to Beta 3 2024-11-15 21:02:26 -05:00
Hassan DRAGA
45257c7f8e Fix wrong ini alloc size 2024-11-15 20:56:20 -05:00
Hassan DRAGA
114ac657e7 Fix other dynamic allocs 2024-11-15 20:42:18 -05:00
Hassan DRAGA
c80f2fa1cd Fix Dynamic Allocation 2024-11-15 20:28:13 -05:00
Albert
8433878d3d Fix memory manager 2024-11-15 17:07:45 -05:00
Albert
5a1e097949 Adding Memory Mutex 2024-11-15 16:28:33 -05:00
Albert
2bef6d9f67 Fix Bridge - Duplicated Click Events 2024-11-15 16:04:47 -05:00
Hassan DRAGA
b122b59444
Merge pull request #519 from AlbertShown/patch-2
Update bridge build Batch
2024-11-11 20:46:21 -05:00
Hassan DRAGA
37cdbfde9d
Merge pull request #520 from AlbertShown/patch-3
Update bridge build Powershell
2024-11-11 20:46:03 -05:00
Showns
6a6385f515
Update bridge build Powershell 2024-11-11 15:13:47 -05:00
Showns
b261ec8c16
Update bridge build Batch 2024-11-11 15:12:20 -05:00
Hassan DRAGA
b803322edc Revert "make sure 4096 bytes not alloc 8192 bytes (#516)"
This reverts commit f161bcaced7fd699a5e6ca56144202227307d248.
2024-11-09 17:08:57 -05:00
Hassan DRAGA
57c0215069 Async Call
webui_set_config(asynchronous_response, true);
2024-11-09 16:29:44 -05:00
Hassan DRAGA
fb6ea0db5b
Merge pull request #505 from MiyamuraMiyako/main
Add user-defined command line parameter.
2024-11-09 13:54:28 -05:00
Hassan DRAGA
65b49d1d09 Fix - Add user-defined command line parameter 2024-11-09 13:50:01 -05:00
Hassan DRAGA
31c0264a04 Update - Add user-defined command line parameter 2024-11-09 13:44:22 -05:00
kbkpbot
f161bcaced
make sure 4096 bytes not alloc 8192 bytes (#516) 2024-11-09 17:30:57 +09:00
kbkpbot
48df019c84
fix linux tcc compile fail (#514) 2024-11-09 17:21:01 +09:00
jimying
d5b25ca1a8
Fix memory error (#508) 2024-10-25 00:05:56 +09:00
AsmX
5fd3f15ac7 Add user-defined command line parameter. 2024-10-19 09:48:34 +08:00
mochalins
15e2d684df scm: Fix Zig build examples from dependency 2024-10-12 13:09:56 +08:00
mochalins
2702d0427b scm: Fix Zig CI to use verbose enum 2024-10-12 12:58:32 +08:00
mochalins
9c7f07bd89 scm: Clean up build.zig, verbose logging levels 2024-10-12 12:58:32 +08:00
mochalins
5545881e4c scm: Limit paths in build.zig.zon
`build.zig.zon`'s paths are meant to specify what is needed when `webui`
is fetched as a dependency from another Zig build system. When being
used as a dependency, files such as tests/examples need not be included.
2024-10-12 12:58:32 +08:00
mochalins
3b0736fb89 fix: Release mode building with Zig 2024-10-11 20:04:46 +08:00
Hassan DRAGA
cf0c54e2bd
Merge pull request #487 from testdrive-profiling-master/main
add setting of minimum window size & default user icon patching. (currently windows only)
2024-10-06 17:00:43 -04:00
Hassan DRAGA
f8e0a20820
Merge pull request #488 from vieiro/feature/file-handler-window
File handlers could receive window number
2024-10-06 12:42:50 -04:00
HyungKi Jeong
7cb1493d0a add setting of minimum window size. (currently windows only)
add default user icon patching. (currently windows only)
actually window size and client size is not match in windows, so I fixed it.
2024-10-02 11:14:26 +09:00
Antonio
ca379f7ba6 Adding @example to the proper function now 2024-10-01 21:00:25 +02:00
Antonio
f8172bdbfa Updated @example for webui_set_file_handler_window 2024-10-01 18:30:10 +02:00
Antonio
3e66411779 File handlers could receive window number 2024-09-30 20:33:18 +02:00
niko
ead99700e9
Merge pull request #473 from ttytm/docs/remove-resolved-workarounds
Remove docs for workarounds for resolved thrid-party conflicts
2024-08-23 08:02:03 +01:00
niko
e8aaba6560
Merge pull request #477 from wansxlysys/main
add php webui wrapper
2024-08-23 08:00:46 +01:00
liming
069cb1f3a5 add php webui 2024-08-20 16:33:18 +08:00
Turiiya
924ea94f25
Update civetweb files to latest commit(3649a5f) (#474) 2024-08-18 14:21:42 +02:00
Turiiya
aec67a1e42 Remove docs for workarounds for resolved thrid-party conflicts
The conflicts were addressed in upstram.
2024-08-16 20:44:33 +02:00
Hassan DRAGA
2e94629304 Fix Bridge TypeScript Navigation Release Mode
* More inf: https://github.com/webui-dev/zig-webui/pull/58#issuecomment-2226417695
2024-07-12 20:38:08 -04:00
Hassan DRAGA
ecccc7e820 Add comment to webui.js 2024-07-12 20:10:25 -04:00
Hassan DRAGA
450197ffbf Removing Issue Template
* Templates stops some people from posting their questions.
2024-07-12 15:33:57 -04:00
Hassan DRAGA
a89a10120a Bridge - Fix unwanted logs 2024-07-12 15:11:37 -04:00
Hassan DRAGA
9c07d87041 Disable Linux WebView in Dynamic Version 2024-07-11 22:09:34 -04:00
Hassan DRAGA
0826a2c5f8 Fix macOS buffer overlap
* https://github.com/webui-dev/webui/issues/453
2024-07-11 20:29:24 -04:00
Hassan DRAGA
47c11dec33 Fix macOS Clang Warnings 2024-07-11 19:53:39 -04:00
Hassan DRAGA
64133f4c30 Fix Clang Warnings 2024-07-11 17:52:54 -04:00
Hassan DRAGA
ef8595ae1c Complete C++ Header 2024-07-11 17:06:37 -04:00
Hassan DRAGA
18f7ce3460 Update C++ Examples 2024-07-11 17:06:23 -04:00
Hassan DRAGA
78a30109de
Merge pull request #452 from webui-dev/WebKit-WebView-Conflict-Fix
Change WebView to Webview (macOS WebKit Conflict)
2024-07-11 15:57:35 -04:00
Hassan DRAGA
17a3a75959 Core - Change WebView to Webview (macOS WebKit Conflict) 2024-07-11 15:28:12 -04:00
Hassan DRAGA
0bfe23ceda Change WebView to Webview (macOS WebKit Conflict) 2024-07-11 13:40:57 -04:00
Hassan DRAGA
fb63521042 Fix serve_a_folder (Now should be Header + Body) 2024-07-11 13:32:31 -04:00
Hassan DRAGA
d213bf487a Debug Log External File Handler (Header + Body) 2024-07-11 13:31:41 -04:00
Hassan DRAGA
8008016de8 Fix HTTP Header Buffer 2024-07-11 13:07:40 -04:00
Hassan DRAGA
1dbce3938e Fix Minor Warnings (is_high_contrast) 2024-07-11 12:09:03 -04:00
Hassan DRAGA
13f1ebe1fe Increase Reload Timeout (500ms to 1500ms) 2024-07-11 10:32:36 -04:00
Hassan DRAGA
c158487417 Fix Invalid Packet Void Response 2024-07-11 10:31:48 -04:00
Hassan DRAGA
708d4a16a3 Unify Comments 2024-07-11 10:10:29 -04:00
Hassan DRAGA
bdd89e22ea Core - Send Bind List After Token 2024-07-10 23:59:31 -04:00
Hassan DRAGA
fc0c867f25 Bridge - Get Bind List After Token
* Get Bind List After Token
* Renaming bridge files
2024-07-10 23:59:08 -04:00
Hassan DRAGA
3f683ea036 Fix GCC Warning 2024-07-09 20:59:24 -04:00
Hassan DRAGA
633a96c54b New Example - virtual_file_system 2024-07-09 19:51:08 -04:00
Hassan DRAGA
1e8642bc6e Supporting header + body in webui_set_file_handler 2024-07-09 19:30:54 -04:00
Hassan DRAGA
b2f505a41c Update C Header - Adding et_mime_type 2024-07-09 19:19:26 -04:00
Hassan DRAGA
af46c34a02 Fix C++ Header 2024-07-09 19:11:51 -04:00
Hassan DRAGA
9350a6aa95
Merge pull request #449 from nater0000/main
Change to support serving files from a c-embed filesystem
2024-07-09 19:01:16 -04:00
Hassan DRAGA
d01c8a8352
Merge pull request #450 from nater0000/get_port
Added a function webui_get_port() to retrieve the server port for the session
2024-07-09 18:54:56 -04:00
Nathan R
9ed9279a98 Added a function webui_get_port() to retrieve the server port for the session 2024-07-09 14:39:38 -07:00
Nathan R
bbcdb9c5e0 Modify _webui_http_handler() to handle a file before a path 2024-07-09 14:29:48 -07:00
Hassan DRAGA
de9508653a
Merge pull request #448 from sensiblearts/main
exposing _webui_get_free_port
2024-07-09 16:02:57 -04:00
David Alm
51d82c82e9 tk 2024-07-09 13:54:59 -04:00
David Alm
0346f0ffdc exposing _webui_get_free_port 2024-07-09 12:06:31 -04:00
Hassan DRAGA
ff97452eb0 Fix Header SameSite and CORS 2024-07-08 23:35:41 -04:00
Hassan DRAGA
50e9e4c2c6 Update example (Bun - Deno - Nodejs) 2024-07-08 19:22:41 -04:00
Hassan DRAGA
0440eeaab1 Adding Bun Runtime 2024-07-08 19:21:51 -04:00
Hassan DRAGA
2a79c2b526 Bridge Minified Version 2024-07-08 17:01:16 -04:00
Hassan DRAGA
faa02ad708 Bridge - Auto-reconnect 2024-07-08 16:37:54 -04:00
jinzhongjia
f888f15dbd fix: zig cross compile from linux to windows error 2024-07-08 09:03:15 +08:00
Hassan DRAGA
4f6fbc58d0 Adding warnings for debug mode 2024-07-07 14:50:47 -04:00
Hassan DRAGA
923f48795f Fix warnings 2024-07-07 14:50:00 -04:00
Hassan DRAGA
e443e318f7 Update readme 2024-07-07 14:20:04 -04:00
Hassan DRAGA
bdf6bac511 Fix Makefile x86 and ARM conflict
Removing ` /MACHINE:X64`
2024-07-06 22:45:06 -04:00
Hassan DRAGA
600e8d36b1 Fix Win32 Folder Check 2024-07-06 21:48:27 -04:00
Hassan DRAGA
59f2d077a6 Supporting Firefox Snap 2024-07-06 21:25:13 -04:00
Hassan DRAGA
13c889a10e Update Text Editor Example 2024-07-06 20:42:33 -04:00
Hassan DRAGA
fb1607b3d3 Fix Linux Exit
* Fix Show update current window
* Fix Linux Exit SEGFAULT
2024-07-06 20:42:03 -04:00
Hassan DRAGA
cdc78e4609 Update default internal icon 2024-07-06 11:32:52 -04:00
Hassan DRAGA
89495f919d
Merge pull request #442 from ttytm/fix/gcc-14-compatibility
Resolve incompatible ptr warning to fix compatibility with gcc-14
2024-07-06 10:18:58 -04:00
Turiiya
3b3e4c4ab0 Resolve incompatible ptr warning to fix compatibility with gcc-14 2024-07-06 13:34:44 +02:00
Turiiya
57a5846746 Test gcc-14 builds in CI 2024-07-06 13:33:11 +02:00
Hassan DRAGA
836e1d115f Fix zig CI build 2024-07-05 18:59:08 -04:00
Hassan DRAGA
56f787cf73 New example - web_app_multi_client 2024-07-05 18:52:56 -04:00
Hassan DRAGA
6ca760163e Adding new API webui_open_url 2024-07-05 18:52:12 -04:00
Hassan DRAGA
f25dd98112 New Event Elements
* Updating webui_config: use_cookies
* Updating webui_event_t: connection_id, cookies
2024-07-05 16:48:32 -04:00
Hassan DRAGA
e8f6a8abdb Cookies System (Heavy Core Changes) 2024-07-05 16:46:51 -04:00
Hassan DRAGA
efe64ba0af Updating example - public_network_access
* Allowing public URL to be updated on refresh
2024-07-03 09:26:22 -04:00
Hassan DRAGA
5f33f70d64 Updating embedded icon 2024-07-02 23:13:34 -04:00
Hassan DRAGA
c4cc398778 Adding webui_interface_get_float_at 2024-07-02 11:31:32 -04:00
Hassan DRAGA
327067cb7d Fix build warnings 2024-07-02 11:30:34 -04:00
Hassan DRAGA
bb887d76f6 New API webui_start_server 2024-07-02 00:45:15 -04:00
Hassan DRAGA
cc103aa37f Header - New APIs
* WebView in browsers list
* multi_client in config
* client_id in webui_event_t
* webui_script_client
* webui_run_client
* webui_close_client
* webui_navigate_client
* webui_show_client
* webui_send_raw_client
2024-07-01 02:37:30 -04:00
Hassan DRAGA
92e98e84e2 New multi-client APIs
* webui_run_client
* webui_close_client
* webui_navigate_client
* webui_show_client
* webui_send_raw_client
2024-07-01 02:34:58 -04:00
Hassan DRAGA
4116ec7581 Bridge - Fix send raw size 2024-07-01 02:31:53 -04:00
Hassan DRAGA
d5a82f98bf Fix All Event Client ID 2024-07-01 00:32:48 -04:00
Hassan DRAGA
da7bb84ca3 MSVC Makefile - Keep .pdb (Debug Symbols) 2024-06-30 23:33:19 -04:00
Hassan DRAGA
4caeb82351 Update Bridge - One-time Token 2024-06-30 23:31:36 -04:00
Hassan DRAGA
88c9996ce6 Multi-Client Design (Heavy Core Change)
* Re-design the core to deal with multi-client requests
* Enhanced Security - Cookie Authorization
* Enhanced Security - One-time Token
* Enhanced Security - Isolated Window Binding IDs
2024-06-30 23:30:38 -04:00
Hassan DRAGA
5a39692fb8
Merge pull request #416 from ttytm/fix/swift
Fix compiling with swift due to incompatible civetweb structname
2024-06-29 11:50:08 -04:00
Hassan DRAGA
b65608dfec Fix monitor_thread (typo) 2024-06-25 22:53:40 -04:00
Hassan DRAGA
9b79e7329c Fix monitor_thread 2024-06-25 22:51:39 -04:00
Hassan DRAGA
b576b2f9de Adding folder_monitor (config)
* Automatically refresh the window when any file in the root folder gets changed.
2024-06-25 22:40:25 -04:00
Hassan DRAGA
88cd5f3774 Adding JS API - isHighContrast 2024-06-25 17:31:14 -04:00
Hassan DRAGA
d0b013ccda Adding webui_browser_exist
More inf: https://github.com/webui-dev/webui/issues/431
2024-06-25 16:20:25 -04:00
Hassan DRAGA
acc77ce5d2 Update high contrast 2024-06-25 14:01:09 -04:00
Hassan DRAGA
8e8abd2273 Up to Beta.2 2024-06-25 13:06:30 -04:00
Hassan DRAGA
b0dd088d56 Examples rename (webui.js) path to (/webui.js)
* All examples should use `/webui.js` instead of `webui.js`, this is because without the slash `/` it won't work if HTML file is located in a sub-folder.
2024-06-25 13:03:44 -04:00
Hassan DRAGA
a93083b2a2 Fix HTTP folder request
Before, a request to `/folder` will return a 404 error, now it will redirect to `/folder/index.html` if exist.
2024-06-25 12:58:37 -04:00
Hassan DRAGA
57f5fca41e Fix MSVC Makefile unrecognized NO_SSL
Fix :
```
cl : Command line warning D9024 : unrecognized source file type 'NO_SSL', object file assumed
cl : Command line warning D9027 : source file 'NO_SSL' ignored
webui.c
```
2024-06-25 11:22:23 -04:00
Hassan DRAGA
6b539c376a
Merge pull request #433 from malisipi/high-contrast-management
High Contrast Management
2024-06-24 21:01:01 -04:00
Mehmet Ali Şipi
900e6f8d61
Add linux support 2024-06-24 21:54:38 +03:00
Mehmet Ali Şipi
5399c1f2fe
Support high contrast detection on Windows. 2024-06-24 16:26:20 +03:00
Mehmet Ali Şipi
3bdacf4c12
Support to disable default high contrast of browser. 2024-06-24 15:27:28 +03:00
Hassan DRAGA
f40d35a60b Faster ARM runners 2024-06-22 20:51:32 -04:00
Hassan DRAGA
c2f410d700 Fix release tag workflow 2024-06-22 20:41:05 -04:00
Hassan DRAGA
81c778cc67 Update C++ Examples 2024-06-21 15:55:38 -04:00
Hassan DRAGA
aca21d905e Adding some C++ APIs 2024-06-21 15:47:08 -04:00
Hassan DRAGA
775455c809 Fix typos in the C header 2024-06-21 15:46:59 -04:00
Hassan DRAGA
d32f0932b4 Simpler Bug Report Template 2024-06-21 12:54:26 -04:00
Hassan DRAGA
e934fe6eee disable aarch64 build test 2024-06-19 16:09:18 -04:00
Hassan DRAGA
0af781390d Temporary disable aarch64 build test 2024-06-19 16:07:22 -04:00
Hassan DRAGA
a0595d992b Fix aarch64 examples test build 2024-06-19 15:50:04 -04:00
Hassan DRAGA
c17dc924fd Fix OpenSSL for aarch64 (ARM64)
* Build OpenSSL from source to use `gcc-aarch64-linux-gnu` to generate `ELF 64-bit ARM`
2024-06-19 15:33:58 -04:00
Hassan DRAGA
734511a1ee Fix compiled aarch64 objects 2024-06-19 15:18:53 -04:00
Hassan DRAGA
104fd4803a Upgrade OpenSSL to v3.3.1 2024-06-19 12:18:29 -04:00
Hassan DRAGA
270c4de9fb Adding Linux ARM.yml 2024-06-19 11:19:39 -04:00
Hassan DRAGA
a628e0780e Remove ARM from Linux.yml 2024-06-19 11:19:05 -04:00
Hassan DRAGA
6e7a7307cc Add Step Linux ARM 2024-06-19 11:18:42 -04:00
Hassan DRAGA
5aa49f6563 Rename Example IDs - call_c_from_js 2024-06-19 08:29:48 -04:00
Hassan DRAGA
56420d67b0 Rename Example IDs - call_js_from_c 2024-06-19 08:22:50 -04:00
Hassan DRAGA
a046af263c Rename Example IDs - custom_web_server 2024-06-18 18:55:54 -04:00
Hassan DRAGA
5657f3f481 Fix NoBrowser Mode
* public_network_access example was broken
2024-06-18 18:50:34 -04:00
Hassan DRAGA
90e774bb13 Rename Example IDs - serve_a_folder 2024-06-18 16:35:13 -04:00
Hassan DRAGA
c598ac996a Fix Deno FFI Warning 2024-06-18 16:33:49 -04:00
Hassan DRAGA
c3ce70c384 Rename Example IDs - text-editor 2024-06-18 12:28:34 -04:00
Hassan DRAGA
2730c9d8e9 Fix ignore all sublevel binaries
* `.exe` and other executables still not-ignored.
* Fix for 218093b958
2024-06-18 12:16:35 -04:00
Hassan DRAGA
1048ffaace
Merge pull request #422 from ttytm/build/tls
Update handling of build variables
2024-06-16 20:07:55 -04:00
Turiiya
8ab54084e4 Utilize CC not being overwritten 2024-06-16 15:50:36 +02:00
Turiiya
6732b84cc1 Only set CC if none is set (don't overwrite env CC)
Allow passing other CCs
2024-06-16 15:50:36 +02:00
Turiiya
56dc82758b Utilize simplified way to pass additional TLS flags 2024-06-16 15:48:04 +02:00
Turiiya
a86217ebf5 Simplify TLS handling 2024-06-16 15:44:24 +02:00
Turiiya
da61335597 Caputure and assert program output in CI 2024-06-16 14:16:32 +02:00
Turiiya
5ed5d688c2 Add cprint test to solidify confirmations in CI test runs 2024-06-16 14:16:32 +02:00
Turiiya
21118a5445 Update labels in issue templates 2024-06-16 14:16:32 +02:00
Turiiya
6cefcb1f3d
Merge pull request #421 from ttytm/ci/add-test 2024-06-16 04:43:51 +02:00
Turiiya
e70f64e2c6 Make labels in issue templates more consistent 2024-06-16 04:33:16 +02:00
Turiiya
b9c4530b42 Include failing test in CI run to make sure tests can fail 2024-06-16 04:21:39 +02:00
Turiiya
63b7cfde5f Add failing_test.c 2024-06-16 04:04:51 +02:00
Turiiya
6d1428ae61 Update test makefile to build test files 2024-06-16 04:04:51 +02:00
Turiiya
5a40b92cd2 Extend test to test passing js args to C 2024-06-16 04:04:51 +02:00
Turiiya
da7be60c78 Run test in CI 2024-06-16 04:04:51 +02:00
Turiiya
218093b958 Update .gitignore to ignore all sublevel build binaries 2024-06-16 01:22:01 +02:00
Turiiya
d4c1415fd8 Add test 2024-06-16 01:22:01 +02:00
Turiiya
9518b9e844
Merge pull request #415 from ttytm/ci/fix-release-cond
Fix condition for release steps when pushing tags
2024-06-15 22:06:05 +02:00
Hassan DRAGA
15d519c13d Fix get_new_window_id
* Details: https://github.com/webui-dev/webui/discussions/418
2024-06-15 14:12:25 -04:00
Turiiya
46b2228ddb Include change in civetweb readme 2024-06-15 04:35:38 +02:00
Turiiya
18f8a1ea23 Fix compiling with swift due to incompatible civetweb structname 2024-06-15 04:29:44 +02:00
Turiiya
23da99b3b7 Fix condition for release steps when pushing tags 2024-06-15 03:42:30 +02:00
Hassan DRAGA
ea5540c833
Merge pull request #413 from ttytm/ci/tls-linux-macos
Include TLS builds in artifact uploads on Linux and macOS
2024-06-13 10:46:49 -04:00
Turiiya
e8e4220b46 Include TLS builds in artifact uploads on Linux and macOS 2024-06-13 16:18:47 +02:00
Hassan DRAGA
0ae019b055
Merge pull request #412 from ttytm/ci/refine
Update workflows
2024-06-13 09:25:48 -04:00
Turiiya
486df2efbd Include tests with different compilers when building examples on Linux 2024-06-13 15:13:20 +02:00
Turiiya
92b7fc7ce1 Display nightly build date in title 2024-06-13 15:08:29 +02:00
Turiiya
2135b091fb Refine workflows, improve maintainability 2024-06-13 15:07:46 +02:00
Hassan DRAGA
02aeef647e
Merge pull request #410 from webui-dev/neroist-patch-1
Add ` --auto-accept-camera-and-microphone-capture` to chromium flags
2024-06-12 18:16:00 -04:00
Jazz
934727b346
Add --auto-accept-camera-and-microphone-capture to chromium flags 2024-06-12 18:07:44 -04:00
Hassan DRAGA
d394a2f92a * Rename webui_set_event_block to webui_set_event_blocking 2024-06-12 18:04:29 -04:00
Turiiya
a860746af7 Fix windows artifact name 2024-06-12 23:51:50 +02:00
Hassan DRAGA
109063e5a4
Merge pull request #409 from ttytm/ci/simplify-artifact-building
Simplify building artifacts in CI
2024-06-12 17:33:51 -04:00
Turiiya
a4f0490d99 Simplify building artifacts on windows 2024-06-12 23:26:13 +02:00
Turiiya
179039bf5a Simplify artifact building on linux and macos 2024-06-12 23:23:51 +02:00
Hassan DRAGA
545c4f5e42
Merge pull request #408 from ttytm/ci/limit-releases
Limit releases to webui origin repo
2024-06-12 17:12:33 -04:00
Turiiya
1416e001e3 Limit releases to webui origin repo 2024-06-12 23:01:04 +02:00
Hassan DRAGA
cc3df4f040 Moving TLS include step 2024-06-12 16:48:33 -04:00
Hassan DRAGA
d4e6d5f3d5 Fix TLS MSVC 2024-06-12 12:03:33 -04:00
Hassan DRAGA
a1e4ef51bb Assert 2024-06-12 11:48:17 -04:00
Hassan DRAGA
6e15893135 Update OpenSSL links 2024-06-12 10:19:29 -04:00
Hassan DRAGA
2257b94a9b Fix Windows TLS CI (OpenSSL Path) 2024-06-11 18:36:38 -04:00
Hassan DRAGA
cb76e0af53 Fix Windows TLS CI (OpenSSL Env) 2024-06-11 18:26:43 -04:00
Hassan DRAGA
bf1a443749 Fix Windows TLS CI (Env) 2024-06-11 18:14:07 -04:00
Hassan DRAGA
7d25559235 Fix Windows TLS CI 2024-06-11 18:07:24 -04:00
Hassan DRAGA
911fe332c6 Windows TLS CI 2024-06-11 18:04:05 -04:00
Hassan DRAGA
93d78bf7c8 Fix Bridge Navigation Event
* If there is no bind all, then keep navigation events as default
* More details (https://github.com/webui-dev/webui/issues/392)
2024-06-11 16:58:33 -04:00
Hassan DRAGA
20c350e3cd Fix Event Block 2024-06-11 15:33:38 -04:00
Hassan DRAGA
4fb247ef25 Adding Event Block APIs
* Adding `webui_set_event_block`
* Adding `ui_event_block` for `webui_set_config`
2024-06-11 15:27:12 -04:00
Hassan DRAGA
f182a12c8f
Merge pull request #404 from ttytm/main
Add CGO check
2024-06-09 18:33:37 -04:00
Turiiya
5be9d902db Add CGO check 2024-06-09 22:29:35 +02:00
Turiiya
4f2ccfb834
Merge pull request #403 from ttytm/fix/dirent-conflict
Fix conflict with including dirent
2024-06-09 20:54:50 +02:00
Turiiya
45c973a387 Fix conflict with including dirent 2024-06-09 20:47:17 +02:00
Hassan DRAGA
561c044924 Update readme about required modifications 2024-06-09 14:12:04 -04:00
Turiiya
c3e2e821c6
Merge pull request #402 from ttytm/civetweb-readme
Add readme about required modifications to civetweb
2024-06-09 16:02:46 +02:00
Turiiya
cdce8348bb Add readme about required modifications to civetweb 2024-06-09 15:34:52 +02:00
Hassan DRAGA
926dd936cb
Merge pull request #401 from webui-dev/zig-nightly
fix: zig nightly becomes `0.14.0`
2024-06-09 00:54:40 -04:00
jinzhongjia
c2bdc44371 update workflows zig version 2024-06-09 11:38:59 +08:00
jinzhongjia
27160810a8 fix: zig nightly becomes 0.14.0 2024-06-09 11:35:29 +08:00
Hassan DRAGA
ab827e0b50
Merge pull request #400 from dgllghr/fix-send-raw-parse
Fix index when parsing data from raw data command
2024-06-08 21:42:09 -04:00
Dan
ee90585a0a
fix index for command data 2024-06-09 01:29:30 +00:00
Dan
eacce2e00c
attempt to fix index in parse 2024-06-09 01:20:37 +00:00
Hassan DRAGA
9039c31e68 Adding isConnected to the JavaScript bridge
* More details https://github.com/webui-dev/webui/issues/392
2024-06-07 18:31:55 -04:00
Hassan DRAGA
ced5d9795e Fix wv crash after browser show
* Because GTK WebView and WKWebView are not thread safe
2024-06-06 22:06:25 -04:00
Jazz
b57a803d5a
Merge pull request #398 from malisipi/main
Remove platform-dependent CSS and use browser titlebar on Firefox
2024-06-06 15:23:05 -04:00
Mehmet Ali Şipi
6c41d8d9b3
Remove platform-dependent CSS and use browser titlebar 2024-06-06 15:28:31 +03:00
Hassan DRAGA
1e6196cb9c
Merge pull request #378 from ttytm/prevent-civetweb-warnings
Prevent warnings from reminder definitions defined in civetweb thridparty
2024-06-05 21:55:55 -04:00
Hassan DRAGA
8b715e61f3 Fix Single Port Redirection
* Fix broken redirection after using single port for HTTP/WS
2024-06-05 21:22:50 -04:00
Hassan DRAGA
a6aee12de0 Single Port for HTTP and WS
* Fix https://github.com/webui-dev/webui/issues/341
2024-06-05 21:16:45 -04:00
Hassan DRAGA
0462ca7fdb Fix WS close warning 2024-06-05 16:41:19 -04:00
Hassan DRAGA
67179f582b Suppress Warnings 2024-06-05 15:40:28 -04:00
Hassan DRAGA
97d7543289
Merge pull request #394 from ttytm/semver-version
Use semver compliant version specification
2024-06-05 14:12:24 -04:00
Hassan DRAGA
30889511ed
Merge pull request #396 from ttytm/fix/macos-dbg-print
Update format specification in macos debug print
2024-06-05 13:58:21 -04:00
Turiiya
3ab322a33f Update format specification in debug print 2024-06-05 19:36:00 +02:00
Turiiya
d8008e3d57 Update version after suggestions 2024-06-05 19:15:29 +02:00
Hassan DRAGA
386a26030c Apply safe std (dyn and static)
* Internal. Using `WEBUI_SPF_DYN` for dynamic buffers, so block size is rounded.
* Internal. Using `WEBUI_SPF_STATIC` for static (stack) buffers, so block size not rounded.
* Fix Clang crash in Linux (https://github.com/webui-dev/webui/issues/388)
2024-06-05 11:56:50 -04:00
Hassan DRAGA
743fe3d011 Add internal safe std (dyn and static) 2024-06-05 11:42:35 -04:00
Hassan DRAGA
6e775b277d Linux - C Adding -LDL lib
* Adding `-ldl`
* Fix https://github.com/webui-dev/webui/issues/380
2024-06-05 09:09:59 -04:00
Hassan DRAGA
62a3b79e4b Linux - C++ Adding -LDL lib
* Adding `-ldl`
2024-06-05 09:09:38 -04:00
Turiiya
cf9764a071 Use semver compliant version specification 2024-06-05 01:21:59 +02:00
Hassan DRAGA
4b8b4faa11 Linux - Faster browser load when GTK WebView is not available
* Fix the internal waiting timeout when GTK WebView is not available
2024-06-04 18:04:39 -04:00
Hassan DRAGA
d46f806038 Win32 - Faster browser load when WebView is not available
* Fix the internal waiting timeout when WebView2 loader DLL is not available
2024-06-04 17:31:53 -04:00
Hassan DRAGA
a29b0753d9 Unfinished - WebView Auto JS Inject 2024-06-04 17:14:56 -04:00
Jazz
ecea17cd3b
Merge pull request #393 from ttytm/issue-templates
Add issue templates
2024-06-04 15:03:05 -04:00
Turiiya
3de023e27e Add issue templates 2024-06-04 19:07:28 +02:00
Jazz
26c9126880
Merge pull request #390 from vindarel/main
README: add Common Lisp wrapper
2024-06-03 14:43:10 -04:00
vindarel
d982e5bd8a README: add Common Lisp wrapper
in alphabetical order after the webui-dev repositories.
2024-06-03 18:30:35 +02:00
Turiiya
33fd4a2f23
Make minor cleanups in build.zig (#389) 2024-06-03 06:38:56 +02:00
Turiiya
62431928d8
Merge pull request #387 from ttytm/update-enums
Use singular form for enum names
2024-06-03 02:10:44 +02:00
Turiiya
bf87e04a6b Rename webui_config to webui_set_config 2024-06-02 18:32:39 +02:00
Turiiya
37bdee47ec Use singular form for enum names 2024-06-02 18:29:15 +02:00
Hassan DRAGA
4466bcfc4e Update webui_get_best_browser description 2024-06-01 16:30:52 -04:00
Hassan DRAGA
c853979fb1 Fix webui_get_best_browser 2024-06-01 16:21:58 -04:00
Hassan DRAGA
bcf08875a7 Removing dup internal calls 2024-06-01 16:19:37 -04:00
Hassan DRAGA
4694a29389 Fix missing some HTTP files 2024-06-01 16:07:18 -04:00
Turiiya
0878256bf8
Merge pull request #382 from ttytm/update-description
Update tagline
2024-06-01 06:06:50 +02:00
Turiiya
ade685fd3f
Merge pull request #384 from ttytm/build/zig-nightly
Add build support with zig `0.13.0-dev`
2024-06-01 06:05:33 +02:00
Turiiya
7a1eb111bb Add build support with zig 0.13.0-dev 2024-06-01 05:40:17 +02:00
Turiiya
0ade1d9b0d Include nightly tests in zig workflow 2024-06-01 05:34:04 +02:00
Turiiya
41428a172c Update tagline 2024-06-01 02:26:16 +02:00
Hassan DRAGA
373c546702
Merge pull request #310 from NicolasBFR/main
Draft: Add CMake build system
2024-05-31 19:01:58 -04:00
Hassan DRAGA
817cc605be
Merge pull request #326 from SpikeHD/expose_browser
Expose `_webui_find_the_best_browser` as `webui_get_best_browser`
2024-05-31 18:24:29 -04:00
Hassan DRAGA
6fe3549684
Merge pull request #351 from GiuseppeCesarano/main
C++ events are now enum instead of const static int
2024-05-31 18:21:44 -04:00
Hassan DRAGA
c8c1b2b757
Merge pull request #361 from xland/patch-1
Add QuickJS Wrapper
2024-05-31 18:20:47 -04:00
Hassan DRAGA
218a129d25
Merge pull request #377 from ttytm/fix/sign-comp2
Update linux webview positon fallback values values to match type declarations
2024-05-31 18:16:49 -04:00
Hassan DRAGA
570a917a7d Fix runtime functionality - Linux 2024-05-31 17:51:30 -04:00
Hassan DRAGA
c537df5abe Fix runtime functionality 2024-05-31 17:46:03 -04:00
Hassan DRAGA
d86a795898 Fix runtime break 2024-05-31 15:37:41 -04:00
Hassan DRAGA
769b011a87 Print used compiler in logs 2024-05-31 10:28:52 -04:00
Turiiya
272b44a5e8 Prevent warnings from reminder definitions defined in civetweb thridparty 2024-05-30 23:52:20 +02:00
Hassan DRAGA
43225227fa Fix warnings - Linux 2024-05-30 16:22:47 -04:00
Hassan DRAGA
2e1717272c Fix warnings - casting 2024-05-30 16:17:15 -04:00
Hassan DRAGA
d3038f6a4a Fix all warnings (MSVC) 2024-05-30 16:02:16 -04:00
Hassan DRAGA
72737eabcf Fix WEBUI_SPF 2024-05-30 15:44:31 -04:00
Hassan DRAGA
36e268c634 Fix warnings - Safe fopen 2024-05-30 15:40:40 -04:00
Hassan DRAGA
d25ae317f4 Fix warnings - Safe strcat 2024-05-30 13:08:21 -04:00
Hassan DRAGA
6ae5046287 Fix warnings - Safe strcpy 2024-05-30 13:02:09 -04:00
Hassan DRAGA
a8709a71b5 Fix webui_set_position args 2024-05-30 12:53:56 -04:00
Hassan DRAGA
34e9b10c68 Fix warnings - Safe strtok 2024-05-30 12:28:58 -04:00
Hassan DRAGA
a1c6802a8a Fix warnings - Safe sprintf 2024-05-30 12:14:52 -04:00
Hassan DRAGA
ce3dce4991
Merge pull request #376 from ttytm/fix/sign-comp
Update variable type decl in internal function `_webui_round_to_memory_block` to resolve sing-comp warning
2024-05-30 09:36:33 -04:00
Turiiya
6d83d7e403 Update linux webview positon fallback values values to match type declaration 2024-05-30 15:09:44 +02:00
Turiiya
cdc1d29879 Update variable type in _webui_round_to_memory_block to resolve sing-comp warning 2024-05-30 06:25:09 +02:00
Hassan DRAGA
4517ba4982 Adding webui_return_float 2024-05-29 19:01:10 -04:00
Hassan DRAGA
065cd3f09c webui_show_wv default center 2024-05-29 18:35:21 -04:00
Turiiya
b4d428d09c
Merge pull request #373 from webui-dev/zig-12+ 2024-05-29 23:59:16 +02:00
Hassan DRAGA
b61b145bb9 Arguments count example 2024-05-29 17:47:13 -04:00
Hassan DRAGA
19b2e32394 Adding webui_get_count 2024-05-29 17:44:03 -04:00
Turiiya
21da984823 CI include Zig 0.12.0 compilation tests in workflow 2024-05-29 23:43:21 +02:00
Turiiya
a7475d16ee Support compiling with zig versions 0.12.0 and above 2024-05-29 23:43:21 +02:00
Hassan DRAGA
19234368ba Float example 2024-05-29 17:39:49 -04:00
Hassan DRAGA
9c9b3dc00a Adding webui_get_float 2024-05-29 17:23:19 -04:00
Hassan DRAGA
8d94cdcae8 Rename WebUI Nightly Development Build 2024-05-29 16:41:31 -04:00
Hassan DRAGA
225f818ce4 Faster window exit 2024-05-29 16:34:42 -04:00
Hassan DRAGA
cd0646274d
Merge pull request #369 from ttytm/build/update-zig-11-build
Refine and fix building with zig
2024-05-29 13:59:31 -04:00
Turiiya
58f764898e Sort params 2024-05-29 19:11:48 +02:00
Turiiya
9ca7c3c8d0 Run CI zig builds verbose 2024-05-29 18:45:58 +02:00
Turiiya
f94fa664b1 Add verbose, build silent by default 2024-05-29 18:45:58 +02:00
Turiiya
3b3ccdfb03 Add setup-xcode action to fix bug with current default XCode CI version 2024-05-29 16:58:10 +02:00
Turiiya
5baf13a068 Run different zig build options in CI 2024-05-29 16:58:10 +02:00
Turiiya
c4485be70e Fix assigning incompatible ptr in webview windows function 2024-05-29 16:58:10 +02:00
Turiiya
6ec0c7bd6c Update linked lib and frameworks 2024-05-29 16:58:10 +02:00
Turiiya
736cd41f9c Update zig example build command in workflow 2024-05-29 16:58:09 +02:00
Turiiya
4f9fc49cfd Add build info print 2024-05-29 16:58:09 +02:00
Turiiya
1f5d52048a Refine zig 0.11 build prep 0.12 build integration 2024-05-29 16:58:09 +02:00
Hassan DRAGA
a54d90607a Fix GC WebView2 2024-05-28 18:04:00 -04:00
Hassan DRAGA
f915af388e Prioritize the server thread 2024-05-28 15:20:28 -04:00
Hassan DRAGA
c31abc32ee Adding webui_config 2024-05-28 14:28:32 -04:00
Turiiya
587963ff6d
Merge pull request #371 from ttytm/ci/examples
Extend test coverage, add CI steps to build C examples with make
2024-05-28 18:43:02 +02:00
Turiiya
b07f5be076 Abstract make command in windows workflow to simplify and reduce redundancy 2024-05-28 18:35:45 +02:00
Turiiya
c82b21033f Extend test coverage, add CI steps to build C examples with make 2024-05-28 18:26:33 +02:00
Hassan DRAGA
ab175b489b Update readme 2024-05-27 16:19:00 -04:00
Hassan DRAGA
ac2230c4c0 Fix GNU Makefile examples 2024-05-27 16:18:53 -04:00
Hassan DRAGA
ba7d032377
Merge pull request #368 from ttytm/build/fix
Fix building v2.5.0-beta1
2024-05-27 10:08:56 -04:00
Turiiya
32d1917ff9 Apply changes to other examples 2024-05-27 14:11:53 +02:00
Turiiya
13e2ccf17d Fix dir in release target 2024-05-27 13:49:10 +02:00
Turiiya
4700c2c5ff Cleanup variables in makefile and move into correct scope 2024-05-27 13:49:06 +02:00
Turiiya
9a057e1b29 Move webkit linker flags to macos conditon 2024-05-27 13:37:44 +02:00
Turiiya
3500b053bb Remove return in function returning void 2024-05-27 13:33:18 +02:00
Hassan DRAGA
b3c8f78271 Fix screenshot 2024-05-26 20:24:26 -04:00
Hassan DRAGA
e921f0dde4 Update screenshot 2024-05-26 20:16:49 -04:00
Hassan DRAGA
7e99ecc7bf WebUI v2.5.0-Beta-1 2024-05-26 20:02:12 -04:00
Hassan DRAGA
ca65af8be6 Adding macOS WKWebView 2024-05-26 20:01:26 -04:00
Hassan DRAGA
c4769e9cc3 Adding WebView2 Third-party
* Headers are taken from Microsoft WebView2 package
2024-05-26 20:00:45 -04:00
Hassan DRAGA
e8d38e4620 Updating Civetweb Third-party 2024-05-26 19:58:48 -04:00
Hassan DRAGA
c832eced7b Updating MSVC Makefile
* Adding `-lOle32` for Windows, needed by WebView2
2024-05-26 19:57:37 -04:00
Hassan DRAGA
c5ddba49fd Update GNU Makefile
* Adding `-lOle32` for Windows, needed by WebView2
* Adding Cocoa and WebKit frameworks, needed by macOS WKWebView
2024-05-26 19:56:47 -04:00
Hassan DRAGA
33ff93f475 Update version to 2.5.0-Beta-1 2024-05-26 19:53:44 -04:00
Hassan DRAGA
d20df6483b Update the date to 2024 2024-05-26 19:52:59 -04:00
Turiiya
9f120e974f Update action versions 2024-05-26 12:06:16 +08:00
Turiiya
bf81ad1b8f Add CI concurency group setting to 2024-05-26 12:06:16 +08:00
Turiiya
cec7b8b756 Add zig workflow 2024-05-26 12:06:16 +08:00
Turiiya
9a1e116701 Make furhter minor cleanup 2024-05-26 11:39:56 +08:00
Turiiya
fb6618ca79 Simplify building examples with Zig 2024-05-26 11:39:56 +08:00
Turiiya
c448c52182 Don't return silently when zig build is not possible 2024-05-26 10:34:47 +08:00
liulun
8ebdb00b43
Add QuickJS Wrapper
Add QuickJS Wrapper
2024-05-24 14:59:23 +08:00
Jazz
a3f3174c73
Merge pull request #357 from halildgn/main
change ubuntu version in linux workflow to support legacy glib
2024-05-09 09:34:49 -04:00
Halil Dogan
7ca2382f99 change ubuntu version in linux workflow to support legacy linux glib 2024-05-09 12:14:38 +02:00
jinzhongjia
deae94bac8 little fix 2024-05-04 08:06:14 +08:00
jinzhongjia
02f05a2936 remove other build.zig 2024-05-04 07:08:54 +08:00
Giuseppe Cesarano
fc10b42318
C++ events are now enum instead of const static int 2024-04-22 09:48:26 +02:00
Jazz
24fefb865b
Merge pull request #349 from webui-dev/with_zig-0.13
[Update]: update to zig nightly 0.13 support
2024-04-21 09:15:01 -04:00
jinzhongjia
4a63099003 update to zig nightly 0.13 support 2024-04-21 13:53:33 +08:00
Jazz
32f876a0ae
Merge pull request #346 from webui-dev/build_api_change
fix api changes of nightly zig `installHeader`
2024-04-14 13:21:39 -04:00
jinzhongjia
faeb246a03 maybe useful to fix 2024-04-14 10:55:22 +08:00
MBK
f37844bd56 fix issue #344 compile error with webui_tls on win32 2024-04-13 17:19:41 +08:00
jinzhongjia
b2ea3861d6 fix api changes of nightly zig 2024-04-10 15:07:57 +08:00
jinzhongjia
a994629f90 fix nightly api change 2024-03-26 07:20:43 +08:00
jinzhongjia
7a690a514d Split build.zig
Split build.zig
 replace strdup with _strdup when compiling with msvc
2024-03-26 07:20:43 +08:00
jinzhongjia
ce4b2e0530 msvc_tmp 2024-03-26 07:20:43 +08:00
fibodevy
a0c42eec91
Merge pull request #342 from thechampagne/main
add missing void
2024-03-25 23:25:56 +01:00
fibodevy
a33a2a2717
Merge pull request #343 from sitd2813/patch-1
Add MIME type for `.mjs`
2024-03-25 23:25:40 +01:00
Gihun Nam | 남기훈
2503683a31
Add MIME type for .mjs 2024-03-24 16:57:05 +09:00
XXIV
6e5ba97b5b
add missing void 2024-03-23 16:05:59 +03:00
Jazz
b1adef299f
Merge pull request #339 from mitchcapper/strict_powershell_buildscript
Use strict mode for powershell bridge script
2024-03-22 17:07:06 -04:00
Mitch Capper
57e6083b7a Use strict mode for powershell bridge script 2024-03-20 16:02:41 -07:00
fibodevy
55e38e89ce
Merge pull request #332 from webui-dev/neroist-patch-1
fix issue #315 - typo in debug logs
2024-02-26 02:58:29 +01:00
Jazz
bb055f8fa8
fix #315 typo in debug logs 2024-02-25 20:36:31 -05:00
SpikeHD
a4168b9b19 feat: expose get_best_browser to C and C++ api 2024-02-13 00:07:53 -08:00
Nicolas Boganski
3fcf8cea97 Add CMake-generated files to gitignore 2024-01-22 16:11:21 +01:00
Nicolas Boganski
328705360a Add CMake build system
New CMakeLists.txt to let users build the libraries using CMake
Build CivetWeb and then use it to build WebUI
2024-01-22 16:08:48 +01:00
iacore
88bd588905
fix: add linux dynamic library "lib" prefix 2024-01-14 16:01:23 +00:00
jinzhongjia
2a5f0c98fb readme: set zig status is complete 2024-01-13 16:19:53 +08:00
Hassan DRAGA
841def61bf
Merge pull request #304 from AlbertShown/patch-1
Adding Delphi wrapper
2024-01-12 09:30:00 -05:00
Showns
1fb87145aa
Adding Delphi wrapper 2024-01-11 17:09:09 -05:00
Hassan DRAGA
350ec1d262
Merge pull request #301 from cwegener/main
fix: too few arguments to webui_set_profile
2024-01-09 10:12:55 -05:00
Christoph Wegener
6d99a29e69
fix: too few arguments to webui_set_profile
When following the C++ hello world tutorial, the first example
immediately fails to compile due to an error in hte C++ header file.

```
In file included from main.cpp:1:
webui.hpp: In member function ‘void webui:🪟:set_proxy(std::string_view) const’:
webui.hpp:202:26: error: too few arguments to function ‘void webui_set_profile(size_t, const char*, const char*)’
  202 |         webui_set_profile(webui_window, proxy_server.data());
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from webui.hpp:21:
webui.h:422:19: note: declared here
  422 | WEBUI_EXPORT void webui_set_profile(size_t window, const char* name, const char* path);
```
2024-01-09 14:50:45 +11:00
Hassan DRAGA
e73b3cfecd New Logo
https://github.com/webui-dev/webui/discussions/292
2024-01-05 12:53:31 -05:00
Hassan DRAGA
f936a8c9e1 Update webui_set_proxy (Incomplete)
* Firefox proxy is not implemented yet
2024-01-05 11:16:24 -05:00
Hassan DRAGA
c56260ff0d
Merge pull request #297 from osljw/main
webui chromium proxy support
2024-01-05 10:43:51 -05:00
Hassan DRAGA
146f40fa51
Merge pull request #298 from webui-dev/zig-build-update
update zig nightly api changes
2024-01-05 10:28:00 -05:00
jinzhongjia
01d025117d update zig nightly api changes 2024-01-05 12:52:32 +08:00
123
5755fead94 remove chromium_options --no-proxy-server, export webui_set_proxy api 2024-01-05 09:16:11 +08:00
Hassan DRAGA
70def025c8 Adding webui.setEventCallback
* Adding new feature to WebUI Bridge to listen for connect/disconnect events in the UI. More events will be added in the future.
*
2024-01-04 16:17:51 -05:00
Ikko Eltociear Ashimine
b3a2677809 Update build.zig
exmaple -> example
2024-01-04 00:44:43 +08:00
jinzhongjia
de98b03522 Simplify build files 2024-01-03 14:31:46 +08:00
jinzhongjia
7c1e2c7588 update 2024-01-02 15:18:52 +08:00
jinzhongjia
8e990d836d Optimizing the build process
Optimizing the build process, we can now use zig to build all C examples
2024-01-02 15:18:52 +08:00
Hassan DRAGA
be5e2940e1
Merge pull request #285 from jinzhongjia/main
[fix]: build error on windows with `build.zig`
2024-01-01 12:40:04 -05:00
jinzhongjia
8e097357e6 [fix]: build error on windows 2024-01-01 22:09:23 +08:00
Hassan DRAGA
c86fc0ce97
Merge pull request #283 from jinzhongjia/build.zig
add `build.zig` to support zig build system
2023-12-31 00:40:53 -05:00
jinzhongjia
d40ce7caeb simplify build.zig 2023-12-31 13:26:57 +08:00
jinzhongjia
c6dc314dbd build.zig 2023-12-31 00:14:30 +08:00
Hassan DRAGA
36b76afeb1
Merge pull request #282 from rtanabe999/fix_typo
Fix typos
2023-12-23 00:14:07 -05:00
rtanabe999
1a495cf2d5
Fix typos 2023-12-22 11:40:42 +09:00
Hassan DRAGA
69066b18f9
Merge pull request #280 from ttytm/ci/fix-macos-artifact-upload
Fix macos artifact upload
2023-12-07 09:29:14 -05:00
Turiiya
288f1e9d39 Fix macos artifact upload 2023-12-07 10:49:35 +01:00
Hassan DRAGA
ac4ea8cd7b Fix webui_set_public 2023-11-29 18:27:44 -05:00
Hassan DRAGA
152ef446c0 Up version to v2.4.2 2023-11-29 18:25:08 -05:00
Hassan DRAGA
29e69a970f Update readme - Features 2023-11-29 18:23:54 -05:00
Hassan DRAGA
663e066f5e New API - webui_set_public
* New API: `webui_set_public()` to let window URL accessible from any public network
2023-11-29 18:23:35 -05:00
Hassan DRAGA
c063f07dcd New example - Public network access 2023-11-29 18:22:35 -05:00
Hassan DRAGA
ff6fdb1361 Make bridge use current host
* To be able to use `webui_set_public()`, the bridge should use the current hostname instead of hardcoded `localhost`.
2023-11-29 18:21:51 -05:00
Hassan DRAGA
02361e0518 Fix wrapper missing all-events call
* Issue (https://github.com/webui-dev/python-webui/issues/12)
2023-11-29 12:08:54 -05:00
Hassan DRAGA
c9801ac2ad
Merge pull request #273 from ttytm/ci/simplify-macos-yml
Simplify macos.yml
2023-11-25 07:38:23 -05:00
Turiiya
4621be9f17 Simplify macos.yml 2023-11-25 11:34:04 +01:00
Hassan DRAGA
c9e17a3eb0
Fix windows.yml 2023-11-22 15:28:13 -05:00
Hassan DRAGA
dd03c9f28d
Updating the Windows workflows - Making files in the archive root 2023-11-22 15:21:28 -05:00
Hassan DRAGA
05b42abd0e
Fix Linux workflows remove x86 (32Bit) 2023-11-21 15:56:17 -05:00
Hassan DRAGA
75574910bd
Fix Linux workflows adding x86 (32Bit) 2023-11-21 15:41:46 -05:00
Hassan DRAGA
031bb879d7
Update Linux workflows adding x86 (32Bit) 2023-11-21 15:36:31 -05:00
Hassan DRAGA
80dd3f0bd4
Update Linux workflows .tar.gz to .zip 2023-11-21 15:16:25 -05:00
Hassan DRAGA
c79f499e5b
Update macOS workflows .tar.gz to .zip 2023-11-21 14:40:38 -05:00
Hassan DRAGA
7c9f404017 Fix bridge
* Last bridge commit break examples after multiple clicks (JS Run)
2023-11-17 17:17:55 -05:00
Hassan DRAGA
a775d1d0c7
Merge pull request #271 from 7flash/7flash/fix-nov17
encoding response in chunks to avoid call stack size limit
2023-11-17 11:02:56 -05:00
Hassan DRAGA
65bafb0f69
Clean PR 2023-11-17 10:50:28 -05:00
Igor Berlenko
88d0aba656 fix encoding callback size limit 2023-11-17 14:47:03 +08:00
Hassan DRAGA
9b745d434c Fix data race in exit-now
* Adding mutex for exit-now
2023-11-16 18:08:18 -05:00
Hassan DRAGA
9d8e6a8c61 Fix data race in win-connected
* Adding mutex for win->connected
2023-11-16 17:59:57 -05:00
Hassan DRAGA
8084a02f87 Up version number to v2.4.1 2023-11-16 16:49:21 -05:00
Hassan DRAGA
b41ab2095b Fix data race in webui_script
* Fix data race in webui_script()
* Adding missing webui_interface_bind()
2023-11-16 16:46:49 -05:00
Hassan DRAGA
44a488025d Fix bridge Maximum call stack size exceeded
Fix https://github.com/webui-dev/webui/issues/270
2023-11-16 16:43:52 -05:00
Hassan DRAGA
4c3932ee00
Merge pull request #264 from ttytm/ci/fix-linux-tag-release
Fix linux tag release
2023-10-29 18:01:57 -04:00
Turiiya
6a862f7f14 Fix linux tag release 2023-10-29 22:39:43 +01:00
Hassan DRAGA
9a5036941d v2.4.0 Release
[Full WebUI v2.4.0 APIs](https://webui.me/docs/2.4.0/#/)
2023-10-29 17:03:25 -04:00
Hassan DRAGA
907f0330a1 Removing Git from GNU-Makefile 2023-10-29 16:40:47 -04:00
Hassan DRAGA
5081b5a333 Update C/C++ headers 2023-10-29 15:51:49 -04:00
Hassan DRAGA
705bf9a5d8 Fix macOS SSL 2023-10-29 15:51:22 -04:00
Hassan DRAGA
451a3e9bd0 Fix readme status 2023-10-29 01:26:32 -04:00
Hassan DRAGA
6a4ac339e6 Fix Linux build 2023-10-29 01:22:48 -04:00
Hassan DRAGA
8adcbeff30 Readme status 2023-10-29 01:20:18 -04:00
Hassan DRAGA
509d9fa976 Adding Odin 2023-10-29 01:17:08 -04:00
Hassan DRAGA
514d09c538 Removing Lint (Code format) 2023-10-29 01:13:59 -04:00
Hassan DRAGA
b907175e0c Manual code format 2023-10-29 01:11:56 -04:00
Hassan DRAGA
855e279daf Removing clang-format 2023-10-29 01:11:31 -04:00
Hassan DRAGA
8a6909fe04 Disable linting CI 2023-10-28 23:13:56 -04:00
Hassan DRAGA
08262f3461 Format code 2023-10-28 19:59:29 -04:00
Hassan DRAGA
f39af55093 C99 to C 2023-10-28 19:51:02 -04:00
Hassan DRAGA
73d6e9f294 custom_web_server Python example 2023-10-28 19:48:19 -04:00
Hassan DRAGA
4c16531a5c Core cleaning 2023-10-28 18:10:12 -04:00
Hassan DRAGA
bac9786d81 New example - Custom Server 2023-10-28 17:55:21 -04:00
Hassan DRAGA
f91ea36fce Fix busy port 2023-10-28 17:47:08 -04:00
Hassan DRAGA
eb50747970 Adding webui_set_port
- New API `webui_set_port(win, port)`
2023-10-28 15:18:55 -04:00
Hassan DRAGA
8363cccc9a Support custom URL
- Now webui_show() can also use a custom URL
2023-10-28 14:37:35 -04:00
Hassan DRAGA
b1d2ae04e4 Cleaning examples 2023-10-28 11:58:28 -04:00
Hassan DRAGA
46c5125e0d Bridge - Backend func as global obj 2023-10-28 11:26:04 -04:00
Hassan DRAGA
87a3a4f4e6 Bridge - Backend functions as global objects
- Making backend functions available under a global object
2023-10-27 17:44:17 -04:00
Hassan DRAGA
30a1e49130 GNU Makefile Adding Musl-GCC
- Adding musl-gcc
- Renaming text-editor to main. It should be the same as other examples
2023-10-27 11:58:26 -04:00
Hassan DRAGA
618c2a7939
Merge pull request #261 from ttytm/chore/fmt
Run formatter
2023-10-27 10:01:31 -04:00
Turiiya
8bf9bf2279 Run formatter 2023-10-27 06:49:59 +02:00
Hassan DRAGA
1866d2573c Format code 2023-10-26 19:08:15 -04:00
Hassan DRAGA
d20d5ccfe4 Check user TLS certificate before use 2023-10-26 19:00:56 -04:00
Hassan DRAGA
d9a4fadefb TLS Readme (GCC) 2023-10-26 19:00:23 -04:00
Hassan DRAGA
b37395d1ac TLS Readme 2023-10-25 20:17:29 -04:00
Hassan DRAGA
c346969eaf MSVC Makefile Update 2023-10-25 20:17:14 -04:00
Hassan DRAGA
6e6bd540e7 GNU Makefile Update 2023-10-25 20:16:57 -04:00
Hassan DRAGA
f96306396e Root TLS & Firefox Linux-Snap 2023-10-25 20:15:15 -04:00
Hassan DRAGA
1e2fa6a7a2 MultiPacket Example 2023-10-24 20:59:32 -04:00
Hassan DRAGA
2a254db6c7 Core MultiPacket 2023-10-24 20:59:20 -04:00
Hassan DRAGA
8d0b43de00 Bridge MultiPakcet 2023-10-24 20:58:59 -04:00
Hassan DRAGA
a59c1fe1db TLS GCC/Clang
- To build lib with TLS: `make WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="~/OpenSSL/include" WEBUI_TLS_LIB="~/OpenSSL/lib"`
- To build examples with TLS: `make WEBUI_USE_TLS=1` (Only Dynamic. No static TLS will be supported)
2023-10-23 17:58:39 -04:00
Hassan DRAGA
4702158384 Format Code 2023-10-22 18:20:37 -04:00
Hassan DRAGA
66c95342bc MSVC Makefile TLS
- To build lib with TLS: `nmake WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="C:\OpenSSL\include" WEBUI_TLS_LIB="C:\OpenSSL\lib"`
- To build examples with TLS: `nmake WEBUI_USE_TLS=1` (Only Dynamic. No static TLS will be supported)
2023-10-21 23:17:25 -04:00
Hassan DRAGA
9fd3dd8d89 Fix TLS links 2023-10-21 22:56:49 -04:00
Hassan DRAGA
270038ee6b Adding TLS to WebUI-Bridge 2023-10-21 22:55:30 -04:00
Hassan DRAGA
7d14be8eb0 Upgrade OpenSSL support from 2.x to 3.1.3 2023-10-21 19:40:38 -04:00
Hassan DRAGA
70e580334a TLS Encryption 2023-10-21 17:16:46 -04:00
Hassan DRAGA
f7428d8d04
Merge pull request #255 from ttytm/ci/update-mac-release-handling
Create mac archive before uploading
2023-10-19 16:38:06 -04:00
Turiiya
cba5d302bc Remove executable bit from dylib 2023-10-13 19:17:28 +02:00
Turiiya
45c685e21c
Merge pull request #253 from ttytm/ci/update-linux-arm64-name 2023-10-13 18:45:05 +02:00
Turiiya
44875e345a Create mac archive before uploading 2023-10-13 18:38:00 +02:00
Turiiya
1d68040d87 Use uniform arm architecture name for release archives 2023-10-13 13:34:24 +02:00
Hassan DRAGA
17981ec20d
Merge pull request #249 from ttytm/fix/macos-ci-build
Fix macOS x64 CI builds
2023-10-11 22:26:30 -04:00
Turiiya
682a8b6975 Fix macOS x64 CI builds 2023-10-12 04:13:13 +02:00
Turiiya
27872465ed
Merge pull request #252 from ttytm/ci/add-pre-commit-config 2023-10-12 01:50:14 +02:00
Turiiya
ca82773fda Add pre-commit config 2023-10-11 22:01:26 +02:00
Turiiya
bd715963f0 Run clang format 2023-10-11 18:33:20 +02:00
Hassan DRAGA
5cc97bedba
Merge pull request #251 from fibodevy/fix_WEBUI_MAX_ARG
`WEBUI_MAX_ARG` fix
2023-10-11 12:24:37 -04:00
fibodevy
e7a344982f
Fix crash when webui.call() is called with more than 17 args
- more than `WEBUI_MAX_ARG+1`
2023-10-11 18:03:50 +02:00
fibodevy
8f80ffe476
WEBUI_MAX_ARG fix 2023-10-11 16:47:34 +02:00
Hassan DRAGA
026617cb18 Adding Shell32.lib to MSVC 2023-10-10 18:05:08 -04:00
Hassan DRAGA
5c5ff75725 Fix WEBUI_MAX_ARG 2023-10-10 18:02:58 -04:00
Hassan DRAGA
99141921ae Regular Tab (Only if AnyBrowser) 2023-10-10 16:33:26 -04:00
Hassan DRAGA
658a6c06e1 Regular Tab
- Now, if WebUI fails to find the browser, it will open the UI in the default web browser as a regular tab. This is better than exit the program and shows nothing.
2023-10-10 15:46:40 -04:00
Hassan DRAGA
42c6e22c49 Unicode Support (Local file name) 2023-10-10 15:18:23 -04:00
Hassan DRAGA
90bfa0f607 Fix macOS Firefox Window Style (workaround) 2023-10-10 13:07:31 -04:00
Turiiya
f60cc6d320
Merge pull request #245 from ttytm/update-makefiles 2023-10-10 03:10:35 +02:00
Turiiya
a0420daec3 Remove trailing whitespaces 2023-10-10 02:36:21 +02:00
Turiiya
77cf950c3b Update make command in readme files 2023-10-10 02:32:19 +02:00
Turiiya
11093c97d4 Update make command in workflows 2023-10-10 02:32:05 +02:00
Turiiya
5518a3e044 Use GNUmakefile and Makefile to simplify MSVC compilation 2023-10-10 02:32:05 +02:00
Turiiya
5e7c407bc0
Merge pull request #244 from ttytm/format 2023-10-09 17:34:17 +02:00
Turiiya
79783e5519 Add prettier to lint workflow 2023-10-08 03:55:05 +02:00
Turiiya
3e8f854a89 Prettify 2023-10-08 03:55:05 +02:00
Turiiya
e74de08e75 Add .prettierrc and .editorconfig 2023-10-08 03:55:05 +02:00
Turiiya
adcf4b8d9d Add lint workflow 2023-10-08 03:48:25 +02:00
Turiiya
50cc7619ba Format C code 2023-10-08 03:48:25 +02:00
Turiiya
f42d01e2f9 Add .clang-format config 2023-10-08 03:48:25 +02:00
Hassan DRAGA
9a78898d62 Fix big-data crash (Civetweb Issue)
- For same reason, data over 97.6Kb (100000 bytes) may have data loss because of Civetweb has an issue. That's make the webui-protocol-header had incorrect data size so it crashes (over flow) if user access the most significant byte. However, WebUI won't crash now. But we should report this to Civetweb.
2023-10-07 15:35:45 -04:00
Hassan DRAGA
61a92b0da1
Merge pull request #241 from clzls/typo-fix
Fix a typo at `webui.c:4511`
2023-10-07 09:20:07 -04:00
Chen (Kina)
d4caaf1593
Update webui.c
Fix a typo at webui.c:4511
2023-10-07 18:14:13 +08:00
Hassan DRAGA
d2c6109533 Fix refresh 403 2023-10-07 00:11:50 -04:00
Hassan DRAGA
c398d35dd0 Adding webui_interface_get_xxx_at
- Adding: webui_interface_get_string_at()
- Adding: webui_interface_get_int_at()
- Adding: webui_interface_get_bool_at()
- Fix crash bug when script result is empty
2023-10-06 20:00:46 -04:00
Hassan DRAGA
058f082cd2 Update e->bind_id for wrappers 2023-10-06 17:44:41 -04:00
Hassan DRAGA
022391380f Update C++ wrapper 2023-10-06 17:25:47 -04:00
Hassan DRAGA
6d5612c24d Fix Double Event
- Removed: webui_interface_get_bind_id()
- Add: webui_event_t -> size_t bind_id

Wrappers that have internal-event-handler may call by mistake the same callback twice when app use all-events. To fix this issue, simply wrappers should replace `webui_interface_get_window_id()` by `e.bind_id`.
2023-10-06 17:25:27 -04:00
Hassan DRAGA
7da0677851 Fix default & custom profile
https://github.com/webui-dev/webui/issues/240
2023-10-06 00:17:05 -04:00
Hassan DRAGA
e8a57331d9 Fix WebSocket keepAlive 2023-10-05 23:44:41 -04:00
Hassan DRAGA
8be79a02eb Fix websocket keepalive timeout 2023-10-05 23:00:58 -04:00
Hassan DRAGA
90dc676e39 Fix GCC printf format warning 2023-10-05 22:50:50 -04:00
Hassan DRAGA
bb1c438e87 Bridge cleaning 2023-10-05 22:08:50 -04:00
Hassan DRAGA
b09c0dca94 Multi Arguments
- New: webui_get_int_at()
- New: webui_get_string_at()
- New: webui_get_bool_at()
- New: webui_get_size_at()
- Change: webui_interface_bind
- Removed: `e->data` becomes `webui_get_xxx_at(e, 0)`
2023-10-05 20:03:12 -04:00
Hassan DRAGA
39f9ab0cd7 Token Secured Requests
- Removed WEBUI_EVENT_MULTI_CONNECTION
- Removed WEBUI_EVENT_UNWANTED_CONNECTION
- Removed webui_set_multi_access()

- Core Added: Token Secured Requests
- Core Added: New Protocol Header
- Core Added: Block WS handshake for non-authorized connections
- Core Added:
2023-10-04 19:22:40 -04:00
Hassan DRAGA
53724d4ef8 Fix multi click sync
- Fix multi click sync. Now the second click won't process until the first one finishes first
2023-10-03 14:35:44 -04:00
Hassan DRAGA
dd6c7ff628 Adding 403 access
- Adding Access Denied (403). Except for local html files.
2023-10-02 22:51:48 -04:00
Hassan DRAGA
e462d7bfed Supporting Firefox Profiles
- Complete Support of Firefox Profiles (.ini)
2023-10-02 18:24:34 -04:00
Hassan DRAGA
a9fa6fad99 Fix non-running
- Fix non-running when no browser is already opened
2023-10-02 11:43:11 -04:00
Hassan DRAGA
e7418ef36a Core re-design - Up to 10ms event speed
- No breaking change
- Re-design the events again to up speed to 10ms
- Fix URL links click
2023-10-01 20:41:52 -04:00
Hassan DRAGA
aade3f2119 Update comments 2023-10-01 13:31:22 -04:00
Hassan DRAGA
edcf4bd5aa
Merge pull request #236 from ttytm/update-functions
Update functions
2023-10-01 10:26:02 -04:00
Turiiya
32cba040b2 Add more webui functions to C++ wrapper 2023-10-01 11:53:33 +02:00
Turiiya
61501ee959 Sort process_id functions in webui.h, update comment 2023-10-01 11:53:29 +02:00
Turiiya
5b784789ad Fix log message for webui_get_parent_process_id 2023-10-01 11:41:13 +02:00
Hassan DRAGA
91c9445912 Fast Events (Internal Core changes)
- Changing the way WS events process for more speed
- Changing the WS events process for less data copy as possible
2023-09-30 23:15:55 -04:00
Hassan DRAGA
4eda2b6670 Clean up example
- Just removing test code.
2023-09-30 16:57:09 -04:00
Hassan DRAGA
24a68d87a6 Update webui_browsers struct
- Adding `NoBrowser = 0,` (The rest is shifted by one)
2023-09-30 16:55:48 -04:00
Hassan DRAGA
62030156e5 Adding webui_delete_all_profiles
- Adding webui_delete_all_profiles()
- Adding webui_delete_profile()
- Adding webui_clean()
- Now. webui_wait() simply means no more windows are running. And app can create and show windows. And of program is now become webui_clean().
- Updating Civetweb (Server close faster now)
2023-09-30 16:26:58 -04:00
Hassan DRAGA
2f694d1a3f Adding webui_clean
- Adding webui_clean() (Firefox not supported yet)
2023-09-29 18:36:57 -04:00
Hassan DRAGA
67620af4cd Improve logs
- Adding event number in `_webui_window_receive()` (logs only)
2023-09-29 14:57:57 -04:00
Turiiya
7c572d8d9f
Merge pull request #234 from ttytm/build/cross-compile-linux
Support more architectures, add linux `aarch64` and `arm` releases
2023-09-29 01:04:55 +02:00
Turiiya
f7cc098d03 Update workflows, add linux aarch64 and arm releases 2023-09-29 01:04:02 +02:00
Turiiya
5cd3f53da7 Update makefiles to support more architectures 2023-09-28 23:19:43 +02:00
fibodevy
a2b807acd9
Merge pull request #232 from fibodevy/fix-printf
Fix enclose `printf()` in `#ifdef WEBUI_LOG`
2023-09-27 22:11:23 +02:00
fibodevy
9ff92268fc
Fix enclose printf() in #ifdef WEBUI_LOG 2023-09-27 22:00:51 +02:00
Hassan DRAGA
6a634cc680 Adding webui_navigate
- Adding webui_navigate()
- Now when using all events webui_bind(MyWindow, "", events), WebUI will block all href requests
- Fix https://github.com/webui-dev/webui/issues/228
2023-09-26 18:59:25 -04:00
Hassan DRAGA
2ca3b793c4 Improving internal exit() 2023-09-25 19:30:25 -04:00
Hassan DRAGA
8fa5c8f7e8
Merge pull request #226 from ttytm/examples/improve-text-editor
Improve text editor example
2023-09-25 18:47:09 -04:00
Giuseppe Cesarano
aa739affba
Updated C++ wrapper 2023-09-25 17:00:08 +02:00
Turiiya
bcf19bdcd4 Add save dialog for saving documents written without opening a file
Set file data after saving such files
2023-09-24 01:39:20 +02:00
Turiiya
0f6981c14d Enable save on unsaved changes instead on file open
Allow to save a documents when not opening a file
2023-09-24 01:39:20 +02:00
Turiiya
31997657ba Refactor text editor example 2023-09-24 00:40:42 +02:00
Turiiya
17e4171508
Fix text editor debug build (#223) 2023-09-23 11:26:54 +02:00
Hassan DRAGA
5e594d5fb9 Update webui_exit() 2023-09-22 22:50:18 -04:00
Hassan DRAGA
5e17a037c1 Fix timer
- Replacing all core timers with `_webui_timer`
2023-09-22 22:25:34 -04:00
Hassan DRAGA
ffccf7491b Updating webui_wait()
- Now `webui_wait()` should exit faster if all windows failed to start
2023-09-22 19:47:12 -04:00
Hassan DRAGA
58f294ea9e Fix Firefox profile 2023-09-22 19:28:40 -04:00
Hassan DRAGA
edc8617e96 Fix Headless Chromium Mode
- Adding `--headless=new`
- Removing forced infinite wait (If user need it he can use webui_set_timeout(0))
2023-09-22 18:02:56 -04:00
Turiiya
e06d972423
Merge pull request #215 from ttytm/example/text-editor-dialog-fix
Fix file dialog in text editor example
2023-09-22 21:02:21 +02:00
Turiiya
5a6df39da9 Update comments 2023-09-22 18:44:46 +02:00
Turiiya
6059a193ab Fix cross-browser compatibility 2023-09-22 18:28:13 +02:00
Turiiya
f00cb22e3b Minor cleanup to example
uniform quote usage
naming closer to conventions
add event only to relevant element
2023-09-22 18:08:12 +02:00
Turiiya
d305b7697a Fix file dialog in text editor example 2023-09-22 17:59:56 +02:00
Turiiya
ee9e8f9e2e
Merge pull request #217 from ttytm/feat/chromium-based-browser
Add `ChromiumBased` to `webui_browsers` enum
2023-09-22 17:39:26 +02:00
fibodevy
a41cf79f0b
Merge pull request #219 from fibodevy/changes
Fix disabling translate feature on Chromium based browsers
2023-09-22 16:53:56 +02:00
Hassan DRAGA
ffb33ba831
Update ChromiumBased
- Moving `ChromiumBased` to `user specified browser` section
- Update the order of `ChromiumBased`
2023-09-22 10:18:02 -04:00
fibodevy
45c5721a36
Fix disabling translate feature on Chromium based browsers 2023-09-22 13:56:15 +02:00
Giuseppe Cesarano
9200ac3b65
Updated C++ wrapper 2023-09-22 10:51:52 +02:00
Turiiya
ea50923288 Add ChromiumBased to webui_browsers enum 2023-09-22 09:05:03 +02:00
Hassan DRAGA
3377718469 Merge branch 'main' of https://github.com/webui-dev/webui 2023-09-21 17:22:18 -04:00
Turiiya
7f296436f9 Make white space usage in text-editor style.css uniform 2023-09-21 23:18:33 +02:00
Turiiya
064af7a39c Fix clicking on icon in text-editor example 2023-09-21 23:18:33 +02:00
Hassan DRAGA
a068a84320 Updating webui_get_url 2023-09-21 16:36:11 -04:00
fibodevy
97857b1cce
Merge pull request #212 from fibodevy/main
Add webui_get_url
2023-09-21 15:41:58 +02:00
Turiiya
6b42874993 Fix macOS architecture for CI debug builds 2023-09-21 13:17:04 +02:00
fibodevy
6f782bc1a8 Adding webui_get_url
- Adding `char* webui_get_url(size_t window);`
2023-09-21 07:21:04 +02:00
Hassan DRAGA
1478c4ffdd Fix macOS build war 2023-09-19 22:30:53 -04:00
Hassan DRAGA
c92ee58a9c Fix webui_get_child_process_id Linux/macOS
- Fix `webui_get_child_process_id()` Linux/macOS
2023-09-19 22:27:16 -04:00
Hassan DRAGA
a616991ca6 Adding webui_set_profile
- Adding `void webui_set_profile(size_t window, const char* name, const char* path)`
- Fix disconnection on 404
- Fix `webui_get_child_process_id()`
- Adding argument `--disable-component-update`
2023-09-19 19:34:09 -04:00
Turiiya
2f22d6c280 Fix clang build in Linux CI 2023-09-15 03:15:20 +02:00
Hassan DRAGA
2160aea9b0 Adding process ID APIs
* Adding `size_t webui_get_child_process_id(size_t window)`
* Adding `size_t webui_get_parent_process_id(size_t window)`
2023-09-14 17:31:29 -04:00
Hassan DRAGA
91dfe07aa6 Fix https://github.com/webui-dev/webui/issues/206
Fix https://github.com/webui-dev/webui/issues/206
2023-09-13 16:12:52 -04:00
Hassan DRAGA
ea63be7921 Adding comments (Not finished) 2 2023-09-13 15:32:14 -04:00
Turiiya
a67ff44829 Revert unintended search and replace changes 2023-09-13 05:47:30 +02:00
Hassan DRAGA
c50a576b90
Adding nightly build link 2023-09-11 23:33:29 -04:00
Turiiya
831ee41cfd Update text editor example docs 2023-09-12 05:30:46 +02:00
Turiiya
a033f1fd6a
Implement nightly releases (#203) 2023-09-12 05:24:33 +02:00
Hassan DRAGA
940dcc50af Adding comments (Not finished) 2023-09-11 18:09:42 -04:00
Hassan DRAGA
0a358cec8a Rename WEBUI_MAX_ARRAY to WEBUI_MAX_IDS 2023-09-11 18:07:20 -04:00
Hassan DRAGA
be9c0bc7cb Reorganize webui.h 2023-09-11 17:18:31 -04:00
Hassan DRAGA
bbc53c0911 Removing webui_core.h 2023-09-11 17:04:08 -04:00
Hassan DRAGA
4fdda5a681 Special Thanks to Turiiya 2023-09-11 16:56:55 -04:00
Turiiya
6d65890789
Merge pull request #201 from ttytm/build/distinct-debug
Improve debug build target usage
2023-09-09 20:35:33 +02:00
Turiiya
72743b1c70 Update workflows 2023-09-09 15:19:25 +02:00
Turiiya
c41533feac Update Makefiles 2023-09-09 15:18:30 +02:00
Turiiya
5804b53906 Update text editor readme 2023-09-07 07:10:05 +02:00
Turiiya
3f8254255d Add macOS build support for text-editor example 2023-09-07 07:10:05 +02:00
Turiiya
24e8f52cee Ignore text-editor executable build output 2023-09-07 07:10:05 +02:00
Turiiya
bcb42c4fbb Add Linux build support for text-editor example 2023-09-07 07:10:05 +02:00
Turiiya
c84e1d08b4 Fix text-editor building, add Makefile 2023-09-07 07:10:05 +02:00
Turiiya
1c4b5182b9 Cleanup Makefile; Use CC= to specify a compiler 2023-09-07 07:10:05 +02:00
Turiiya
740f6ed873 Use a single Makefile to build examples 2023-09-07 07:10:05 +02:00
Turiiya
75ebbf9625
Remove TCC related code (#200) 2023-09-06 14:52:59 +02:00
Turiiya
eaaf49a7d3 Update images with wide widths to fill content 2023-09-05 22:42:08 +02:00
Turiiya
0a1e0ebcf5 Improve directory independency of Makefile Dir variables 2023-09-05 02:08:17 +02:00
Turiiya
67fa22009e Remove remaining @cd "$(_LIB)" && $(MAKE) residues in examples 2023-09-05 02:08:07 +02:00
Hassan DRAGA
a1ba285468 Adding download section
- Adding download section to the readme
2023-09-02 12:17:30 -04:00
Hassan DRAGA
de21160566 Unicode HTML Text Test
- Adding some Unicode text in HTML files (serve_a_foler example)
2023-09-02 11:23:57 -04:00
Hassan DRAGA
697fdae90e Adding HTML UTF8 Tag
- To allow Unicode test in the UI we should make sure `<meta charset="UTF-8">` is added to the HTML head tags
2023-09-02 11:07:58 -04:00
Hassan DRAGA
d281258f72 Socket Bind 127.0.0.1
- Updating Civetweb to bind on `127.0.0.1` instead of `0.0.0.0`
2023-09-01 18:33:18 -04:00
Turiiya
8a5880a060 Inlcude microsoft-edge-beta in webui_browser_exist check 2023-09-01 21:05:48 +02:00
Hassan DRAGA
b952745732 Safer Exit
- Making sure WebUI does no more work when it's time to Exit
2023-08-31 16:25:02 -04:00
Turiiya
ae1bf47772 Fix missing webui in macOS artifacts 2023-08-31 22:06:33 +02:00
Turiiya
0ed682fcf2 Include debug builds in CI 2023-08-31 22:06:33 +02:00
Hassan DRAGA
294883704b Adding webui.js to C++ examples
- Adding `webui.js` to C++ examples
2023-08-30 21:48:56 -04:00
Hassan DRAGA
4fae3e19ed Adding webui.js to C examples
- Adding `webui.js` to C examples
2023-08-30 21:41:59 -04:00
Hassan DRAGA
bdea4fc64c Removing extras sign
- Simply removing extras character `"/webui.js"` to `"webui.js"`
2023-08-30 21:27:15 -04:00
Hassan DRAGA
7f73b90836 Removing Bridge Injection from WebUI
- The best way to fix all HTML-DOM issues and all WebUI-Bridge injection issues at once is simply by manually putting `webui.js` in all HTML content and files
- Starting from this commit, WebUI will no longer inject WebUI-Bridge JavaScript into content. Now, it's user responsabelity to simply adding `<script src="webui.js"></script>`  in all his HTML content and files
2023-08-30 21:25:06 -04:00
Hassan DRAGA
3beb01bc78 Fix one mem leak
- Fix one mem leak
- Fix internal data size type
2023-08-30 20:02:53 -04:00
Hassan DRAGA
d2bf059d4e Change signed long to unsigned
- The JavaScript data size should be unsigned `size_t` instead of `signed long long`
2023-08-30 19:47:31 -04:00
Hassan DRAGA
bc9d074b4d Improve set_size and set_position
- Improve `webui_set_size()` and `webui_set_position()`
- Now size and position works after reload of the UI
- Add window size to Firefox
- Add window position to Firefox (JS-Bridge only, no command line is available for Firefox)
2023-08-29 21:12:45 -04:00
Albert Shown
661ab75dec C++ set_size and set_position
* C++ `set_size()`
* C++ `set_position()`
2023-08-28 18:53:32 -04:00
Albert Shown
e91d6d70bf Adding webui_set_size and webui_set_position
* Adding `webui_set_size()`
* Adding `webui_set_position()`
2023-08-28 18:45:52 -04:00
Turiiya
500f030c35 Prevent bridge build permission error 2023-08-26 22:15:04 +02:00
Turiiya
782fdf461a Remove obsolete build workflow 2023-08-25 20:43:22 +02:00
Turiiya
cde123517d
Optimize CI (#168) 2023-08-25 20:38:49 +02:00
Hassan DRAGA
9574724f99
Merge pull request #179 from ttytm/docs/refine-comments
Refine API comments
2023-08-25 10:35:36 -04:00
Hassan DRAGA
94a3db07b7 Fix https://github.com/webui-dev/webui/issues/180
* Update `CLOSE` command
* Update bridge
2023-08-25 10:24:41 -04:00
Hassan DRAGA
349dbad06b Fix https://github.com/webui-dev/webui/issues/178
* Fix https://github.com/webui-dev/webui/issues/178
* Updating `webui_new_window_id()` to use `default_server_root_path`
2023-08-25 09:49:34 -04:00
Turiiya
ee66862f87 Refine API comments 2023-08-25 07:59:14 +02:00
Hassan DRAGA
e5363cd5c3 Fix Communication Protocol
* Clean Communication Protocol
* Update bridge
* Fix https://github.com/webui-dev/webui/issues/176
2023-08-25 00:33:11 -04:00
Hassan DRAGA
9308d767c9 Quick fix example makefiles
* Removing `@cd "$(LIB)" && $(MAKE) debug`
2023-08-24 23:24:27 -04:00
Hassan DRAGA
74830815cd Adding webui_set_default_root_folder()
* Adding `webui_set_default_root_folder()`
* Fix non initialized webui-core in some scenarios
2023-08-24 21:54:13 -04:00
Hassan DRAGA
eda58b315e Wait longer for WS
* When running the browser for the first time after a fresh PC start, it take time to run and connect. So increasing WS timeout from `1.5s` to `3s`. While browser running timeout stay `30s`.
2023-08-24 18:06:41 -04:00
Hassan DRAGA
cdfed3d7a2 Mem comments
* Just some comments about mem
2023-08-24 17:48:41 -04:00
Hassan DRAGA
ccac4a482e Cleaning
* Removing Visual Studio Solution Examples
* Removing `webui.h` from examples
2023-08-24 17:21:09 -04:00
Turiiya
db5bc6bed3
Update style of interop examples (#175) 2023-08-24 17:53:31 +02:00
Hassan DRAGA
cf794df7d9 Bind any time
* Now `webui_bind()` can update the UI with new IDs at any time
2023-08-23 22:53:06 -04:00
Turiiya
af3e61c5c0
Fix file deletion in Windows GCC CI build (#174) 2023-08-24 03:48:46 +02:00
Turiiya
2194f600f2 Enquote paths in Makefile 2023-08-24 00:05:33 +02:00
Turiiya
b368b819b9 Fix mkdir dist in build step on windows 2023-08-23 21:40:57 +02:00
Hassan DRAGA
0d400644d1 Adding DataSize to wrappers interface
* Adding DataSize to wrappers interface `webui_interface_bind()`
2023-08-22 22:13:58 -04:00
Hassan DRAGA
8c965807e1 Fix Makefile MSVC
* Fix Makefile MSVC. Wont work if `dist` folder not exist
2023-08-22 22:12:59 -04:00
Hassan DRAGA
7f0656c255 Bridge build windows batch script 2023-08-22 21:43:39 -04:00
Jazz
b4a3092480
fix some calls to "webui_decode" 2023-08-22 20:05:03 -04:00
Turiiya
77df52247d Add pascal wrapper, alphabetize 2023-08-23 00:15:15 +02:00
Turiiya
83c802608c Cleanup quotes 2023-08-23 00:15:15 +02:00
Hassan DRAGA
e941e35fc6 Send Raw to backend
* Send Raw to backend
* Updating bridge
* No memory copy when source is UI as is guaranteed to stay alive
2023-08-22 18:11:35 -04:00
Hassan DRAGA
ece2b15456 Update C++ header 2023-08-22 14:36:25 -04:00
Hassan DRAGA
7ac0b7c3d4 Rebuild the bridge after renaming
* Rebuild the bridge after renaming the class object from `WebUiClient` to `WebuiBridge`
2023-08-21 17:59:29 -04:00
Hassan DRAGA
2784a076a1 Update MSVC Makefile
* Move output to `dist` instead of `root`
* Update format
2023-08-21 17:40:48 -04:00
Turiiya
8299c0a9ba
Keep -DMUST_IMPLEMENT_CLOCK_GETTIME for Windows GCC (#167) 2023-08-21 23:26:25 +02:00
Turiiya
7a59da84f0
Update readme (#166)
Co-authored-by: Hassan DRAGA <dragahassan@gmail.com>
2023-08-21 23:06:46 +02:00
Turiiya
a79ebbf7ac Don't try to rebuild library when running example Makefiles 2023-08-21 22:43:30 +02:00
Turiiya
900d9670ca Rename output dir from build to dist 2023-08-21 19:04:43 +02:00
Turiiya
9a8081647d Update Readme 2023-08-21 19:04:43 +02:00
Turiiya
491c9541db Update CI 2023-08-21 19:04:43 +02:00
Turiiya
80ec655901 Remove build directory 2023-08-21 19:04:43 +02:00
Turiiya
3432cf4562 Update examples to use new build output directory 2023-08-21 19:04:43 +02:00
Turiiya
bb9cdb1c88 Add Makefile.nmake for MSVC compilation 2023-08-21 19:04:43 +02:00
Turiiya
6bc8133232 Add Makefile in project root 2023-08-21 19:04:43 +02:00
Turiiya
2bc90bd9cc Fix CI cache restore for Windows 2023-08-21 18:32:18 +02:00
Hassan DRAGA
a5810e63d8 Rename class Client to Bridge 2023-08-21 09:23:29 -04:00
Hassan DRAGA
1a71813a2b Update bridge build readme 2023-08-20 22:03:09 -04:00
Hassan DRAGA
549f901a9b Update PowerShell bridge build
* Update PowerShell bridge build to detect Python and NPM if installed
* Auto install ESBuild
2023-08-20 21:52:12 -04:00
Hassan DRAGA
4768018655 Fix webui_show_browser() missing mutex
* Fix `webui_show_browser()` missing flag, this was causing the mutex to never unlock in `wait()`
2023-08-20 21:17:29 -04:00
Turiiya
7839a42cba Update CI to use build scripts 2023-08-21 03:11:27 +02:00
Turiiya
4088230ebc Add bridge build scripts 2023-08-21 03:11:27 +02:00
Hassan DRAGA
68a5d48e87 Mutex Conditional
* Improve `webui_wait()` by using mutex conditional signal instead of `sleep()` as suggested by @GiuseppeCesarano
2023-08-20 01:17:53 -04:00
Hassan DRAGA
78da533a3a Adding Mutex
* Adding Mutex in server threads
* Adding Mutex in WS Send threads
* Adding Mutex in WS Receive threads
2023-08-19 23:25:41 -04:00
Hassan DRAGA
6a762b161f Update SVG
* Update SVG (Make lib more smaller)
* Increase max dynamic mem from 46kb to 64mb to serve large JS script when is needed
2023-08-19 22:20:40 -04:00
Hassan DRAGA
3133bcb92a Update webui_fn to webui.call
* Update all old js APIs `webui_fn()` to `webui.call()`
2023-08-19 17:54:52 -04:00
Hassan DRAGA
52885648d2 Up to v2.4.0
* Up all to v2.4.0
2023-08-19 17:49:08 -04:00
Hassan DRAGA
28274c53e8 New API webui_set_hide
* Adding `webui_set_hide()` to run the window in hidden mode
2023-08-18 18:16:35 -04:00
Hassan DRAGA
3fe765cad3 Fix Workflows macOS
* macOS build use old Python instead of Python 3
2023-08-18 16:20:19 -04:00
Hassan DRAGA
ba84f249b5 New API webui_send_raw
* Adding `webui_send_raw()` to be able to send raw binary data to UI
* Soon I will add UI to Backend
2023-08-18 16:16:07 -04:00
Hassan DRAGA
ecff6fdf0f Update Workflows 2023-08-18 16:08:40 -04:00
Hassan DRAGA
672a7db67b Removing bridge build
* Removing bridge build from build script to make webui can be build by a simple C99 compiler
* Bridge development is only in `webui/bridge` folder
2023-08-18 15:52:40 -04:00
Hassan DRAGA
096b0cf836 WebUI Bridge
* Creation of the webui bridge folder
* Keeping the possibility of compiling webui by a simple C99 compiler only
* Replacing `xxd` by a simple python script
* Adding the readme
* From now, we will use the TypeScript version, Many thanks to @JOTSR
2023-08-18 15:50:31 -04:00
Hassan DRAGA
e569039b0d Removing Client Folder
* Removing Client Folder, the webui-bridge development should be in a different root folder than the webui-core
2023-08-18 15:46:29 -04:00
Hassan DRAGA
5b0333dbba Cleaning binaries
* Removing all compiled objects
2023-08-18 15:42:48 -04:00
Albert Shown
eab5f1a4e3
Merge pull request #156 from 7flash/main-1
allow faster rendering
2023-08-10 12:55:07 -04:00
JOTSR
1bf8e669a1
Merge pull request #152 from ttytm/ci/add-release-step
ci: add release step
2023-08-10 12:16:54 +02:00
Igor Berlenko
acceaca7db
Update webui.c 2023-08-10 10:34:48 +08:00
Albert Shown
0723ad46ac
Merge pull request #153 from ttytm/build/remove-build-output
build: remove macos example binaries
2023-08-09 17:57:24 -04:00
Turiiya
8fd74a902b chore: add example binary outputs to .gitignore 2023-08-06 22:35:48 +02:00
Turiiya
8f68da6dd8 build: remove macos example binaries 2023-08-06 22:34:55 +02:00
Turiiya
c455048a24 specify bit version like webui does in rest of code 2023-08-06 21:42:09 +02:00
Turiiya
49a26c7faa ci: add release steps for tags 2023-08-04 15:01:11 +02:00
Turiiya
6a85c9dfac ci: update artifact names 2023-08-04 14:54:35 +02:00
Julien Oculi
b68ab52409 refactor: improve client type export 2023-08-01 15:52:10 +02:00
Julien Oculi
b883ca8aea fix: 🏷️ remove unecessary generic export 2023-08-01 15:08:45 +02:00
Julien Oculi
095a9e85e1 refactor: change client import extension
Use *.ts style import to allow remote type references.
2023-08-01 15:04:22 +02:00
Turiiya
edf5eeae65 docs: fix typo 2023-07-24 23:10:50 +02:00
Turiiya
b5b528d03e ci: limit build action to relevant changes
Don't run build if only markdown files are modified
2023-07-24 23:06:09 +02:00
Turiiya
6d81f79230
Merge pull request #148 from tobealive/docs/cleanup 2023-07-24 21:05:44 +02:00
Turiiya
87cdf9acac docs: center align header section and images 2023-07-24 20:59:27 +02:00
Turiiya
c4925dd4b8 docs: update badge labels 2023-07-24 20:59:27 +02:00
Turiiya
4818e6018c docs: use github hosted assets for README.md 2023-07-24 17:44:50 +02:00
Turiiya
4d76051471
Merge pull request #144 from tobealive/chore/remove-build-outputs 2023-07-24 17:44:24 +02:00
Turiiya
7eec4ac7c2 chore: update .gitignore to ignore build outputs 2023-07-22 15:15:50 +02:00
Turiiya
7ebcc72dc3 build: update build scripts to create distributable directories 2023-07-22 15:15:50 +02:00
Turiiya
3d2fcc4363 build: remove build outputs from repository source 2023-07-22 15:15:50 +02:00
Turiiya
7ebf1f3299
ci: rework build workflow, deploy artifacts (#143) 2023-07-22 01:45:47 +02:00
Julien Oculi
10e11da5e2 build: 🐛 fix typo in macos local build script 2023-07-20 14:01:09 +02:00
Julien Oculi
639571c4d1 refactor: support 4MB string as discussed in #128 2023-07-20 11:40:34 +02:00
Julien Oculi
b63ddfa185 feat: support async/await for webui_script 2023-07-20 11:36:18 +02:00
Albert Shown
54075bf1ec
Correct Original Creator Name (LICENSE)
@hassandraga is the original creator of WebUI.
2023-07-17 16:36:45 -04:00
Julien Oculi
673c3278b9 fix: 🐛 support doctype directive for html string 2023-07-16 19:50:30 +02:00
Julien Oculi
e4f052140b docs: ✏️ fix doc typo 2023-07-15 19:17:06 +02:00
Julien Oculi
006e28b97d ci: 👷 fix esbuild command disable tree shaking 2023-07-15 19:16:31 +02:00
Albert Shown
979b0b5877
Merge pull request #132 from JOTSR/refactor/improve-js-bridge
refactor, fix and add feat to js bridge
2023-07-13 16:23:11 -04:00
Albert Shown
af06ebe165
Merge pull request #133 from petabyt/refactor-args
Refactor hardcoded browser CLI arguments
2023-07-13 16:06:59 -04:00
Albert Shown
ae96c7299c
Fix default switch case _webui_get_browser_args 2023-07-13 16:04:59 -04:00
Albert Shown
711dc0996d
Update _webui_get_browser_args
* Adding logs
* Return total bytes written
* Adding default to the switch case
2023-07-13 15:40:16 -04:00
Daniel C
e025a179cf Refactor hardcoded browser CLI arguments
- added _webui_get_browser_args
- Currently, the arguments for all chromium-based browsers are the same, and are hardcoded
into each start function. This adds a function that autofills the CLI arguments.
```
static int _webui_get_browser_args(_webui_window_t* win, size_t browser, char *buffer, size_t max);
```
The browser type is passed through in browser - sometimes win->current_browser is set as DefaultBrowser,
and the start function is trying all CLI arguments to see which one runs.
2023-07-12 19:57:07 -04:00
Julien Oculi
068d99fa04 build: 🐛 fix xxd local build script
Refactor xxd executing command to keep the same output variables names as in github action build script.
2023-07-12 02:38:48 +02:00
Julien Oculi
21fdee9eba ci: 👷 update gh action to transpile webui.ts 2023-07-12 02:03:35 +02:00
Julien Oculi
4919613bee build: 🐛 patch windows local build script 2023-07-12 02:01:00 +02:00
Julien Oculi
d169029523 fix: 🔒 replace dangerous eval by Function class 2023-07-12 01:54:27 +02:00
Julien Oculi
b38c9eb532 build: update local build script to include esbuild process 2023-07-12 01:21:23 +02:00
Julien Oculi
5ac34890e8 Merge branch 'chore/include-js-xxd' into refactor/improve-js-bridge 2023-07-12 01:12:00 +02:00
Julien Oculi
8026cf8886 build: 🐛 fix local xxd build command
Use the same path as in github action to keep the same variables names.
2023-07-12 01:11:18 +02:00
Julien Oculi
55b69ba46c fix: 🐛 skip payload JSON.stringify for strings 2023-07-12 01:06:40 +02:00
Julien Oculi
93b4f23a7b fix: 🐛 wait for dom to load before bindings 2023-07-12 01:02:50 +02:00
Julien Oculi
5572dc7a1c refactor: ♻️ rewrite bridge genration to fit recent changes 2023-07-12 00:39:13 +02:00
Julien Oculi
3bf700e139 fix: ✏️ reference error "webui" instead of "this" 2023-07-12 00:17:44 +02:00
Julien Oculi
62b953d31f fix: 🔒 prevent user to reinstanciate WebUiClient 2023-07-12 00:01:28 +02:00
Julien Oculi
d26c89e175 build: 👷 force 'use-strict' directive for transpilled js 2023-07-11 23:35:23 +02:00
Julien Oculi
378bd3cfba ci: 👷 add js output files to .gitignore 2023-07-11 23:21:08 +02:00
Julien Oculi
3890c41bd4 fix: 🐛 promise resolve instead of reject when conditions are not fulfilled 2023-07-11 23:19:53 +02:00
Julien Oculi
f7007ef71c feat: support JSON value for bindings payload and response 2023-07-11 23:12:22 +02:00
Julien Oculi
455e7333ff fix: 🐛 type error as checking method instead of private attribute 2023-07-11 23:08:09 +02:00
Julien Oculi
0e83205383 fix: 🐛 update json handling for string 2023-07-11 22:50:39 +02:00
Albert Shown
4c9b4fe00f
Merge pull request #131 from JOTSR/chore/include-js-xxd
refactor: split js bridge source code from lib source code
2023-07-11 16:14:57 -04:00
Julien Oculi
87e8742544 refactor!: ♻️ rename API methods
BREAKING CHANGE: Rename API mathods for better expressivity.
2023-07-11 22:00:43 +02:00
Julien Oculi
8b467a464c feat: add json support for webui decode/encode 2023-07-11 21:24:27 +02:00
Julien Oculi
2f527e717e fix: 🐛 replace event listeners to handle html injection
Use addRefreshableEventListner instead of directly binding event listeners to automatically attanch listener if html code is injected client side by the user.
2023-07-11 18:38:56 +02:00
Julien Oculi
3f4119d267 feat: support link handling for not supported Navigation API browsers 2023-07-11 18:28:35 +02:00
Julien Oculi
99dea3f9ac refactor: ♻️ simplify contextmenu listener 2023-07-11 00:56:58 +02:00
Julien Oculi
a9535a1d7e docs: 📝 fix webui.fn examples 2023-07-11 00:47:00 +02:00
Julien Oculi
3e20e0dc3a revert: pass link argument as #close() declaration is fixed 2023-07-11 00:11:12 +02:00
Julien Oculi
00db084421 refactor: ⚰️ delete unecessary types definition file 2023-07-11 00:04:46 +02:00
Julien Oculi
eda195f668 feat: 🧑‍💻 export webui instance for type inference and project integration 2023-07-11 00:02:09 +02:00
Julien Oculi
be02f83e31 refactor: ♻️ move injected variables declaration 2023-07-10 23:59:36 +02:00
Julien Oculi
f1af7bb9ce docs: 📝 add JSDoc and better types for API exposed methods 2023-07-10 23:58:10 +02:00
Julien Oculi
dbc27e49e0 fix: 🐛 type error and wrond default value 2023-07-10 23:52:37 +02:00
Julien Oculi
892229f0a1 refactor: ♻️ rewrite start private method
Reduce code nesting. Remove deduplicated code. Improve readability. Use template literals instead of string concatenation. Use Uint8Array.of instead of pushing manually data into. Simplify code.
2023-07-10 23:49:52 +02:00
Julien Oculi
a08f46481a refactor: ♻️ simplify and refactor sendClick 2023-07-10 22:27:56 +02:00
Julien Oculi
9d87505004 refactor: ♻️ rewrite and simplify sendEventNavigation
use Uint8Array.of to construct buffer instead of pushing datas through a loop
2023-07-10 22:14:27 +02:00
Julien Oculi
c528255458 refactor: ♻️ rewrite and simplify fnPromise
Construct Uint8Array with "of" instead of push data into it. Use template string. Remove temp constants.
2023-07-10 19:37:31 +02:00
Julien Oculi
75859ff859 refactor: ♻️ rewrite and simplify isExternalLink 2023-07-10 18:12:40 +02:00
Julien Oculi
964910d4af refactor: ⚰️ remove empty event listener 2023-07-10 18:02:15 +02:00
Julien Oculi
8849b2cdaf refactor: ♻️ move webui instance related code to contructor
Keep internal attributes and methods private
2023-07-10 18:01:22 +02:00
Julien Oculi
84ea9b8b42 style: 🎨 format code 2023-07-10 17:54:13 +02:00
Julien Oculi
390a9dc168 fix: 🐛 add missing declarations 2023-07-10 17:53:38 +02:00
Julien Oculi
07e786f4b1 fix: 🏷️ types errors and definitions 2023-07-10 17:49:14 +02:00
Julien Oculi
f0655307d2 fix: 🗑️ remove deprecated code 2023-07-10 17:31:19 +02:00
Julien Oculi
507f3ebd60 style: 🎨 fomart code following standard JS 2023-07-10 17:26:31 +02:00
Julien Oculi
046ff37a05 fix: 🐛 log if navigation API missing
Navigation API is experimental and not in firefox, safari of opera, need to polyfill
2023-07-10 17:23:35 +02:00
Julien Oculi
caf9e16de0 refactor: ♻️ prefers globalThis cross runtime global object instead of window 2023-07-10 17:17:29 +02:00
Julien Oculi
7912046d8b refactor: ♻️ expose webui globally 2023-07-10 17:15:52 +02:00
Julien Oculi
904855eec8 fix: 🐛 Text(En/De)coder constructor don't take arguments 2023-07-10 16:44:41 +02:00
Julien Oculi
6117505650 refactor: ♻️ replace snake_case by camelCase 2023-07-10 16:42:00 +02:00
Julien Oculi
f8175ab7a3 refactor: 🔒 improve type security and performance by using strict equality 2023-07-10 16:39:49 +02:00
Julien Oculi
eaad13d0d5 refactor: ✏️ replace deprecated var by const or let 2023-07-10 16:37:09 +02:00
Julien Oculi
956a9ff339 refactor: ♻️ switch to class model and use typescript 2023-07-10 16:31:43 +02:00
Julien Oculi
45d922ff8b build: 🐛 fix gh action build process 2023-07-08 00:52:32 +02:00
Julien Oculi
81857eb25f build: 🐛 fix action due to xxd output not in include 2023-07-07 00:33:44 +02:00
Julien Oculi
32d0dbdd0e refactor: revert declaration move 2023-07-07 00:15:43 +02:00
Julien Oculi
17a951a9e8 build: 🐛 move webui_javascript_bridge declaration to fix gh action build process 2023-07-07 00:09:48 +02:00
Julien Oculi
969c388006 build: 🐛 update build run to fix location error 2023-07-06 23:59:02 +02:00
Julien Oculi
4099952634 docs: 📝 add JsDoc and examples to type definition 2023-07-06 23:29:14 +02:00
Albert Shown
f71a63f2b4
Merge pull request #129 from JOTSR/main
fix: html error pages displayed as plain text
2023-07-06 17:16:27 -04:00
Julien Oculi
b78d0abb97 feat: add type definition to js API
Improve discoverability and integration within a project.
2023-07-06 23:13:03 +02:00
Julien Oculi
c13a9e88e3 build: 👷 update github actions to execute xxd
Use xxd to build js file into C-String. Todo, add a script to simplify action and allow multiple text file to be embedded
2023-07-06 22:58:59 +02:00
Julien Oculi
8c4cc1c429 build: 👷 update build script to execute xxd 2023-07-06 22:55:02 +02:00
Julien Oculi
43b9f103e3 build: 👷 untrack xxd .c files output 2023-07-06 22:54:21 +02:00
Julien Oculi
1687d5b759 fix: ✏️ remove copy artifact 2023-07-06 22:38:57 +02:00
Julien Oculi
72b37e39c7 fix: 🐛 apply merge update to js file 2023-07-06 22:31:20 +02:00
Julien Oculi
f79bb3458a Merge branch 'fix/js-webui-undefined' into chore/include-js-xxd 2023-07-06 22:28:17 +02:00
Julien Oculi
4f2cab41d4 fix: update old malloc size 2023-07-06 22:19:40 +02:00
Julien Oculi
5cc88c3c3c fix: 🐛 webui js API is undefined
Change html structure order to force js bridge to execute before any user content. Fix js possibly undefined listener that can crash the app if bridge is loaded earlier.
2023-07-06 22:06:55 +02:00
Julien Oculi
0ff4101c9b refactor: ♻️ split webui source code and js bridge
Move js bridge outiside of webui.c source code to improve dev experience and simplify editing. It also allow to write types def for client. Use xxd to inject bridge into source code.
2023-07-06 19:18:04 +02:00
Julien Oculi
4877d1e4da fix: ✏️ update deprecated js mime type 2023-07-06 12:55:52 +02:00
Julien Oculi
28c49dd4cc fix: 🐛 html error page served with wrong mime-type
Civetweb only allow serving error page as text/plain. Added a new webui internal function to serve text/html error pages.
2023-07-06 12:29:49 +02:00
Albert Shown
0b55abff5a Finished webui_set_file_handler API
* Finishing the `webui_set_file_handler()` feature. Thanks to @petabyt
* Removing `free()` and replace it by the WebUI version
* Minor core changes to make `webui_set_file_handler()` working
* Update serve a folder example to show how to use `webui_set_file_handler()`

## New Public API:
* `void webui_set_file_handler(size_t window, const void* (*handler)(const char* filename, int* length))`
* `void* webui_malloc(size_t size)`
2023-06-26 12:11:03 -04:00
Albert Shown
bd2f83516e
Merge pull request #126 from petabyt/main
Add webui_set_file_handler
2023-06-26 09:11:40 -04:00
Daniel C
20f828a47f Add webui_set_file_handler
Allows a handler to be given to the file server to return embedded content, as well as allocated content
2023-06-24 16:03:19 -04:00
Albert Shown
89feefb41c
Merge pull request #123 from justinmchase/feature/tar-gz
Rename output to `*.tar.gz`
2023-06-20 11:00:08 -04:00
Justin Chase
c57a19f204 rename output to tar.gz 2023-06-19 15:12:58 +00:00
Albert Shown
20276882dd
Merge pull request #122 from sanderdatema/patch-1
MacOS needs forward slashes
2023-06-19 10:58:53 -04:00
Sander Datema
6d700fce2b
MacOS needs forward slashes 2023-06-19 07:53:39 +02:00
Albert Shown
c16647fc6e
Merge pull request #121 from DougAnderson444/patch-1
Update README.md
2023-06-14 13:08:59 -04:00
Doug A
fd0be388d7
Update README.md
replace with `webui-dev`
2023-06-14 11:17:56 -03:00
Jazz
c06f225904
Update README.md 2023-05-27 21:25:39 -04:00
Hassan DRAGA
78ca30a585 Adding webui_set_root_folder (macOS)
* macOS build of (d786f6db2a)
2023-05-27 20:51:34 -04:00
Hassan DRAGA
36436d7ef7 Adding webui_set_root_folder (Linux)
* Linux build of (d786f6db2a)
2023-05-27 20:38:12 -04:00
Hassan DRAGA
d786f6db2a Adding webui_set_root_folder
* Adding New API `bool _webui_set_root_folder(_webui_window_t* win, const char* path)`
2023-05-27 20:30:31 -04:00
Hassan DRAGA
234d0d40ba
Merge pull request #113 from GiuseppeCesarano/main
C++ header reorganization completed.
2023-05-27 19:40:23 -04:00
Giuseppe Cesarano
3cf9191509
C++ header reorganization completed.
* Event struct is now a class with it's methods
* All examples updated to use the new API
2023-05-27 22:33:36 +02:00
Albert Shown
e2931ac8fa
Merge pull request #111 from demetera/vivaldi-arch-fix-snapshot
Vivaldi-snapshot condition for Arch
2023-05-26 14:23:10 -04:00
Demetera
1d149165b2 added vivaldi-snapshot condition 2023-05-26 19:20:23 +02:00
Albert Shown
d0477a1f1e
Merge pull request #108 from GiuseppeCesarano/main
Fix C++ examples
2023-05-25 16:08:00 -04:00
Giuseppe Cesarano
9a683acdef
Fix C++ examples 2023-05-25 21:45:42 +02:00
Hassan DRAGA
fa0918e862 Update C++ examples (Broken) 2023-05-24 19:57:34 -04:00
Hassan DRAGA
8d3924833c Minor coding style update 2023-05-24 19:48:28 -04:00
Hassan DRAGA
026714bbc8
Merge pull request #106 from GiuseppeCesarano/main
C++ header restructured.
2023-05-24 19:26:35 -04:00
Hassan DRAGA
85db018779
Merge pull request #107 from demetera/fix-vivaldi-arch
vivaldi fix for Arch
2023-05-24 19:12:45 -04:00
Giuseppe Cesarano
5564d32c1d
Removed const window& in event 2023-05-25 00:46:33 +02:00
Giuseppe Cesarano
010c91bcc6
C++ examples updated. 2023-05-25 00:27:29 +02:00
Demetera
2891a5b5bf vivaldi fix for Arch 2023-05-24 20:38:17 +02:00
Giuseppe Cesarano
be7132aa01
C++ header restructured. 2023-05-24 13:27:22 +02:00
Hassan DRAGA
25f66ae8fc Update makefile to C++17
* Update makefile from C++11 to C++17
2023-05-23 22:49:49 -04:00
Hassan DRAGA
0213b80adb
Merge pull request #105 from GiuseppeCesarano/main
Adherence to noninvasive C++ best practices
2023-05-23 22:45:18 -04:00
Giuseppe Cesarano
f18bf530af
Adherence to noninvasive C++ best practices
* nullptr instead of NULL
* const-ed member function where possible
* Removed empty window destructor
* Using member initializer in constructor
* Using std::string_view instead of const std::string&
* Using inline on free functions
2023-05-24 00:06:37 +02:00
Hassan DRAGA
cdf67b17ac C++ Improvement
* Set C++11 as minimal standard
* Fix C++ Makefile in macOS
* Update the C++ WebUI header to use references (https://github.com/webui-dev/webui/issues/103)
* Update `webui_return_string()` argument from `char*` to `const char*`
2023-05-21 12:20:54 -04:00
Hassan DRAGA
e955ee2228 Removing website
* Removing website
* Website repo is now in https://github.com/webui-dev/website
2023-05-16 08:06:24 -04:00
Jazz
5280738772
Add link to Nim APIs documentation 2023-05-15 23:50:53 -04:00
Jazz
dc98f8c0a4
Add Nim documentation 2023-05-15 23:47:53 -04:00
371 changed files with 96575 additions and 19138 deletions

View File

@ -1,45 +0,0 @@
name: Build WebUI
on:
push:
pull_request:
branches: [ main ]
jobs:
Windows-WebUI:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/setup-msbuild@v1.1
- name: Windows-WebUI
shell: cmd
run: |
cd build\Windows\GCC
mingw32-make
cd ..\..\..
cd build\Windows\MSVC
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
nmake
Linux-WebUI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Linux-WebUI
run: |
cd build/Linux/GCC
make
cd ../../..
cd build/Linux/Clang
sudo ln -s llvm-ar-13 /usr/bin/llvm-ar
sudo ln -s llvm-ranlib-13 /usr/bin/llvm-ranlib
make
macOS-WebUI:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- name: macOS-WebUI
run: |
cd build/macOS/Clang
make

54
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,54 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
name: CI
on:
push:
paths-ignore: ['**/*.md']
pull_request:
branches: [main]
paths-ignore: ['**/*.md']
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name == 'main' && github.sha || github.ref }}
cancel-in-progress: true
jobs:
windows:
uses: ./.github/workflows/windows.yml
permissions:
contents: write
macos:
uses: ./.github/workflows/macos.yml
permissions:
contents: write
linux:
uses: ./.github/workflows/linux.yml
permissions:
contents: write
linux_arm:
uses: ./.github/workflows/linux_arm.yml
permissions:
contents: write
linux_redhat:
uses: ./.github/workflows/linux_redhat.yml
permissions:
contents: write
linux_arch:
uses: ./.github/workflows/linux_arch.yml
permissions:
contents: write
zig:
uses: ./.github/workflows/zig.yml

View File

@ -1,20 +0,0 @@
name: WebUI-FTP
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: WebUI-FTP
uses: airvzxf/ftp-deployment-action@latest
with:
server: ${{ secrets.WEBUI_FTP_SERVER }}
user: ${{ secrets.WEBUI_FTP_USERNAME }}
password: ${{ secrets.WEBUI_FTP_PASSWORD }}
local_dir: "./website"
remote_dir: "./public_html"
delete: "true"
ftp_ssl_allow: "false"
max_retries: "3"

193
.github/workflows/linux.yml vendored Normal file
View File

@ -0,0 +1,193 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
name: Linux
on:
workflow_call:
jobs:
setup:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Bundle WebUI Bridge
run: |
npm i -g esbuild
chmod +x bridge/build.sh
bridge/build.sh
- uses: actions/cache@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
build:
needs: setup
runs-on: ubuntu-22.04
permissions:
contents: write
strategy:
matrix:
include:
- cc: gcc
arch: x64
- cc: clang
arch: x64
fail-fast: false
env:
ARTIFACT: webui-linux-${{ matrix.cc }}-${{ matrix.arch }}
CC: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
fail-on-cache-miss: true
- name: Setup
run: |
if [ "$CC" == "clang" ]; then
sudo ln -s llvm-ar-14 /usr/bin/llvm-ar
sudo ln -s llvm-ranlib-14 /usr/bin/llvm-ranlib
sudo ln -s llvm-strip-14 /usr/bin/llvm-strip
fi
- name: Build Debug Target
run: make debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: make
- name: Build TLS Debug Target
run: make WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
run: make WEBUI_USE_TLS=1
- name: Build Examples
run: |
examples_base_dir=$(pwd)/examples/C
for example in $(find $examples_base_dir/* -maxdepth 0 -type d); do
echo "> $example"
cd $example || (exit_code=1 && continue)
if ! make; then
echo "Failed to build '$example'"
exit_code=1
continue
fi
if [[ ! -e "main" || ! -e "main-dyn" ]] ; then
echo "Failed to find executable for '$example'" && find .
exit_code=1
continue
fi
done
exit $exit_code
- name: Setup Browser
uses: browser-actions/setup-chrome@v1
- name: Prepare Artifact
run: |
cp -r include dist
mv dist/ "$ARTIFACT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
- name: Prepare Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
run: |
zip -r "$ARTIFACT.zip" "$ARTIFACT"
if [ $GITHUB_REF_TYPE == tag ]; then
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=WebUI Nightly Build $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "BODY=Generated from commit $GITHUB_SHA."
} >> $GITHUB_ENV
fi
- name: Update Nightly Tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}
allowUpdates: true
build-ubuntu-22:
needs: setup
runs-on: ubuntu-22.04
permissions:
contents: write
strategy:
matrix:
include:
- cc: gcc
arch: x64
- cc: clang
arch: x64
fail-fast: false
env:
ARTIFACT: webui-linux-${{ matrix.cc }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
fail-on-cache-miss: true
- name: Setup
run: |
CC="${{ matrix.cc }}"
if [ "$CC" == "clang" ]; then
sudo ln -s llvm-ar-14 /usr/bin/llvm-ar
sudo ln -s llvm-ranlib-14 /usr/bin/llvm-ranlib
sudo ln -s llvm-strip-14 /usr/bin/llvm-strip
else
sudo apt -qq install gcc-11
CC+="-11"
fi
echo "CC=$CC" >> $GITHUB_ENV
- name: Build Debug Target
run: make debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: make
- name: Build TLS Debug Target
run: make WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
run: make WEBUI_USE_TLS=1
- name: Build Examples
run: |
examples_base_dir=$(pwd)/examples/C
for example in $(find $examples_base_dir/* -maxdepth 0 -type d); do
echo "> $example"
cd $example || (exit_code=1 && continue)
if ! make; then
echo "Failed to build '$example'"
exit_code=1
continue
fi
if [[ ! -e "main" || ! -e "main-dyn" ]] ; then
echo "Failed to find executable for '$example'" && find .
exit_code=1
continue
fi
done
exit $exit_code

111
.github/workflows/linux_arch.yml vendored Normal file
View File

@ -0,0 +1,111 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
name: Linux-Arch
on:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- cc: gcc
arch: x64
- cc: clang
arch: x64
fail-fast: false
env:
ARTIFACT: webui-linux-arch-${{ matrix.cc }}-${{ matrix.arch }}
CC: ${{ matrix.cc }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Arch Linux Docker Image
run: |
docker build -t archlinux:latest - <<EOF
FROM archlinux:latest
RUN pacman -Syu --noconfirm git npm make gcc clang llvm lld
EOF
- name: Run build inside Arch Linux container
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
--user root \
-e CC=${{ matrix.cc }} \
archlinux:latest \
bash -c "
git config --global --add safe.directory /workspace &&
npm i -g esbuild &&
chmod +x bridge/build.sh &&
if [ '${{ matrix.cc }}' == 'clang' ]; then
export AR=llvm-ar
export STRIP=llvm-strip
fi &&
./bridge/build.sh &&
make debug &&
make &&
make WEBUI_USE_TLS=1 debug &&
make WEBUI_USE_TLS=1 &&
chown -R $(id -u):$(id -g) /workspace
"
- name: Prepare Artifact
run: |
cp -r include dist
mv dist/ "$ARTIFACT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT}}
- name: Prepare Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
run: |
zip -r "$ARTIFACT.zip" "$ARTIFACT"
if [ $GITHUB_REF_TYPE == tag ]; then
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=WebUI Nightly Build $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "BODY=Generated from commit $GITHUB_SHA."
} >> $GITHUB_ENV
fi
- name: Update Nightly Tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}
allowUpdates: true

165
.github/workflows/linux_arm.yml vendored Normal file
View File

@ -0,0 +1,165 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
name: Linux ARM
on:
workflow_call:
jobs:
setup:
runs-on: buildjet-32vcpu-ubuntu-2204-arm
steps:
- uses: actions/checkout@v4
- name: Check CPU Architecture
run: |
ARCH=$(uname -m)
if [[ "$ARCH" != "arm"* && "$ARCH" != "aarch64" ]]; then
echo "Expected ARM-based CPU architecture. Detected: $ARCH"
exit 1
else
echo "ARM CPU Detected: $ARCH"
fi
- name: Bundle WebUI Bridge
run: |
npm i -g esbuild
chmod +x bridge/build.sh
bridge/build.sh
- uses: actions/cache@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
build:
needs: setup
# Same as `buildjet-32vcpu-ubuntu-2204-arm`
runs-on: ubuntu-22.04
permissions:
contents: write
strategy:
matrix:
include:
- cc: gcc
arch: arm
- cc: gcc
arch: arm64
fail-fast: false
env:
ARTIFACT: webui-linux-${{ matrix.cc }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
fail-on-cache-miss: true
- name: Setup
run: |
CC=${{ matrix.cc }}
if [ "${{ matrix.arch }}" == "arm64" ]; then
sudo apt update
sudo apt install -y gcc-aarch64-linux-gnu
CC=aarch64-linux-gnu-gcc
wget https://github.com/openssl/openssl/releases/download/openssl-3.3.1/openssl-3.3.1.tar.gz
tar -xzf openssl-3.3.1.tar.gz
cd openssl-3.3.1
./Configure linux-generic64 --prefix=/usr/aarch64-linux-gnu --cross-compile-prefix=aarch64-linux-gnu- --release -latomic
make
sudo make install
elif [ "${{ matrix.arch }}" == "arm" ]; then
sudo apt update
sudo apt install -y gcc-arm-linux-gnueabi
CC=arm-linux-gnueabi-gcc
wget https://github.com/openssl/openssl/releases/download/openssl-3.3.1/openssl-3.3.1.tar.gz
tar -xzf openssl-3.3.1.tar.gz
cd openssl-3.3.1
./Configure linux-generic32 --prefix=/usr/arm-linux-gnueabi --cross-compile-prefix=arm-linux-gnueabi- --release -latomic
make
sudo make install
fi
echo "CC=$CC" >> $GITHUB_ENV
- name: Build Debug Target
run: make debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: make
- name: Build TLS Debug ARM64 Target
if: matrix.arch == 'arm64'
run: make WEBUI_USE_TLS=1 debug WEBUI_TLS_INCLUDE="/usr/aarch64-linux-gnu/include" WEBUI_TLS_LIB="/usr/aarch64-linux-gnu/lib"
- name: Build TLS Debug ARM Target
if: matrix.arch == 'arm'
run: make WEBUI_USE_TLS=1 debug WEBUI_TLS_INCLUDE="/usr/arm-linux-gnueabi/include" WEBUI_TLS_LIB="/usr/arm-linux-gnueabi/lib"
- name: Build TLS Release ARM64 Target
if: matrix.arch == 'arm64'
run: make WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="/usr/aarch64-linux-gnu/include" WEBUI_TLS_LIB="/usr/aarch64-linux-gnu/lib"
- name: Build TLS Release ARM Target
if: matrix.arch == 'arm'
run: make WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="/usr/arm-linux-gnueabi/include" WEBUI_TLS_LIB="/usr/arm-linux-gnueabi/lib"
# - name: Build Examples
# if: matrix.arch == 'arm64'
# run: |
# examples_base_dir=$(pwd)/examples/C
# for example in $(find $examples_base_dir/* -maxdepth 0 -type d); do
# echo "> $example"
# cd $example || (exit_code=1 && continue)
# if ! make CC=aarch64-linux-gnu-gcc; then
# echo "Failed to build '$example'"
# exit_code=1
# continue
# fi
# if [[ ! -e "main" || ! -e "main-dyn" ]] ; then
# echo "Failed to find executable for '$example'" && find .
# exit_code=1
# continue
# fi
# done
# exit $exit_code
- name: Prepare Artifact
run: |
cp -r include dist
mv dist/ "$ARTIFACT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
- name: Prepare Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
run: |
zip -r "$ARTIFACT.zip" "$ARTIFACT"
if [ $GITHUB_REF_TYPE == tag ]; then
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=WebUI Nightly Build $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "BODY=Generated from commit $GITHUB_SHA."
} >> $GITHUB_ENV
fi
- name: Update Nightly Tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}
allowUpdates: true

113
.github/workflows/linux_redhat.yml vendored Normal file
View File

@ -0,0 +1,113 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
name: Linux-RedHat
on:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- cc: gcc
arch: x64
- cc: clang
arch: x64
fail-fast: false
env:
ARTIFACT: webui-linux-redhat-${{ matrix.cc }}-${{ matrix.arch }}
CC: ${{ matrix.cc }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build RedHat Docker Image
run: |
docker build -t redhat:latest - <<EOF
FROM almalinux:9
RUN dnf install -y epel-release
RUN dnf groupinstall -y "Development Tools"
RUN dnf install -y git nodejs npm clang llvm-toolset lld openssl-devel
EOF
- name: Run build inside RedHat container
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
--user root \
-e CC=${{ matrix.cc }} \
redhat:latest \
bash -c "
git config --global --add safe.directory /workspace &&
npm i -g esbuild &&
chmod +x bridge/build.sh &&
if [ '${{ matrix.cc }}' == 'clang' ]; then
export AR=llvm-ar
export STRIP=llvm-strip
fi &&
./bridge/build.sh &&
make debug &&
make &&
make WEBUI_USE_TLS=1 debug &&
make WEBUI_USE_TLS=1 &&
chown -R $(id -u):$(id -g) /workspace
"
- name: Prepare Artifact
run: |
cp -r include dist
mv dist/ "$ARTIFACT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
- name: Prepare Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
run: |
zip -r "$ARTIFACT.zip" "$ARTIFACT"
if [ $GITHUB_REF_TYPE == tag ]; then
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=WebUI Nightly Build $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "BODY=Generated from commit $GITHUB_SHA."
} >> $GITHUB_ENV
fi
- name: Update Nightly Tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}
allowUpdates: true

125
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,125 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
name: macOS
on:
workflow_call:
jobs:
setup:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Bundle WebUI Bridge
run: |
npm i -g esbuild
chmod +x bridge/build.sh
bridge/build.sh
- uses: actions/cache@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
build:
needs: setup
runs-on: macos-latest
permissions:
contents: write
strategy:
matrix:
cc: [clang]
arch: [x64, arm64]
fail-fast: false
env:
ARTIFACT: webui-macos-${{ matrix.cc }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
fail-on-cache-miss: true
- name: Setup OpenSSL
run: |
echo "WEBUI_TLS_INCLUDE=$(brew --cellar)/openssl@1.1/1.1.1w/include/" >> $GITHUB_ENV
echo "WEBUI_TLS_LIB=$(brew --cellar)/openssl@1.1/1.1.1w/lib/" >> $GITHUB_ENV
- name: Build Debug Target
run: make ARCH_TARGET=${{ matrix.arch }} debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: make ARCH_TARGET=${{ matrix.arch }}
- name: Build TLS Debug Target
if: ${{ matrix.arch != 'x64' }}
run: make ARCH_TARGET=${{ matrix.arch }} WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
if: ${{ matrix.arch != 'x64' }}
run: make ARCH_TARGET=${{ matrix.arch }} WEBUI_USE_TLS=1
- name: Build examples
if: ${{ matrix.arch != 'x64' }}
run: |
examples_base_dir=$(pwd)/examples/C
for example in $(find $examples_base_dir/* -maxdepth 0 -type d); do
echo "> $example"
cd $example || (exit_code=1 && continue)
if ! make ARCH_TARGET=${{ matrix.arch }}; then
echo "Failed to build '$example'"
exit_code=1
continue
fi
if [[ ! -e "main" || ! -e "main-dyn" ]] ; then
echo "Failed to find executable for '$example'" && find .
exit_code=1
continue
fi
done
exit $exit_code
- name: Prepare Artifacts
run: |
cp -r include dist
mv dist/ "$ARTIFACT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
- name: Prepare Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
run: |
zip -r "$ARTIFACT.zip" "$ARTIFACT"
if [ $GITHUB_REF_TYPE == tag ]; then
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=WebUI Nightly Build $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "BODY=Generated from commit $GITHUB_SHA."
} >> $GITHUB_ENV
fi
- name: Update Nightly Tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}
allowUpdates: true

133
.github/workflows/windows.yml vendored Normal file
View File

@ -0,0 +1,133 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
name: Windows
on:
workflow_call:
jobs:
setup:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Bundle WebUI Bridge
run: bridge/build.ps1
- uses: actions/cache@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
build:
needs: setup
runs-on: windows-latest
permissions:
contents: write
strategy:
matrix:
cc: ['gcc', 'msvc']
include:
- cc: gcc
make: mingw32-make
- cc: msvc
make: nmake
fail-fast: false
env:
ARTIFACT: webui-windows-${{ matrix.cc }}-x64
WEBUI_TLS_INCLUDE: "C:\\Program Files\\OpenSSL\\include"
WEBUI_TLS_LIB: "C:\\Program Files\\OpenSSL\\lib"
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
fail-on-cache-miss: true
- uses: microsoft/setup-msbuild@v2
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.cc == 'msvc'
- name: Build Debug Target
run: ${{ matrix.make }} debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: ${{ matrix.make }}
- name: Build TLS Debug Target
run: ${{ matrix.make }} WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
run: ${{ matrix.make }} WEBUI_USE_TLS=1
- name: Build examples
run: |
$examples_base_dir = "$(Get-Location)/examples/C/"
foreach ($example in Get-ChildItem -Path $examples_base_dir -Directory) {
Write-Host "> $example"
Set-Location -Path $example.FullName
if (!$?) {
$exit_code = 1
continue
}
$make_output = Invoke-Expression ${{ matrix.make }}
if (!$?) {
Write-Host "Failed to build '$example': $make_output"
$exit_code = 1
continue
}
Write-Output $make_output
if (!(Test-Path "main.exe") -or !(Test-Path "main-dyn.exe")) {
Write-Host "Failed to find executable for '$example'"
Get-ChildItem
$exit_code = 1
continue
}
}
exit $exit_code
- name: Prepare Artifact
shell: bash
run: |
cp -r include dist
mv dist/ "$ARTIFACT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
- name: Prepare Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
shell: bash
run: |
7z a -tzip "$ARTIFACT.zip" "$ARTIFACT/*"
if [ $GITHUB_REF_TYPE == tag ]; then
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=WebUI Nightly Build $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "BODY=Generated from commit $GITHUB_SHA."
} >> $GITHUB_ENV
fi
- name: Update Nightly Tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}
allowUpdates: true

36
.github/workflows/zig.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Zig Build
on:
workflow_call:
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [0.14.0, '']
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: maxim-lobanov/setup-xcode@v1
if: runner.os == 'macOS'
with:
xcode-version: latest-stable
- uses: actions/checkout@v4
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ matrix.version }}
- name: Build static library
run: zig build -Dverbose=debug
- name: Build dynamic library
if: ${{ !cancelled() }}
run: zig build -Ddynamic -Dverbose=debug
- name: Build static library with TLS support
if: runner.os == 'Linux'
run: zig build -Denable-tls -Dverbose=debug
- name: Build dynamic library with TLS support
if: runner.os == 'Linux'
run: zig build -Ddynamic -Denable-tls -Dverbose=debug
- name: Build examples
run: zig build examples

40
.gitignore vendored
View File

@ -1,4 +1,5 @@
# Build
build/
*.exe
*.ilk
*.pdb
@ -6,9 +7,32 @@
*.res
*.out
*.def
*.obj
*.iobj
# All sub-level build binaries
*/**/*
!*/**/*/
!*/**/*.*
!*makefile
!Makefile
*/**/*.exe
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Logs
*.log
@ -23,6 +47,8 @@
.idea/
*.recipe
*.idb
*.iobj
*.pdb
# Visual Studio for Mac
.idea/
@ -90,3 +116,13 @@ Thumbs.db
# User-specific private settings
*.DotSettings.user
# Compressed
*.zip
*.gz
# CMake
**/cmake_install.cmake
**/CMakeCache.txt
**/CMakeFiles/
.zig-cache

59
CMakeLists.txt Normal file
View File

@ -0,0 +1,59 @@
cmake_minimum_required(VERSION 3.10)
# Project name
project(WebUILibrary)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Variables for library names, source files, etc.
set(WEBUI_OUT_LIB_NAME "webui-2")
# Conditional compilation for TLS
option(WEBUI_USE_TLS "Enable TLS support" OFF)
if(WEBUI_USE_TLS)
find_package(OpenSSL REQUIRED)
set(WEBUI_OUT_LIB_NAME "webui-2-secure")
endif()
# Source files (already filled)
set(SOURCE_FILES
src/civetweb/civetweb.c
src/webui.c
)
# Library targets
add_library(webui ${SOURCE_FILES})
target_include_directories(webui PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_compile_definitions(webui PUBLIC NDEBUG NO_CACHING NO_CGI USE_WEBSOCKET)
if(BUILD_SHARED_LIBS AND WIN32)
target_compile_definitions(webui PRIVATE CIVETWEB_DLL_EXPORTS PUBLIC CIVETWEB_DLL_IMPORTS)
endif()
if(WEBUI_USE_TLS)
target_compile_definitions(webui PUBLIC WEBUI_TLS NO_SSL_DL OPENSSL_API_1_1)
target_link_libraries(webui PRIVATE OpenSSL::SSL OpenSSL::Crypto)
else()
target_compile_definitions(webui PUBLIC NO_SSL)
endif()
set_target_properties(webui PROPERTIES
OUTPUT_NAME ${WEBUI_OUT_LIB_NAME}
PREFIX "")
# Install headers
install(FILES include/webui.h include/webui.hpp DESTINATION include)
# Install targets
install(TARGETS webui
EXPORT webui
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
install(EXPORT webui
FILE webui-config.cmake
NAMESPACE webui::
DESTINATION share/webui
)

200
GNUmakefile Normal file
View File

@ -0,0 +1,200 @@
# WebUI Library
# == 1. VARIABLES =============================================================
WEBUI_OUT_LIB_NAME = webui-2
# Detect the OS once
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
else
DETECTED_OS := $(shell uname -s)
endif
# TLS
WEBUI_USE_TLS =
WEBUI_TLS_INCLUDE ?= .
WEBUI_TLS_LIB ?= .
TLS_CFLAG = -DNO_SSL
TLS_LDFLAG_DYNAMIC =
ifeq ($(WEBUI_USE_TLS), 1)
WEBUI_OUT_LIB_NAME = webui-2-secure
TLS_CFLAG = -DWEBUI_TLS -DNO_SSL_DL -DOPENSSL_API_1_1
ifeq ($(DETECTED_OS),Windows)
TLS_LDFLAG_DYNAMIC = -lssl -lcrypto -lbcrypt
else
TLS_LDFLAG_DYNAMIC = -lssl -lcrypto
endif
endif
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))
BUILD_DIR := $(MAKEFILE_DIR)/dist
# ARGS
CC ?= gcc
ifeq ($(CC), cc)
ifeq ($(DETECTED_OS),Darwin)
CC = clang
else
CC = gcc
endif
endif
# Allow to add arch-target for macOS CI cross compilation
ARCH_TARGET ?=
# BUILD FLAGS
CIVETWEB_BUILD_FLAGS := -o civetweb.o -I"$(MAKEFILE_DIR)/include/" -c "$(MAKEFILE_DIR)/src/civetweb/civetweb.c" -I"$(WEBUI_TLS_INCLUDE)" $(TLS_CFLAG) -w
CIVETWEB_DEFINE_FLAGS = -DNDEBUG -DNO_CACHING -DNO_CGI -DUSE_WEBSOCKET $(TLS_CFLAG)
WEBUI_BUILD_FLAGS := -o webui.o -I"$(MAKEFILE_DIR)/include/" -c "$(MAKEFILE_DIR)/src/webui.c" -I"$(WEBUI_TLS_INCLUDE)" $(TLS_CFLAG)
WARNING_RELEASE := -w
WARNING_LOG := -Wall -Wno-unused
# OUTPUT FILES
# The static output is the same for all platforms
# The dynamic output is platform dependent
LIB_STATIC_OUT := lib$(WEBUI_OUT_LIB_NAME)-static.a
# Platform defaults and dynamic library outputs
ifeq ($(DETECTED_OS),Windows)
# Windows
SHELL := CMD
PLATFORM := windows
LIB_DYN_OUT := $(WEBUI_OUT_LIB_NAME).dll
LWS2_OPT := -lws2_32 -lole32
CIVETWEB_DEFINE_FLAGS += -DMUST_IMPLEMENT_CLOCK_GETTIME
else ifeq ($(DETECTED_OS),Darwin)
# MacOS
PLATFORM := macos
CC = clang
LIB_DYN_OUT := lib$(WEBUI_OUT_LIB_NAME).dylib
WEBKIT_OBJ := wkwebview.o
WKWEBKIT_BUILD_FLAGS := -o wkwebview.o -c "$(MAKEFILE_DIR)/src/webview/wkwebview.m"
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
else
# Linux
PLATFORM := linux
LIB_DYN_OUT := lib$(WEBUI_OUT_LIB_NAME).so
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
# macOS can set `ARCH_TARGET=arm64` for cross-compilation.
ifneq ($(ARCH_TARGET),)
ifneq ($(PLATFORM),macos)
$(error ARCH_TARGET is only available on macOS)
endif
ifeq ($(ARCH_TARGET),arm64)
TARGET := -target arm64-apple-darwin -arch arm64
else ifeq ($(ARCH_TARGET),x64)
TARGET := -target x86_64-apple-darwin -arch x86_64
else
$(error Unsupported ARCH_TARGET: $(ARCH_TARGET). Use 'arm64' or 'x64'.)
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: --debug
release: --release
clean: --clean-$(PLATFORM)
# == 2.1 INTERNAL TARGETS =====================================================
--debug:
# Create build directory
ifeq ($(PLATFORM),windows)
@mkdir "$(BUILD_DIR)/debug" >nul 2>&1 ||:
else
@mkdir -p "$(BUILD_DIR)/debug"
endif
# Build macOS WKWebView
ifeq ($(DETECTED_OS),Darwin)
@cd "$(BUILD_DIR)/debug" \
&& echo "Build WebUI Objective-C WKWebKit ($(CC) $(TARGET) debug)..." \
&& $(CC) $(TARGET) $(WKWEBKIT_BUILD_FLAGS) -g -DWEBUI_LOG
endif
# Static with Debug info
@cd "$(BUILD_DIR)/debug" \
&& echo "Build WebUI library ($(CC) $(TARGET) debug static)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -g \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) $(WARNING_LOG) -g -DWEBUI_LOG \
&& $(LLVM_OPT)ar rc $(LIB_STATIC_OUT) webui.o civetweb.o $(WEBKIT_OBJ) \
&& $(LLVM_OPT)ranlib $(LIB_STATIC_OUT)
# Dynamic with Debug info
@cd "$(BUILD_DIR)/debug" \
&& echo "Build WebUI library ($(CC) $(TARGET) debug dynamic)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -g -fPIC \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) $(WARNING_LOG) -g -fPIC -DWEBUI_LOG -DWEBUI_DYNAMIC \
&& $(CC) $(TARGET) -shared -o $(LIB_DYN_OUT) webui.o civetweb.o $(WEBKIT_OBJ) -g -L"$(WEBUI_TLS_LIB)" $(TLS_LDFLAG_DYNAMIC) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS)
ifeq ($(PLATFORM),windows)
@cd "$(BUILD_DIR)/debug" && del *.o >nul 2>&1
else
@rm -f $(BUILD_DIR)/debug/*.o
endif
@echo "Done."
--release:
# Create build directory
ifeq ($(PLATFORM),windows)
@mkdir "$(BUILD_DIR)" >nul 2>&1 ||:
else
@mkdir -p "$(BUILD_DIR)"
endif
# Build macOS WKWebView
ifeq ($(DETECTED_OS),Darwin)
@cd "$(BUILD_DIR)" \
&& echo "Build WebUI Objective-C WKWebKit ($(CC) $(TARGET) release)..." \
&& $(CC) $(TARGET) $(WKWEBKIT_BUILD_FLAGS) -Os
endif
# Static Release
@cd "$(BUILD_DIR)" \
&& echo "Build WebUI library ($(CC) $(TARGET) release static)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -Os \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) $(WARNING_RELEASE) -Os \
&& $(LLVM_OPT)ar rc $(LIB_STATIC_OUT) webui.o civetweb.o $(WEBKIT_OBJ) \
&& $(LLVM_OPT)ranlib $(LIB_STATIC_OUT)
# Dynamic Release
@cd "$(BUILD_DIR)" \
&& echo "Build WebUI library ($(CC) $(TARGET) release dynamic)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -Os -fPIC \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) $(WARNING_RELEASE) -O3 -fPIC -DWEBUI_DYNAMIC \
&& $(CC) $(TARGET) -shared -o $(LIB_DYN_OUT) webui.o civetweb.o $(WEBKIT_OBJ) -L"$(WEBUI_TLS_LIB)" $(TLS_LDFLAG_DYNAMIC) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS)
# Clean
ifeq ($(PLATFORM),windows)
@strip --strip-unneeded $(BUILD_DIR)/$(LIB_DYN_OUT)
@cd "$(BUILD_DIR)" && del *.o >nul 2>&1
else
@rm -f $(BUILD_DIR)/*.o
endif
@echo "Done."
# PLATFROM CLEAN TARGETS
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
@- cd "$(BUILD_DIR)" \
&& rm -f *.o \
&& rm -f *.so \
&& rm -f *.dylib \
&& rm -f *.a
--clean-windows:
@- cd "$(BUILD_DIR)" \
&& del *.a >nul 2>&1 \
&& del *.o >nul 2>&1 \
&& del *.dll >nul 2>&1 \
&& del *.obj >nul 2>&1 \
&& del *.ilk >nul 2>&1 \
&& del *.pdb >nul 2>&1 \
&& del *.lib >nul 2>&1 \
&& del *.exp >nul 2>&1

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Albert Shown
Copyright (c) 2025 Hassan Draga
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

92
Makefile Normal file
View File

@ -0,0 +1,92 @@
# WebUI Library
# Windows - Microsoft Visual C
# == 1. VARIABLES =============================================================
WEBUI_OUT_LIB_NAME = webui-2
TLS_CFLAG = /DNO_SSL
# TLS Enabled
!IF "$(WEBUI_USE_TLS)" == "1"
WEBUI_OUT_LIB_NAME = webui-2-secure
TLS_CFLAG = /DWEBUI_TLS /DNO_SSL_DL /DOPENSSL_API_1_1
TLS_LDFLAG_DYNAMIC = libssl.lib libcrypto.lib
!IF "$(WEBUI_TLS_INCLUDE)" != ""
TLS_CFLAG = $(TLS_CFLAG) /I"$(WEBUI_TLS_INCLUDE)"
!ELSE
TLS_CFLAG = $(TLS_CFLAG) /I"."
!ENDIF
!IF "$(WEBUI_TLS_LIB)" != ""
TLS_LDFLAG_DYNAMIC = $(TLS_LDFLAG_DYNAMIC) /LIBPATH:"$(WEBUI_TLS_LIB)"
!ELSE
TLS_LDFLAG_DYNAMIC += $(TLS_LDFLAG_DYNAMIC) /LIBPATH:"."
!ENDIF
!ENDIF
# Build Flags
CIVETWEB_BUILD_FLAGS = /Fo"civetweb.obj" /c /EHsc "$(MAKEDIR)/src/civetweb/civetweb.c" /I"$(MAKEDIR)/src/civetweb/" $(TLS_CFLAG)
CIVETWEB_DEFINE_FLAGS = /D NDEBUG /D NO_CACHING /D NO_CGI /D USE_WEBSOCKET
WEBUI_BUILD_FLAGS = /Fo"webui.obj" /c /EHsc "$(MAKEDIR)/src/webui.c" /I"$(MAKEDIR)/include" /I"$(WEBUI_TLS_INCLUDE)" $(TLS_CFLAG)
WARNING_RELEASE = /w
WARNING_LOG = /W4
# Output Commands
LIB_STATIC_OUT = /OUT:"$(WEBUI_OUT_LIB_NAME)-static.lib" "webui.obj" "civetweb.obj"
LIB_DYN_OUT = /DLL /OUT:"$(WEBUI_OUT_LIB_NAME).dll" "webui.obj" "civetweb.obj" user32.lib Advapi32.lib Shell32.lib Ole32.lib $(TLS_LDFLAG_DYNAMIC)
# == 2.TARGETS ================================================================
all: release
debug:
@- mkdir dist\debug >nul 2>&1
# Static with Debug info
@- cd $(MAKEDIR)/dist/debug
@echo Build WebUI Library (MSVC Debug Static)...
@cl /Zl /Zi $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zl /Zi $(WEBUI_BUILD_FLAGS) $(WARNING_LOG) /D WEBUI_LOG
@lib $(LIB_STATIC_OUT)
# Dynamic with Debug info
@echo Build WebUI Library (MSVC Debug Dynamic)...
@cl /Zi $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zi $(WEBUI_BUILD_FLAGS) $(WARNING_LOG) /D WEBUI_LOG /D WEBUI_DYNAMIC
@link $(LIB_DYN_OUT)
# Clean
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.exp >nul 2>&1
@echo Done.
release:
@- mkdir dist >nul 2>&1
@- cd $(MAKEDIR)/dist
# Static Release
@echo Build WebUI Library (MSVC Release Static)...
@cl /Zl $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zl $(WEBUI_BUILD_FLAGS) $(WARNING_RELEASE)
@lib $(LIB_STATIC_OUT)
# Dynamic Release
@echo Build WebUI Library (MSVC Release Dynamic)...
@cl $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl $(WEBUI_BUILD_FLAGS) $(WARNING_RELEASE) /D WEBUI_DYNAMIC
@link $(LIB_DYN_OUT)
# Clean
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.exp >nul 2>&1
@- echo Done.
clean:
@- cd $(BUILD_DIR)
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.exp >nul 2>&1
@- del *.dll >nul 2>&1
@- del *.lib >nul 2>&1
@- echo Done.

356
README.md
View File

@ -1,140 +1,298 @@
![ScreenShot](logo/webui_240_shadow.png)
<div align="center">
# WebUI v2.3.0
![Logo](https://raw.githubusercontent.com/webui-dev/webui-logo/14fd595844f57ce751dfc751297b1468b10de77a/webui_120.svg)
[![Website](https://img.shields.io/circleci/project/github/badges/shields/master?style=for-the-badge)](https://github.com/webui-dev/webui) [![Website](https://img.shields.io/github/issues/webui-dev/webui.svg?branch=master&style=for-the-badge&url=https://google.com)](https://github.com/webui-dev/webui/issues) [![Website](https://img.shields.io/website?label=webui.me&style=for-the-badge&url=https://google.com)](https://webui.me/)
# WebUI v2.5.0-beta.4
> Use any web browser as GUI, with your preferred language in the backend and HTML5 in the frontend, all in a lightweight portable lib.
[build-status]: https://img.shields.io/github/actions/workflow/status/webui-dev/webui/ci.yml?branch=main&style=for-the-badge&logo=githubactions&labelColor=414868&logoColor=C0CAF5
[last-commit]: https://img.shields.io/github/last-commit/webui-dev/webui?style=for-the-badge&logo=github&logoColor=C0CAF5&labelColor=414868
[release-version]: https://img.shields.io/github/v/tag/webui-dev/webui?style=for-the-badge&logo=webtrees&logoColor=C0CAF5&labelColor=414868&color=7664C6
[license]: https://img.shields.io/github/license/webui-dev/webui?style=for-the-badge&logo=opensourcehardware&label=License&logoColor=C0CAF5&labelColor=414868&color=8c73cc
![ScreenShot](screenshot.png)
[![][build-status]](https://github.com/webui-dev/webui/actions?query=branch%3Amain)
[![][last-commit]](https://github.com/webui-dev/webui/pulse)
[![][release-version]](https://github.com/webui-dev/webui/releases/latest)
[![][license]](https://github.com/webui-dev/webui/blob/main/LICENSE)
> :warning: **Notice**:
>
> * WebUI it's not a web-server solution or a framework, but it's an lightweight portable lib to use any installed web browser as a user interface.
>
> * We are currently writing documentation.
> Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
![Screenshot](https://raw.githubusercontent.com/webui-dev/webui-logo/main/screenshot.png)
</div>
## Download
- [Latest Stable Release](https://github.com/webui-dev/webui/releases)
- [Nightly Build](https://github.com/webui-dev/webui/releases/tag/nightly)
## Contents
- [Features](#features)
- [Showcase](#showcase)
- [UI & The Web Technologies](#ui--the-web-technologies)
- [Documentation](#documentation)
- [Build](#build)
- [Examples](#examples)
- [Wrappers](#wrappers)
- [Supported Web Browsers](#supported-web-browsers)
- [License](#license)
## Features
- Written in Pure C
- Fully Independent (*No need for any third-party runtimes*)
- Lightweight (*~160 Kb using TCC*) & Small memory footprint
- Fast binary communication protocol between WebUI and the browser (*Instead of JSON*)
- Portable (*Needs only a web browser or a WebView at runtime*)
- One header file
- Lightweight (*Few Kb library*) & Small memory footprint
- Fast binary communication protocol
- Multi-platform & Multi-Browser
- Using private profile for safety
## Screenshot
This [text editor example](https://github.com/webui-dev/webui/tree/main/examples/C/text-editor) is written in C using WebUI as the GUI library. The final executable is portable and has less than _1 MB_ in size (_+html and css files_).
![ScreenShot](webui_c_example.png)
## CppCon 2019 Presentation
[Borislav Stanimirov](https://ibob.bg/) discusses using HTML5 in the web browser as GUI at the [C++ Conference 2019 (*YouTube*)](https://www.youtube.com/watch?v=bbbcZd4cuxg).
<!-- <div align="center">
<a href="https://www.youtube.com/watch?v=bbbcZd4cuxg"><img src="https://img.youtube.com/vi/bbbcZd4cuxg/0.jpg" alt="Embrace Modern Technology: Using HTML 5 for GUI in C++ - Borislav Stanimirov - CppCon 2019"></a>
</div> -->
![ScreenShot](cppcon_2019.png)
- Cross-platform WebView
## UI & The Web Technologies
[Borislav Stanimirov](https://ibob.bg/) discusses using HTML5 in the web browser as GUI at the [C++ Conference 2019 (_YouTube_)](https://www.youtube.com/watch?v=bbbcZd4cuxg).
<div align="center">
![CPPCon](https://github.com/webui-dev/webui/assets/34311583/4e830caa-4ca0-44ff-825f-7cd6d94083c8)
</div>
Web application UI design is not just about how a product looks but how it works. Using web technologies in your UI makes your product modern and professional, And a well-designed web application will help you make a solid first impression on potential customers. Great web application design also assists you in nurturing leads and increasing conversions. In addition, it makes navigating and using your web app easier for your users.
## Why Use Web Browser?
### Why Use Web Browsers?
Today's web browsers have everything a modern UI needs. Web browsers are very sophisticated and optimized. Therefore, using it as a GUI will be an excellent choice. While old legacy GUI lib is complex and outdated, a WebView-based app is still an option. However, a WebView needs a huge SDK to build and many dependencies to run, and it can only provide some features like a real web browser. That is why WebUI uses real web browsers to give you full features of comprehensive web technologies while keeping your software lightweight and portable.
## How does it work?
### How Does it Work?
![ScreenShot](webui_diagram.png)
<div align="center">
![Diagram](https://github.com/ttytm/webui/assets/34311583/dbde3573-3161-421e-925c-392a39f45ab3)
</div>
Think of WebUI like a WebView controller, but instead of embedding the WebView controller in your program, which makes the final program big in size, and non-portable as it needs the WebView runtimes. Instead, by using WebUI, you use a tiny static/dynamic library to run any installed web browser and use it as GUI, which makes your program small, fast, and portable. **All it needs is a web browser**.
## Runtime Dependencies Comparison
### Runtime Dependencies Comparison
| | WebView | Qt | WebUI |
| ------ | ------ | ------ | ------ |
| Runtime Dependencies on Windows | *WebView2* | *QtCore, QtGui, QtWidgets* | ***A Web Browser*** |
| Runtime Dependencies on Linux | *GTK3, WebKitGTK* | *QtCore, QtGui, QtWidgets* | ***A Web Browser*** |
| Runtime Dependencies on macOS | *Cocoa, WebKit* | *QtCore, QtGui, QtWidgets* | ***A Web Browser*** |
| | Tauri / WebView | Qt | WebUI |
| ------------------------------- | ----------------- | -------------------------- | ------------------- |
| Runtime Dependencies on Windows | _WebView2_ | _QtCore, QtGui, QtWidgets_ | **_A Web Browser_** |
| Runtime Dependencies on Linux | _GTK3, WebKitGTK_ | _QtCore, QtGui, QtWidgets_ | **_A Web Browser_** |
| Runtime Dependencies on macOS | _Cocoa, WebKit_ | _QtCore, QtGui, QtWidgets_ | **_A Web Browser_** |
## Documentation
- [Online Documentation - C](https://webui.me/docs/#/c_api)
- [Online Documentation - C++](https://webui.me/docs/#/cpp_api)
> **Note**
> We are currently writing documentation.
## Build
- [Online Documentation](https://webui.me/docs/)
- [Windows](https://github.com/webui-dev/webui/tree/main/build/Windows)
- [Linux](https://github.com/webui-dev/webui/tree/main/build/Linux)
- [macOS](https://github.com/webui-dev/webui/tree/main/build/macOS)
## Build WebUI Library
## Examples
### Windows
- [C](https://github.com/webui-dev/webui/tree/main/examples/C)
- [C++](https://github.com/webui-dev/webui/tree/main/examples/C++)
| Compiler | Command |
|----------|---------|
| GCC | `mingw32-make` |
| MSVC | `nmake` |
## Wrappers
<details>
<summary><strong>Windows SSL/TLS (Optional)</strong></summary>
Download and install the OpenSSL pre-compiled binaries for Windows:
- [Python](https://github.com/webui-dev/python-webui)
- [TypeScript / JavaScript](https://github.com/webui-dev/deno-webui)
- [Go](https://github.com/webui-dev/go-webui)
- [Rust](https://github.com/webui-dev/rust-webui) (*Not Complete*)
- [V](https://github.com/webui-dev/v-webui)
- [Nim](https://github.com/webui-dev/nim-webui)
- [Zig](https://github.com/webui-dev/zig-webui) (*Not Complete*)
- **MSVC**: [x64 OpenSSL v3.3.1](https://slproweb.com/download/Win64OpenSSL-3_3_1.msi) or [_32Bit_](https://slproweb.com/download/Win32OpenSSL-3_3_1.msi). See the [Wiki list](https://wiki.openssl.org/index.php/Binaries) for more info.
- **MinGW**: [Curl for Windows with OpenSSL](https://curl.se/windows/)
```powershell
# GCC
mingw32-make WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="C:\curl-xxx-xxx-mingw\curl-xxx-xxx-mingw\include" WEBUI_TLS_LIB="C:\curl-xxx-xxx-mingw\curl-xxx-xxx-mingw\lib"
# MSVC
nmake WEBUI_USE_TLS=1 WEBUI_TLS_INCLUDE="C:\Program Files\OpenSSL-xxx\include" WEBUI_TLS_LIB="C:\Program Files\OpenSSL-xxx\lib"
```
</details>
### Linux
| Compiler | Command |
|----------|---------|
| GCC | `make` |
| Clang | `make CC=clang` |
<details>
<summary><strong>Linux SSL/TLS (Optional)</strong></summary>
```sh
sudo apt update
sudo apt install libssl-dev
# GCC
make WEBUI_USE_TLS=1
# Clang
make WEBUI_USE_TLS=1 CC=clang
```
</details>
### macOS
| Compiler | Command |
|----------|---------|
| Default | `make` |
<details>
<summary><strong>macOS SSL/TLS (Optional)</strong></summary>
```sh
brew install openssl
make WEBUI_USE_TLS=1
```
</details>
## Minimal WebUI Application
- **C**
```c
#include "webui.h"
int main() {
size_t my_window = webui_new_window();
webui_show(my_window, "<html><head><script src=\"webui.js\"></script></head> Hello World ! </html>");
webui_wait();
return 0;
}
```
- **C++**
```cpp
#include "webui.hpp"
#include <iostream>
int main() {
webui::window my_window;
my_window.show("<html><head><script src=\"webui.js\"></script></head> C++ Hello World ! </html>");
webui::wait();
return 0;
}
```
- **More C/C++ Examples**
- [C](https://github.com/webui-dev/webui/tree/main/examples/C)
- [C++](https://github.com/webui-dev/webui/tree/main/examples/C++)
- **Other Languages**
- [Wrappers List](#Wrappers)
## Build WebUI Application
### Windows
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lws2_32 -Wall -luser32 -static -lole32 -o my_application.exe` |
| GCC | Dynamic | `gcc -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" "webui-2.dll" -lws2_32 -Wall -luser32 -lole32 -o my_application.exe` |
| MSVC | Static | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
| MSVC | Dynamic | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
<details>
<summary><strong>Windows With SSL/TLS (Optional)</strong></summary>
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lws2_32 -Wall -luser32 -static -lole32 -o my_application.exe` |
| GCC | Dynamic | `gcc -Wl,-subsystem=windows my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" "webui-2-secure.dll" -lws2_32 -Wall -luser32 -lole32 -o my_application.exe` |
| MSVC | Static | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2-secure-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
| MSVC | Dynamic | `cl my_application.c /I"_PATH_TO_WEBUI_INCLUDE_" /link /LIBPATH:"_PATH_TO_WEBUI_LIB_" /SUBSYSTEM:WINDOWS webui-2-secure.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:my_application.exe` |
</details>
### Linux
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lpthread -lm -ldl -o my_application` |
| GCC | Dynamic | `gcc my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2 -lpthread -lm -ldl -o my_application` |
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lpthread -lm -ldl -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2 -lpthread -lm -ldl -o my_application` |
<details>
<summary><strong>Linux With SSL/TLS (Optional)</strong></summary>
| Compiler | Type | Command |
|----------|--------|---------|
| GCC | Static | `gcc -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lpthread -lm -ldl -o my_application` |
| GCC | Dynamic | `gcc my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure -lpthread -lm -ldl -o my_application` |
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lpthread -lm -ldl -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure -lpthread -lm -ldl -o my_application` |
</details>
### macOS
| Compiler | Type | Command |
|----------|--------|---------|
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-static -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2 -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
<details>
<summary><strong>macOS With SSL/TLS (Optional)</strong></summary>
| Compiler | Type | Command |
|----------|--------|---------|
| Clang | Static | `clang -Os my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure-static -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
| Clang | Dynamic | `clang my_application.c -I"_PATH_TO_WEBUI_INCLUDE_" -L"_PATH_TO_WEBUI_LIB_" -lwebui-2-secure -lpthread -lm -framework Cocoa -framework WebKit -o my_application` |
</details>
## Wrappers
| Language | v2.4.0 API | v2.5.0 API | Link |
| --------------- | --- | -------------- | --------------------------------------------------------- |
| Python | ✔️ | _not complete_ | [Python-WebUI](https://github.com/webui-dev/python-webui) |
| Go | ✔️ | _not complete_ | [Go-WebUI](https://github.com/webui-dev/go-webui) |
| Zig | ✔️ | _not complete_ | [Zig-WebUI](https://github.com/webui-dev/zig-webui) |
| Nim | ✔️ | _not complete_ | [Nim-WebUI](https://github.com/webui-dev/nim-webui) |
| V | ✔️ | _not complete_ | [V-WebUI](https://github.com/webui-dev/v-webui) |
| Rust | _not complete_ | _not complete_ | [Rust-WebUI](https://github.com/webui-dev/rust-webui) |
| TS / JS (Deno) | ✔️ | _not complete_ | [Deno-WebUI](https://github.com/webui-dev/deno-webui) |
| TS / JS (Bun) | _not complete_ | _not complete_ | [Bun-WebUI](https://github.com/webui-dev/bun-webui) |
| Swift | _not complete_ | _not complete_ | [Swift-WebUI](https://github.com/webui-dev/swift-webui) |
| Odin | _not complete_ | _not complete_ | [Odin-WebUI](https://github.com/webui-dev/odin-webui) |
| Pascal | _not complete_ | _not complete_ | [Pascal-WebUI](https://github.com/webui-dev/pascal-webui) |
| Purebasic | _not complete_ | _not complete_ | [Purebasic-WebUI](https://github.com/webui-dev/purebasic-webui)|
| - | | |
| Common Lisp | _not complete_ | _not complete_ | [cl-webui](https://github.com/garlic0x1/cl-webui) |
| Delphi | _not complete_ | _not complete_ | [WebUI4Delphi](https://github.com/salvadordf/WebUI4Delphi) |
| C# | _not complete_ | _not complete_ | [WebUI4CSharp](https://github.com/salvadordf/WebUI4CSharp) |
| WebUI.NET | _not complete_ | _not complete_ | [WebUI.NET](https://github.com/Juff-Ma/WebUI.NET) |
| QuickJS | _not complete_ | _not complete_ | [QuickUI](https://github.com/xland/QuickUI) |
| PHP | _not complete_ | _not complete_ | [PHPWebUiComposer](https://github.com/KingBes/php-webui-composer) |
## Supported Web Browsers
| OS | Browser | Status |
| ------ | ------ | ------ |
| Windows | Mozilla Firefox | ✔️ |
| Windows | Google Chrome | ✔️ |
| Windows | Microsoft Edge | ✔️ |
| Windows | Chromium | ✔️ |
| Windows | Yandex | ✔️ |
| Windows | Brave | ✔️ |
| Windows | Vivaldi | ✔️ |
| Windows | Epic | ✔️ |
| Windows | Opera | *coming soon* |
| - | - | - |
| Linux | Mozilla Firefox | ✔️ |
| Linux | Google Chrome | ✔️ |
| Linux | Microsoft Edge | ✔️ |
| Linux | Chromium | ✔️ |
| Linux | Yandex | ✔️ |
| Linux | Brave | ✔️ |
| Linux | Vivaldi | ✔️ |
| Linux | Epic | *Does Not Exist* |
| Linux | Opera | *coming soon* |
| - | - | - |
| macOS | Mozilla Firefox | ✔️ |
| macOS | Google Chrome | ✔️ |
| macOS | Microsoft Edge | ✔️ |
| macOS | Chromium | ✔️ |
| macOS | Yandex | ✔️ |
| macOS | Brave | ✔️ |
| macOS | Vivaldi | ✔️ |
| macOS | Epic | ✔️ |
| macOS | Apple Safari | *coming soon* |
| macOS | Opera | *coming soon* |
| 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_ |
## Supported Languages
## Supported WebView
| Language | Status | Link |
| ------ | ------ | ------ |
| C/C++ | ✔️ | [WebUI](https://github.com/webui-dev/webui) |
| Python | ✔️ | [Python-WebUI](https://github.com/webui-dev/python-webui) |
| TypeScript / JavaScript | ✔️ | [Deno-WebUI](https://github.com/webui-dev/deno-webui) |
| Go | ✔️ | [Go-WebUI](https://github.com/webui-dev/go-webui) |
| Rust | *Not Complete* | [Rust-WebUI](https://github.com/webui-dev/rust-webui) |
| V | ✔️ | [V-WebUI](https://github.com/webui-dev/v-webui) |
| Nim | ✔️ | [Nim-WebUI](https://github.com/webui-dev/nim-webui) |
| Zig | *Not Complete* | [Zig-WebUI](https://github.com/webui-dev/zig-webui) |
| WebView | Status |
| --------------- | --------------- |
| Windows WebView2 | ✔️ |
| Linux GTK WebView | ✔️ |
| macOS WKWebView | ✔️ |
### License

Binary file not shown.

Binary file not shown.

View File

@ -1,198 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_H
#define _WEBUI_H
#define WEBUI_VERSION "2.3.0"
// Dynamic Library Exports
#if defined(_MSC_VER) || defined(__TINYC__)
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT __declspec(dllexport)
#endif
#else
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT extern
#endif
#endif
// -- C STD ---------------------------
#include <stdbool.h>
#include <inttypes.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stddef.h>
#include <time.h>
#include <errno.h>
#include <math.h>
#if defined(__GNUC__) || defined(__TINYC__)
#include <dirent.h>
#endif
// -- Windows -------------------------
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <direct.h>
#include <io.h>
#include <tchar.h>
#include <tlhelp32.h>
#define WEBUI_GET_CURRENT_DIR _getcwd
#define WEBUI_FILE_EXIST _access
#define WEBUI_POPEN _popen
#define WEBUI_PCLOSE _pclose
#define WEBUI_MAX_PATH MAX_PATH
#endif
// -- Linux ---------------------------
#ifdef __linux__
#include <unistd.h>
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/time.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Apple ---------------------------
#ifdef __APPLE__
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/syslimits.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Enums ---------------------------
enum webui_browsers {
AnyBrowser = 0, // 0. Default recommended web browser
Chrome, // 1. Google Chrome
Firefox, // 2. Mozilla Firefox
Edge, // 3. Microsoft Edge
Safari, // 4. Apple Safari
Chromium, // 5. The Chromium Project
Opera, // 6. Opera Browser
Brave, // 7. The Brave Browser
Vivaldi, // 8. The Vivaldi Browser
Epic, // 9. The Epic Browser
Yandex, // 10. The Yandex Browser
};
enum webui_runtimes {
None = 0, // 0. Prevent WebUI from using any runtime for .js and .ts files
Deno, // 1. Use Deno runtime for .js and .ts files
NodeJS, // 2. Use Nodejs runtime for .js files
};
enum webui_events {
WEBUI_EVENT_DISCONNECTED = 0, // 0. Window disconnection event
WEBUI_EVENT_CONNECTED, // 1. Window connection event
WEBUI_EVENT_MULTI_CONNECTION, // 2. New window connection event
WEBUI_EVENT_UNWANTED_CONNECTION, // 3. New unwanted window connection event
WEBUI_EVENT_MOUSE_CLICK, // 4. Mouse click event
WEBUI_EVENT_NAVIGATION, // 5. Window navigation event
WEBUI_EVENT_CALLBACK, // 6. Function call event
};
// -- Structs -------------------------
typedef struct webui_event_t {
size_t window; // Pointer to the window object
unsigned int event_type; // Event type
char* element; // HTML element ID
char* data; // JavaScript data
unsigned int event_number; // Internal WebUI
} webui_event_t;
// -- Definitions ---------------------
// Create a new webui window object.
WEBUI_EXPORT size_t webui_new_window(void);
// Bind a specific html element click event with a function. Empty element means all events.
WEBUI_EXPORT unsigned int webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e));
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
WEBUI_EXPORT bool webui_show(size_t window, const char* content);
// Same as webui_show(). But with a specific web browser.
WEBUI_EXPORT bool webui_show_browser(size_t window, const char* content, unsigned int browser);
// Set the window in Kiosk mode (Full screen)
WEBUI_EXPORT void webui_set_kiosk(size_t window, bool status);
// Wait until all opened windows get closed.
WEBUI_EXPORT void webui_wait(void);
// Close a specific window.
WEBUI_EXPORT void webui_close(size_t window);
// Close all opened windows. webui_wait() will break.
WEBUI_EXPORT void webui_exit(void);
// -- Other ---------------------------
// Check a specific window if it's still running
WEBUI_EXPORT bool webui_is_shown(size_t window);
// Set the maximum time in seconds to wait for browser to start
WEBUI_EXPORT void webui_set_timeout(unsigned int second);
// Set the default embedded HTML favicon
WEBUI_EXPORT void webui_set_icon(size_t window, const char* icon, const char* icon_type);
// Allow the window URL to be re-used in normal web browsers
WEBUI_EXPORT void webui_set_multi_access(size_t window, bool status);
// -- JavaScript ----------------------
// Run JavaScript quickly with no waiting for the response.
WEBUI_EXPORT bool webui_run(size_t window, const char* script);
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
WEBUI_EXPORT bool webui_script(size_t window, const char* script, unsigned int timeout, char* buffer, size_t buffer_length);
// Chose between Deno and Nodejs runtime for .js and .ts files.
WEBUI_EXPORT void webui_set_runtime(size_t window, unsigned int runtime);
// Parse argument as integer.
WEBUI_EXPORT long long int webui_get_int(webui_event_t* e);
// Parse argument as string.
WEBUI_EXPORT const char* webui_get_string(webui_event_t* e);
// Parse argument as boolean.
WEBUI_EXPORT bool webui_get_bool(webui_event_t* e);
// Return the response to JavaScript as integer.
WEBUI_EXPORT void webui_return_int(webui_event_t* e, long long int n);
// Return the response to JavaScript as string.
WEBUI_EXPORT void webui_return_string(webui_event_t* e, char* s);
// Return the response to JavaScript as boolean.
WEBUI_EXPORT void webui_return_bool(webui_event_t* e, bool b);
// -- Interface -----------------------
// Bind a specific html element click event with a function. Empty element means all events. This replace webui_bind(). The func is (Window, EventType, Element, Data, EventNumber)
WEBUI_EXPORT unsigned int webui_interface_bind(size_t window, const char* element, void (*func)(size_t, unsigned int, char*, char*, unsigned int));
// When using `webui_interface_bind()` you may need this function to easily set your callback response.
WEBUI_EXPORT void webui_interface_set_response(size_t window, unsigned int event_number, const char* response);
// Check if the app still running or not. This replace webui_wait().
WEBUI_EXPORT bool webui_interface_is_app_running(void);
// Get window unique ID
WEBUI_EXPORT unsigned int webui_interface_get_window_id(size_t window);
#endif /* _WEBUI_H */

View File

@ -1,153 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_HPP
#define _WEBUI_HPP
// C++ STD
#include <string>
// WebUI C Header
extern "C" {
#include "webui.h"
}
namespace webui {
// Create a new webui window object.
size_t new_window(void) {
return webui_new_window();
}
// Bind a specific html element click event with a function. Empty element means all events.
unsigned int bind(size_t window, std::string element, void (*func)(webui_event_t* e)) {
return webui_bind(window, element.c_str(), func);
}
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
bool show(size_t window, std::string content) {
return webui_show(window, content.c_str());
}
// Same as show(). But with a specific web browser.
bool show_browser(size_t window, std::string content, unsigned int browser) {
return webui_show_browser(window, content.c_str(), browser);
}
// Wait until all opened windows get closed.
void wait(void) {
webui_wait();
}
// Close a specific window.
void close(size_t window) {
webui_close(window);
}
// Set the window in Kiosk mode (Full screen)
void set_kiosk(size_t window, bool status) {
webui_set_kiosk(window, status);
}
// Close all opened windows. wait() will break.
void exit(void) {
webui_exit();
}
// -- Other ---------------------------
// Check a specific window if it's still running
bool is_shown(size_t window) {
return webui_is_shown(window);
}
// Set the maximum time in seconds to wait for browser to start
void set_timeout(unsigned int second) {
webui_set_timeout(second);
}
// Set the default embedded HTML favicon
void set_icon(size_t window, std::string icon, std::string icon_type) {
webui_set_icon(window, icon.c_str(), icon_type.c_str());
}
// Allow the window URL to be re-used in normal web browsers
void set_multi_access(size_t window, bool status) {
webui_set_multi_access(window, status);
}
// -- JavaScript ----------------------
// Quickly run a JavaScript (no response waiting).
bool run(size_t window, std::string script) {
return webui_run(window, script.c_str());
}
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
bool script(size_t window, std::string script, unsigned int timeout, char* buffer, size_t buffer_length) {
return webui_script(window, script.c_str(), timeout, buffer, buffer_length);
}
// Chose between Deno and Nodejs runtime for .js and .ts files.
void set_runtime(size_t window, unsigned int runtime) {
webui_set_runtime(window, runtime);
}
// Parse argument as integer.
long long int get_int(webui_event_t* e) {
return webui_get_int(e);
}
// Parse argument as string.
std::string get_string(webui_event_t* e) {
return std::string(webui_get_string(e));
}
// Parse argument as boolean.
bool get_bool(webui_event_t* e) {
return webui_get_bool(e);
}
// Return the response to JavaScript as integer.
void return_int(webui_event_t* e, long long int n) {
webui_return_int(e, n);
}
// Return the response to JavaScript as string.
void return_string(webui_event_t* e, std::string s) {
webui_return_string(e, &s[0]);
}
// Return the response to JavaScript as boolean.
void return_bool(webui_event_t* e, bool b) {
webui_return_bool(e, b);
}
// -- Interface -----------------------
// Bind a specific html element click event with a function. Empty element means all events. This replace bind(). The func is (Window, EventType, Element, Data, EventNumber)
unsigned int interface_bind(size_t window, std::string element, void (*func)(size_t, unsigned int, char*, char*, unsigned int)) {
return webui_interface_bind(window, element.c_str(), func);
}
// When using `interface_bind()` you need this function to easily set your callback response.
void interface_set_response(size_t window, webui_event_t* e, std::string response) {
webui_interface_set_response(window, e->event_number, response.c_str());
}
// Check if the app still running or not. This replace wait().
bool interface_is_app_running(void) {
return webui_interface_is_app_running();
}
// Get window unique ID
unsigned int interface_get_window_id(size_t window) {
return webui_interface_get_window_id(window);
}
}
#endif /* _WEBUI_HPP */

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,215 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_H
#define _WEBUI_H
#define WEBUI_VERSION "2.3.0"
#define WEBUI_MAX_IDS (512)
// Dynamic Library Exports
#if defined(_MSC_VER) || defined(__TINYC__)
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT __declspec(dllexport)
#endif
#else
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT extern
#endif
#endif
// -- C STD ---------------------------
#include <stdbool.h>
#include <inttypes.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stddef.h>
#include <time.h>
#include <errno.h>
#include <math.h>
#if defined(__GNUC__) || defined(__TINYC__)
#include <dirent.h>
#endif
// -- Windows -------------------------
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <direct.h>
#include <io.h>
#include <tchar.h>
#include <tlhelp32.h>
#define WEBUI_GET_CURRENT_DIR _getcwd
#define WEBUI_FILE_EXIST _access
#define WEBUI_POPEN _popen
#define WEBUI_PCLOSE _pclose
#define WEBUI_MAX_PATH MAX_PATH
#endif
// -- Linux ---------------------------
#ifdef __linux__
#include <unistd.h>
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/time.h>
#include <signal.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Apple ---------------------------
#ifdef __APPLE__
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/syslimits.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#include <signal.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Enums ---------------------------
enum webui_browsers {
AnyBrowser = 0, // 0. Default recommended web browser
Chrome, // 1. Google Chrome
Firefox, // 2. Mozilla Firefox
Edge, // 3. Microsoft Edge
Safari, // 4. Apple Safari
Chromium, // 5. The Chromium Project
Opera, // 6. Opera Browser
Brave, // 7. The Brave Browser
Vivaldi, // 8. The Vivaldi Browser
Epic, // 9. The Epic Browser
Yandex, // 10. The Yandex Browser
};
enum webui_runtimes {
None = 0, // 0. Prevent WebUI from using any runtime for .js and .ts files
Deno, // 1. Use Deno runtime for .js and .ts files
NodeJS, // 2. Use Nodejs runtime for .js files
};
enum webui_events {
WEBUI_EVENT_DISCONNECTED = 0, // 0. Window disconnection event
WEBUI_EVENT_CONNECTED, // 1. Window connection event
WEBUI_EVENT_MULTI_CONNECTION, // 2. New window connection event
WEBUI_EVENT_UNWANTED_CONNECTION, // 3. New unwanted window connection event
WEBUI_EVENT_MOUSE_CLICK, // 4. Mouse click event
WEBUI_EVENT_NAVIGATION, // 5. Window navigation event
WEBUI_EVENT_CALLBACK, // 6. Function call event
};
// -- Structs -------------------------
typedef struct webui_event_t {
size_t window; // The window object number
size_t event_type; // Event type
char* element; // HTML element ID
char* data; // JavaScript data
size_t event_number; // Internal WebUI
} webui_event_t;
// -- Definitions ---------------------
// Create a new webui window object.
WEBUI_EXPORT size_t webui_new_window(void);
// Create a new webui window object.
WEBUI_EXPORT void webui_new_window_id(size_t window_number);
// Get a free window ID that can be used with `webui_new_window_id()`
WEBUI_EXPORT size_t webui_get_new_window_id(void);
// Bind a specific html element click event with a function. Empty element means all events.
WEBUI_EXPORT size_t webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e));
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
WEBUI_EXPORT bool webui_show(size_t window, const char* content);
// Same as webui_show(). But with a specific web browser.
WEBUI_EXPORT bool webui_show_browser(size_t window, const char* content, size_t browser);
// Set the window in Kiosk mode (Full screen)
WEBUI_EXPORT void webui_set_kiosk(size_t window, bool status);
// Wait until all opened windows get closed.
WEBUI_EXPORT void webui_wait(void);
// Close a specific window only. The window object will still exist.
WEBUI_EXPORT void webui_close(size_t window);
// Close a specific window and free all memory resources.
WEBUI_EXPORT void webui_destroy(size_t window);
// Close all opened windows. webui_wait() will break.
WEBUI_EXPORT void webui_exit(void);
// -- Other ---------------------------
// Check a specific window if it's still running
WEBUI_EXPORT bool webui_is_shown(size_t window);
// Set the maximum time in seconds to wait for browser to start
WEBUI_EXPORT void webui_set_timeout(size_t second);
// Set the default embedded HTML favicon
WEBUI_EXPORT void webui_set_icon(size_t window, const char* icon, const char* icon_type);
// Allow the window URL to be re-used in normal web browsers
WEBUI_EXPORT void webui_set_multi_access(size_t window, bool status);
// -- JavaScript ----------------------
// Run JavaScript quickly with no waiting for the response.
WEBUI_EXPORT void webui_run(size_t window, const char* script);
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
WEBUI_EXPORT bool webui_script(size_t window, const char* script, size_t timeout, char* buffer, size_t buffer_length);
// Chose between Deno and Nodejs runtime for .js and .ts files.
WEBUI_EXPORT void webui_set_runtime(size_t window, size_t runtime);
// Parse argument as integer.
WEBUI_EXPORT long long int webui_get_int(webui_event_t* e);
// Parse argument as string.
WEBUI_EXPORT const char* webui_get_string(webui_event_t* e);
// Parse argument as boolean.
WEBUI_EXPORT bool webui_get_bool(webui_event_t* e);
// Return the response to JavaScript as integer.
WEBUI_EXPORT void webui_return_int(webui_event_t* e, long long int n);
// Return the response to JavaScript as string.
WEBUI_EXPORT void webui_return_string(webui_event_t* e, char* s);
// Return the response to JavaScript as boolean.
WEBUI_EXPORT void webui_return_bool(webui_event_t* e, bool b);
// Base64 encoding. Use this to safely send text based data to the UI. If it fails it will return NULL.
WEBUI_EXPORT char* webui_encode(const char* str);
// Base64 decoding. Use this to safely decode received Base64 text from the UI. If it fails it will return NULL.
WEBUI_EXPORT char* webui_decode(const char* str);
// Safely free a buffer allocated by WebUI, for example when using webui_encode().
WEBUI_EXPORT void webui_free(void* ptr);
// -- Interface -----------------------
// Bind a specific html element click event with a function. Empty element means all events. This replace webui_bind(). The func is (Window, EventType, Element, Data, EventNumber)
WEBUI_EXPORT size_t webui_interface_bind(size_t window, const char* element, void (*func)(size_t, size_t, char*, char*, size_t));
// When using `webui_interface_bind()` you may need this function to easily set your callback response.
WEBUI_EXPORT void webui_interface_set_response(size_t window, size_t event_number, const char* response);
// Check if the app still running or not. This replace webui_wait().
WEBUI_EXPORT bool webui_interface_is_app_running(void);
// Get window unique ID
WEBUI_EXPORT size_t webui_interface_get_window_id(size_t window);
// Get a unique ID. Same ID as `webui_bind()`. Return > 0 if bind exist.
WEBUI_EXPORT size_t webui_interface_get_bind_id(size_t window, const char* element);
#endif /* _WEBUI_H */

Binary file not shown.

View File

@ -1,198 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_H
#define _WEBUI_H
#define WEBUI_VERSION "2.3.0"
// Dynamic Library Exports
#if defined(_MSC_VER) || defined(__TINYC__)
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT __declspec(dllexport)
#endif
#else
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT extern
#endif
#endif
// -- C STD ---------------------------
#include <stdbool.h>
#include <inttypes.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stddef.h>
#include <time.h>
#include <errno.h>
#include <math.h>
#if defined(__GNUC__) || defined(__TINYC__)
#include <dirent.h>
#endif
// -- Windows -------------------------
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <direct.h>
#include <io.h>
#include <tchar.h>
#include <tlhelp32.h>
#define WEBUI_GET_CURRENT_DIR _getcwd
#define WEBUI_FILE_EXIST _access
#define WEBUI_POPEN _popen
#define WEBUI_PCLOSE _pclose
#define WEBUI_MAX_PATH MAX_PATH
#endif
// -- Linux ---------------------------
#ifdef __linux__
#include <unistd.h>
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/time.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Apple ---------------------------
#ifdef __APPLE__
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/syslimits.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Enums ---------------------------
enum webui_browsers {
AnyBrowser = 0, // 0. Default recommended web browser
Chrome, // 1. Google Chrome
Firefox, // 2. Mozilla Firefox
Edge, // 3. Microsoft Edge
Safari, // 4. Apple Safari
Chromium, // 5. The Chromium Project
Opera, // 6. Opera Browser
Brave, // 7. The Brave Browser
Vivaldi, // 8. The Vivaldi Browser
Epic, // 9. The Epic Browser
Yandex, // 10. The Yandex Browser
};
enum webui_runtimes {
None = 0, // 0. Prevent WebUI from using any runtime for .js and .ts files
Deno, // 1. Use Deno runtime for .js and .ts files
NodeJS, // 2. Use Nodejs runtime for .js files
};
enum webui_events {
WEBUI_EVENT_DISCONNECTED = 0, // 0. Window disconnection event
WEBUI_EVENT_CONNECTED, // 1. Window connection event
WEBUI_EVENT_MULTI_CONNECTION, // 2. New window connection event
WEBUI_EVENT_UNWANTED_CONNECTION, // 3. New unwanted window connection event
WEBUI_EVENT_MOUSE_CLICK, // 4. Mouse click event
WEBUI_EVENT_NAVIGATION, // 5. Window navigation event
WEBUI_EVENT_CALLBACK, // 6. Function call event
};
// -- Structs -------------------------
typedef struct webui_event_t {
size_t window; // Pointer to the window object
unsigned int event_type; // Event type
char* element; // HTML element ID
char* data; // JavaScript data
unsigned int event_number; // Internal WebUI
} webui_event_t;
// -- Definitions ---------------------
// Create a new webui window object.
WEBUI_EXPORT size_t webui_new_window(void);
// Bind a specific html element click event with a function. Empty element means all events.
WEBUI_EXPORT unsigned int webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e));
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
WEBUI_EXPORT bool webui_show(size_t window, const char* content);
// Same as webui_show(). But with a specific web browser.
WEBUI_EXPORT bool webui_show_browser(size_t window, const char* content, unsigned int browser);
// Set the window in Kiosk mode (Full screen)
WEBUI_EXPORT void webui_set_kiosk(size_t window, bool status);
// Wait until all opened windows get closed.
WEBUI_EXPORT void webui_wait(void);
// Close a specific window.
WEBUI_EXPORT void webui_close(size_t window);
// Close all opened windows. webui_wait() will break.
WEBUI_EXPORT void webui_exit(void);
// -- Other ---------------------------
// Check a specific window if it's still running
WEBUI_EXPORT bool webui_is_shown(size_t window);
// Set the maximum time in seconds to wait for browser to start
WEBUI_EXPORT void webui_set_timeout(unsigned int second);
// Set the default embedded HTML favicon
WEBUI_EXPORT void webui_set_icon(size_t window, const char* icon, const char* icon_type);
// Allow the window URL to be re-used in normal web browsers
WEBUI_EXPORT void webui_set_multi_access(size_t window, bool status);
// -- JavaScript ----------------------
// Run JavaScript quickly with no waiting for the response.
WEBUI_EXPORT bool webui_run(size_t window, const char* script);
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
WEBUI_EXPORT bool webui_script(size_t window, const char* script, unsigned int timeout, char* buffer, size_t buffer_length);
// Chose between Deno and Nodejs runtime for .js and .ts files.
WEBUI_EXPORT void webui_set_runtime(size_t window, unsigned int runtime);
// Parse argument as integer.
WEBUI_EXPORT long long int webui_get_int(webui_event_t* e);
// Parse argument as string.
WEBUI_EXPORT const char* webui_get_string(webui_event_t* e);
// Parse argument as boolean.
WEBUI_EXPORT bool webui_get_bool(webui_event_t* e);
// Return the response to JavaScript as integer.
WEBUI_EXPORT void webui_return_int(webui_event_t* e, long long int n);
// Return the response to JavaScript as string.
WEBUI_EXPORT void webui_return_string(webui_event_t* e, char* s);
// Return the response to JavaScript as boolean.
WEBUI_EXPORT void webui_return_bool(webui_event_t* e, bool b);
// -- Interface -----------------------
// Bind a specific html element click event with a function. Empty element means all events. This replace webui_bind(). The func is (Window, EventType, Element, Data, EventNumber)
WEBUI_EXPORT unsigned int webui_interface_bind(size_t window, const char* element, void (*func)(size_t, unsigned int, char*, char*, unsigned int));
// When using `webui_interface_bind()` you may need this function to easily set your callback response.
WEBUI_EXPORT void webui_interface_set_response(size_t window, unsigned int event_number, const char* response);
// Check if the app still running or not. This replace webui_wait().
WEBUI_EXPORT bool webui_interface_is_app_running(void);
// Get window unique ID
WEBUI_EXPORT unsigned int webui_interface_get_window_id(size_t window);
#endif /* _WEBUI_H */

View File

@ -1,153 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_HPP
#define _WEBUI_HPP
// C++ STD
#include <string>
// WebUI C Header
extern "C" {
#include "webui.h"
}
namespace webui {
// Create a new webui window object.
size_t new_window(void) {
return webui_new_window();
}
// Bind a specific html element click event with a function. Empty element means all events.
unsigned int bind(size_t window, std::string element, void (*func)(webui_event_t* e)) {
return webui_bind(window, element.c_str(), func);
}
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
bool show(size_t window, std::string content) {
return webui_show(window, content.c_str());
}
// Same as show(). But with a specific web browser.
bool show_browser(size_t window, std::string content, unsigned int browser) {
return webui_show_browser(window, content.c_str(), browser);
}
// Wait until all opened windows get closed.
void wait(void) {
webui_wait();
}
// Close a specific window.
void close(size_t window) {
webui_close(window);
}
// Set the window in Kiosk mode (Full screen)
void set_kiosk(size_t window, bool status) {
webui_set_kiosk(window, status);
}
// Close all opened windows. wait() will break.
void exit(void) {
webui_exit();
}
// -- Other ---------------------------
// Check a specific window if it's still running
bool is_shown(size_t window) {
return webui_is_shown(window);
}
// Set the maximum time in seconds to wait for browser to start
void set_timeout(unsigned int second) {
webui_set_timeout(second);
}
// Set the default embedded HTML favicon
void set_icon(size_t window, std::string icon, std::string icon_type) {
webui_set_icon(window, icon.c_str(), icon_type.c_str());
}
// Allow the window URL to be re-used in normal web browsers
void set_multi_access(size_t window, bool status) {
webui_set_multi_access(window, status);
}
// -- JavaScript ----------------------
// Quickly run a JavaScript (no response waiting).
bool run(size_t window, std::string script) {
return webui_run(window, script.c_str());
}
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
bool script(size_t window, std::string script, unsigned int timeout, char* buffer, size_t buffer_length) {
return webui_script(window, script.c_str(), timeout, buffer, buffer_length);
}
// Chose between Deno and Nodejs runtime for .js and .ts files.
void set_runtime(size_t window, unsigned int runtime) {
webui_set_runtime(window, runtime);
}
// Parse argument as integer.
long long int get_int(webui_event_t* e) {
return webui_get_int(e);
}
// Parse argument as string.
std::string get_string(webui_event_t* e) {
return std::string(webui_get_string(e));
}
// Parse argument as boolean.
bool get_bool(webui_event_t* e) {
return webui_get_bool(e);
}
// Return the response to JavaScript as integer.
void return_int(webui_event_t* e, long long int n) {
webui_return_int(e, n);
}
// Return the response to JavaScript as string.
void return_string(webui_event_t* e, std::string s) {
webui_return_string(e, &s[0]);
}
// Return the response to JavaScript as boolean.
void return_bool(webui_event_t* e, bool b) {
webui_return_bool(e, b);
}
// -- Interface -----------------------
// Bind a specific html element click event with a function. Empty element means all events. This replace bind(). The func is (Window, EventType, Element, Data, EventNumber)
unsigned int interface_bind(size_t window, std::string element, void (*func)(size_t, unsigned int, char*, char*, unsigned int)) {
return webui_interface_bind(window, element.c_str(), func);
}
// When using `interface_bind()` you need this function to easily set your callback response.
void interface_set_response(size_t window, webui_event_t* e, std::string response) {
webui_interface_set_response(window, e->event_number, response.c_str());
}
// Check if the app still running or not. This replace wait().
bool interface_is_app_running(void) {
return webui_interface_is_app_running();
}
// Get window unique ID
unsigned int interface_get_window_id(size_t window) {
return webui_interface_get_window_id(window);
}
}
#endif /* _WEBUI_HPP */

Binary file not shown.

Binary file not shown.

Binary file not shown.

6
bridge/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Do not track Nodejs output files
node_modules/
*.json
# Do not track js2c.py output files
*.js

47
bridge/README.md Normal file
View File

@ -0,0 +1,47 @@
# 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](https://esbuild.github.io/) to produce `webui.js`, then converted to C header using the Python script `js2c.py` to generate `webui_bridge.h`.
### Windows
- Install [Python](https://www.python.org/downloads/)
- Install [Node.js](https://nodejs.org/en/download)
- cd `webui\bridge`
- `npm install esbuild`
- `.\node_modules\.bin\esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=.\ .\webui.ts`
- `python js2c.py`
### Windows PowerShell
- cd `webui\bridge`
- `./build.ps1`
- If you get _running scripts is disabled on this
system_ error. Then run `Set-ExecutionPolicy RemoteSigned` to enable script execution. After done, you can roll back by running `Set-ExecutionPolicy Restricted`
### Linux
- Install [Python](https://www.python.org/downloads/)
- Install [Node.js](https://nodejs.org/en/download)
- cd `webui/bridge`
- `npm install esbuild`
- `./node_modules/.bin/esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=./ ./webui.ts`
- `python js2c.py`
### Linux Bash
- cd `webui\bridge`
- sh `./build.sh`
### macOS
- Install [Python](https://www.python.org/downloads/)
- Install [Node.js](https://nodejs.org/en/download)
- cd `webui/bridge`
- `npm install esbuild`
- `./node_modules/.bin/esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=./ ./webui.ts`
- `python js2c.py`
### macOS Bash
- cd `webui\bridge`
- sh `./build.sh`

45
bridge/build.bat Normal file
View File

@ -0,0 +1,45 @@
@echo off
SETLOCAL EnableDelayedExpansion
REM Get current location and project root
cd %~dp0
FOR /F "tokens=*" %%i IN ('git rev-parse --show-toplevel') DO SET project_root=%%i
cd %project_root%/bridge
REM Check which python command is available
SET python_cmd=python
@REM python3 --version > NUL 2>&1
@REM IF %errorlevel%==0 (
@REM SET python_cmd=python3
@REM ) ELSE (
@REM python --version > NUL 2>&1
@REM IF %errorlevel%==0 (
@REM SET python_cmd=python
@REM ) ELSE (
@REM echo Error: Please install Python.
@REM cd %cd%
@REM exit /b
@REM )
@REM )
REM Check if node_modules\esbuild exists, if not, install using npm
IF NOT EXIST "%project_root%\bridge\node_modules\esbuild\" (
where npm > NUL 2>&1
IF %errorlevel%==0 (
echo Installing esbuild...
npm install --prefix ./ esbuild
) ELSE (
echo Error: Please install NPM.
cd %cd%
exit /b
)
)
REM Transpile WebUI-Bridge (TS to JS) & Convert WebUI-Bridge (JS to C)
echo Transpile and bundle WebUI-Bridge from TypeScript to JavaScript...
.\node_modules\.bin\esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --minify-syntax --minify-whitespace --outdir=. ./webui.ts & %python_cmd% js2c.py
echo Done.
cd %cd%
ENDLOCAL

71
bridge/build.ps1 Normal file
View File

@ -0,0 +1,71 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
Set-StrictMode -version latest
$ErrorActionPreference="Stop"
$current_location = Get-Location
$project_root = git rev-parse --show-toplevel
Set-Location $project_root/bridge
$silent=$false
$log_level=$null
# Arguments
foreach ($opt in $args) {
switch ($opt) {
"--silent" { $silent = $true }
default {
Write-Host "Invalid option: $opt"
exit
}
}
}
if ($silent) { $log_level = "--log-level=warning" }
$ErrorActionPreference="SilentlyContinue"
# Check which python command is available
$commandResult = python3 --version 2>&1 > $null
if (!$?) {
$commandResult = python --version 2>&1 > $null
if (!$?) {
Write-Host "Error: Please install Python."
Set-Location $current_location
exit
}
else {
$python_cmd = "python"
}
} else {
$python_cmd = "python3"
}
$ErrorActionPreference="Stop"
# Check if node_modules\esbuild exists, if not, install using npm
if (-not (Test-Path "$project_root\bridge\node_modules\esbuild")) {
if (Get-Command npm -ErrorAction SilentlyContinue) {
if (!$silent) { Write-Host "Installing esbuild..." }
npm install --prefix ./ esbuild
} else {
Write-Host "Error: Please install NPM."
Set-Location $current_location
exit
}
}
# Transpile WebUI-Bridge (TS to JS)
if (!$silent) { Write-Host "Transpile and bundle WebUI-Bridge from TypeScript to JavaScript..." }
.\node_modules\.bin\esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --minify-syntax --minify-whitespace --outdir=. ./webui.ts $log_level
# Convert WebUI-Bridge (JS to C)
if (!$silent) { Write-Host "Convert WebUI-Bridge JavaScript to C Header..." }
& $python_cmd js2c.py
# Done
if (!$silent) { Write-Host "Done." }
Set-Location $current_location

37
bridge/build.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
project_root=$(git rev-parse --show-toplevel)
cd $project_root/bridge
# Loop through all arguments
for opt in "$@"; do
case $opt in
--silent)
silent=true
;;
*)
echo "Invalid option: $opt"
exit 0
;;
esac
shift # Move to the next argument
done
if [ "$silent" = true ]; then log_level=--log-level=warning; fi
if [ "$silent" != true ]; then echo "Transpile and bundle TS sources to webui.js"; fi
esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --minify-syntax --minify-whitespace --outdir=. ./webui.ts $log_level
if [ "$silent" != true ]; then echo "Convert JS source to C header"; fi
python3 js2c.py
if [ "$silent" != true ]; then echo "Done."; fi

64
bridge/js2c.py Normal file
View File

@ -0,0 +1,64 @@
# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# WebUI JavaScript to C Header
def js_to_c_header(input_filename, output_filename):
try:
print(f"Converting '{input_filename}' to '{output_filename}'...")
# comment
comment = (
"// WebUI v2.5.0-beta.4\n"
"// https://webui.me\n"
"// https://github.com/webui-dev/webui\n"
"// Copyright (c) 2020-2025 Hassan Draga.\n"
"// Licensed under MIT License.\n"
"// All rights reserved.\n"
"// Canada.\n\n"
)
# Read JS file content
with open(input_filename, 'r', encoding='utf-8') as file_js:
content = file_js.read()
file_js.close()
# Add comment to js
new_content = comment + content
with open(input_filename, 'w') as file_js:
file_js.write(new_content)
file_js.close()
# Convert each character in JS content to its hexadecimal value
hex_values = ["0x{:02x}".format(ord(char)) for char in new_content]
# Prepare the content for the C header file
header_content = (
comment +
"// --- PLEASE DO NOT EDIT THIS FILE -------\n"
"// --- THIS FILE IS GENERATED BY JS2C.PY --\n\n"
"#ifndef WEBUI_BRIDGE_H\n"
"#define WEBUI_BRIDGE_H\n"
"unsigned char webui_javascript_bridge[] = { "
)
# Split the hexadecimal values to make the output more readable, adding a new line every 10 values
for i in range(0, len(hex_values), 10):
header_content += "\n " + ', '.join(hex_values[i:i+10]) + ','
header_content += "\n 0x00\n};\n\n#endif // WEBUI_BRIDGE_H"
# Write the header content to the output file
with open(output_filename, 'w', encoding='utf-8') as file_h:
file_h.write(header_content)
file_h.close()
except FileNotFoundError:
print(f"Error: File '{input_filename}' not found.")
return
# Main
js_to_c_header('webui.js', 'webui_bridge.h')

56
bridge/utils.ts Normal file
View File

@ -0,0 +1,56 @@
/*
https://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2025 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
File: WebUI Bridge Utils
Copyright (c) 2024 Oculi Julien.
*/
/**
* Allows you to automatically bind an event listener to newly added
* elements that match a specific selector within a given root element.
* Track dom update to rebind event listeners automatically.
*
* @param {HTMLElement} root - The root element to observe for changes.
* @param {string} targetSelector - Query selector matching elements that you want to bind the event listener to.
* @param {K} type - Type of event listener to bind (same as for addEventListener).
* @param listener - Event listener to bind (same as for addEventListener).
* @param {boolean | AddEventListenerOptions} [options] - Event listener options (same as for addEventListener).
* @returns the used observer to allow disconnect.
*/
export function addRefreshableEventListener<K extends keyof HTMLElementEventMap>(
root: HTMLElement,
targetSelector: string,
type: K,
listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown,
options?: boolean | AddEventListenerOptions,
) {
function rebindListener(mutations: MutationRecord[]) {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (!(node instanceof HTMLElement)) return; // Target only html elements
if (node.matches(targetSelector)) {
// Bind event on added nodes
node.addEventListener<K>(type, listener, options);
}
for (const child of node.querySelectorAll(targetSelector)) {
if (!(child instanceof HTMLElement)) continue; //Target only html elements
child.addEventListener<K>(type, listener, options);
}
}
}
}
const observer = new MutationObserver(rebindListener); //Set mutation observer callback
observer.observe(root, { subtree: true, childList: true }); // Observe root element and all his children
return observer; // Allow user to stop observer for performance issues
}
/**
* Async function constructor
*/
export const AsyncFunction = async function () {}.constructor;

974
bridge/webui.ts Normal file
View File

@ -0,0 +1,974 @@
'use-strict'; // Force strict mode for transpiled
/*
WebUI Bridge
https://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2025 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
Converted from JavaScript to TypeScript
By Oculi Julien. Copyright (c) 2023.
*/
//@ts-ignore use *.ts import real extension
import { AsyncFunction, addRefreshableEventListener } from './utils.ts';
type DataTypes = string | number | boolean | Uint8Array;
class WebuiBridge {
// WebUI Settings
#secure: boolean;
#token: number;
#port: number;
#log: boolean;
#winX: number;
#winY: number;
#winW: number;
#winH: number;
// Frameless Dragging
#isDragging: boolean = false;
#initialMouseX: number = 0;
#initialMouseY: number = 0;
#initialWindowX: number = window.screenX || window.screenLeft;
#initialWindowY: number = window.screenY || window.screenTop;
#currentWindowX: number = window.screenX || window.screenLeft;
#currentWindowY: number = window.screenY || window.screenTop;
// Internals
#ws: WebSocket;
#wsStayAlive: boolean = true;
#wsStayAliveTimeout: number = 500;
#wsWasConnected: boolean = false;
#TokenAccepted: boolean = false;
#closeReason: number = 0;
#closeValue: string;
#AllEvents: boolean = false;
#callPromiseID: Uint16Array = new Uint16Array(1);
#callPromiseResolve: (((data: string) => unknown) | undefined)[] = [];
#allowNavigation: boolean = true;
#sendQueue: Uint8Array[] = [];
#isSending: boolean = false;
#bindsList: string[];
// WebUI Const
#WEBUI_SIGNATURE: number = 221;
#CMD_JS: number = 254;
#CMD_JS_QUICK: number = 253;
#CMD_CLICK: number = 252;
#CMD_NAVIGATION: number = 251;
#CMD_CLOSE: number = 250;
#CMD_CALL_FUNC: number = 249;
#CMD_SEND_RAW: number = 248;
#CMD_NEW_ID: number = 247;
#CMD_MULTI: number = 246;
#CMD_CHECK_TK: number = 245;
#CMD_WINDOW_DRAG: number = 244;
#CMD_WINDOW_RESIZED: number = 243;
#MULTI_CHUNK_SIZE: number = 65500;
#PROTOCOL_SIZE: number = 8; // Protocol header size in bytes
#PROTOCOL_SIGN: number = 0; // Protocol byte position: Signature (1 Byte)
#PROTOCOL_TOKEN: number = 1; // Protocol byte position: Token (4 Bytes)
#PROTOCOL_ID: number = 5; // Protocol byte position: ID (2 Bytes)
#PROTOCOL_CMD: number = 7; // Protocol byte position: Command (1 Byte)
#PROTOCOL_DATA: number = 8; // Protocol byte position: Data (n Byte)
#Token: Uint32Array = new Uint32Array(1);
#Ping: Boolean = true;
// Events
#eventsCallback: ((event: number) => void) | null = null;
event = {
// TODO: Make `event` static and solve the ESBUILD `_WebuiBridge` issue.
CONNECTED: 0,
DISCONNECTED: 1,
};
// Constructor
constructor({
secure = false,
token = 0,
port = 0,
log = false,
winX = 0,
winY = 0,
winW = 0,
winH = 0,
}: {
secure: boolean;
token: number;
port: number;
log?: boolean;
winX: number;
winY: number;
winW: number;
winH: number;
}) {
// Constructor arguments are injected by webui.c
this.#secure = secure;
this.#token = token;
this.#port = port;
this.#log = log;
this.#winX = winX;
this.#winY = winY;
this.#winW = winW;
this.#winH = winH;
// Token
this.#Token[0] = this.#token;
// Instance
if ('webui' in globalThis) {
throw new Error('Sorry. WebUI is already defined, only one instance is allowed.');
}
// Positioning the current window
if (this.#winX !== undefined && this.#winY !== undefined) {
// window.moveTo(this.#winX, this.#winY);
}
// Resize the current window
if (this.#winW !== undefined && this.#winH !== undefined) {
// window.resizeTo(this.#winW, this.#winH);
}
// WebSocket
if (!('WebSocket' in window)) {
alert('Sorry. WebSocket is not supported by your web browser.');
if (!this.#log) globalThis.close();
}
// Connect to the backend application
this.#start();
// Navigation event listener
if ('navigation' in globalThis) {
globalThis.navigation.addEventListener('navigate', (event) => {
if (!this.#allowNavigation) {
if (this.#AllEvents && (this.#wsIsConnected())) {
event.preventDefault();
const url = new URL(event.destination.url);
if (this.#log) console.log(`WebUI -> DOM -> Navigation Event [${url.href}]`);
this.#sendEventNavigation(url.href);
}
}
});
} else {
// Click navigation event listener
addRefreshableEventListener(document.body, 'a', 'click', (event) => {
if (!this.#allowNavigation) {
if (this.#AllEvents && (this.#wsIsConnected())) {
event.preventDefault();
const { href } = event.target as HTMLAnchorElement;
if (this.#log) console.log(`WebUI -> DOM -> Navigation Click Event [${href}]`);
this.#sendEventNavigation(href);
}
}
});
}
// Prevent F5 refresh
document.addEventListener('keydown', (event) => {
if (this.#log) return; // Allowed in debug mode
if (event.key === 'F5') event.preventDefault();
});
// Frameless Dragging
document.addEventListener("mousemove", (e) => {
// WebUI `-webkit-app-region: drag;` custom implementation
if (e.buttons !== 1) {
this.#isDragging = false;
return;
}
if (!this.#isDragging) {
let target = e.target;
while (target) {
if (window.getComputedStyle(target).getPropertyValue("-webkit-app-region") === "drag") {
this.#initialMouseX = e.screenX;
this.#initialMouseY = e.screenY;
this.#initialWindowX = this.#currentWindowX;
this.#initialWindowY = this.#currentWindowY;
this.#isDragging = true;
break;
}
target = target.parentElement;
}
return;
}
// Calculate window position relative to cursor movement
const deltaX = e.screenX - this.#initialMouseX;
const deltaY = e.screenY - this.#initialMouseY;
let newX = this.#initialWindowX + deltaX;
let newY = this.#initialWindowY + deltaY;
// Fix out of screen
if (newX < 0) newX = 0;
if (newY < 0) newY = 0;
// Move the window
this.#sendDrag(newX, newY);
// Update the last window position
this.#currentWindowX = newX;
this.#currentWindowY = newY;
});
// Stop frameless dragging on mouse release
document.addEventListener("mouseup", () => {
this.#isDragging = false;
});
onbeforeunload = () => {
this.#close();
};
setTimeout(() => {
if (!this.#wsWasConnected) {
alert('Sorry. WebUI failed to connect to the backend application. Please try again.');
}
}, 1500);
}
// Methods
#close(reason = 0, value = '') {
this.#closeReason = reason;
this.#closeValue = value;
if (this.#wsIsConnected()) {
this.#ws.close();
}
}
#freezeUi() {
setTimeout(() => {
if (!this.#wsIsConnected()) {
if (document.getElementById('webui-error-connection-lost')) return;
const div = document.createElement('div');
div.id = 'webui-error-connection-lost';
Object.assign(div.style, {
position: 'relative',
top: '0',
left: '0',
width: '100%',
backgroundColor: '#ff4d4d',
color: '#fff',
textAlign: 'center',
padding: '2px 0',
fontFamily: 'Arial, sans-serif',
fontSize: '14px',
zIndex: '1000',
lineHeight: '1'
});
div.innerText = 'WebUI Error: Connection with the backend is lost.';
document.body.insertBefore(div, document.body.firstChild);
}
}, 1000);
}
#unfreezeUI() {
const div = document.getElementById('webui-error-connection-lost');
if (div) {
div.remove();
}
}
#isTextBasedCommand(cmd: number): Boolean {
if (cmd !== this.#CMD_SEND_RAW) return true;
return false;
}
#parseDimensions(input: string): {x: number; y: number; width: number; height: number} {
try {
const parts = input.split(',');
if (parts.length !== 4) return {x: 0, y: 0, width: 0, height: 0};
const x = parseFloat(parts[0]),
y = parseFloat(parts[1]),
width = parseFloat(parts[2]),
height = parseFloat(parts[3]);
return [x, y, width, height].some(isNaN) ? {x: 0, y: 0, width: 0, height: 0} : {x, y, width, height};
} catch {
return {x: 0, y: 0, width: 0, height: 0};
}
}
#getDataStrFromPacket(buffer: Uint8Array, startIndex: number): string {
let stringBytes: number[] = [];
for (let i = startIndex; i < buffer.length; i++) {
if (buffer[i] === 0) {
// Check for null byte
break;
}
stringBytes.push(buffer[i]);
}
// Convert the array of bytes to a string
const stringText = new TextDecoder().decode(new Uint8Array(stringBytes));
return stringText;
}
#getID(buffer: Uint8Array, index: number): number {
if (index < 0 || index >= buffer.length - 1) {
throw new Error('Index out of bounds or insufficient data.');
}
const firstByte = buffer[index];
const secondByte = buffer[index + 1];
const combined = (secondByte << 8) | firstByte; // Works only for little-endian
return combined;
}
#addToken(buffer: Uint8Array, value: number, index: number): void {
if (value < 0 || value > 0xffffffff) {
throw new Error('Number is out of the range for 4 bytes representation.');
}
if (index < 0 || index > buffer.length - 4) {
throw new Error('Index out of bounds or insufficient space in buffer.');
}
// WebUI expect Little-endian (Work for Little/Big endian platforms)
buffer[index] = value & 0xff; // Least significant byte
buffer[index + 1] = (value >>> 8) & 0xff;
buffer[index + 2] = (value >>> 16) & 0xff;
buffer[index + 3] = (value >>> 24) & 0xff; // Most significant byte
}
#addID(buffer: Uint8Array, value: number, index: number): void {
if (value < 0 || value > 0xffff) {
throw new Error('Number is out of the range for 2 bytes representation.');
}
if (index < 0 || index > buffer.length - 2) {
throw new Error('Index out of bounds or insufficient space in buffer.');
}
// WebUI expect Little-endian (Work for Little/Big endian platforms)
buffer[index] = value & 0xff; // Least significant byte
buffer[index + 1] = (value >>> 8) & 0xff; // Most significant byte
}
#start() {
this.#keepAlive();
this.#callPromiseID[0] = 0;
// Connect to the backend application
this.#wsConnect();
}
#keepAlive = async () => {
while (true) {
if (this.#Ping) {
// Some web browsers may close the connection
// let's send a void message to keep WS open
this.#sendData(new TextEncoder().encode('ping'));
} else {
// There is an active communication
this.#Ping = true;
}
await new Promise((resolve) => setTimeout(resolve, 20000));
}
};
#clicksListener() {
document.querySelectorAll<HTMLElement>("[id]").forEach(e => {
if (this.#AllEvents || ((e.id !== '') && (this.#bindsList.includes(e.id)))) {
if (e.id && !e.dataset.webui_click_is_set) {
e.dataset.webui_click_is_set = "true";
e.addEventListener("click", () => this.#sendClick(e.id));
}
}
});
}
async #sendData(packet: Uint8Array) {
this.#Ping = false;
if ((!this.#wsIsConnected()) || packet === undefined) return;
// Enqueue the packet
this.#sendQueue.push(packet);
if (this.#isSending) return;
this.#isSending = true;
while (this.#sendQueue.length > 0) {
const currentPacket = this.#sendQueue.shift()!;
if (currentPacket.length < this.#MULTI_CHUNK_SIZE) {
this.#ws.send(currentPacket.buffer);
} else {
// Pre-packet to let WebUI be ready for multi packet
const pre_packet = Uint8Array.of(
this.#WEBUI_SIGNATURE,
0,
0,
0,
0, // Token (4 Bytes)
0,
0, // ID (2 Bytes)
this.#CMD_MULTI,
...new TextEncoder().encode(currentPacket.length.toString()),
0,
);
this.#ws.send(pre_packet.buffer);
// Send chunks
let offset = 0;
const sendChunk = async () => {
if (offset < currentPacket.length) {
const chunkSize = Math.min(this.#MULTI_CHUNK_SIZE, currentPacket.length - offset);
const chunk = currentPacket.subarray(offset, offset + chunkSize);
this.#ws.send(chunk);
offset += chunkSize;
await sendChunk();
}
};
await sendChunk();
}
}
this.#isSending = false;
}
#sendClick(elem: string) {
if (this.#wsIsConnected()) {
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Element]
const packet =
elem !== ''
? Uint8Array.of(
this.#WEBUI_SIGNATURE,
0,
0,
0,
0, // Token (4 Bytes)
0,
0, // ID (2 Bytes)
this.#CMD_CLICK,
...new TextEncoder().encode(elem),
0,
)
: Uint8Array.of(
this.#WEBUI_SIGNATURE,
0,
0,
0,
0, // Token (4 Bytes)
0,
0, // ID (2 Bytes)
this.#CMD_CLICK,
0,
);
this.#addToken(packet, this.#token, this.#PROTOCOL_TOKEN);
// this.#addID(packet, 0, this.#PROTOCOL_ID)
this.#sendData(packet);
if (this.#log) console.log(`WebUI -> Send Click [${elem}]`);
}
}
#checkToken() {
if (this.#wsIsConnected()) {
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
const packet =
Uint8Array.of(
this.#WEBUI_SIGNATURE,
0,
0,
0,
0, // Token (4 Bytes)
0,
0, // ID (2 Bytes)
this.#CMD_CHECK_TK,
0,
);
this.#addToken(packet, this.#token, this.#PROTOCOL_TOKEN);
// this.#addID(packet, 0, this.#PROTOCOL_ID)
this.#sendData(packet);
if (this.#log) console.log(`WebUI -> Send Token [0x${this.#token.toString(16).padStart(8, '0')}]`);
}
}
#sendEventNavigation(url: string) {
if (url !== '') {
if (this.#wsIsConnected()) {
if (this.#log) console.log(`WebUI -> Send Navigation Event [${url}]`);
const packet = Uint8Array.of(
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [URL]
this.#WEBUI_SIGNATURE,
0,
0,
0,
0, // Token (4 Bytes)
0,
0, // ID (2 Bytes)
this.#CMD_NAVIGATION,
...new TextEncoder().encode(url),
);
this.#addToken(packet, this.#token, this.#PROTOCOL_TOKEN);
// this.#addID(packet, 0, this.#PROTOCOL_ID)
this.#sendData(packet);
}
}
}
#sendDrag(x: number, y: number) {
if (this.#wsIsConnected()) {
if (this.#log) console.log(`WebUI -> Send Drag Event [${x}, ${y}]`);
const packet = Uint8Array.of(
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [X]
// 4: [Y]
this.#WEBUI_SIGNATURE,
0,
0,
0,
0, // Token (4 Bytes)
0,
0, // ID (2 Bytes)
this.#CMD_WINDOW_DRAG,
...new Uint8Array(new Int32Array([x]).buffer), // X (4 Bytes)
...new Uint8Array(new Int32Array([y]).buffer), // Y (4 Bytes)
);
this.#addToken(packet, this.#token, this.#PROTOCOL_TOKEN);
// this.#addID(packet, 0, this.#PROTOCOL_ID)
this.#sendData(packet);
}
}
#closeWindowTimer() {
setTimeout(function () {
globalThis.close();
}, 1000);
}
#updateBindsList() {
if (this.#bindsList.includes('')) {
this.#AllEvents = true;
this.#allowNavigation = false;
}
this.#generateCallObjects();
this.#clicksListener();
}
#toUint16(value: number): number {
return value & 0xffff;
}
#generateCallObjects() {
for (const bind of this.#bindsList) {
if (bind.trim()) {
const fn = bind;
if (fn.trim()) {
if (fn !== '__webui_core_api__') {
if (typeof (window as any)[fn] === 'undefined') {
this[fn] = (...args: DataTypes[]) => this.call(fn, ...args);
(window as any)[fn] = (...args: string[]) => this.call(fn, ...args);
if (this.#log) console.log(`WebUI -> Binding backend function [${fn}]`);
}
}
}
}
}
}
#callPromise(fn: string, ...args: DataTypes[]) {
--this.#callPromiseID[0];
const callId = this.#toUint16(this.#callPromiseID[0]);
// Combine lengths
let argsLengths = args
.map((arg) => {
if (typeof arg === 'object') {
// Uint8Array
return arg.length;
} else {
// string, number, boolean
return new TextEncoder().encode(arg.toString()).length;
}
})
.join(';');
// Combine values
let argsValues: Uint8Array = new Uint8Array();
for (const arg of args) {
let buffer: Uint8Array;
if (typeof arg === 'object') {
buffer = arg; // Uint8Array
} else {
// string, number, boolean
buffer = new TextEncoder().encode(arg.toString());
}
const temp = new Uint8Array(argsValues.length + buffer.length + 1);
temp.set(argsValues, 0);
temp.set(buffer, argsValues.length);
temp[argsValues.length + buffer.length] = 0x00;
argsValues = temp;
}
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Fn, Null, {LenLen...}, Null, {Data,Null,Data,Null...}]
let packet = new Uint8Array(0);
const packetPush = (data: Uint8Array) => {
const newPacket = new Uint8Array(packet.length + data.length);
newPacket.set(packet);
newPacket.set(data, packet.length);
packet = newPacket;
};
packetPush(new Uint8Array([this.#WEBUI_SIGNATURE]));
packetPush(new Uint8Array([0, 0, 0, 0])); // Token (4 Bytes)
packetPush(new Uint8Array([0, 0])); // ID (2 Bytes)
packetPush(new Uint8Array([this.#CMD_CALL_FUNC]));
packetPush(new TextEncoder().encode(fn));
packetPush(new Uint8Array([0]));
packetPush(new TextEncoder().encode(argsLengths));
packetPush(new Uint8Array([0]));
packetPush(new Uint8Array(argsValues));
this.#addToken(packet, this.#token, this.#PROTOCOL_TOKEN);
this.#addID(packet, callId, this.#PROTOCOL_ID);
return new Promise((resolve) => {
this.#callPromiseResolve[callId] = resolve;
this.#sendData(packet);
});
}
async callCore(fn: string, ...args: DataTypes[]): Promise<DataTypes> {
return this.call('__webui_core_api__', fn, ...args);
}
// -- WebSocket ----------------------------
#wsIsConnected(): boolean {
return ((this.#ws) && (this.#ws.readyState === WebSocket.OPEN));
}
#wsConnect(): void {
if (this.#wsIsConnected()) {
this.#ws.close();
}
this.#TokenAccepted = false;
const host = window.location.hostname;
const url = this.#secure ? ('wss://' + host) : ('ws://' + host);
this.#ws = new WebSocket(`${url}:${this.#port}/_webui_ws_connect`);
this.#ws.binaryType = 'arraybuffer';
this.#ws.onopen = this.#wsOnOpen.bind(this);
this.#ws.onmessage = this.#wsOnMessage.bind(this);
this.#ws.onclose = this.#wsOnClose.bind(this);
this.#ws.onerror = this.#wsOnError.bind(this);
}
#wsOnOpen = (event: Event) => {
this.#wsWasConnected = true;
this.#unfreezeUI();
if (this.#log) console.log('WebUI -> Connected');
this.#checkToken();
};
#wsOnError = (event: Event) => {
if (this.#log) console.log(`WebUI -> Connection failed.`);
};
#wsOnClose = (event: CloseEvent) => {
if (this.#closeReason === this.#CMD_NAVIGATION) {
this.#closeReason = 0;
if (this.#log) console.log(`WebUI -> Connection lost. Navigation to [${this.#closeValue}]`);
this.#allowNavigation = true;
globalThis.location.replace(this.#closeValue);
} else {
if (this.#wsStayAlive) {
// Re-connect
if (this.#log) console.log(`WebUI -> Connection lost (${event.code}). Reconnecting...`);
this.#freezeUi();
setTimeout(() => this.#wsConnect(), this.#wsStayAliveTimeout);
}
else if (this.#log) {
// Debug close
console.log(`WebUI -> Connection lost (${event.code})`);
this.#freezeUi();
} else {
// Release close
this.#closeWindowTimer();
}
}
// Event Callback
if (this.#eventsCallback) {
this.#eventsCallback(this.event.DISCONNECTED);
}
};
#wsOnMessage = async (event: MessageEvent) => {
const buffer8 = new Uint8Array(event.data);
if (buffer8.length < this.#PROTOCOL_SIZE) return;
if (buffer8[this.#PROTOCOL_SIGN] !== this.#WEBUI_SIGNATURE) return;
if (this.#isTextBasedCommand(buffer8[this.#PROTOCOL_CMD])) {
// UTF8 Text based commands
const callId = this.#getID(buffer8, this.#PROTOCOL_ID);
// Process Command
switch (buffer8[this.#PROTOCOL_CMD]) {
case this.#CMD_JS_QUICK:
case this.#CMD_JS:
{
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Script]
const script: string = this.#getDataStrFromPacket(buffer8, this.#PROTOCOL_DATA);
const scriptSanitize = script.replace(/(?:\r\n|\r|\n)/g, '\n');
if (this.#log) console.log(`WebUI -> CMD -> JS [${scriptSanitize}]`);
// Get callback result
let FunReturn = 'undefined';
let FunError = false;
try {
FunReturn = await AsyncFunction(scriptSanitize)();
} catch (e) {
FunError = true;
FunReturn = e.message;
}
// Stop if this is a quick call
if (buffer8[this.#PROTOCOL_CMD] === this.#CMD_JS_QUICK) return;
// Get the call return
if (FunReturn === undefined) {
FunReturn = 'undefined';
}
// Logging
if (this.#log && !FunError) console.log(`WebUI -> CMD -> JS -> Return Success [${FunReturn}]`);
if (this.#log && FunError) console.log(`WebUI -> CMD -> JS -> Return Error [${FunReturn}]`);
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Error, Script Response]
let packet = new Uint8Array(0);
const packetPush = (data: Uint8Array) => {
const newPacket = new Uint8Array(packet.length + data.length);
newPacket.set(packet);
newPacket.set(data, packet.length);
packet = newPacket;
};
const packetPushStr = (data: string) => {
const chunkSize = 1024 * 8;
if (data.length > chunkSize) {
const encoder = new TextEncoder();
for (let i = 0; i < data.length; i += chunkSize) {
const chunk = data.substring(i, Math.min(i + chunkSize, data.length));
const encodedChunk = encoder.encode(chunk);
packetPush(encodedChunk);
}
} else {
packetPush(new TextEncoder().encode(data));
}
};
packetPush(new Uint8Array([this.#WEBUI_SIGNATURE]));
packetPush(new Uint8Array([0, 0, 0, 0])); // Token (4 Bytes)
packetPush(new Uint8Array([0, 0])); // ID (2 Bytes)
packetPush(new Uint8Array([this.#CMD_JS]));
packetPush(new Uint8Array(FunError ? [1] : [0]));
packetPushStr(FunReturn);
packetPush(new Uint8Array([0]));
this.#addToken(packet, this.#token, this.#PROTOCOL_TOKEN);
this.#addID(packet, callId, this.#PROTOCOL_ID);
this.#sendData(packet);
}
break;
case this.#CMD_CALL_FUNC:
{
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Call Response]
const callResponse: string = this.#getDataStrFromPacket(buffer8, this.#PROTOCOL_DATA);
if (this.#log) {
console.log(`WebUI -> CMD -> Call Response [${callResponse}]`);
}
if (this.#callPromiseResolve[callId]) {
if (this.#log) {
console.log(`WebUI -> CMD -> Resolving Response #${callId}...`);
}
this.#callPromiseResolve[callId]?.(callResponse);
this.#callPromiseResolve[callId] = undefined;
}
}
break;
case this.#CMD_NAVIGATION:
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [URL]
const url: string = this.#getDataStrFromPacket(buffer8, this.#PROTOCOL_DATA);
if (this.#log) console.log(`WebUI -> CMD -> Navigation [${url}]`);
this.#close(this.#CMD_NAVIGATION, url);
break;
case this.#CMD_WINDOW_RESIZED:
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [x,y,width,height]
const widthAndHeight: string = this.#getDataStrFromPacket(buffer8, this.#PROTOCOL_DATA);
const { x, y, width, height } = this.#parseDimensions(widthAndHeight);
// Update drag positions
this.#currentWindowX = x;
this.#currentWindowY = y;
if (this.#log) console.log(`WebUI -> CMD -> Window Resized [x: ${x}, y: ${y}, width: ${width}, height: ${height}]`);
break;
case this.#CMD_NEW_ID:
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [New Element]
const newElement: string = this.#getDataStrFromPacket(buffer8, this.#PROTOCOL_DATA);
if (this.#log) console.log(`WebUI -> CMD -> New Bind ID [${newElement}]`);
if (!this.#bindsList.includes(newElement)) this.#bindsList.push(newElement);
// Generate objects
this.#updateBindsList();
break;
case this.#CMD_CLOSE:
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
if (this.#log) {
// Debug Close
console.log(`WebUI -> CMD -> Close`);
if (this.#wsIsConnected()) {
this.#wsStayAlive = false;
this.#ws.close();
}
}
else {
// Release Close
globalThis.close();
}
break;
case this.#CMD_CHECK_TK:
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Status]
// 5: [BindsList]
const status = (buffer8[this.#PROTOCOL_DATA] == 0 ? false : true);
const tokenHex = `0x${this.#token.toString(16).padStart(8, '0')}`;
if (status) {
if (this.#log) console.log(`WebUI -> CMD -> Token [${tokenHex}] Accepted`);
this.#TokenAccepted = true;
// Get binds list (CSV)
let csv: string = this.#getDataStrFromPacket(buffer8, this.#PROTOCOL_DATA + 1);
csv = csv.endsWith(',') ? csv.slice(0, -1) : csv;
this.#bindsList = csv.split(',');
// Generate objects
this.#updateBindsList();
// User event callback
if (this.#eventsCallback) {
this.#eventsCallback(this.event.CONNECTED);
}
}
else {
if (this.#log) console.log(`WebUI -> CMD -> Token [${tokenHex}] Not Accepted. Reload page...`);
// Refresh the page to get a new token
this.#allowNavigation = true;
this.#wsStayAlive = false;
globalThis.location.reload();
}
break;
}
} else {
// Raw-binary based commands
switch (buffer8[this.#PROTOCOL_CMD]) {
case this.#CMD_SEND_RAW:
// Protocol
// 0: [SIGNATURE]
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Function,Null,Raw Data]
// Get function name
const functionName: string = this.#getDataStrFromPacket(buffer8, this.#PROTOCOL_DATA);
// Get the raw data
const rawDataIndex: number = this.#PROTOCOL_DATA + functionName.length + 1;
const rawDataSize: number = (buffer8.length - rawDataIndex) - 1;
const userRawData = buffer8.subarray(rawDataIndex, (rawDataIndex + rawDataSize));
if (this.#log) console.log(`WebUI -> CMD -> Received Raw ${rawDataSize} bytes for [${functionName}()]`);
// Call the user function, and pass the raw data
if (typeof window[functionName] === 'function') window[functionName](userRawData);
else await AsyncFunction(functionName + '(userRawData)')();
break;
}
}
};
// -- Public APIs --------------------------
/**
* Call a backend function
*
* @param fn - binding name
* @param data - data to be send to the backend function
* @return - Response of the backend callback string
* @example - const res = await webui.call("myID", 123, true, "Hi", new Uint8Array([0x42, 0x43, 0x44]))
*/
async call(fn: string, ...args: DataTypes[]): Promise<DataTypes> {
if (!fn) return Promise.reject(new SyntaxError('No binding name is provided'));
if (!this.#wsIsConnected()) return Promise.reject(new Error('WebSocket is not connected'));
// Check binding list
if (fn !== '__webui_core_api__') {
if (!this.#AllEvents && !this.#bindsList.includes(`${fn}`))
return Promise.reject(new ReferenceError(`No binding was found for "${fn}"`));
}
// Call backend and wait for response
if (this.#log) console.log(`WebUI -> Calling [${fn}(...)]`);
const response = (await this.#callPromise(fn, ...args)) as string;
// WebUI lib accept `DataTypes` but return only string
if (typeof response !== 'string') return '';
return response;
}
/**
* Active or deactivate webui debug logging
*
* @param status - log status to set
*/
setLogging(status: boolean) {
if (status) {
console.log('WebUI -> Log Enabled.');
this.#log = true;
} else {
console.log('WebUI -> Log Disabled.');
this.#log = false;
}
}
/**
* Encode text into base64 string
*
* @param data - text string
*/
encode(data: string): string {
return btoa(data);
}
/**
* Decode base64 string into text
*
* @param data - base64 string
*/
decode(data: string): string {
return atob(data);
}
/**
* Set a callback to receive events like connect/disconnect
*
* @param callback - callback function `myCallback(e)`
* @example - webui.setEventCallback((e) => {if(e == webui.event.CONNECTED){ ... }});
*/
setEventCallback(callback: (e: number) => void): void {
this.#eventsCallback = callback;
}
/**
* Check if UI is connected to the back-end. The connection
* is done by including `webui.js` virtual file in the HTML.
*
* @return - Boolean `true` if connected
*/
isConnected(): boolean {
return ((this.#wsIsConnected()) && (this.#TokenAccepted));
}
/**
* Get OS high contrast preference.
*
* @return - Boolean `True` if OS is using high contrast theme
*/
async isHighContrast(): Promise<boolean> {
// Call a core function and wait for response
const response = await this.callCore("high_contrast") as boolean;
if (this.#log) console.log(`Core Response: [${response}]`);
return response;
}
/**
* When binding all events on the backend, WebUI blocks all navigation events
* and sends them to the backend. This API allows you to control that behavior.
*
* @param status - Boolean `True` means WebUI will allow navigations
* @example - webui.allowNavigation(true); // Allow navigation
* window.location.replace('www.test.com'); // This will now proceed as usual
*/
allowNavigation(status: boolean): void {
this.#allowNavigation = status;
}
}
// Export
type webui = WebuiBridge;
export default webui;
export type { WebuiBridge };
// Wait for the html to be parsed
addEventListener('load', () => {
document.body.addEventListener('contextmenu', (event) => event.preventDefault());
addRefreshableEventListener(document.body, 'input', 'contextmenu', (event) => event.stopPropagation());
});

1766
bridge/webui_bridge.h Normal file

File diff suppressed because it is too large Load Diff

210
build.zig Normal file
View File

@ -0,0 +1,210 @@
const std = @import("std");
const builtin = @import("builtin");
const Build = std.Build;
const OptimizeMode = std.builtin.OptimizeMode;
const Compile = Build.Step.Compile;
const Module = Build.Module;
const lib_name = "webui";
var global_log_level: std.log.Level = .warn;
/// Vendored dependencies of webui.
pub const Dependency = enum {
civetweb,
// TODO: Check and add all vendored dependencies, e.g. "webview"
};
const DebugDependencies = std.EnumSet(Dependency);
pub fn build(b: *Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const is_dynamic = b.option(bool, "dynamic", "build the dynamic library") orelse false;
const enable_tls = b.option(bool, "enable-tls", "enable TLS support") orelse false;
const verbose = b.option(std.log.Level, "verbose", "set verbose output") orelse .warn;
global_log_level = verbose;
// TODO: Support list of dependencies once support is limited to >0.13.0
const debug = b.option(Dependency, "debug", "enable dependency debug output");
const debug_dependencies = DebugDependencies.initMany(if (debug) |d| &.{d} else &.{});
if (enable_tls and !target.query.isNative()) {
log(.err, .WebUI, "cross compilation is not supported with TLS enabled", .{});
return error.InvalidBuildConfiguration;
}
log(.info, .WebUI, "Building {s} WebUI library{s}...", .{
if (is_dynamic) "dynamic" else "static",
if (enable_tls) " with TLS support" else "",
});
defer {
log(.info, .WebUI, "Done.", .{});
}
const webui = if (is_dynamic) b.addSharedLibrary(.{
.name = lib_name,
.target = target,
.optimize = optimize,
.pic = true,
}) else b.addStaticLibrary(.{
.name = lib_name,
.target = target,
.optimize = optimize,
});
try addLinkerFlags(b, webui, enable_tls, debug_dependencies);
b.installArtifact(webui);
try build_examples(b, webui);
}
fn addLinkerFlags(
b: *Build,
webui: *Compile,
enable_tls: bool,
debug_dependencies: DebugDependencies,
) !void {
const webui_target = webui.rootModuleTarget();
const is_windows = webui_target.os.tag == .windows;
const is_darwin = webui_target.os.tag == .macos;
const debug = webui.root_module.optimize.? == .Debug;
// Prepare compiler flags.
const no_tls_flags: []const []const u8 = &.{"-DNO_SSL"};
const tls_flags: []const []const u8 = &.{ "-DWEBUI_TLS", "-DNO_SSL_DL", "-DOPENSSL_API_1_1" };
const civetweb_flags: []const []const u8 = &.{
"-DNO_CACHING",
"-DNO_CGI",
"-DUSE_WEBSOCKET",
"-Wno-error=date-time",
};
if (debug) {
webui.root_module.addCMacro("WEBUI_LOG", "");
}
webui.addCSourceFile(.{
.file = b.path("src/webui.c"),
.flags = if (enable_tls) tls_flags else no_tls_flags,
});
const civetweb_debug = debug and debug_dependencies.contains(.civetweb);
webui.addCSourceFile(.{
.file = b.path("src/civetweb/civetweb.c"),
.flags = if (enable_tls and !civetweb_debug)
civetweb_flags ++ tls_flags ++ .{"-DNDEBUG"}
else if (enable_tls and civetweb_debug)
civetweb_flags ++ tls_flags
else if (!enable_tls and !civetweb_debug)
civetweb_flags ++ .{"-DUSE_WEBSOCKET"} ++ no_tls_flags ++ .{"-DNDEBUG"}
else
civetweb_flags ++ .{"-DUSE_WEBSOCKET"} ++ no_tls_flags,
});
webui.linkLibC();
webui.addIncludePath(b.path("include"));
webui.installHeader(b.path("include/webui.h"), "webui.h");
if (is_darwin) {
webui.addCSourceFile(.{
.file = b.path("src/webview/wkwebview.m"),
.flags = &.{},
});
webui.linkFramework("Cocoa");
webui.linkFramework("WebKit");
} else if (is_windows) {
webui.linkSystemLibrary("ws2_32");
webui.linkSystemLibrary("ole32");
if (webui_target.abi == .msvc) {
webui.linkSystemLibrary("Advapi32");
webui.linkSystemLibrary("Shell32");
webui.linkSystemLibrary("user32");
}
if (enable_tls) {
webui.linkSystemLibrary("bcrypt");
}
}
if (enable_tls) {
webui.linkSystemLibrary("ssl");
webui.linkSystemLibrary("crypto");
}
for (webui.root_module.link_objects.items) |lo| {
switch (lo) {
.c_source_file => |csf| {
log(.debug, .WebUI, "{s} linker flags: {s}", .{
csf.file.src_path.sub_path,
csf.flags,
});
},
else => {},
}
}
}
fn build_examples(b: *Build, webui: *Compile) !void {
const build_examples_step = b.step("examples", "builds the library and its examples");
const target = webui.root_module.resolved_target.?;
const optimize = webui.root_module.optimize.?;
const examples_path = b.path("examples/C").getPath(b);
var examples_dir = std.fs.cwd().openDir(
examples_path,
.{ .iterate = true },
) catch |e| switch (e) {
// Do not attempt building examples if directory does not exist.
error.FileNotFound => return,
else => return e,
};
defer examples_dir.close();
var paths = examples_dir.iterate();
while (try paths.next()) |val| {
if (val.kind != .directory) {
continue;
}
const example_name = val.name;
const exe = b.addExecutable(.{
.name = example_name,
.target = target,
.optimize = optimize,
});
const path = try std.fmt.allocPrint(b.allocator, "examples/C/{s}/main.c", .{example_name});
defer b.allocator.free(path);
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe.linkLibrary(webui);
const exe_install = b.addInstallArtifact(exe, .{});
const exe_run = b.addRunArtifact(exe);
const step_name = try std.fmt.allocPrint(b.allocator, "run_{s}", .{example_name});
defer b.allocator.free(step_name);
const step_desc = try std.fmt.allocPrint(b.allocator, "run example {s}", .{example_name});
defer b.allocator.free(step_desc);
const cwd = try std.fmt.allocPrint(b.allocator, "src/examples/{s}", .{example_name});
defer b.allocator.free(cwd);
exe_run.setCwd(b.path(cwd));
exe_run.step.dependOn(&exe_install.step);
build_examples_step.dependOn(&exe_install.step);
b.step(step_name, step_desc).dependOn(&exe_run.step);
}
}
/// Function to runtime-scope log levels based on build flag, for all scopes.
fn log(
comptime level: std.log.Level,
comptime scope: @TypeOf(.EnumLiteral),
comptime format: []const u8,
args: anytype,
) void {
const should_print: bool = @intFromEnum(global_log_level) >= @intFromEnum(level);
if (should_print) {
switch (comptime level) {
.err => std.log.scoped(scope).err(format, args),
.warn => std.log.scoped(scope).warn(format, args),
.info => std.log.scoped(scope).info(format, args),
.debug => std.log.scoped(scope).debug(format, args),
}
}
}

14
build.zig.zon Normal file
View File

@ -0,0 +1,14 @@
.{
.name = .webui,
.version = "2.5.0-beta.4",
.fingerprint = 0xac5d87f2e5831aa7,
.paths = .{
"src",
"include",
"bridge",
"build.zig",
"build.zig.zon",
"LICENSE",
"README.md",
},
}

View File

@ -1,45 +0,0 @@
# WebUI Library
# Linux - Clang
SOURCE=../../../src
INCLUDE=../../../include
INCLUDE_CIVETWEB=../../../src/civetweb
all: release
debug:
# Static with Debug info
@echo "Build WebUI Library (Clang Debug Static)..."
@clang -g -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@llvm-ar rc libwebui-2-static-x64.a webui.o civetweb.o
@llvm-ranlib libwebui-2-static-x64.a
# Dynamic with Debug info
@echo "Build WebUI Library (Clang Debug Dynamic)..."
@clang -g -fPIC -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@clang -g -shared -o webui-2-x64.so webui.o civetweb.o
# Clean
@- rm -f *.o
@echo "Done."
release:
# Static Release
@echo "Build WebUI Library (Clang Release Static)..."
@clang -Os -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@llvm-ar rc libwebui-2-static-x64.a webui.o civetweb.o
@llvm-ranlib libwebui-2-static-x64.a
# Dynamic Release
@echo "Build WebUI Library (Clang Release Dynamic)..."
@clang -O3 -fPIC -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@clang -shared -o webui-2-x64.so webui.o civetweb.o
# Clean
@- rm -f *.o
@echo "Done."
clean:
- rm -f *.o
- rm -f *.so
- rm -f *.a

Binary file not shown.

View File

@ -1,45 +0,0 @@
# WebUI Library
# Linux - GCC
SOURCE=../../../src
INCLUDE=../../../include
INCLUDE_CIVETWEB=../../../src/civetweb
all: release
debug:
# Static with Debug info
@echo "Build WebUI Library (GCC Debug Static)..."
@gcc -g -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@gcc -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@ar rc libwebui-2-static-x64.a webui.o civetweb.o
@ranlib libwebui-2-static-x64.a
# Dynamic with Debug info
@echo "Build WebUI Library (GCC Debug Dynamic)..."
@gcc -g -fPIC -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@gcc -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@gcc -g -shared -o webui-2-x64.so webui.o civetweb.o
# Clean
@- rm -f *.o
@echo "Done."
release:
# Static Release
@echo "Build WebUI Library (GCC Release Static)..."
@gcc -Os -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@gcc -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@ar rc libwebui-2-static-x64.a webui.o civetweb.o
@ranlib libwebui-2-static-x64.a
# Dynamic Release
@echo "Build WebUI Library (GCC Release Dynamic)..."
@gcc -O3 -fPIC -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@gcc -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@gcc -shared -o webui-2-x64.so webui.o civetweb.o
# Clean
@- rm -f *.o
@echo "Done."
clean:
- rm -f *.o
- rm -f *.so
- rm -f *.a

Binary file not shown.

View File

@ -1,15 +0,0 @@
# Build WebUI Library - Linux
- **GCC**
```sh
git clone https://github.com/alifcommunity/webui.git
cd webui\build\Linux\GCC
make
```
- **Clang**
```sh
git clone https://github.com/alifcommunity/webui.git
cd webui\build\Linux\Clang
make
```

View File

@ -1,27 +0,0 @@
# Build WebUI Library
To build the WebUI you will need a `C99` compiler. No dependencies is needed.
### Manually build
[Windows](https://github.com/alifcommunity/webui/tree/main/build/Windows)
[Linux](https://github.com/alifcommunity/webui/tree/main/build/Linux)
[macOS](https://github.com/alifcommunity/webui/tree/main/build/macOS)
### Build WebUI in debug mode & Copy libs into examples folder
Windows: `windows_build debug`
Linux: `sh linux_build.sh debug`
macOS: `sh macos_build.sh debug`
### Build WebUI in release mode
Windows: `windows_build`
Linux: `sh linux_build.sh`
macOS: `sh macos_build.sh`

View File

@ -1,47 +0,0 @@
# WebUI Library
# Windows - GNU Compiler Collection
SHELL=CMD
SOURCE=../../../src
INCLUDE=../../../include
INCLUDE_CIVETWEB=../../../src/civetweb
all: release
debug:
# Static with Debug info
@echo Build WebUI Library (GCC Debug Static)...
@gcc -g -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET -DMUST_IMPLEMENT_CLOCK_GETTIME
@gcc -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@ar rc libwebui-2-static-x64.a webui.o civetweb.o
@ranlib libwebui-2-static-x64.a
# Dynamic with Debug info
@echo Build WebUI Library (GCC Debug Dynamic)...
@gcc -g -fPIC -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET -DMUST_IMPLEMENT_CLOCK_GETTIME
@gcc -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@gcc -g -shared -o webui-2-x64.dll webui.o civetweb.o -lws2_32
# Clean
@- del *.o >nul 2>&1
@echo Done.
release:
# Static Release
@echo Build WebUI Library (GCC Release Static)...
@gcc -Os -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET -DMUST_IMPLEMENT_CLOCK_GETTIME
@gcc -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@ar rc libwebui-2-static-x64.a webui.o civetweb.o
@ranlib libwebui-2-static-x64.a
# Dynamic Release
@echo Build WebUI Library (GCC Release Dynamic)...
@gcc -Os -fPIC -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET -DMUST_IMPLEMENT_CLOCK_GETTIME
@gcc -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@gcc -shared -o webui-2-x64.dll webui.o civetweb.o -lws2_32
@strip --strip-unneeded webui-2-x64.dll
# Clean
@- del *.o >nul 2>&1
@echo Done.
clean:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1

Binary file not shown.

View File

@ -1,45 +0,0 @@
# WebUI Library
# Windows - Microsoft Visual C
all: release
debug:
# Static with Debug info
@echo Build WebUI Library (MSVC Debug Static)...
@cl /Zl /Zi /Focivetweb.obj /c /EHsc "../../../src/civetweb/civetweb.c" /I "../../../src/civetweb/" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET 1>NUL 2>&1
@cl /Zl /Zi /Fowebui.obj /c /EHsc /DWEBUI_LOG "../../../src/webui.c" /I "../../../include" 1>NUL 2>&1
@lib /OUT:webui-2-static-x64.lib webui.obj civetweb.obj 1>NUL 2>&1
# Dynamic with Debug info
@echo Build WebUI Library (MSVC Debug Dynamic)...
@cl /Zi /Focivetweb.obj /c /EHsc "../../../src/civetweb/civetweb.c" /I "../../../src/civetweb/" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET 1>NUL 2>&1
@cl /Zi /Fowebui.obj /c /EHsc /DWEBUI_LOG "../../../src/webui.c" /I "../../../include" 1>NUL 2>&1
@link /DLL /OUT:webui-2-x64.dll webui.obj civetweb.obj user32.lib Advapi32.lib 1>NUL 2>&1
# Clean
@- del *.obj >nul 2>&1
@echo Done.
release:
# Static Release
@echo Build WebUI Library (MSVC Release Static)...
@cl /Zl /Focivetweb.obj /c /EHsc "../../../src/civetweb/civetweb.c" /I "../../../src/civetweb/" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET 1>NUL 2>&1
@cl /Zl /Fowebui.obj /c /EHsc "../../../src/webui.c" /I "../../../include" 1>NUL 2>&1
@lib /OUT:webui-2-static-x64.lib webui.obj civetweb.obj 1>NUL 2>&1
# Dynamic Release
@echo Build WebUI Library (MSVC Release Dynamic)...
@cl /Focivetweb.obj /c /EHsc "../../../src/civetweb/civetweb.c" /I "../../../src/civetweb/" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET 1>NUL 2>&1
@cl /Fowebui.obj /c /EHsc "../../../src/webui.c" /I "../../../include" 1>NUL 2>&1
@link /DLL /OUT:webui-2-x64.dll webui.obj civetweb.obj user32.lib Advapi32.lib 1>NUL 2>&1
# Clean
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.pdb >nul 2>&1
@- del *.exp >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.dll >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.lib >nul 2>&1
- del *.exp >nul 2>&1

Binary file not shown.

Binary file not shown.

View File

@ -1,23 +0,0 @@
# Build WebUI Library - Windows
- **Microsoft Visual Studio Build Tools**
```sh
git clone https://github.com/alifcommunity/webui.git
cd webui\build\Windows\MSVC
nmake
```
- **MinGW**
```sh
git clone https://github.com/alifcommunity/webui.git
cd webui\build\Windows\GCC
mingw32-make
```
- **TCC**
```sh
git clone https://github.com/alifcommunity/webui.git
cd webui\build\Windows\TCC
mingw32-make
```

View File

@ -1,45 +0,0 @@
# WebUI Library
# Windows - Tiny C Compiler
SHELL=CMD
SOURCE=../../../src
INCLUDE=../../../include
INCLUDE_CIVETWEB=../../../src/civetweb
all: release
debug:
# Static with Debug info
@echo Build WebUI Library (TCC Debug Static)...
@tcc -g -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -w -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@tcc -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG -w
@tcc -m64 -ar rcs libwebui-2-static-x64.a webui.o civetweb.o
# Dynamic with Debug info
# @echo Build WebUI Library (TCC Debug Dynamic)...
# @tcc -g -fPIC -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -w -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
# @tcc -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG -w
# @tcc -g -shared -o webui-2-x64.dll webui.o civetweb.o -lws2_32 -lAdvapi32
# Clean
@- del *.o >nul 2>&1
@echo Done.
release:
# Static Release
@echo Build WebUI Library (TCC Release Static)...
@tcc -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -w -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@tcc -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -w
@tcc -m64 -ar rcs libwebui-2-static-x64.a webui.o civetweb.o
# Dynamic Release
# @echo Build WebUI Library (TCC Release Dynamic)...
# @tcc -fPIC -m64 -o civetweb.o -I "$(INCLUDE_CIVETWEB)" -c "$(SOURCE)/civetweb/civetweb.c" -w -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
# @tcc -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -w
# @tcc -shared -o webui-2-x64.dll webui.o civetweb.o -lws2_32 -lAdvapi32
# Clean
@- del *.o >nul 2>&1
@echo Done.
clean:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.def >nul 2>&1

View File

@ -1,85 +0,0 @@
#!/bin/bash
WEBUI_VERSION=2.3.0
ARG1=$1
if [ "$ARG1" = "debug" ]; then
CLANG_CMD="make debug"
GCC_CMD="make debug"
else
CLANG_CMD="make"
GCC_CMD="make"
fi
echo "";
echo "WebUI v$WEBUI_VERSION Build Script"
echo "Platform: Linux x64"
echo "Compiler: GCC and Clang"
RootPath="$PWD/../"
cd "$RootPath"
echo "";
echo "Building WebUI using GCC...";
echo "";
# Build WebUI Library using GCC
cd "$RootPath"
cd "build/Linux/GCC"
$GCC_CMD
echo "";
echo "Building WebUI using Clang...";
echo "";
# Build WebUI Library using Clang
cd "$RootPath"
cd "build/Linux/Clang"
$CLANG_CMD
echo "";
echo "Copying WebUI libs to the examples folder..."
echo "";
cd "$RootPath"
# C - Text Editor
cp -f "include/webui.h" "examples/C/text-editor/webui.h"
cp -f "build/Linux/GCC/webui-2-x64.so" "examples/C/text-editor/webui-2-x64.so"
echo "";
if [ "$ARG1" = "" ]; then
echo "Copying WebUI libs to the release folder..."
echo "";
# Release Linux Include
cp -f "include/webui.h" "Release/Linux/include/webui.h"
cp -f "include/webui.hpp" "Release/Linux/include/webui.hpp"
# Release Linux GCC
cp -f "build/Linux/GCC/webui-2-x64.so" "Release/Linux/GCC/webui-2-x64.so"
cp -f "build/Linux/GCC/libwebui-2-static-x64.a" "Release/Linux/GCC/libwebui-2-static-x64.a"
# Release Linux Clang
cp -f "build/Linux/Clang/webui-2-x64.so" "Release/Linux/Clang/webui-2-x64.so"
cp -f "build/Linux/Clang/libwebui-2-static-x64.a" "Release/Linux/Clang/libwebui-2-static-x64.a"
echo "";
echo "Compressing the release folder..."
echo "";
TAR_OUT="webui-linux-x64-v$WEBUI_VERSION.zip"
cd "Release"
sleep 2
tar -c -f $TAR_OUT Linux/*
cd "$RootPath"
echo "";
echo "Cleaning..."
echo "";
find ./ -type f -name "*.o" -exec rm -f {} \;
fi
cd "build"

View File

@ -1,45 +0,0 @@
# WebUI Library
# macOS - Clang
SOURCE=../../../src
INCLUDE=../../../include
INCLUDE_CIVETWEB=../../../src/civetweb
all: release
debug:
# Static with Debug info
@echo "Build WebUI Library (Clang Debug Static)..."
@clang -g -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -DWEBUI_LOG -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@ar rc libwebui-2-static-x64.a webui.o civetweb.o
@ranlib libwebui-2-static-x64.a
# Dynamic with Debug info
@echo "Build WebUI Library (Clang Debug Dynamic)..."
@clang -g -fPIC -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -DWEBUI_LOG -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
@clang -g -shared -o webui-2-x64.dyn webui.o civetweb.o
#Clean
@- rm -f *.o
@echo "Done."
release:
# Static Release
@echo "Build WebUI Library (Clang Release Static)..."
@clang -Os -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@ar rc libwebui-2-static-x64.a webui.o civetweb.o
@ranlib libwebui-2-static-x64.a
# Dynamic Release
@echo "Build WebUI Library (Clang Release Dynamic)..."
@clang -O3 -fPIC -m64 -o civetweb.o -I "$(INCLUDE)" -c "$(SOURCE)/civetweb/civetweb.c" -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
@clang -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@clang -shared -o webui-2-x64.dyn webui.o civetweb.o
# Clean
@- rm -f *.o
@echo "Done."
clean:
- rm -f *.o
- rm -f *.dylib
- rm -f *.a

Binary file not shown.

View File

@ -1,9 +0,0 @@
# Build WebUI Library - macOS
- **Clang**
```sh
git clone https://github.com/alifcommunity/webui.git
cd webui\build\macOS\Clang
make
```

View File

@ -1,72 +0,0 @@
#!/bin/bash
WEBUI_VERSION=2.3.0
ARG1=$1
if [ "$ARG1" = "debug" ]; then
CLANG_CMD="make debug"
GCC_CMD="make debug"
else
CLANG_CMD="make"
GCC_CMD="make"
fi
echo "";
echo "WebUI v$WEBUI_VERSION Build Script"
echo "Platform: macOS x64"
echo "Compiler: Clang"
RootPath="$PWD/../"
cd "$RootPath"
echo "";
echo "Building WebUI using Clang...";
echo "";
# Build WebUI Library using Clang
cd "$RootPath"
cd "build/macOS/Clang"
$CLANG_CMD
echo "";
echo "Copying WebUI libs to the examples folder..."
echo "";
cd "$RootPath"
# C - Text Editor
cp -f "include/webui.h" "examples/C/text-editor/webui.h"
cp -f "build/macOS/Clang/webui-2-x64.dyn" "examples/C/text-editor/webui-2-x64.dyn"
echo "";
if [ "$ARG1" = "" ]; then
echo "Copying WebUI libs to the release folder..."
echo "";
# Release macOS Include
cp -f "include/webui.h" "Release/macOS/include/webui.h"
cp -f "include/webui.hpp" "Release/macOS/include/webui.hpp"
# Release macOS Clang
cp -f "build/macOS/Clang/webui-2-x64.dyn" "Release/macOS/Clang/webui-2-x64.dyn"
cp -f "build/macOS/Clang/libwebui-2-static-x64.a" "Release/macOS/Clang/libwebui-2-static-x64.a"
echo "";
echo "Compressing the release folder..."
echo "";
TAR_OUT="webui-macos-x64-v$WEBUI_VERSION.zip"
cd "Release"
sleep 2
tar -c -f $TAR_OUT macOS/*
cd "$RootPath"
echo "";
echo "Cleaning..."
echo "";
find ./ -type f -name "*.o" -exec rm -f {} \;
fi
cd "build"

View File

@ -1,115 +0,0 @@
@echo off
set WEBUI_VERSION=2.3.0
set ARG1=%1
IF "%ARG1%"=="debug" (
set MSVC_CMD=nmake debug
set GCC_CMD=mingw32-make debug
) else (
set MSVC_CMD=nmake
set GCC_CMD=mingw32-make
)
echo.
echo WebUI v%WEBUI_VERSION% Build Script
echo Platform: Microsoft Windows x64
echo Compiler: MSVC, GCC and TCC
Set RootPath=%CD%\..\
cd "%RootPath%"
echo.
echo Building WebUI using MSVC...
REM Build WebUI Library using MSVC
cd "%RootPath%"
cd "build\Windows\MSVC"
%MSVC_CMD%
echo.
echo Building WebUI using GCC...
echo.
REM Build WebUI Library using GCC
cd "%RootPath%"
cd "build\Windows\GCC"
%GCC_CMD%
echo.
echo Building WebUI using TCC...
echo.
REM Build WebUI Library using TCC
cd "%RootPath%"
cd "build\Windows\TCC"
%GCC_CMD%
echo.
echo Copying WebUI libs to the examples folder...
echo.
cd "%RootPath%"
REM C++ (Visual Studio 2022)
copy /Y "include\webui.h" "examples\C++\VS2022\serve_a_folder\my_webui_app\webui.h"
copy /Y "include\webui.hpp" "examples\C++\VS2022\serve_a_folder\my_webui_app\webui.hpp"
copy /Y "build\Windows\MSVC\webui-2-static-x64.lib" "examples\C++\VS2022\serve_a_folder\my_webui_app\webui-2-static-x64.lib"
REM C++ (Visual Studio 2019)
copy /Y "include\webui.h" "examples\C++\VS2019\serve_a_folder\my_webui_app\webui.h"
copy /Y "include\webui.hpp" "examples\C++\VS2019\serve_a_folder\my_webui_app\webui.hpp"
copy /Y "build\Windows\MSVC\webui-2-static-x64.lib" "examples\C++\VS2019\serve_a_folder\my_webui_app\webui-2-static-x64.lib"
REM C - Text Editor
copy /Y "include\webui.h" "examples\C\text-editor\webui.h"
copy /Y "build\Windows\MSVC\webui-2-x64.dll" "examples\C\text-editor\webui-2-x64.dll"
echo.
IF "%ARG1%"=="" (
echo Copying WebUI libs to the release folder...
echo.
REM Release Windows Include
copy /Y "include\webui.h" "Release\Windows\include\webui.h"
REM Release Windows MSVC
copy /Y "build\Windows\MSVC\webui-2-x64.dll" "Release\Windows\MSVC\webui-2-x64.dll"
copy /Y "build\Windows\MSVC\webui-2-x64.lib" "Release\Windows\MSVC\webui-2-x64.lib"
copy /Y "build\Windows\MSVC\webui-2-static-x64.lib" "Release\Windows\MSVC\webui-2-static-x64.lib"
REM Release Windows GCC
copy /Y "build\Windows\GCC\webui-2-x64.dll" "Release\Windows\GCC\webui-2-x64.dll"
copy /Y "build\Windows\GCC\libwebui-2-static-x64.a" "Release\Windows\GCC\libwebui-2-static-x64.a"
REM Release Windows TCC
REM copy /Y "build\Windows\TCC\webui-2-x64.dll" "Release\Windows\TCC\webui-2-x64.dll"
REM copy /Y "build\Windows\TCC\webui-2-x64.def" "Release\Windows\TCC\webui-2-x64.def"
copy /Y "build\Windows\TCC\libwebui-2-static-x64.a" "Release\Windows\TCC\libwebui-2-static-x64.a"
echo.
echo Compressing the release folder...
set TAR_OUT=webui-windows-x64-v%WEBUI_VERSION%.zip
cd "Release"
timeout 2 > NUL
tar.exe -c -f %TAR_OUT% Windows\*
cd "%RootPath%"
echo.
echo Cleaning...
DEL /Q /F /S "*.exe" >nul 2>&1
DEL /Q /F /S "*.o" >nul 2>&1
DEL /Q /F /S "*.exp" >nul 2>&1
DEL /Q /F /S "*.pdb" >nul 2>&1
DEL /Q /F /S "*.ilk" >nul 2>&1
DEL /Q /F /S "*.obj" >nul 2>&1
DEL /Q /F /S "*.iobj" >nul 2>&1
DEL /Q /F /S "*.res" >nul 2>&1
DEL /Q /F /S "*.bak" >nul 2>&1
DEL /Q /F /S "*.DS_Store" >nul 2>&1
)
cd "build"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

37
examples/C++/README.md Normal file
View File

@ -0,0 +1,37 @@
# 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_c_from_js`: Calls C++ from JavaScript.
- `call_js_from_c`: Calls JavaScript from C++.
- `serve_a_folder`: Uses WebUI to serve a folder that contains multiple files.
To build an example, cd into its directory and run the make command.
- **Windows**
```sh
# G++
mingw32-make
# MSVC
nmake
```
- **Linux**
```sh
# G++
make
# Clang
make CXX=clang
```
- **macOS**
```sh
make
```

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.33027.164
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "my_webui_app", "my_webui_app\my_webui_app.vcxproj", "{CC54CE9B-9584-4C08-8AB1-C08549E404FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Debug|x64.ActiveCfg = Debug|x64
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Debug|x64.Build.0 = Debug|x64
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Release|x64.ActiveCfg = Release|x64
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B59013B5-9B18-4E50-992A-5ABD6F569433}
EndGlobalSection
EndGlobal

View File

@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Serve a Folder Example (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">Serve a Folder Example (C++)</h3>
<br>
<p id="description">
You can edit this HTML file as you need.<br>
Also, you can config WebUI to use Deno or Nodejs runtime for your JS/TS files.<br>
<br>
Please click on the link to switch to the second page<br>
Or click on the button to switch to the second page programmatically.
</p>
<br>
<h4><a href="second.html">Second Page As A Simple Link</a></h4>
<br>
<button id="SwitchToSecondPage">Switch to The Second Page Programmatically</button>
<br>
<br>
<button id="OpenNewWindow">Open The Second Window</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,103 +0,0 @@
// Include the WebUI header
#include "webui.hpp"
// Include C++ STD
#include <iostream>
// Making this object global so show_second_window() can access it.
webui::window my_second_window;
// Example of a simple Class
class MyClass {
public:
// This method gets called every time the
// user clicks on "OpenNewWindow"
void show_second_window(webui::event* e) {
// Show a new window, and navigate to `/second.html`
// if the window is already opened, then switch in the same window
my_second_window.show("second.html");
}
// This method gets called every time the
// user clicks on "SwitchToSecondPage"
void switch_to_second_page(webui::event* e) {
// Switch to `/second.html` in the same opened window.
e->window.show("second.html");
}
// Example of a simple function (Not a method)
// This function receives all events because
// it's get bind with an empty HTML ID.
void events(webui::event* e) {
if (e->event_type == webui::CONNECTED)
std::cout << "Window Connected." << std::endl;
else if (e->event_type == webui::DISCONNECTED)
std::cout << "Window Disconnected." << std::endl;
else if (e->event_type == webui::MOUSE_CLICK)
std::cout << "Click on element: " << e->element << std::endl;
else if (e->event_type == webui::NAVIGATION)
std::cout << "Starting navigation to: " << e->data << std::endl;
}
// Example of a simple function (Not a method)
void exit_app(webui::event* e) {
// Close all opened windows
webui::exit();
}
};
// Wrapper:
// Because WebUI is written in C, so it can not
// access `MyClass` directly. That's why we should
// create a simple C++ wrapper.
MyClass obj;
void show_second_window_wrp(webui::event* e) { obj.show_second_window(e); }
void switch_to_second_page_wrp(webui::event* e) { obj.switch_to_second_page(e); }
void events_wrp(webui::event* e) { obj.events(e); }
void exit_app_wrp(webui::event* e) { obj.exit_app(e); }
int main() {
// Print logs (debug build only)
std::cout << "Starting..." << std::endl;
// Create a new window
webui::window my_window;
// Bind HTML element IDs with a C functions
my_window.bind("SwitchToSecondPage", switch_to_second_page_wrp);
my_window.bind("OpenNewWindow", show_second_window_wrp);
my_window.bind("Exit", exit_app_wrp);
my_second_window.bind("Exit", exit_app_wrp);
// Bind all events
my_window.bind("", events_wrp);
// Show a new window
my_window.show("index.html"); // my_window.show_browser("index.html", Chrome);
// Wait until all windows get closed
webui::wait();
// Print logs (debug build only)
std::cout << "Thank you." << std::endl;
return 0;
}
#ifdef _WIN32
// Release build
int WINAPI wWinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nShowCmd
) {
return main();
}
#endif

View File

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{cc54ce9b-9584-4c08-8ab1-c08549e404fe}</ProjectGuid>
<RootNamespace>mywebuiapp</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies>webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="my_webui_app.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="webui.h" />
<ClInclude Include="webui.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="my_webui_app.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="webui.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="webui.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Second Page (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">This is the second page !</h3>
<br>
<button id="Exit">Call Exit()</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,215 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_H
#define _WEBUI_H
#define WEBUI_VERSION "2.3.0"
#define WEBUI_MAX_IDS (512)
// Dynamic Library Exports
#if defined(_MSC_VER) || defined(__TINYC__)
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT __declspec(dllexport)
#endif
#else
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT extern
#endif
#endif
// -- C STD ---------------------------
#include <stdbool.h>
#include <inttypes.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stddef.h>
#include <time.h>
#include <errno.h>
#include <math.h>
#if defined(__GNUC__) || defined(__TINYC__)
#include <dirent.h>
#endif
// -- Windows -------------------------
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <direct.h>
#include <io.h>
#include <tchar.h>
#include <tlhelp32.h>
#define WEBUI_GET_CURRENT_DIR _getcwd
#define WEBUI_FILE_EXIST _access
#define WEBUI_POPEN _popen
#define WEBUI_PCLOSE _pclose
#define WEBUI_MAX_PATH MAX_PATH
#endif
// -- Linux ---------------------------
#ifdef __linux__
#include <unistd.h>
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/time.h>
#include <signal.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Apple ---------------------------
#ifdef __APPLE__
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/syslimits.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#include <signal.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Enums ---------------------------
enum webui_browsers {
AnyBrowser = 0, // 0. Default recommended web browser
Chrome, // 1. Google Chrome
Firefox, // 2. Mozilla Firefox
Edge, // 3. Microsoft Edge
Safari, // 4. Apple Safari
Chromium, // 5. The Chromium Project
Opera, // 6. Opera Browser
Brave, // 7. The Brave Browser
Vivaldi, // 8. The Vivaldi Browser
Epic, // 9. The Epic Browser
Yandex, // 10. The Yandex Browser
};
enum webui_runtimes {
None = 0, // 0. Prevent WebUI from using any runtime for .js and .ts files
Deno, // 1. Use Deno runtime for .js and .ts files
NodeJS, // 2. Use Nodejs runtime for .js files
};
enum webui_events {
WEBUI_EVENT_DISCONNECTED = 0, // 0. Window disconnection event
WEBUI_EVENT_CONNECTED, // 1. Window connection event
WEBUI_EVENT_MULTI_CONNECTION, // 2. New window connection event
WEBUI_EVENT_UNWANTED_CONNECTION, // 3. New unwanted window connection event
WEBUI_EVENT_MOUSE_CLICK, // 4. Mouse click event
WEBUI_EVENT_NAVIGATION, // 5. Window navigation event
WEBUI_EVENT_CALLBACK, // 6. Function call event
};
// -- Structs -------------------------
typedef struct webui_event_t {
size_t window; // The window object number
size_t event_type; // Event type
char* element; // HTML element ID
char* data; // JavaScript data
size_t event_number; // Internal WebUI
} webui_event_t;
// -- Definitions ---------------------
// Create a new webui window object.
WEBUI_EXPORT size_t webui_new_window(void);
// Create a new webui window object.
WEBUI_EXPORT void webui_new_window_id(size_t window_number);
// Get a free window ID that can be used with `webui_new_window_id()`
WEBUI_EXPORT size_t webui_get_new_window_id(void);
// Bind a specific html element click event with a function. Empty element means all events.
WEBUI_EXPORT size_t webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e));
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
WEBUI_EXPORT bool webui_show(size_t window, const char* content);
// Same as webui_show(). But with a specific web browser.
WEBUI_EXPORT bool webui_show_browser(size_t window, const char* content, size_t browser);
// Set the window in Kiosk mode (Full screen)
WEBUI_EXPORT void webui_set_kiosk(size_t window, bool status);
// Wait until all opened windows get closed.
WEBUI_EXPORT void webui_wait(void);
// Close a specific window only. The window object will still exist.
WEBUI_EXPORT void webui_close(size_t window);
// Close a specific window and free all memory resources.
WEBUI_EXPORT void webui_destroy(size_t window);
// Close all opened windows. webui_wait() will break.
WEBUI_EXPORT void webui_exit(void);
// -- Other ---------------------------
// Check a specific window if it's still running
WEBUI_EXPORT bool webui_is_shown(size_t window);
// Set the maximum time in seconds to wait for browser to start
WEBUI_EXPORT void webui_set_timeout(size_t second);
// Set the default embedded HTML favicon
WEBUI_EXPORT void webui_set_icon(size_t window, const char* icon, const char* icon_type);
// Allow the window URL to be re-used in normal web browsers
WEBUI_EXPORT void webui_set_multi_access(size_t window, bool status);
// -- JavaScript ----------------------
// Run JavaScript quickly with no waiting for the response.
WEBUI_EXPORT void webui_run(size_t window, const char* script);
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
WEBUI_EXPORT bool webui_script(size_t window, const char* script, size_t timeout, char* buffer, size_t buffer_length);
// Chose between Deno and Nodejs runtime for .js and .ts files.
WEBUI_EXPORT void webui_set_runtime(size_t window, size_t runtime);
// Parse argument as integer.
WEBUI_EXPORT long long int webui_get_int(webui_event_t* e);
// Parse argument as string.
WEBUI_EXPORT const char* webui_get_string(webui_event_t* e);
// Parse argument as boolean.
WEBUI_EXPORT bool webui_get_bool(webui_event_t* e);
// Return the response to JavaScript as integer.
WEBUI_EXPORT void webui_return_int(webui_event_t* e, long long int n);
// Return the response to JavaScript as string.
WEBUI_EXPORT void webui_return_string(webui_event_t* e, char* s);
// Return the response to JavaScript as boolean.
WEBUI_EXPORT void webui_return_bool(webui_event_t* e, bool b);
// Base64 encoding. Use this to safely send text based data to the UI. If it fails it will return NULL.
WEBUI_EXPORT char* webui_encode(const char* str);
// Base64 decoding. Use this to safely decode received Base64 text from the UI. If it fails it will return NULL.
WEBUI_EXPORT char* webui_decode(const char* str);
// Safely free a buffer allocated by WebUI, for example when using webui_encode().
WEBUI_EXPORT void webui_free(void* ptr);
// -- Interface -----------------------
// Bind a specific html element click event with a function. Empty element means all events. This replace webui_bind(). The func is (Window, EventType, Element, Data, EventNumber)
WEBUI_EXPORT size_t webui_interface_bind(size_t window, const char* element, void (*func)(size_t, size_t, char*, char*, size_t));
// When using `webui_interface_bind()` you may need this function to easily set your callback response.
WEBUI_EXPORT void webui_interface_set_response(size_t window, size_t event_number, const char* response);
// Check if the app still running or not. This replace webui_wait().
WEBUI_EXPORT bool webui_interface_is_app_running(void);
// Get window unique ID
WEBUI_EXPORT size_t webui_interface_get_window_id(size_t window);
// Get a unique ID. Same ID as `webui_bind()`. Return > 0 if bind exist.
WEBUI_EXPORT size_t webui_interface_get_bind_id(size_t window, const char* element);
#endif /* _WEBUI_H */

View File

@ -1,249 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_HPP
#define _WEBUI_HPP
// C++ STD
#include <string>
// WebUI C Header
extern "C" {
#include "webui.h"
}
namespace webui {
const int DISCONNECTED = 0; // 0. Window disconnection event
const int CONNECTED = 1; // 1. Window connection event
const int MULTI_CONNECTION = 2; // 2. New window connection event
const int UNWANTED_CONNECTION = 3; // 3. New unwanted window connection event
const int MOUSE_CLICK = 4; // 4. Mouse click event
const int NAVIGATION = 5; // 5. Window navigation event
const int CALLBACKS = 6; // 6. Function call event
class window;
// Event struct
struct event {
webui::window& window; // The window object
unsigned int event_type; // Event type
std::string element; // HTML element ID
std::string data; // JavaScript data
unsigned int event_number; // Internal WebUI
// Window object constructor that
// initializes the reference, This
// is to avoid creating copies.
event(webui::window& window_obj) : window(window_obj) {}
};
// List of callbacks: user_function(webui::event* e)
void (*callback_list[512])(webui::event*);
// List of window objects: webui::window
webui::window* window_list[512];
// Event handler
// WebUI is written in C. So there is no way
// to make C call a C++ class member. That's
// why this function should be outside class
void event_handler(webui_event_t* c_e) {
// Get a unique ID. Same ID as `webui_bind()`. Return > 0 if bind exist.
unsigned int id = webui_interface_get_bind_id(c_e->window, c_e->element);
if(id < 1)
return;
// Create a new event struct
webui::event e(*window_list[id]);
// `e.window` is already initialized by `e` constructor
e.event_type = c_e->event_type;
e.element = (c_e->element != NULL ? std::string(c_e->element) : std::string(""));
e.data = (c_e->data != NULL ? std::string(c_e->data) : std::string(""));
e.event_number = c_e->event_number;
// Call the user callback
if(callback_list[id] != NULL)
callback_list[id](&e);
}
class window {
private:
size_t webui_window = 0;
webui_event_t* convert_event_to_webui_event(webui::event* e) {
// Convert C++ `webui::event` to C `webui_event_t`
webui_event_t* c_e = new webui_event_t;
c_e->window = this->webui_window;
c_e->event_type = e->event_type;
c_e->element = (char*)e->element.c_str();
c_e->data = (char*)e->data.c_str();
c_e->event_number = e->event_number;
return c_e;
}
public:
// Constructor
window() {
this->webui_window = webui_new_window();
}
// Destructor
~window() {
// Nothing to do.
// No needs to call `webui_close()`
}
// Bind a specific html element click event with a function. Empty element means all events.
void bind(std::string element, void (*func)(webui::event* e)) {
// Get unique ID
unsigned int id = webui_bind(this->webui_window, element.c_str(), webui::event_handler);
// Save window object
window_list[id] = this;
// Save callback
callback_list[id] = func;
}
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
bool show(std::string content) {
return webui_show(this->webui_window, content.c_str());
}
// Same as show(). But with a specific web browser.
bool show_browser(std::string content, unsigned int browser) {
return webui_show_browser(this->webui_window, content.c_str(), browser);
}
// Close a specific window.
void close() {
webui_close(this->webui_window);
}
// Set the window in Kiosk mode (Full screen)
void set_kiosk(bool status) {
webui_set_kiosk(this->webui_window, status);
}
// -- Other ---------------------------
// Check a specific window if it's still running
bool is_shown() {
return webui_is_shown(this->webui_window);
}
// Set the default embedded HTML favicon
void set_icon(std::string icon, std::string icon_type) {
webui_set_icon(this->webui_window, icon.c_str(), icon_type.c_str());
}
// Allow the window URL to be re-used in normal web browsers
void set_multi_access(bool status) {
webui_set_multi_access(this->webui_window, status);
}
// -- JavaScript ----------------------
// Quickly run a JavaScript (no response waiting).
void run(std::string script) {
webui_run(this->webui_window, script.c_str());
}
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
bool script(std::string script, unsigned int timeout, char* buffer, size_t buffer_length) {
return webui_script(this->webui_window, script.c_str(), timeout, buffer, buffer_length);
}
// Chose between Deno and Nodejs runtime for .js and .ts files.
void set_runtime(unsigned int runtime) {
webui_set_runtime(this->webui_window, runtime);
}
// Parse argument as integer.
long long int get_int(webui::event* e) {
webui_event_t* c_e = convert_event_to_webui_event(e);
long long int ret = webui_get_int(c_e);
delete c_e;
return ret;
}
// Parse argument as string.
std::string get_string(webui::event* e) {
webui_event_t* c_e = convert_event_to_webui_event(e);
std::string ret = std::string(webui_get_string(c_e));
delete c_e;
return ret;
}
// Parse argument as boolean.
bool get_bool(webui::event* e) {
webui_event_t* c_e = convert_event_to_webui_event(e);
bool ret = webui_get_bool(c_e);
delete c_e;
return ret;
}
// Return the response to JavaScript as integer.
void return_int(webui::event* e, long long int n) {
webui_event_t* c_e = convert_event_to_webui_event(e);
webui_return_int(c_e, n);
delete c_e;
}
// Return the response to JavaScript as string.
void return_string(webui::event* e, std::string s) {
webui_event_t* c_e = convert_event_to_webui_event(e);
webui_return_string(c_e, &s[0]);
delete c_e;
}
// Return the response to JavaScript as boolean.
void return_bool(webui::event* e, bool b) {
webui_event_t* c_e = convert_event_to_webui_event(e);
webui_return_bool(c_e, b);
delete c_e;
}
};
// Wait until all opened windows get closed.
void wait(void) {
webui_wait();
}
// Close all opened windows. wait() will break.
void exit(void) {
webui_exit();
}
// Set the maximum time in seconds to wait for browser to start
void set_timeout(unsigned int second) {
webui_set_timeout(second);
}
// Base64 encoding. Use this to safely send text based data to the UI. If it fails it will return NULL.
std::string encode(std::string str) {
std::string ret = std::string(webui_encode(str.c_str()));
return ret;
}
// Base64 decoding. Use this to safely decode received Base64 text from the UI. If it fails it will return NULL.
std::string decode(std::string str) {
std::string ret = std::string(webui_decode(str.c_str()));
return ret;
}
// Safely free a buffer allocated by WebUI, for example when using webui_encode().
void free(void* ptr) {
webui_free(ptr);
}
}
#endif /* _WEBUI_HPP */

View File

@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Serve a Folder Example (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">Serve a Folder Example (C++)</h3>
<br>
<p id="description">
You can edit this HTML file as you need.<br>
Also, you can config WebUI to use Deno or Nodejs runtime for your JS/TS files.<br>
<br>
Please click on the link to switch to the second page<br>
Or click on the button to switch to the second page programmatically.
</p>
<br>
<h4><a href="second.html">Second Page As A Simple Link</a></h4>
<br>
<button id="SwitchToSecondPage">Switch to The Second Page Programmatically</button>
<br>
<br>
<button id="OpenNewWindow">Open The Second Window</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Second Page (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">This is the second page !</h3>
<br>
<button id="Exit">Call Exit()</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Serve a Folder Example (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">Serve a Folder Example (C++)</h3>
<br>
<p id="description">
You can edit this HTML file as you need.<br>
Also, you can config WebUI to use Deno or Nodejs runtime for your JS/TS files.<br>
<br>
Please click on the link to switch to the second page<br>
Or click on the button to switch to the second page programmatically.
</p>
<br>
<h4><a href="second.html">Second Page As A Simple Link</a></h4>
<br>
<button id="SwitchToSecondPage">Switch to The Second Page Programmatically</button>
<br>
<br>
<button id="OpenNewWindow">Open The Second Window</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Second Page (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">This is the second page !</h3>
<br>
<button id="Exit">Call Exit()</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.33027.164
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "my_webui_app", "my_webui_app\my_webui_app.vcxproj", "{CC54CE9B-9584-4C08-8AB1-C08549E404FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Debug|x64.ActiveCfg = Debug|x64
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Debug|x64.Build.0 = Debug|x64
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Release|x64.ActiveCfg = Release|x64
{CC54CE9B-9584-4C08-8AB1-C08549E404FE}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B59013B5-9B18-4E50-992A-5ABD6F569433}
EndGlobalSection
EndGlobal

View File

@ -1,39 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Serve a Folder Example (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">Serve a Folder Example (C++)</h3>
<br>
<p id="description">
You can edit this HTML file as you need.<br>
Also, you can config WebUI to use Deno or Nodejs runtime for your JS/TS files.<br>
<br>
Please click on the link to switch to the second page<br>
Or click on the button to switch to the second page programmatically.
</p>
<br>
<h4><a href="second.html">Second Page As A Simple Link</a></h4>
<br>
<button id="SwitchToSecondPage">Switch to The Second Page Programmatically</button>
<br>
<br>
<button id="OpenNewWindow">Open The Second Window</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,103 +0,0 @@
// Include the WebUI header
#include "webui.hpp"
// Include C++ STD
#include <iostream>
// Making this object global so show_second_window() can access it.
webui::window my_second_window;
// Example of a simple Class
class MyClass {
public:
// This method gets called every time the
// user clicks on "OpenNewWindow"
void show_second_window(webui::event* e) {
// Show a new window, and navigate to `/second.html`
// if the window is already opened, then switch in the same window
my_second_window.show("second.html");
}
// This method gets called every time the
// user clicks on "SwitchToSecondPage"
void switch_to_second_page(webui::event* e) {
// Switch to `/second.html` in the same opened window.
e->window.show("second.html");
}
// Example of a simple function (Not a method)
// This function receives all events because
// it's get bind with an empty HTML ID.
void events(webui::event* e) {
if (e->event_type == webui::CONNECTED)
std::cout << "Window Connected." << std::endl;
else if (e->event_type == webui::DISCONNECTED)
std::cout << "Window Disconnected." << std::endl;
else if (e->event_type == webui::MOUSE_CLICK)
std::cout << "Click on element: " << e->element << std::endl;
else if (e->event_type == webui::NAVIGATION)
std::cout << "Starting navigation to: " << e->data << std::endl;
}
// Example of a simple function (Not a method)
void exit_app(webui::event* e) {
// Close all opened windows
webui::exit();
}
};
// Wrapper:
// Because WebUI is written in C, so it can not
// access `MyClass` directly. That's why we should
// create a simple C++ wrapper.
MyClass obj;
void show_second_window_wrp(webui::event* e) { obj.show_second_window(e); }
void switch_to_second_page_wrp(webui::event* e) { obj.switch_to_second_page(e); }
void events_wrp(webui::event* e) { obj.events(e); }
void exit_app_wrp(webui::event* e) { obj.exit_app(e); }
int main() {
// Print logs (debug build only)
std::cout << "Starting..." << std::endl;
// Create a new window
webui::window my_window;
// Bind HTML element IDs with a C functions
my_window.bind("SwitchToSecondPage", switch_to_second_page_wrp);
my_window.bind("OpenNewWindow", show_second_window_wrp);
my_window.bind("Exit", exit_app_wrp);
my_second_window.bind("Exit", exit_app_wrp);
// Bind all events
my_window.bind("", events_wrp);
// Show a new window
my_window.show("index.html"); // my_window.show_browser("index.html", Chrome);
// Wait until all windows get closed
webui::wait();
// Print logs (debug build only)
std::cout << "Thank you." << std::endl;
return 0;
}
#ifdef _WIN32
// Release build
int WINAPI wWinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nShowCmd
) {
return main();
}
#endif

View File

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{cc54ce9b-9584-4c08-8ab1-c08549e404fe}</ProjectGuid>
<RootNamespace>mywebuiapp</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies>webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="my_webui_app.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="webui.h" />
<ClInclude Include="webui.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="my_webui_app.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="webui.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="webui.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebUI - Second Page (C++)</title>
<style>
body {
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #43264c, #762f59, #501349);
background: linear-gradient(to right, #43264c, #762f59, #501349);
text-align: center;
font-size: 16px;
font-family: sans-serif;
}
</style>
</head>
<body>
<h3 id="title">This is the second page !</h3>
<br>
<button id="Exit">Call Exit()</button>
</body>
<!-- Connect this window to the background app -->
<script src="/webui.js"></script>
</html>

View File

@ -1,215 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_H
#define _WEBUI_H
#define WEBUI_VERSION "2.3.0"
#define WEBUI_MAX_IDS (512)
// Dynamic Library Exports
#if defined(_MSC_VER) || defined(__TINYC__)
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT __declspec(dllexport)
#endif
#else
#ifndef WEBUI_EXPORT
#define WEBUI_EXPORT extern
#endif
#endif
// -- C STD ---------------------------
#include <stdbool.h>
#include <inttypes.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stddef.h>
#include <time.h>
#include <errno.h>
#include <math.h>
#if defined(__GNUC__) || defined(__TINYC__)
#include <dirent.h>
#endif
// -- Windows -------------------------
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <direct.h>
#include <io.h>
#include <tchar.h>
#include <tlhelp32.h>
#define WEBUI_GET_CURRENT_DIR _getcwd
#define WEBUI_FILE_EXIST _access
#define WEBUI_POPEN _popen
#define WEBUI_PCLOSE _pclose
#define WEBUI_MAX_PATH MAX_PATH
#endif
// -- Linux ---------------------------
#ifdef __linux__
#include <unistd.h>
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/time.h>
#include <signal.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Apple ---------------------------
#ifdef __APPLE__
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/syslimits.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#include <signal.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Enums ---------------------------
enum webui_browsers {
AnyBrowser = 0, // 0. Default recommended web browser
Chrome, // 1. Google Chrome
Firefox, // 2. Mozilla Firefox
Edge, // 3. Microsoft Edge
Safari, // 4. Apple Safari
Chromium, // 5. The Chromium Project
Opera, // 6. Opera Browser
Brave, // 7. The Brave Browser
Vivaldi, // 8. The Vivaldi Browser
Epic, // 9. The Epic Browser
Yandex, // 10. The Yandex Browser
};
enum webui_runtimes {
None = 0, // 0. Prevent WebUI from using any runtime for .js and .ts files
Deno, // 1. Use Deno runtime for .js and .ts files
NodeJS, // 2. Use Nodejs runtime for .js files
};
enum webui_events {
WEBUI_EVENT_DISCONNECTED = 0, // 0. Window disconnection event
WEBUI_EVENT_CONNECTED, // 1. Window connection event
WEBUI_EVENT_MULTI_CONNECTION, // 2. New window connection event
WEBUI_EVENT_UNWANTED_CONNECTION, // 3. New unwanted window connection event
WEBUI_EVENT_MOUSE_CLICK, // 4. Mouse click event
WEBUI_EVENT_NAVIGATION, // 5. Window navigation event
WEBUI_EVENT_CALLBACK, // 6. Function call event
};
// -- Structs -------------------------
typedef struct webui_event_t {
size_t window; // The window object number
size_t event_type; // Event type
char* element; // HTML element ID
char* data; // JavaScript data
size_t event_number; // Internal WebUI
} webui_event_t;
// -- Definitions ---------------------
// Create a new webui window object.
WEBUI_EXPORT size_t webui_new_window(void);
// Create a new webui window object.
WEBUI_EXPORT void webui_new_window_id(size_t window_number);
// Get a free window ID that can be used with `webui_new_window_id()`
WEBUI_EXPORT size_t webui_get_new_window_id(void);
// Bind a specific html element click event with a function. Empty element means all events.
WEBUI_EXPORT size_t webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e));
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
WEBUI_EXPORT bool webui_show(size_t window, const char* content);
// Same as webui_show(). But with a specific web browser.
WEBUI_EXPORT bool webui_show_browser(size_t window, const char* content, size_t browser);
// Set the window in Kiosk mode (Full screen)
WEBUI_EXPORT void webui_set_kiosk(size_t window, bool status);
// Wait until all opened windows get closed.
WEBUI_EXPORT void webui_wait(void);
// Close a specific window only. The window object will still exist.
WEBUI_EXPORT void webui_close(size_t window);
// Close a specific window and free all memory resources.
WEBUI_EXPORT void webui_destroy(size_t window);
// Close all opened windows. webui_wait() will break.
WEBUI_EXPORT void webui_exit(void);
// -- Other ---------------------------
// Check a specific window if it's still running
WEBUI_EXPORT bool webui_is_shown(size_t window);
// Set the maximum time in seconds to wait for browser to start
WEBUI_EXPORT void webui_set_timeout(size_t second);
// Set the default embedded HTML favicon
WEBUI_EXPORT void webui_set_icon(size_t window, const char* icon, const char* icon_type);
// Allow the window URL to be re-used in normal web browsers
WEBUI_EXPORT void webui_set_multi_access(size_t window, bool status);
// -- JavaScript ----------------------
// Run JavaScript quickly with no waiting for the response.
WEBUI_EXPORT void webui_run(size_t window, const char* script);
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
WEBUI_EXPORT bool webui_script(size_t window, const char* script, size_t timeout, char* buffer, size_t buffer_length);
// Chose between Deno and Nodejs runtime for .js and .ts files.
WEBUI_EXPORT void webui_set_runtime(size_t window, size_t runtime);
// Parse argument as integer.
WEBUI_EXPORT long long int webui_get_int(webui_event_t* e);
// Parse argument as string.
WEBUI_EXPORT const char* webui_get_string(webui_event_t* e);
// Parse argument as boolean.
WEBUI_EXPORT bool webui_get_bool(webui_event_t* e);
// Return the response to JavaScript as integer.
WEBUI_EXPORT void webui_return_int(webui_event_t* e, long long int n);
// Return the response to JavaScript as string.
WEBUI_EXPORT void webui_return_string(webui_event_t* e, char* s);
// Return the response to JavaScript as boolean.
WEBUI_EXPORT void webui_return_bool(webui_event_t* e, bool b);
// Base64 encoding. Use this to safely send text based data to the UI. If it fails it will return NULL.
WEBUI_EXPORT char* webui_encode(const char* str);
// Base64 decoding. Use this to safely decode received Base64 text from the UI. If it fails it will return NULL.
WEBUI_EXPORT char* webui_decode(const char* str);
// Safely free a buffer allocated by WebUI, for example when using webui_encode().
WEBUI_EXPORT void webui_free(void* ptr);
// -- Interface -----------------------
// Bind a specific html element click event with a function. Empty element means all events. This replace webui_bind(). The func is (Window, EventType, Element, Data, EventNumber)
WEBUI_EXPORT size_t webui_interface_bind(size_t window, const char* element, void (*func)(size_t, size_t, char*, char*, size_t));
// When using `webui_interface_bind()` you may need this function to easily set your callback response.
WEBUI_EXPORT void webui_interface_set_response(size_t window, size_t event_number, const char* response);
// Check if the app still running or not. This replace webui_wait().
WEBUI_EXPORT bool webui_interface_is_app_running(void);
// Get window unique ID
WEBUI_EXPORT size_t webui_interface_get_window_id(size_t window);
// Get a unique ID. Same ID as `webui_bind()`. Return > 0 if bind exist.
WEBUI_EXPORT size_t webui_interface_get_bind_id(size_t window, const char* element);
#endif /* _WEBUI_H */

View File

@ -1,249 +0,0 @@
/*
WebUI Library 2.3.0
http://webui.me
https://github.com/webui-dev/webui
Copyright (c) 2020-2023 Hassan Draga.
Licensed under MIT License.
All rights reserved.
Canada.
*/
#ifndef _WEBUI_HPP
#define _WEBUI_HPP
// C++ STD
#include <string>
// WebUI C Header
extern "C" {
#include "webui.h"
}
namespace webui {
const int DISCONNECTED = 0; // 0. Window disconnection event
const int CONNECTED = 1; // 1. Window connection event
const int MULTI_CONNECTION = 2; // 2. New window connection event
const int UNWANTED_CONNECTION = 3; // 3. New unwanted window connection event
const int MOUSE_CLICK = 4; // 4. Mouse click event
const int NAVIGATION = 5; // 5. Window navigation event
const int CALLBACKS = 6; // 6. Function call event
class window;
// Event struct
struct event {
webui::window& window; // The window object
unsigned int event_type; // Event type
std::string element; // HTML element ID
std::string data; // JavaScript data
unsigned int event_number; // Internal WebUI
// Window object constructor that
// initializes the reference, This
// is to avoid creating copies.
event(webui::window& window_obj) : window(window_obj) {}
};
// List of callbacks: user_function(webui::event* e)
void (*callback_list[512])(webui::event*);
// List of window objects: webui::window
webui::window* window_list[512];
// Event handler
// WebUI is written in C. So there is no way
// to make C call a C++ class member. That's
// why this function should be outside class
void event_handler(webui_event_t* c_e) {
// Get a unique ID. Same ID as `webui_bind()`. Return > 0 if bind exist.
unsigned int id = webui_interface_get_bind_id(c_e->window, c_e->element);
if(id < 1)
return;
// Create a new event struct
webui::event e(*window_list[id]);
// `e.window` is already initialized by `e` constructor
e.event_type = c_e->event_type;
e.element = (c_e->element != NULL ? std::string(c_e->element) : std::string(""));
e.data = (c_e->data != NULL ? std::string(c_e->data) : std::string(""));
e.event_number = c_e->event_number;
// Call the user callback
if(callback_list[id] != NULL)
callback_list[id](&e);
}
class window {
private:
size_t webui_window = 0;
webui_event_t* convert_event_to_webui_event(webui::event* e) {
// Convert C++ `webui::event` to C `webui_event_t`
webui_event_t* c_e = new webui_event_t;
c_e->window = this->webui_window;
c_e->event_type = e->event_type;
c_e->element = (char*)e->element.c_str();
c_e->data = (char*)e->data.c_str();
c_e->event_number = e->event_number;
return c_e;
}
public:
// Constructor
window() {
this->webui_window = webui_new_window();
}
// Destructor
~window() {
// Nothing to do.
// No needs to call `webui_close()`
}
// Bind a specific html element click event with a function. Empty element means all events.
void bind(std::string element, void (*func)(webui::event* e)) {
// Get unique ID
unsigned int id = webui_bind(this->webui_window, element.c_str(), webui::event_handler);
// Save window object
window_list[id] = this;
// Save callback
callback_list[id] = func;
}
// Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
bool show(std::string content) {
return webui_show(this->webui_window, content.c_str());
}
// Same as show(). But with a specific web browser.
bool show_browser(std::string content, unsigned int browser) {
return webui_show_browser(this->webui_window, content.c_str(), browser);
}
// Close a specific window.
void close() {
webui_close(this->webui_window);
}
// Set the window in Kiosk mode (Full screen)
void set_kiosk(bool status) {
webui_set_kiosk(this->webui_window, status);
}
// -- Other ---------------------------
// Check a specific window if it's still running
bool is_shown() {
return webui_is_shown(this->webui_window);
}
// Set the default embedded HTML favicon
void set_icon(std::string icon, std::string icon_type) {
webui_set_icon(this->webui_window, icon.c_str(), icon_type.c_str());
}
// Allow the window URL to be re-used in normal web browsers
void set_multi_access(bool status) {
webui_set_multi_access(this->webui_window, status);
}
// -- JavaScript ----------------------
// Quickly run a JavaScript (no response waiting).
void run(std::string script) {
webui_run(this->webui_window, script.c_str());
}
// Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
bool script(std::string script, unsigned int timeout, char* buffer, size_t buffer_length) {
return webui_script(this->webui_window, script.c_str(), timeout, buffer, buffer_length);
}
// Chose between Deno and Nodejs runtime for .js and .ts files.
void set_runtime(unsigned int runtime) {
webui_set_runtime(this->webui_window, runtime);
}
// Parse argument as integer.
long long int get_int(webui::event* e) {
webui_event_t* c_e = convert_event_to_webui_event(e);
long long int ret = webui_get_int(c_e);
delete c_e;
return ret;
}
// Parse argument as string.
std::string get_string(webui::event* e) {
webui_event_t* c_e = convert_event_to_webui_event(e);
std::string ret = std::string(webui_get_string(c_e));
delete c_e;
return ret;
}
// Parse argument as boolean.
bool get_bool(webui::event* e) {
webui_event_t* c_e = convert_event_to_webui_event(e);
bool ret = webui_get_bool(c_e);
delete c_e;
return ret;
}
// Return the response to JavaScript as integer.
void return_int(webui::event* e, long long int n) {
webui_event_t* c_e = convert_event_to_webui_event(e);
webui_return_int(c_e, n);
delete c_e;
}
// Return the response to JavaScript as string.
void return_string(webui::event* e, std::string s) {
webui_event_t* c_e = convert_event_to_webui_event(e);
webui_return_string(c_e, &s[0]);
delete c_e;
}
// Return the response to JavaScript as boolean.
void return_bool(webui::event* e, bool b) {
webui_event_t* c_e = convert_event_to_webui_event(e);
webui_return_bool(c_e, b);
delete c_e;
}
};
// Wait until all opened windows get closed.
void wait(void) {
webui_wait();
}
// Close all opened windows. wait() will break.
void exit(void) {
webui_exit();
}
// Set the maximum time in seconds to wait for browser to start
void set_timeout(unsigned int second) {
webui_set_timeout(second);
}
// Base64 encoding. Use this to safely send text based data to the UI. If it fails it will return NULL.
std::string encode(std::string str) {
std::string ret = std::string(webui_encode(str.c_str()));
return ret;
}
// Base64 decoding. Use this to safely decode received Base64 text from the UI. If it fails it will return NULL.
std::string decode(std::string str) {
std::string ret = std::string(webui_decode(str.c_str()));
return ret;
}
// Safely free a buffer allocated by WebUI, for example when using webui_encode().
void free(void* ptr) {
webui_free(ptr);
}
}
#endif /* _WEBUI_HPP */

Some files were not shown because too many files have changed in this diff Show More