mirror of
https://github.com/webui-dev/webui
synced 2025-03-28 21:13:17 +00:00
Compare commits
1073 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9dd20b5c98 | ||
![]() |
65fd9a8800 | ||
![]() |
3c03d4f45c | ||
![]() |
1f80350564 | ||
![]() |
4c8fc25b2d | ||
![]() |
b59ddf1c0c | ||
![]() |
5fafc9b6b6 | ||
![]() |
995f1ab25f | ||
![]() |
d274723ec6 | ||
![]() |
9430e57040 | ||
![]() |
78b163c350 | ||
![]() |
af455d38ee | ||
![]() |
5c52beebfb | ||
![]() |
ea5e9a57fc | ||
![]() |
c50fcdf5da | ||
![]() |
433dcc25e0 | ||
![]() |
c66b71a98c | ||
![]() |
f21f4f14e1 | ||
![]() |
84758f6742 | ||
![]() |
aec0f654ba | ||
![]() |
ed3aae5790 | ||
![]() |
d2b40ee7e6 | ||
![]() |
25c7e3f16c | ||
![]() |
361237669b | ||
![]() |
c6d5b58352 | ||
![]() |
7e257de1b0 | ||
![]() |
16aec7e181 | ||
![]() |
5415b19b5f | ||
![]() |
c9baba76b7 | ||
![]() |
f4b9043288 | ||
![]() |
facd97c107 | ||
![]() |
223608479b | ||
![]() |
305070eeb1 | ||
![]() |
7d310a7c1f | ||
![]() |
d58e04ff05 | ||
![]() |
1b2f7b637b | ||
![]() |
dacbfcd257 | ||
![]() |
b1595c766c | ||
![]() |
130a26cc21 | ||
![]() |
8bf01b0d3e | ||
![]() |
3a959d0402 | ||
![]() |
6cca39ecac | ||
![]() |
e019f00fad | ||
![]() |
fcd903d424 | ||
![]() |
6b61f311c8 | ||
![]() |
7dddb64d92 | ||
![]() |
bf1c8ada92 | ||
![]() |
e558709118 | ||
![]() |
b6457c88bb | ||
![]() |
8d9c6b275b | ||
![]() |
5ac66da94b | ||
![]() |
92324edf6f | ||
![]() |
9926908e4b | ||
![]() |
fd716ddcac | ||
![]() |
ef5df7f28c | ||
![]() |
5d497e3b83 | ||
![]() |
02328acc6d | ||
![]() |
b4ce0284ae | ||
![]() |
61444bfaa7 | ||
![]() |
70b6689106 | ||
![]() |
7b661f142b | ||
![]() |
72039fa0ca | ||
![]() |
bd2611ba60 | ||
![]() |
93ec28addb | ||
![]() |
52c1777c77 | ||
![]() |
3734f9fe9f | ||
![]() |
fb29c6cac4 | ||
![]() |
18b5d14f8e | ||
![]() |
f4e327208f | ||
![]() |
8c58fcb973 | ||
![]() |
8f5a306574 | ||
![]() |
e92f9b7824 | ||
![]() |
c386758414 | ||
![]() |
0f8925e358 | ||
![]() |
44971f9bca | ||
![]() |
8fa1fdb89d | ||
![]() |
cdebbfee0a | ||
![]() |
bf94687089 | ||
![]() |
36676f68ff | ||
![]() |
56f1e4eb2b | ||
![]() |
553e65e218 | ||
![]() |
d9af5b2c17 | ||
![]() |
27c877f73f | ||
![]() |
c9c7562496 | ||
![]() |
1594f9e40d | ||
![]() |
133da5072b | ||
![]() |
8eb49857c1 | ||
![]() |
6c299e49ed | ||
![]() |
ad869075d2 | ||
![]() |
0d8ed71a8a | ||
![]() |
c512af1e6c | ||
![]() |
63284fe2a7 | ||
![]() |
f2961585e2 | ||
![]() |
fb5c2ab616 | ||
![]() |
c52ac5fc4a | ||
![]() |
3ff8742f3e | ||
![]() |
27088bd5d2 | ||
![]() |
8a7ea878b5 | ||
![]() |
2d3a68ebea | ||
![]() |
1eb06bb0c7 | ||
![]() |
ddc94db8db | ||
![]() |
0268c3723b | ||
![]() |
7f60505709 | ||
![]() |
f412473dca | ||
![]() |
728cd8370d | ||
![]() |
0a088943d5 | ||
![]() |
cdda40df5f | ||
![]() |
2adfee2e04 | ||
![]() |
c05a18a2f4 | ||
![]() |
9e68b911ae | ||
![]() |
5486cb4e9c | ||
![]() |
2e9d65d2bc | ||
![]() |
c9087c35b1 | ||
![]() |
4dcf4ce07c | ||
![]() |
e0b09e3a49 | ||
![]() |
d7a87ed6f9 | ||
![]() |
737ee76cbc | ||
![]() |
b6f70527be | ||
![]() |
c9abbc9cdb | ||
![]() |
d695c5b8fc | ||
![]() |
d757120977 | ||
![]() |
0ff3b1351b | ||
![]() |
41497e1a52 | ||
![]() |
ef18fdc772 | ||
![]() |
09128cefb0 | ||
![]() |
0f4cf1a4b8 | ||
![]() |
734f00aaac | ||
![]() |
3c9137eef5 | ||
![]() |
6511bc56d8 | ||
![]() |
2a5a449900 | ||
![]() |
a3ea3619ee | ||
![]() |
a509155eaf | ||
![]() |
9d2b80d3b3 | ||
![]() |
e67788ad70 | ||
![]() |
9814a18e0a | ||
![]() |
7189093a5d | ||
![]() |
7156f6a1e2 | ||
![]() |
4a67f91554 | ||
![]() |
e01fb64666 | ||
![]() |
984de15efa | ||
![]() |
3084ff3e26 | ||
![]() |
2a406f5276 | ||
![]() |
8fc3d1a39a | ||
![]() |
89a54eb621 | ||
![]() |
39628742aa | ||
![]() |
f59d0463e0 | ||
![]() |
6e7b0dacb2 | ||
![]() |
be972b50a4 | ||
![]() |
ed77621974 | ||
![]() |
e8863a06c1 | ||
![]() |
09cfb561d1 | ||
![]() |
5273ef3925 | ||
![]() |
dc82dabf3b | ||
![]() |
39095cea86 | ||
![]() |
a44283b04d | ||
![]() |
5a710c29ce | ||
![]() |
387bebe2c1 | ||
![]() |
72ae4703aa | ||
![]() |
12dee8bab7 | ||
![]() |
45257c7f8e | ||
![]() |
114ac657e7 | ||
![]() |
c80f2fa1cd | ||
![]() |
8433878d3d | ||
![]() |
5a1e097949 | ||
![]() |
2bef6d9f67 | ||
![]() |
b122b59444 | ||
![]() |
37cdbfde9d | ||
![]() |
6a6385f515 | ||
![]() |
b261ec8c16 | ||
![]() |
b803322edc | ||
![]() |
57c0215069 | ||
![]() |
fb6ea0db5b | ||
![]() |
65b49d1d09 | ||
![]() |
31c0264a04 | ||
![]() |
f161bcaced | ||
![]() |
48df019c84 | ||
![]() |
d5b25ca1a8 | ||
![]() |
5fd3f15ac7 | ||
![]() |
15e2d684df | ||
![]() |
2702d0427b | ||
![]() |
9c7f07bd89 | ||
![]() |
5545881e4c | ||
![]() |
3b0736fb89 | ||
![]() |
cf0c54e2bd | ||
![]() |
f8e0a20820 | ||
![]() |
7cb1493d0a | ||
![]() |
ca379f7ba6 | ||
![]() |
f8172bdbfa | ||
![]() |
3e66411779 | ||
![]() |
ead99700e9 | ||
![]() |
e8aaba6560 | ||
![]() |
069cb1f3a5 | ||
![]() |
924ea94f25 | ||
![]() |
aec67a1e42 | ||
![]() |
2e94629304 | ||
![]() |
ecccc7e820 | ||
![]() |
450197ffbf | ||
![]() |
a89a10120a | ||
![]() |
9c07d87041 | ||
![]() |
0826a2c5f8 | ||
![]() |
47c11dec33 | ||
![]() |
64133f4c30 | ||
![]() |
ef8595ae1c | ||
![]() |
18f7ce3460 | ||
![]() |
78a30109de | ||
![]() |
17a3a75959 | ||
![]() |
0bfe23ceda | ||
![]() |
fb63521042 | ||
![]() |
d213bf487a | ||
![]() |
8008016de8 | ||
![]() |
1dbce3938e | ||
![]() |
13f1ebe1fe | ||
![]() |
c158487417 | ||
![]() |
708d4a16a3 | ||
![]() |
bdd89e22ea | ||
![]() |
fc0c867f25 | ||
![]() |
3f683ea036 | ||
![]() |
633a96c54b | ||
![]() |
1e8642bc6e | ||
![]() |
b2f505a41c | ||
![]() |
af46c34a02 | ||
![]() |
9350a6aa95 | ||
![]() |
d01c8a8352 | ||
![]() |
9ed9279a98 | ||
![]() |
bbcdb9c5e0 | ||
![]() |
de9508653a | ||
![]() |
51d82c82e9 | ||
![]() |
0346f0ffdc | ||
![]() |
ff97452eb0 | ||
![]() |
50e9e4c2c6 | ||
![]() |
0440eeaab1 | ||
![]() |
2a79c2b526 | ||
![]() |
faa02ad708 | ||
![]() |
f888f15dbd | ||
![]() |
4f6fbc58d0 | ||
![]() |
923f48795f | ||
![]() |
e443e318f7 | ||
![]() |
bdf6bac511 | ||
![]() |
600e8d36b1 | ||
![]() |
59f2d077a6 | ||
![]() |
13c889a10e | ||
![]() |
fb1607b3d3 | ||
![]() |
cdc78e4609 | ||
![]() |
89495f919d | ||
![]() |
3b3e4c4ab0 | ||
![]() |
57a5846746 | ||
![]() |
836e1d115f | ||
![]() |
56f787cf73 | ||
![]() |
6ca760163e | ||
![]() |
f25dd98112 | ||
![]() |
e8f6a8abdb | ||
![]() |
efe64ba0af | ||
![]() |
5f33f70d64 | ||
![]() |
c4cc398778 | ||
![]() |
327067cb7d | ||
![]() |
bb887d76f6 | ||
![]() |
cc103aa37f | ||
![]() |
92e98e84e2 | ||
![]() |
4116ec7581 | ||
![]() |
d5a82f98bf | ||
![]() |
da7bb84ca3 | ||
![]() |
4caeb82351 | ||
![]() |
88c9996ce6 | ||
![]() |
5a39692fb8 | ||
![]() |
b65608dfec | ||
![]() |
9b79e7329c | ||
![]() |
b576b2f9de | ||
![]() |
88cd5f3774 | ||
![]() |
d0b013ccda | ||
![]() |
acc77ce5d2 | ||
![]() |
8e8abd2273 | ||
![]() |
b0dd088d56 | ||
![]() |
a93083b2a2 | ||
![]() |
57f5fca41e | ||
![]() |
6b539c376a | ||
![]() |
900e6f8d61 | ||
![]() |
5399c1f2fe | ||
![]() |
3bdacf4c12 | ||
![]() |
f40d35a60b | ||
![]() |
c2f410d700 | ||
![]() |
81c778cc67 | ||
![]() |
aca21d905e | ||
![]() |
775455c809 | ||
![]() |
d32f0932b4 | ||
![]() |
e934fe6eee | ||
![]() |
0af781390d | ||
![]() |
a0595d992b | ||
![]() |
c17dc924fd | ||
![]() |
734511a1ee | ||
![]() |
104fd4803a | ||
![]() |
270c4de9fb | ||
![]() |
a628e0780e | ||
![]() |
6e7a7307cc | ||
![]() |
5aa49f6563 | ||
![]() |
56420d67b0 | ||
![]() |
a046af263c | ||
![]() |
5657f3f481 | ||
![]() |
90e774bb13 | ||
![]() |
c598ac996a | ||
![]() |
c3ce70c384 | ||
![]() |
2730c9d8e9 | ||
![]() |
1048ffaace | ||
![]() |
8ab54084e4 | ||
![]() |
6732b84cc1 | ||
![]() |
56dc82758b | ||
![]() |
a86217ebf5 | ||
![]() |
da61335597 | ||
![]() |
5ed5d688c2 | ||
![]() |
21118a5445 | ||
![]() |
6cefcb1f3d | ||
![]() |
e70f64e2c6 | ||
![]() |
b9c4530b42 | ||
![]() |
63b7cfde5f | ||
![]() |
6d1428ae61 | ||
![]() |
5a40b92cd2 | ||
![]() |
da7be60c78 | ||
![]() |
218093b958 | ||
![]() |
d4c1415fd8 | ||
![]() |
9518b9e844 | ||
![]() |
15d519c13d | ||
![]() |
46b2228ddb | ||
![]() |
18f8a1ea23 | ||
![]() |
23da99b3b7 | ||
![]() |
ea5540c833 | ||
![]() |
e8e4220b46 | ||
![]() |
0ae019b055 | ||
![]() |
486df2efbd | ||
![]() |
92b7fc7ce1 | ||
![]() |
2135b091fb | ||
![]() |
02aeef647e | ||
![]() |
934727b346 | ||
![]() |
d394a2f92a | ||
![]() |
a860746af7 | ||
![]() |
109063e5a4 | ||
![]() |
a4f0490d99 | ||
![]() |
179039bf5a | ||
![]() |
545c4f5e42 | ||
![]() |
1416e001e3 | ||
![]() |
cc3df4f040 | ||
![]() |
d4e6d5f3d5 | ||
![]() |
a1e4ef51bb | ||
![]() |
6e15893135 | ||
![]() |
2257b94a9b | ||
![]() |
cb76e0af53 | ||
![]() |
bf1a443749 | ||
![]() |
7d25559235 | ||
![]() |
911fe332c6 | ||
![]() |
93d78bf7c8 | ||
![]() |
20c350e3cd | ||
![]() |
4fb247ef25 | ||
![]() |
f182a12c8f | ||
![]() |
5be9d902db | ||
![]() |
4f2ccfb834 | ||
![]() |
45c973a387 | ||
![]() |
561c044924 | ||
![]() |
c3e2e821c6 | ||
![]() |
cdce8348bb | ||
![]() |
926dd936cb | ||
![]() |
c2bdc44371 | ||
![]() |
27160810a8 | ||
![]() |
ab827e0b50 | ||
![]() |
ee90585a0a | ||
![]() |
eacce2e00c | ||
![]() |
9039c31e68 | ||
![]() |
ced5d9795e | ||
![]() |
b57a803d5a | ||
![]() |
6c41d8d9b3 | ||
![]() |
1e6196cb9c | ||
![]() |
8b715e61f3 | ||
![]() |
a6aee12de0 | ||
![]() |
0462ca7fdb | ||
![]() |
67179f582b | ||
![]() |
97d7543289 | ||
![]() |
30889511ed | ||
![]() |
3ab322a33f | ||
![]() |
d8008e3d57 | ||
![]() |
386a26030c | ||
![]() |
743fe3d011 | ||
![]() |
6e775b277d | ||
![]() |
62a3b79e4b | ||
![]() |
cf9764a071 | ||
![]() |
4b8b4faa11 | ||
![]() |
d46f806038 | ||
![]() |
a29b0753d9 | ||
![]() |
ecea17cd3b | ||
![]() |
3de023e27e | ||
![]() |
26c9126880 | ||
![]() |
d982e5bd8a | ||
![]() |
33fd4a2f23 | ||
![]() |
62431928d8 | ||
![]() |
bf87e04a6b | ||
![]() |
37bdee47ec | ||
![]() |
4466bcfc4e | ||
![]() |
c853979fb1 | ||
![]() |
bcf08875a7 | ||
![]() |
4694a29389 | ||
![]() |
0878256bf8 | ||
![]() |
ade685fd3f | ||
![]() |
7a1eb111bb | ||
![]() |
0ade1d9b0d | ||
![]() |
41428a172c | ||
![]() |
373c546702 | ||
![]() |
817cc605be | ||
![]() |
6fe3549684 | ||
![]() |
c8c1b2b757 | ||
![]() |
218a129d25 | ||
![]() |
570a917a7d | ||
![]() |
c537df5abe | ||
![]() |
d86a795898 | ||
![]() |
769b011a87 | ||
![]() |
272b44a5e8 | ||
![]() |
43225227fa | ||
![]() |
2e1717272c | ||
![]() |
d3038f6a4a | ||
![]() |
72737eabcf | ||
![]() |
36e268c634 | ||
![]() |
d25ae317f4 | ||
![]() |
6ae5046287 | ||
![]() |
a8709a71b5 | ||
![]() |
34e9b10c68 | ||
![]() |
a1c6802a8a | ||
![]() |
ce3dce4991 | ||
![]() |
6d83d7e403 | ||
![]() |
cdc1d29879 | ||
![]() |
4517ba4982 | ||
![]() |
065cd3f09c | ||
![]() |
b4d428d09c | ||
![]() |
b61b145bb9 | ||
![]() |
19b2e32394 | ||
![]() |
21da984823 | ||
![]() |
a7475d16ee | ||
![]() |
19234368ba | ||
![]() |
9c9b3dc00a | ||
![]() |
8d94cdcae8 | ||
![]() |
225f818ce4 | ||
![]() |
cd0646274d | ||
![]() |
58f764898e | ||
![]() |
9ca7c3c8d0 | ||
![]() |
f94fa664b1 | ||
![]() |
3b3ccdfb03 | ||
![]() |
5baf13a068 | ||
![]() |
c4485be70e | ||
![]() |
6ec0c7bd6c | ||
![]() |
736cd41f9c | ||
![]() |
4f9fc49cfd | ||
![]() |
1f5d52048a | ||
![]() |
a54d90607a | ||
![]() |
f915af388e | ||
![]() |
c31abc32ee | ||
![]() |
587963ff6d | ||
![]() |
b07f5be076 | ||
![]() |
c82b21033f | ||
![]() |
ab175b489b | ||
![]() |
ac2230c4c0 | ||
![]() |
ba7d032377 | ||
![]() |
32d1917ff9 | ||
![]() |
13e2ccf17d | ||
![]() |
4700c2c5ff | ||
![]() |
9a057e1b29 | ||
![]() |
3500b053bb | ||
![]() |
b3c8f78271 | ||
![]() |
e921f0dde4 | ||
![]() |
7e99ecc7bf | ||
![]() |
ca65af8be6 | ||
![]() |
c4769e9cc3 | ||
![]() |
e8d38e4620 | ||
![]() |
c832eced7b | ||
![]() |
c5ddba49fd | ||
![]() |
33ff93f475 | ||
![]() |
d20df6483b | ||
![]() |
9f120e974f | ||
![]() |
bf81ad1b8f | ||
![]() |
cec7b8b756 | ||
![]() |
9a1e116701 | ||
![]() |
fb6618ca79 | ||
![]() |
c448c52182 | ||
![]() |
8ebdb00b43 | ||
![]() |
a3f3174c73 | ||
![]() |
7ca2382f99 | ||
![]() |
deae94bac8 | ||
![]() |
02f05a2936 | ||
![]() |
fc10b42318 | ||
![]() |
24fefb865b | ||
![]() |
4a63099003 | ||
![]() |
32f876a0ae | ||
![]() |
faeb246a03 | ||
![]() |
f37844bd56 | ||
![]() |
b2ea3861d6 | ||
![]() |
a994629f90 | ||
![]() |
7a690a514d | ||
![]() |
ce4b2e0530 | ||
![]() |
a0c42eec91 | ||
![]() |
a33a2a2717 | ||
![]() |
2503683a31 | ||
![]() |
6e5ba97b5b | ||
![]() |
b1adef299f | ||
![]() |
57e6083b7a | ||
![]() |
55e38e89ce | ||
![]() |
bb055f8fa8 | ||
![]() |
a4168b9b19 | ||
![]() |
3fcf8cea97 | ||
![]() |
328705360a | ||
![]() |
88bd588905 | ||
![]() |
2a5f0c98fb | ||
![]() |
841def61bf | ||
![]() |
1fb87145aa | ||
![]() |
350ec1d262 | ||
![]() |
6d99a29e69 | ||
![]() |
e73b3cfecd | ||
![]() |
f936a8c9e1 | ||
![]() |
c56260ff0d | ||
![]() |
146f40fa51 | ||
![]() |
01d025117d | ||
![]() |
5755fead94 | ||
![]() |
70def025c8 | ||
![]() |
b3a2677809 | ||
![]() |
de98b03522 | ||
![]() |
7c1e2c7588 | ||
![]() |
8e990d836d | ||
![]() |
be5e2940e1 | ||
![]() |
8e097357e6 | ||
![]() |
c86fc0ce97 | ||
![]() |
d40ce7caeb | ||
![]() |
c6dc314dbd | ||
![]() |
36b76afeb1 | ||
![]() |
1a495cf2d5 | ||
![]() |
69066b18f9 | ||
![]() |
288f1e9d39 | ||
![]() |
ac4ea8cd7b | ||
![]() |
152ef446c0 | ||
![]() |
29e69a970f | ||
![]() |
663e066f5e | ||
![]() |
c063f07dcd | ||
![]() |
ff6fdb1361 | ||
![]() |
02361e0518 | ||
![]() |
c9801ac2ad | ||
![]() |
4621be9f17 | ||
![]() |
c9e17a3eb0 | ||
![]() |
dd03c9f28d | ||
![]() |
05b42abd0e | ||
![]() |
75574910bd | ||
![]() |
031bb879d7 | ||
![]() |
80dd3f0bd4 | ||
![]() |
c79f499e5b | ||
![]() |
7c9f404017 | ||
![]() |
a775d1d0c7 | ||
![]() |
65bafb0f69 | ||
![]() |
88d0aba656 | ||
![]() |
9b745d434c | ||
![]() |
9d8e6a8c61 | ||
![]() |
8084a02f87 | ||
![]() |
b41ab2095b | ||
![]() |
44a488025d | ||
![]() |
4c3932ee00 | ||
![]() |
6a862f7f14 | ||
![]() |
9a5036941d | ||
![]() |
907f0330a1 | ||
![]() |
5081b5a333 | ||
![]() |
705bf9a5d8 | ||
![]() |
451a3e9bd0 | ||
![]() |
6a4ac339e6 | ||
![]() |
8adcbeff30 | ||
![]() |
509d9fa976 | ||
![]() |
514d09c538 | ||
![]() |
b907175e0c | ||
![]() |
855e279daf | ||
![]() |
8a6909fe04 | ||
![]() |
08262f3461 | ||
![]() |
f39af55093 | ||
![]() |
73d6e9f294 | ||
![]() |
4c16531a5c | ||
![]() |
bac9786d81 | ||
![]() |
f91ea36fce | ||
![]() |
eb50747970 | ||
![]() |
8363cccc9a | ||
![]() |
b1d2ae04e4 | ||
![]() |
46c5125e0d | ||
![]() |
87a3a4f4e6 | ||
![]() |
30a1e49130 | ||
![]() |
618c2a7939 | ||
![]() |
8bf9bf2279 | ||
![]() |
1866d2573c | ||
![]() |
d20d5ccfe4 | ||
![]() |
d9a4fadefb | ||
![]() |
b37395d1ac | ||
![]() |
c346969eaf | ||
![]() |
6e6bd540e7 | ||
![]() |
f96306396e | ||
![]() |
1e2fa6a7a2 | ||
![]() |
2a254db6c7 | ||
![]() |
8d0b43de00 | ||
![]() |
a59c1fe1db | ||
![]() |
4702158384 | ||
![]() |
66c95342bc | ||
![]() |
9fd3dd8d89 | ||
![]() |
270038ee6b | ||
![]() |
7d14be8eb0 | ||
![]() |
70e580334a | ||
![]() |
f7428d8d04 | ||
![]() |
cba5d302bc | ||
![]() |
45c685e21c | ||
![]() |
44875e345a | ||
![]() |
1d68040d87 | ||
![]() |
17981ec20d | ||
![]() |
682a8b6975 | ||
![]() |
27872465ed | ||
![]() |
ca82773fda | ||
![]() |
bd715963f0 | ||
![]() |
5cc97bedba | ||
![]() |
e7a344982f | ||
![]() |
8f80ffe476 | ||
![]() |
026617cb18 | ||
![]() |
5c5ff75725 | ||
![]() |
99141921ae | ||
![]() |
658a6c06e1 | ||
![]() |
42c6e22c49 | ||
![]() |
90bfa0f607 | ||
![]() |
f60cc6d320 | ||
![]() |
a0420daec3 | ||
![]() |
77cf950c3b | ||
![]() |
11093c97d4 | ||
![]() |
5518a3e044 | ||
![]() |
5e7c407bc0 | ||
![]() |
79783e5519 | ||
![]() |
3e8f854a89 | ||
![]() |
e74de08e75 | ||
![]() |
adcf4b8d9d | ||
![]() |
50cc7619ba | ||
![]() |
f42d01e2f9 | ||
![]() |
9a78898d62 | ||
![]() |
61a92b0da1 | ||
![]() |
d4caaf1593 | ||
![]() |
d2c6109533 | ||
![]() |
c398d35dd0 | ||
![]() |
058f082cd2 | ||
![]() |
022391380f | ||
![]() |
6d5612c24d | ||
![]() |
7da0677851 | ||
![]() |
e8a57331d9 | ||
![]() |
8be79a02eb | ||
![]() |
90dc676e39 | ||
![]() |
bb1c438e87 | ||
![]() |
b09c0dca94 | ||
![]() |
39f9ab0cd7 | ||
![]() |
53724d4ef8 | ||
![]() |
dd6c7ff628 | ||
![]() |
e462d7bfed | ||
![]() |
a9fa6fad99 | ||
![]() |
e7418ef36a | ||
![]() |
aade3f2119 | ||
![]() |
edcf4bd5aa | ||
![]() |
32cba040b2 | ||
![]() |
61501ee959 | ||
![]() |
5b784789ad | ||
![]() |
91c9445912 | ||
![]() |
4eda2b6670 | ||
![]() |
24a68d87a6 | ||
![]() |
62030156e5 | ||
![]() |
2f694d1a3f | ||
![]() |
67620af4cd | ||
![]() |
7c572d8d9f | ||
![]() |
f7cc098d03 | ||
![]() |
5cd3f53da7 | ||
![]() |
a2b807acd9 | ||
![]() |
9ff92268fc | ||
![]() |
6a634cc680 | ||
![]() |
2ca3b793c4 | ||
![]() |
8fa5c8f7e8 | ||
![]() |
aa739affba | ||
![]() |
bcf19bdcd4 | ||
![]() |
0f6981c14d | ||
![]() |
31997657ba | ||
![]() |
17e4171508 | ||
![]() |
5e594d5fb9 | ||
![]() |
5e17a037c1 | ||
![]() |
ffccf7491b | ||
![]() |
58f294ea9e | ||
![]() |
edc8617e96 | ||
![]() |
e06d972423 | ||
![]() |
5a6df39da9 | ||
![]() |
6059a193ab | ||
![]() |
f00cb22e3b | ||
![]() |
d305b7697a | ||
![]() |
ee9e8f9e2e | ||
![]() |
a41cf79f0b | ||
![]() |
ffb33ba831 | ||
![]() |
45c5721a36 | ||
![]() |
9200ac3b65 | ||
![]() |
ea50923288 | ||
![]() |
3377718469 | ||
![]() |
7f296436f9 | ||
![]() |
064af7a39c | ||
![]() |
a068a84320 | ||
![]() |
97857b1cce | ||
![]() |
6b42874993 | ||
![]() |
6f782bc1a8 | ||
![]() |
1478c4ffdd | ||
![]() |
c92ee58a9c | ||
![]() |
a616991ca6 | ||
![]() |
2f22d6c280 | ||
![]() |
2160aea9b0 | ||
![]() |
91dfe07aa6 | ||
![]() |
ea63be7921 | ||
![]() |
a67ff44829 | ||
![]() |
c50a576b90 | ||
![]() |
831ee41cfd | ||
![]() |
a033f1fd6a | ||
![]() |
940dcc50af | ||
![]() |
0a358cec8a | ||
![]() |
be9c0bc7cb | ||
![]() |
bbc53c0911 | ||
![]() |
4fdda5a681 | ||
![]() |
6d65890789 | ||
![]() |
72743b1c70 | ||
![]() |
c41533feac | ||
![]() |
5804b53906 | ||
![]() |
3f8254255d | ||
![]() |
24e8f52cee | ||
![]() |
bcb42c4fbb | ||
![]() |
c84e1d08b4 | ||
![]() |
1c4b5182b9 | ||
![]() |
740f6ed873 | ||
![]() |
75ebbf9625 | ||
![]() |
eaaf49a7d3 | ||
![]() |
0a1e0ebcf5 | ||
![]() |
67fa22009e | ||
![]() |
a1ba285468 | ||
![]() |
de21160566 | ||
![]() |
697fdae90e | ||
![]() |
d281258f72 | ||
![]() |
8a5880a060 | ||
![]() |
b952745732 | ||
![]() |
ae1bf47772 | ||
![]() |
0ed682fcf2 | ||
![]() |
294883704b | ||
![]() |
4fae3e19ed | ||
![]() |
bdea4fc64c | ||
![]() |
7f73b90836 | ||
![]() |
3beb01bc78 | ||
![]() |
d2bf059d4e | ||
![]() |
bc9d074b4d | ||
![]() |
661ab75dec | ||
![]() |
e91d6d70bf | ||
![]() |
500f030c35 | ||
![]() |
782fdf461a | ||
![]() |
cde123517d | ||
![]() |
9574724f99 | ||
![]() |
94a3db07b7 | ||
![]() |
349dbad06b | ||
![]() |
ee66862f87 | ||
![]() |
e5363cd5c3 | ||
![]() |
9308d767c9 | ||
![]() |
74830815cd | ||
![]() |
eda58b315e | ||
![]() |
cdfed3d7a2 | ||
![]() |
ccac4a482e | ||
![]() |
db5bc6bed3 | ||
![]() |
cf794df7d9 | ||
![]() |
af3e61c5c0 | ||
![]() |
2194f600f2 | ||
![]() |
b368b819b9 | ||
![]() |
0d400644d1 | ||
![]() |
8c965807e1 | ||
![]() |
7f0656c255 | ||
![]() |
b4a3092480 | ||
![]() |
77df52247d | ||
![]() |
83c802608c | ||
![]() |
e941e35fc6 | ||
![]() |
ece2b15456 | ||
![]() |
7ac0b7c3d4 | ||
![]() |
2784a076a1 | ||
![]() |
8299c0a9ba | ||
![]() |
7a59da84f0 | ||
![]() |
a79ebbf7ac | ||
![]() |
900d9670ca | ||
![]() |
9a8081647d | ||
![]() |
491c9541db | ||
![]() |
80ec655901 | ||
![]() |
3432cf4562 | ||
![]() |
bb9cdb1c88 | ||
![]() |
6bc8133232 | ||
![]() |
2bc90bd9cc | ||
![]() |
a5810e63d8 | ||
![]() |
1a71813a2b | ||
![]() |
549f901a9b | ||
![]() |
4768018655 | ||
![]() |
7839a42cba | ||
![]() |
4088230ebc | ||
![]() |
68a5d48e87 | ||
![]() |
78da533a3a | ||
![]() |
6a762b161f | ||
![]() |
3133bcb92a | ||
![]() |
52885648d2 | ||
![]() |
28274c53e8 | ||
![]() |
3fe765cad3 | ||
![]() |
ba84f249b5 | ||
![]() |
ecff6fdf0f | ||
![]() |
672a7db67b | ||
![]() |
096b0cf836 | ||
![]() |
e569039b0d | ||
![]() |
5b0333dbba | ||
![]() |
eab5f1a4e3 | ||
![]() |
1bf8e669a1 | ||
![]() |
acceaca7db | ||
![]() |
0723ad46ac | ||
![]() |
8fd74a902b | ||
![]() |
8f68da6dd8 | ||
![]() |
c455048a24 | ||
![]() |
49a26c7faa | ||
![]() |
6a85c9dfac | ||
![]() |
b68ab52409 | ||
![]() |
b883ca8aea | ||
![]() |
095a9e85e1 | ||
![]() |
edf5eeae65 | ||
![]() |
b5b528d03e | ||
![]() |
6d81f79230 | ||
![]() |
87cdf9acac | ||
![]() |
c4925dd4b8 | ||
![]() |
4818e6018c | ||
![]() |
4d76051471 | ||
![]() |
7eec4ac7c2 | ||
![]() |
7ebcc72dc3 | ||
![]() |
3d2fcc4363 | ||
![]() |
7ebf1f3299 | ||
![]() |
10e11da5e2 | ||
![]() |
639571c4d1 | ||
![]() |
b63ddfa185 | ||
![]() |
54075bf1ec | ||
![]() |
673c3278b9 | ||
![]() |
e4f052140b | ||
![]() |
006e28b97d | ||
![]() |
979b0b5877 | ||
![]() |
af06ebe165 | ||
![]() |
ae96c7299c | ||
![]() |
711dc0996d | ||
![]() |
e025a179cf | ||
![]() |
068d99fa04 | ||
![]() |
21fdee9eba | ||
![]() |
4919613bee | ||
![]() |
d169029523 | ||
![]() |
b38c9eb532 | ||
![]() |
5ac34890e8 | ||
![]() |
8026cf8886 | ||
![]() |
55b69ba46c | ||
![]() |
93b4f23a7b | ||
![]() |
5572dc7a1c | ||
![]() |
3bf700e139 | ||
![]() |
62b953d31f | ||
![]() |
d26c89e175 | ||
![]() |
378bd3cfba | ||
![]() |
3890c41bd4 | ||
![]() |
f7007ef71c | ||
![]() |
455e7333ff | ||
![]() |
0e83205383 | ||
![]() |
4c9b4fe00f | ||
![]() |
87e8742544 | ||
![]() |
8b467a464c | ||
![]() |
2f527e717e | ||
![]() |
3f4119d267 | ||
![]() |
99dea3f9ac | ||
![]() |
a9535a1d7e | ||
![]() |
3e20e0dc3a | ||
![]() |
00db084421 | ||
![]() |
eda195f668 | ||
![]() |
be02f83e31 | ||
![]() |
f1af7bb9ce | ||
![]() |
dbc27e49e0 | ||
![]() |
892229f0a1 | ||
![]() |
a08f46481a | ||
![]() |
9d87505004 | ||
![]() |
c528255458 | ||
![]() |
75859ff859 | ||
![]() |
964910d4af | ||
![]() |
8849b2cdaf | ||
![]() |
84ea9b8b42 | ||
![]() |
390a9dc168 | ||
![]() |
07e786f4b1 | ||
![]() |
f0655307d2 | ||
![]() |
507f3ebd60 | ||
![]() |
046ff37a05 | ||
![]() |
caf9e16de0 | ||
![]() |
7912046d8b | ||
![]() |
904855eec8 | ||
![]() |
6117505650 | ||
![]() |
f8175ab7a3 | ||
![]() |
eaad13d0d5 | ||
![]() |
956a9ff339 | ||
![]() |
45d922ff8b | ||
![]() |
81857eb25f | ||
![]() |
32d0dbdd0e | ||
![]() |
17a951a9e8 | ||
![]() |
969c388006 | ||
![]() |
4099952634 | ||
![]() |
f71a63f2b4 | ||
![]() |
b78d0abb97 | ||
![]() |
c13a9e88e3 | ||
![]() |
8c4cc1c429 | ||
![]() |
43b9f103e3 | ||
![]() |
1687d5b759 | ||
![]() |
72b37e39c7 | ||
![]() |
f79bb3458a | ||
![]() |
4f2cab41d4 | ||
![]() |
5cc88c3c3c | ||
![]() |
0ff4101c9b | ||
![]() |
4877d1e4da | ||
![]() |
28c49dd4cc | ||
![]() |
0b55abff5a | ||
![]() |
bd2f83516e | ||
![]() |
20f828a47f | ||
![]() |
89feefb41c | ||
![]() |
c57a19f204 | ||
![]() |
20276882dd | ||
![]() |
6d700fce2b | ||
![]() |
c16647fc6e | ||
![]() |
fd0be388d7 | ||
![]() |
c06f225904 | ||
![]() |
78ca30a585 | ||
![]() |
36436d7ef7 | ||
![]() |
d786f6db2a | ||
![]() |
234d0d40ba | ||
![]() |
3cf9191509 | ||
![]() |
e2931ac8fa | ||
![]() |
1d149165b2 | ||
![]() |
d0477a1f1e | ||
![]() |
9a683acdef | ||
![]() |
fa0918e862 | ||
![]() |
8d3924833c | ||
![]() |
026714bbc8 | ||
![]() |
85db018779 | ||
![]() |
5564d32c1d | ||
![]() |
010c91bcc6 | ||
![]() |
2891a5b5bf | ||
![]() |
be7132aa01 | ||
![]() |
25f66ae8fc | ||
![]() |
0213b80adb | ||
![]() |
f18bf530af | ||
![]() |
cdf67b17ac | ||
![]() |
e955ee2228 | ||
![]() |
5280738772 | ||
![]() |
dc98f8c0a4 | ||
![]() |
914c988f25 | ||
![]() |
bf757a7dc7 | ||
![]() |
7db9826676 | ||
![]() |
e71b816b71 | ||
![]() |
fec91226c1 | ||
![]() |
c130731c1f | ||
![]() |
4d4abe8f2a | ||
![]() |
f8f704f76a | ||
![]() |
e3ee8b4dbe | ||
![]() |
e41d3113e9 | ||
![]() |
bc5e5b2a56 | ||
![]() |
71eeb25453 | ||
![]() |
4e0a7fe5c1 | ||
![]() |
980d4a4306 | ||
![]() |
aacc8b0ddd | ||
![]() |
3e1a636288 | ||
![]() |
4f969262ce | ||
![]() |
270ae1b0c4 | ||
![]() |
47cd45e458 | ||
![]() |
e526419956 | ||
![]() |
6f7523585a | ||
![]() |
6bcf73c9e9 | ||
![]() |
a4e9e14903 | ||
![]() |
1f98ce6d10 | ||
![]() |
eafbd8cb49 | ||
![]() |
192b3172be | ||
![]() |
c34d469a7e | ||
![]() |
e116261130 | ||
![]() |
ca7b4f50ed | ||
![]() |
e5ba5fb6e6 | ||
![]() |
254e3733b2 | ||
![]() |
0cd8ab02fe | ||
![]() |
41b5ab3bd7 | ||
![]() |
7c418a6ed2 | ||
![]() |
be39bbd35d | ||
![]() |
7de2a6a467 | ||
![]() |
9c12422079 | ||
![]() |
8fabfcc728 | ||
![]() |
03340f6b6d | ||
![]() |
7392fdc8cd | ||
![]() |
24be46127c | ||
![]() |
591020ffc5 | ||
![]() |
543a0e9ced | ||
![]() |
29694c40cf | ||
![]() |
6682774208 | ||
![]() |
77e99e24d0 | ||
![]() |
b9314db953 | ||
![]() |
c537cf55e7 | ||
![]() |
537d5a677a | ||
![]() |
6ef37f068a | ||
![]() |
684a1296c0 | ||
![]() |
2aca7500fc | ||
![]() |
866796c8d2 | ||
![]() |
93f815422b | ||
![]() |
15478a0dcf | ||
![]() |
e32936036f | ||
![]() |
f4f168c912 | ||
![]() |
01e19872ac | ||
![]() |
579d9e5b23 | ||
![]() |
8d6ef7d7c8 | ||
![]() |
7ae70f31e3 | ||
![]() |
1436fd0f0a | ||
![]() |
bf0a0db8c4 | ||
![]() |
72a6c2b5bf | ||
![]() |
01d22d4c1f | ||
![]() |
e7c6bba62c | ||
![]() |
93f8552a6c | ||
![]() |
296dfdc0b4 | ||
![]() |
263ffe86ef | ||
![]() |
cefeb8daf1 | ||
![]() |
3cb8962b9a | ||
![]() |
3a0cd4968f | ||
![]() |
527d000b45 | ||
![]() |
6c344182f1 | ||
![]() |
52d3530c81 | ||
![]() |
1ea5d9f54b | ||
![]() |
756a28a644 | ||
![]() |
51f552d738 | ||
![]() |
e1d8f3f43c | ||
![]() |
04b3ab7734 | ||
![]() |
2de4a80867 | ||
![]() |
28f6c35e3e | ||
![]() |
7f7c28b24a | ||
![]() |
18d68ab586 | ||
![]() |
abe94a1387 | ||
![]() |
82fd95d864 | ||
![]() |
ef2671f267 | ||
![]() |
c89d92fc80 | ||
![]() |
4bb6846915 | ||
![]() |
a786cfaf0d | ||
![]() |
7b871b9843 | ||
![]() |
1a202a3c1e | ||
![]() |
848f8831be | ||
![]() |
ea49a6270c | ||
![]() |
44591c6f03 | ||
![]() |
0e6ac9b813 | ||
![]() |
9a38611454 | ||
![]() |
06d9f809c2 | ||
![]() |
0688fb1bf9 | ||
![]() |
cc5cf97c30 | ||
![]() |
cf7b7fb5d5 | ||
![]() |
211c010fb1 | ||
![]() |
61d26ce724 | ||
![]() |
8c0cde9e06 | ||
![]() |
a3a14e362a | ||
![]() |
b7bf608240 | ||
![]() |
45d04e57c0 | ||
![]() |
2310636389 | ||
![]() |
599d452a70 | ||
![]() |
9aca227129 | ||
![]() |
7b81828535 | ||
![]() |
cd786649be | ||
![]() |
8bc7a69138 | ||
![]() |
e1e640dd57 | ||
![]() |
d13d711ef4 | ||
![]() |
808b6ca2bf | ||
![]() |
58e4c336ae | ||
![]() |
291be8bf2b | ||
![]() |
8d00f4e5ca | ||
![]() |
1a1e4c7a00 | ||
![]() |
58a1da7487 | ||
![]() |
060ea8189f | ||
![]() |
8072279ebc | ||
![]() |
5d7bdf5b5d | ||
![]() |
889a55cfad | ||
![]() |
79f22f1305 | ||
![]() |
aaf4a123e4 | ||
![]() |
688e239e27 | ||
![]() |
c3a02919d3 | ||
![]() |
e8ce3b54f6 | ||
![]() |
d02eead1a9 | ||
![]() |
0c1504835e | ||
![]() |
9c14eef124 |
54
.github/workflows/ci.yml
vendored
Normal file
54
.github/workflows/ci.yml
vendored
Normal 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
|
38
.github/workflows/cmake.yml
vendored
38
.github/workflows/cmake.yml
vendored
@ -1,38 +0,0 @@
|
||||
name: Build WebUI
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
GCC-Linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Linux-GCC-Build
|
||||
run: |
|
||||
cd build/Linux/GCC
|
||||
make
|
||||
|
||||
MinGW-Windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Windows-MinGW-Build
|
||||
shell: cmd
|
||||
run: |
|
||||
cd build/Windows/GCC
|
||||
mingw32-make
|
||||
|
||||
MSVC-Windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: microsoft/setup-msbuild@v1.1
|
||||
- name: Windows-MSVC-Build
|
||||
shell: cmd
|
||||
run: |
|
||||
cd build/Windows/MSVC
|
||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||
nmake
|
193
.github/workflows/linux.yml
vendored
Normal file
193
.github/workflows/linux.yml
vendored
Normal 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
111
.github/workflows/linux_arch.yml
vendored
Normal 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
165
.github/workflows/linux_arm.yml
vendored
Normal 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
113
.github/workflows/linux_redhat.yml
vendored
Normal 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
125
.github/workflows/macos.yml
vendored
Normal 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
133
.github/workflows/windows.yml
vendored
Normal 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
36
.github/workflows/zig.yml
vendored
Normal 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
|
112
.gitignore
vendored
112
.gitignore
vendored
@ -1,25 +1,93 @@
|
||||
# Build
|
||||
build/
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
*.a
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.lib
|
||||
*.exp
|
||||
*.res
|
||||
*.out
|
||||
*.o
|
||||
*.def
|
||||
|
||||
# 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
|
||||
*.logs
|
||||
*.tlog
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
.vscode/
|
||||
.vs/
|
||||
Debug/
|
||||
Release/
|
||||
|
||||
# Visual Studio
|
||||
.idea/
|
||||
*.recipe
|
||||
*.idb
|
||||
*.iobj
|
||||
*.pdb
|
||||
|
||||
# Visual Studio for Mac
|
||||
.idea/
|
||||
|
||||
# Visual Studio cache files
|
||||
ipch/
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
|
||||
# Others
|
||||
.builds
|
||||
*~*
|
||||
*.cache
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*.swp
|
||||
*.userosscache
|
||||
*.err
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# NuGet
|
||||
packages/
|
||||
!packages/repositories.config
|
||||
*.nupkg
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userprefs
|
||||
*.sln.docstates
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
@ -32,3 +100,29 @@ target/
|
||||
|
||||
# Broken NTFS
|
||||
nul
|
||||
|
||||
# Zig
|
||||
zig-cache/
|
||||
zig-out/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
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
59
CMakeLists.txt
Normal 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
200
GNUmakefile
Normal 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
|
695
LICENSE
695
LICENSE
@ -1,674 +1,21 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
MIT License
|
||||
|
||||
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
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
92
Makefile
Normal file
92
Makefile
Normal 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.
|
327
README.md
327
README.md
@ -1,96 +1,303 @@
|
||||
# WebUI
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/alifcommunity/webui) [](https://github.com/alifcommunity/webui/issues) [](https://webui.me/)
|
||||

|
||||
|
||||
> Use any web browser as GUI, with your preferred language in the backend, and HTML/JS/TS/CSS in the frontend.
|
||||
# WebUI v2.5.0-beta.4
|
||||
|
||||

|
||||
[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
|
||||
|
||||
> :warning: **Notice**:
|
||||
>
|
||||
> * WebUI it's not a web-server solution or a framework, but it's an easy-embeddable tool to use any installed web browser as a user interface.
|
||||
>
|
||||
> * We are currently writing documentation.
|
||||
>
|
||||
> * WebUI is not ready yet for production release.
|
||||
[![][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)
|
||||
|
||||
> 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.
|
||||
|
||||

|
||||
|
||||
</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 library*)
|
||||
- Lightweight (*~160 Kb using TCC*) & Small memory footprint
|
||||
- Fast WS binary communication (*App--WebUI--Browser*)
|
||||
- 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
|
||||
- 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">
|
||||
|
||||

|
||||
|
||||
</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.
|
||||
|
||||
## Comparison
|
||||
### How Does it Work?
|
||||
|
||||

|
||||
<div align="center">
|
||||
|
||||
| | WebView | Qt | WebUI |
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| Dependencies on Windows | *Windows APIs, WebView2* | *QtCore, QtGui, QtWidgets* | *No need* |
|
||||
| Dependencies on Linux | *GTK3, WebKitGTK* | *QtCore, QtGui, QtWidgets* | *No need* |
|
||||
| Dependencies on macOS | *Cocoa, WebKit* | *QtCore, QtGui, QtWidgets* | *No need* |
|
||||

|
||||
|
||||
</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
|
||||
|
||||
| | 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](https://webui.me/docs/)
|
||||
> **Note**
|
||||
> We are currently writing documentation.
|
||||
|
||||
## Build
|
||||
- [Online Documentation](https://webui.me/docs/)
|
||||
|
||||
- [Windows](https://github.com/alifcommunity/webui/tree/main/build/Windows)
|
||||
- [Linux](https://github.com/alifcommunity/webui/tree/main/build/Linux)
|
||||
## Build WebUI Library
|
||||
|
||||
## Examples
|
||||
### Windows
|
||||
|
||||
- [C](https://github.com/alifcommunity/webui/tree/main/examples/C)
|
||||
- [C++](https://github.com/alifcommunity/webui/tree/main/examples/C++)
|
||||
- [Python](https://github.com/alifcommunity/webui/tree/main/examples/Python)
|
||||
- [TypeScript / JavaScript](https://github.com/alifcommunity/webui/tree/main/examples/TypeScript)
|
||||
- [Go](https://github.com/alifcommunity/webui/tree/main/examples/Go/hello_world)
|
||||
- [Rust](https://github.com/alifcommunity/webui/tree/main/examples/Rust/hello_world)
|
||||
- [V on malisipi/vwebui](https://github.com/malisipi/vwebui/tree/main/examples)
|
||||
|
||||
## Supported Browser
|
||||
| Compiler | Command |
|
||||
|----------|---------|
|
||||
| GCC | `mingw32-make` |
|
||||
| MSVC | `nmake` |
|
||||
|
||||
| OS | Browser | Status |
|
||||
| ------ | ------ | ------ |
|
||||
| Windows | Firefox | ✔️ |
|
||||
| Windows | Chrome | ✔️ |
|
||||
| Windows | Edge | ✔️ |
|
||||
| Linux | Firefox | ✔️ |
|
||||
| Linux | Chrome | ✔️ |
|
||||
| macOS | Firefox | *coming soon* |
|
||||
| macOS | Chrome | *coming soon* |
|
||||
| macOS | Safari | *coming soon* |
|
||||
<details>
|
||||
<summary><strong>Windows SSL/TLS (Optional)</strong></summary>
|
||||
|
||||
Download and install the OpenSSL pre-compiled binaries for Windows:
|
||||
|
||||
## Supported Language
|
||||
- **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/)
|
||||
|
||||
| Language | Status | Link |
|
||||
| ------ | ------ | ------ |
|
||||
| C | ✔️ | [examples/C](https://github.com/alifcommunity/webui/tree/main/examples/C) |
|
||||
| C++ | ✔️ | [examples/C++](https://github.com/alifcommunity/webui/tree/main/examples/C%2B%2B) |
|
||||
| Python | ✔️ | [examples/Python](https://github.com/alifcommunity/webui/tree/main/examples/Python) |
|
||||
| JavaScript | ✔️ | [examples/TypeScript/Nodejs](https://github.com/alifcommunity/webui/tree/main/examples/TypeScript/Nodejs) |
|
||||
| TypeScript | ✔️ | [examples/TypeScript/Deno](https://github.com/alifcommunity/webui/tree/main/examples/TypeScript/Deno) |
|
||||
| Go | ✔️ | [examples/Go](https://github.com/alifcommunity/webui/tree/main/examples/Go) |
|
||||
| Rust | ✔️ | [examples/Rust](https://github.com/alifcommunity/webui/tree/main/examples/Rust) |
|
||||
| V | ✔️ | [malisipi/vwebui](https://github.com/malisipi/vwebui) |
|
||||
```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
|
||||
|
||||
| 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 WebView
|
||||
|
||||
| WebView | Status |
|
||||
| --------------- | --------------- |
|
||||
| Windows WebView2 | ✔️ |
|
||||
| Linux GTK WebView | ✔️ |
|
||||
| macOS WKWebView | ✔️ |
|
||||
|
||||
### License
|
||||
|
||||
> GNU General Public License v3.0
|
||||
> Licensed under MIT License.
|
||||
|
||||
### Stargazers
|
||||
|
||||
[](https://github.com/alifcommunity/webui/stargazers)
|
||||
[](https://github.com/webui-dev/webui/stargazers)
|
||||
|
6
bridge/.gitignore
vendored
Normal file
6
bridge/.gitignore
vendored
Normal 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
47
bridge/README.md
Normal 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
45
bridge/build.bat
Normal 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
71
bridge/build.ps1
Normal 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
37
bridge/build.sh
Executable 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
64
bridge/js2c.py
Normal 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
56
bridge/utils.ts
Normal 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
974
bridge/webui.ts
Normal 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
1766
bridge/webui_bridge.h
Normal file
File diff suppressed because it is too large
Load Diff
210
build.zig
Normal file
210
build.zig
Normal 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
14
build.zig.zon
Normal 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",
|
||||
},
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
# WebUI Library
|
||||
# Linux - Clang
|
||||
|
||||
SOURCE=../../../src
|
||||
INCLUDE=../../../include
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Static with Debug info
|
||||
@echo "Build WebUI Library (Debug Static)..."
|
||||
@clang -g -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@clang -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@llvm-ar rc libwebui-2-static-x64.a webui.o mongoose.o
|
||||
@llvm-ranlib libwebui-2-static-x64.a
|
||||
# Dynamic with Debug info
|
||||
@echo "Build WebUI Library (Debug Dynamic)..."
|
||||
@clang -g -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@clang -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@clang -g -shared -o webui-2-x64.so webui.o mongoose.o
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
release:
|
||||
# Static Release
|
||||
@echo "Build WebUI Library (Release Static)..."
|
||||
@clang -Os -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@clang -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@llvm-ar rc libwebui-2-static-x64.a webui.o mongoose.o
|
||||
@llvm-ranlib libwebui-2-static-x64.a
|
||||
# Dynamic Release
|
||||
@echo "Build WebUI Library (Release Dynamic)..."
|
||||
@clang -O3 -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@clang -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@clang -shared -o webui-2-x64.so webui.o mongoose.o
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
clean:
|
||||
- rm -f *.o
|
||||
- rm -f *.so
|
||||
- rm -f *.a
|
@ -1,44 +0,0 @@
|
||||
# WebUI Library
|
||||
# Linux - GCC
|
||||
|
||||
SOURCE=../../../src
|
||||
INCLUDE=../../../include
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Static with Debug info
|
||||
@echo "Build WebUI Library (Debug Static)..."
|
||||
@gcc -g -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@gcc -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@ar rc libwebui-2-static-x64.a webui.o mongoose.o
|
||||
@ranlib libwebui-2-static-x64.a
|
||||
# Dynamic with Debug info
|
||||
@echo "Build WebUI Library (Debug Dynamic)..."
|
||||
@gcc -g -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@gcc -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@gcc -g -shared -o webui-2-x64.so webui.o mongoose.o
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
release:
|
||||
# Static Release
|
||||
@echo "Build WebUI Library (Release Static)..."
|
||||
@gcc -Os -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@gcc -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@ar rc libwebui-2-static-x64.a webui.o mongoose.o
|
||||
@ranlib libwebui-2-static-x64.a
|
||||
# Dynamic Release
|
||||
@echo "Build WebUI Library (Release Dynamic)..."
|
||||
@gcc -O3 -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@gcc -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@gcc -shared -o webui-2-x64.so webui.o mongoose.o
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
clean:
|
||||
- rm -f *.o
|
||||
- rm -f *.so
|
||||
- rm -f *.a
|
@ -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
|
||||
```
|
@ -1,6 +0,0 @@
|
||||
# Build WebUI Library
|
||||
|
||||
To build the WebUI you will need a `C99` compiler. No dependencies is needed.
|
||||
|
||||
[Windows](https://github.com/alifcommunity/webui/tree/main/build/Windows)
|
||||
[Linux](https://github.com/alifcommunity/webui/tree/main/build/Linux)
|
@ -1,45 +0,0 @@
|
||||
# WebUI Library
|
||||
# Windows - GNU Compiler Collection
|
||||
|
||||
SHELL=CMD
|
||||
SOURCE=../../../src
|
||||
INCLUDE=../../../include
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Static with Debug info
|
||||
@echo Build WebUI Library (Debug Static)...
|
||||
@gcc -g -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@gcc -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
|
||||
@ar rc libwebui-2-static-x64.a webui.o mongoose.o
|
||||
@ranlib libwebui-2-static-x64.a
|
||||
# Dynamic with Debug info
|
||||
@echo Build WebUI Library (Debug Dynamic)...
|
||||
@gcc -g -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@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 mongoose.o -lws2_32
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
# Static Release
|
||||
@echo Build WebUI Library (Release Static)...
|
||||
@gcc -Os -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@gcc -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@ar rc libwebui-2-static-x64.a webui.o mongoose.o
|
||||
@ranlib libwebui-2-static-x64.a
|
||||
# Dynamic Release
|
||||
@echo Build WebUI Library (Release Dynamic)...
|
||||
@gcc -O3 -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c" -Wno-stringop-overread
|
||||
@gcc -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@gcc -shared -o webui-2-x64.dll webui.o mongoose.o -lws2_32
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
@ -1,45 +0,0 @@
|
||||
# WebUI Library
|
||||
# Windows - Microsoft Visual C
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Static with Debug info
|
||||
@echo Build WebUI Library (Debug Static)...
|
||||
@cl /Zi /Fomongoose.obj /c /EHsc "../../../src/mongoose.c" /I "../../../include" >nul 2>&1
|
||||
@cl /Zi /Fowebui.obj /c /EHsc /DWEBUI_LOG "../../../src/webui.c" /I "../../../include" >nul 2>&1
|
||||
@lib /OUT:webui-2-static-x64.lib webui.obj mongoose.obj >nul 2>&1
|
||||
# Dynamic with Debug info
|
||||
@echo Build WebUI Library (Debug Dynamic)...
|
||||
@cl /Zi /Fomongoose.obj /c /EHsc "../../../src/mongoose.c" /I "../../../include" >nul 2>&1
|
||||
@cl /Zi /Fowebui.obj /c /EHsc /DWEBUI_LOG "../../../src/webui.c" /I "../../../include" >nul 2>&1
|
||||
@link /DLL /OUT:webui-2-x64.dll webui.obj mongoose.obj user32.lib >nul 2>&1
|
||||
# Clean
|
||||
@- del *.obj >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
# Static Release
|
||||
@echo Build WebUI Library (Release Static)...
|
||||
@cl /Fomongoose.obj /c /EHsc "../../../src/mongoose.c" /I "../../../include" >nul 2>&1
|
||||
@cl /Fowebui.obj /c /EHsc "../../../src/webui.c" /I "../../../include" >nul 2>&1
|
||||
@lib /OUT:webui-2-static-x64.lib webui.obj mongoose.obj >nul 2>&1
|
||||
# Dynamic Release
|
||||
@echo Build WebUI Library (Release Dynamic)...
|
||||
@cl /Fomongoose.obj /c /EHsc "../../../src/mongoose.c" /I "../../../include" >nul 2>&1
|
||||
@cl /Fowebui.obj /c /EHsc "../../../src/webui.c" /I "../../../include" >nul 2>&1
|
||||
@link /DLL /OUT:webui-2-x64.dll webui.obj mongoose.obj user32.lib >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
|
@ -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
|
||||
```
|
@ -1,44 +0,0 @@
|
||||
# WebUI Library
|
||||
# Windows - Tiny C Compiler
|
||||
|
||||
SHELL=CMD
|
||||
SOURCE=../../../src
|
||||
INCLUDE=../../../include
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Static with Debug info
|
||||
@echo Build WebUI Library (Debug Static)...
|
||||
@tcc -g -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@tcc -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
|
||||
@tcc -m64 -ar rcs libwebui-2-static-x64.a webui.o mongoose.o
|
||||
# Dynamic with Debug info
|
||||
@echo Build WebUI Library (Debug Dynamic)...
|
||||
@tcc -g -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@tcc -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c" -DWEBUI_LOG
|
||||
@tcc -g -shared -o webui-2-x64.dll webui.o mongoose.o -lws2_32
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
# Static Release
|
||||
@echo Build WebUI Library (Release Static)...
|
||||
@tcc -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@tcc -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@tcc -m64 -ar rcs libwebui-2-static-x64.a webui.o mongoose.o
|
||||
# Dynamic Release
|
||||
@echo Build WebUI Library (Release Dynamic)...
|
||||
@tcc -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
|
||||
@tcc -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
|
||||
@tcc -shared -o webui-2-x64.dll webui.o mongoose.o -lws2_32
|
||||
# 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
|
37
examples/C++/README.md
Normal file
37
examples/C++/README.md
Normal 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
|
||||
```
|
141
examples/C++/call_cpp_from_js/GNUmakefile
Normal file
141
examples/C++/call_cpp_from_js/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C++ Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
|
||||
CC = g++
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C++ Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C++ Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),g++ clang aarch64-linux-gnu-g++ arm-linux-gnueabihf-g++ musl-g++),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
63
examples/C++/call_cpp_from_js/Makefile
Normal file
63
examples/C++/call_cpp_from_js/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# WebUI C++ Example
|
||||
# Windows - Microsoft Visual C++
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Debug Static)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C++ Example (Debug Dynamic)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Release Static)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C++ Example (Release Dynamic)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
131
examples/C++/call_cpp_from_js/main.cpp
Normal file
131
examples/C++/call_cpp_from_js/main.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
// Call C++ from JavaScript Example
|
||||
|
||||
// Include the WebUI header
|
||||
#include "webui.hpp"
|
||||
|
||||
// Include C++ STD
|
||||
#include <iostream>
|
||||
|
||||
void my_function_string(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// my_function_string('Hello', 'World`);
|
||||
|
||||
std::string str_1 = e->get_string(); // Or e->get_string(0);
|
||||
std::string str_2 = e->get_string(1);
|
||||
|
||||
std::cout << "my_function_string 1: " << str_1 << std::endl; // Hello
|
||||
std::cout << "my_function_string 2: " << str_2 << std::endl; // World
|
||||
}
|
||||
|
||||
void my_function_integer(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// my_function_integer(123, 456, 789);
|
||||
|
||||
long long number_1 = e->get_int(); // Or e->get_int(0);
|
||||
long long number_2 = e->get_int(1);
|
||||
long long number_3 = e->get_int(2);
|
||||
|
||||
std::cout << "my_function_integer 1: " << number_1 << std::endl; // 123
|
||||
std::cout << "my_function_integer 2: " << number_2 << std::endl; // 456
|
||||
std::cout << "my_function_integer 3: " << number_3 << std::endl; // 789
|
||||
}
|
||||
|
||||
void my_function_boolean(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// my_function_boolean(true, false);
|
||||
|
||||
bool status_1 = e->get_bool(); // Or e->get_bool(0);
|
||||
bool status_2 = e->get_bool(1);
|
||||
|
||||
std::cout << "my_function_boolean 1: " << (status_1 ? "True" : "False") << std::endl;
|
||||
std::cout << "my_function_boolean 2: " << (status_2 ? "True" : "False") << std::endl;
|
||||
}
|
||||
|
||||
void my_function_with_response(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// my_function_with_response(number, 2).then(...)
|
||||
|
||||
long long number = e->get_int(0);
|
||||
long long times = e->get_int(1);
|
||||
|
||||
long long res = number * times;
|
||||
|
||||
std::cout << "my_function_with_response: " << number << " * " << times << " = " << res << std::endl;
|
||||
|
||||
// Send back the response to JavaScript
|
||||
e->return_int(res);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// HTML
|
||||
const std::string my_html = R"V0G0N(
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script src="/webui.js"></script>
|
||||
|
||||
<title>Call C++ from JavaScript Example</title>
|
||||
<style>
|
||||
body {
|
||||
background: linear-gradient(to left, #36265a, #654da9);
|
||||
color: AliceBlue;
|
||||
font-size: 16px sans-serif;
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
}
|
||||
button {
|
||||
margin: 5px 0 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>WebUI - Call C++ from JavaScript</h1>
|
||||
<p>Call C++ functions with arguments (<em>See the logs in your terminal</em>)</p>
|
||||
<button onclick="my_function_string('Hello', 'World');">Call my_function_string()</button>
|
||||
<br>
|
||||
<button onclick="my_function_integer(123, 456, 789);">Call my_function_integer()</button>
|
||||
<br>
|
||||
<button onclick="my_function_boolean(true, false);">Call my_function_boolean()</button>
|
||||
<br>
|
||||
<p>Call a C++ function that returns a response</p>
|
||||
<button onclick="MyJS();">Call my_function_with_response()</button>
|
||||
<div>Double: <input type="text" id="MyInputID" value="2"></div>
|
||||
<script>
|
||||
function MyJS() {
|
||||
const MyInput = document.getElementById('MyInputID');
|
||||
const number = MyInput.value;
|
||||
my_function_with_response(number, 2).then((response) => {
|
||||
MyInput.value = response;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
)V0G0N";
|
||||
|
||||
// Create a window
|
||||
webui::window my_window;
|
||||
|
||||
// Bind HTML elements with C++ functions
|
||||
my_window.bind("my_function_string", my_function_string);
|
||||
my_window.bind("my_function_integer", my_function_integer);
|
||||
my_window.bind("my_function_boolean", my_function_boolean);
|
||||
my_window.bind("my_function_with_response", my_function_with_response);
|
||||
|
||||
// Show the window
|
||||
my_window.show(my_html); // webui_show_browser(my_window, my_html, Chrome);
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui::wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) { main(); }
|
||||
#endif
|
141
examples/C++/call_js_from_cpp/GNUmakefile
Normal file
141
examples/C++/call_js_from_cpp/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C++ Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
|
||||
CC = g++
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C++ Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C++ Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),g++ clang aarch64-linux-gnu-g++ arm-linux-gnueabihf-g++ musl-g++),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
63
examples/C++/call_js_from_cpp/Makefile
Normal file
63
examples/C++/call_js_from_cpp/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# WebUI C++ Example
|
||||
# Windows - Microsoft Visual C++
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Debug Static)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C++ Example (Debug Dynamic)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Release Static)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C++ Example (Release Dynamic)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
121
examples/C++/call_js_from_cpp/main.cpp
Normal file
121
examples/C++/call_js_from_cpp/main.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
// Call JavaScript from C++ Example
|
||||
|
||||
// Include the WebUI header
|
||||
#include "webui.hpp"
|
||||
|
||||
// Include C++ STD
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
void my_function_exit(webui::window::event* e) {
|
||||
|
||||
// Close all opened windows
|
||||
webui::exit();
|
||||
}
|
||||
|
||||
void my_function_count(webui::window::event* e) {
|
||||
|
||||
// Create a buffer to hold the response
|
||||
char response[64];
|
||||
|
||||
// This is another way to create a buffer:
|
||||
// std::string buffer;
|
||||
// buffer.reserve(64);
|
||||
// my_window.script(..., ..., &buffer[0], 64);
|
||||
|
||||
// Run JavaScript
|
||||
if (!e->get_window().script("return GetCount();", 0, response, 64)) {
|
||||
|
||||
if (!e->get_window().is_shown())
|
||||
std::cout << "Window closed." << std::endl;
|
||||
else
|
||||
std::cout << "JavaScript Error: " << response << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the count
|
||||
int count = std::stoi(response);
|
||||
|
||||
// Increment
|
||||
count++;
|
||||
|
||||
// Generate a JavaScript
|
||||
std::stringstream js;
|
||||
js << "SetCount(" << count << ");";
|
||||
|
||||
// Run JavaScript (Quick Way)
|
||||
e->get_window().run(js.str());
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// HTML
|
||||
const std::string my_html = R"V0G0N(
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script src="/webui.js"></script>
|
||||
<title>Call JavaScript from C++ Example</title>
|
||||
<style>
|
||||
body {
|
||||
background: linear-gradient(to left, #36265a, #654da9);
|
||||
color: AliceBlue;
|
||||
font: 16px sans-serif;
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
}
|
||||
button {
|
||||
margin: 5px 0 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>WebUI - Call JavaScript from C++</h1>
|
||||
<br>
|
||||
<h1 id="count">0</h1>
|
||||
<br>
|
||||
<button OnClick="my_function_count();">Manual Count</button>
|
||||
<br>
|
||||
<button OnClick="AutoTest();">Auto Count (Every 10ms)</button>
|
||||
<br>
|
||||
<button id="Exit">Exit</button>
|
||||
<script>
|
||||
let count = 0;
|
||||
function GetCount() {
|
||||
return count;
|
||||
}
|
||||
function SetCount(number) {
|
||||
document.getElementById('count').innerHTML = number;
|
||||
count = number;
|
||||
}
|
||||
function AutoTest(number) {
|
||||
setInterval(function() {
|
||||
my_function_count();
|
||||
}, 10);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
)V0G0N";
|
||||
|
||||
// Create a window
|
||||
webui::window my_window;
|
||||
|
||||
// Bind HTML elements with C++ functions
|
||||
my_window.bind("my_function_count", my_function_count);
|
||||
my_window.bind("Exit", my_function_exit);
|
||||
|
||||
// Show the window
|
||||
my_window.show(my_html); // my_window.show_browser(my_html, Chrome);
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui::wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) { main(); }
|
||||
#endif
|
@ -1,42 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C++ Example
|
||||
# Linux - Clang
|
||||
|
||||
LIB=../../../../../build/Linux/Clang
|
||||
INCLUDE=../../../../../include
|
||||
SOURCE=../..
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo "Build C++ Example (Static Debug)..."
|
||||
@clang -g -static -m64 -o main "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C++ Example (Dynamic Debug)..."
|
||||
@clang -g -m64 -o main-dyn "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo "Build C++ Example (Static Release)..."
|
||||
@clang -static -Os -m64 -o main "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
@llvm-strip --strip-all main
|
||||
# Dynamic Release
|
||||
@echo "Build C++ Example (Dynamic Release)..."
|
||||
@clang -m64 -o main-dyn "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
@llvm-strip --strip-all main-dyn
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
clean:
|
||||
- rm -f *.o
|
||||
- rm -f *.so
|
||||
- rm -f *.a
|
@ -1,42 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C++ Example
|
||||
# Linux - GCC
|
||||
|
||||
LIB=../../../../../build/Linux/GCC
|
||||
INCLUDE=../../../../../include
|
||||
SOURCE=../..
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo "Build C++ Example (Static Debug)..."
|
||||
@gcc -g -static -m64 -o main "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C++ Example (Dynamic Debug)..."
|
||||
@gcc -g -m64 -o main-dyn "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo "Build C++ Example (Static Release)..."
|
||||
@gcc -static -Os -m64 -o main "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
@strip --strip-all main
|
||||
# Dynamic Release
|
||||
@echo "Build C++ Example (Dynamic Release)..."
|
||||
@gcc -m64 -o main-dyn "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
@strip --strip-all main-dyn
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
clean:
|
||||
- rm -f *.o
|
||||
- rm -f *.so
|
||||
- rm -f *.a
|
@ -1,36 +0,0 @@
|
||||
|
||||
# WebUI Examples - C++
|
||||
|
||||
To build the C++ example you will need any C++11 compiler, no dependencies is needed.
|
||||
|
||||
### Windows
|
||||
|
||||
- **Build Tools for Microsoft Visual Studio**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui\examples\C++\Windows\MSVC
|
||||
nmake
|
||||
```
|
||||
|
||||
- **MinGW**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui\examples\C++\Windows\GCC
|
||||
mingw32-make
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
- **GCC**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui/examples/C++/Linux/GCC
|
||||
make
|
||||
```
|
||||
|
||||
- **Clang**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui/examples/C++/Linux/Clang
|
||||
make
|
||||
```
|
@ -1,51 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C++ Example
|
||||
# Windows - GCC
|
||||
|
||||
SHELL=CMD
|
||||
LIB=../../../../../build/Windows/GCC
|
||||
INCLUDE=../../../../../include
|
||||
SOURCE=../..
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo Build C++ Example (Debug Static)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@g++ -g -static -m64 -o main.exe "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" win.res -lwebui-2-static-x64 -lws2_32 -Wall -Wl,-subsystem=console -luser32
|
||||
# Dynamic with Debug info
|
||||
@echo Build C++ Example (Debug Dynamic)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@g++ -g -m64 -o main-dyn.exe "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" win.res "$(LIB)/webui-2-x64.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@- del *.res >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo Build C++ Example (Release Static)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@g++ -static -Os -m64 -o main.exe "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" win.res -lwebui-2-static-x64 -lws2_32 -Wall -Wl,-subsystem=windows -luser32
|
||||
@strip --strip-all main.exe
|
||||
# Dynamic Release
|
||||
@echo Build C++ Example (Release Dynamic)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@g++ -m64 -o main-dyn.exe "$(SOURCE)/main.cpp" -I "$(INCLUDE)" -L "$(LIB)" win.res "$(LIB)/webui-2-x64.dll" -lws2_32 -Wall -Wl,-subsystem=windows -luser32
|
||||
@strip --strip-all main-dyn.exe
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@- del *.res >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.res >nul 2>&1
|
Binary file not shown.
Before Width: | Height: | Size: 105 KiB |
@ -1,24 +0,0 @@
|
||||
id ICON "win.ico"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "My Business Name"
|
||||
VALUE "LegalCopyright", "My Business Name"
|
||||
VALUE "FileDescription", "My WebUI Application"
|
||||
VALUE "InternalName", "MyApplication"
|
||||
VALUE "ProductName", "My Application"
|
||||
VALUE "FileVersion", "1.0"
|
||||
VALUE "OriginalFilename", "webui.exe"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
@ -1,49 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C++ Example
|
||||
# Windows - Microsoft Visual C
|
||||
|
||||
SHELL=CMD
|
||||
_LIB=../../../../../build/Windows/MSVC/
|
||||
_INCLUDE=../../../../../include/
|
||||
_SOURCE=../../
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(_LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo Build C++ Example (Debug Static)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl /Zi "$(_SOURCE)/main.cpp" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:CONSOLE win.res webui-2-static-x64.lib user32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
# Dynamic with Debug info
|
||||
@echo Build C++ Example (Debug Dynamic)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl /Zi "$(_SOURCE)/main.cpp" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:CONSOLE win.res webui-2-x64.lib user32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(_LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo Build C++ Example (Release Static)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl "$(_SOURCE)/main.cpp" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:WINDOWS win.res webui-2-static-x64.lib user32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
# Dynamic Release
|
||||
@echo Build C++ Example (Release Dynamic)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl "$(_SOURCE)/main.cpp" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:WINDOWS win.res webui-2-x64.lib user32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.res >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
||||
- del *.res >nul 2>&1
|
Binary file not shown.
Before Width: | Height: | Size: 105 KiB |
@ -1,24 +0,0 @@
|
||||
id ICON "win.ico"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "My Business Name"
|
||||
VALUE "LegalCopyright", "My Business Name"
|
||||
VALUE "FileDescription", "My WebUI Application"
|
||||
VALUE "InternalName", "MyApplication"
|
||||
VALUE "ProductName", "My Application"
|
||||
VALUE "FileVersion", "1.0"
|
||||
VALUE "OriginalFilename", "webui.exe"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
@ -1,44 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32901.82
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world", "hello_world\hello_world.vcxproj", "{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8} = {9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webui-2-static-x64", "webui-2-static-x64\webui-2-static-x64.vcxproj", "{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x64.Build.0 = Debug|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x64.ActiveCfg = Release|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x64.Build.0 = Release|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x86.Build.0 = Release|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x64.Build.0 = Debug|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x86.Build.0 = Debug|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x64.ActiveCfg = Release|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x64.Build.0 = Release|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x86.ActiveCfg = Release|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4425B328-866A-440A-962A-41301F16C6D5}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
WebUI Library 2.x
|
||||
C++ Visual Studio Example
|
||||
|
||||
http://webui.me
|
||||
https://github.com/alifcommunity/webui
|
||||
|
||||
Licensed under GNU General Public License v3.0.
|
||||
Copyright (C)2023 Hassan DRAGA <https://github.com/hassandraga>.
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <webui.h>
|
||||
}
|
||||
|
||||
// Window struct
|
||||
webui_window_t* my_window;
|
||||
|
||||
// UI HTML
|
||||
const char* my_html = "<!DOCTYPE html>"
|
||||
"<html><head><title>WebUI 2 - C++ Visual Studio Example</title>"
|
||||
"<style>body{color: white; background: #0F2027;"
|
||||
"background: -webkit-linear-gradient(to right, #8d4887, #521b4e, #3e073a);"
|
||||
"background: linear-gradient(to right, #8d4887, #521b4e, #3e073a);"
|
||||
"text-align:center; font-size: 18px; font-family: sans-serif;}</style></head><body>"
|
||||
"<h1>WebUI 2 - C++ Visual Studio Example</h1><br>"
|
||||
"<input type=\"password\" id=\"MyInput\"><br><br>"
|
||||
"<button id=\"MyButton1\">Check Password</button> - <button id=\"MyButton2\">Exit</button>"
|
||||
"</body></html>";
|
||||
|
||||
// Check the password function
|
||||
void check_the_password(webui_event_t* e) {
|
||||
|
||||
// This function get called every time the user click on "MyButton1"
|
||||
|
||||
webui_script_t js;
|
||||
js.script = " return document.getElementById(\"MyInput\").value; ";
|
||||
js.timeout = 3;
|
||||
|
||||
// Run the JavaScript on the UI (Web Browser)
|
||||
webui_script(my_window, &js);
|
||||
|
||||
// Check if there is any JavaScript error
|
||||
if (js.result.error) {
|
||||
|
||||
printf("JavaScript Error: %s\n", js.result.data);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the password
|
||||
const char* password = js.result.data;
|
||||
printf("Password: %s\n", password);
|
||||
|
||||
// Check the password
|
||||
if (strcmp(password, "123456") == 0) {
|
||||
|
||||
// Correct password
|
||||
js.script = "alert('Good. Password is correct.')";
|
||||
webui_script(my_window, &js);
|
||||
}
|
||||
else {
|
||||
|
||||
// Wrong password
|
||||
js.script = "alert('Sorry. Wrong password.')";
|
||||
webui_script(my_window, &js);
|
||||
}
|
||||
|
||||
// Free data resources
|
||||
webui_script_cleanup(&js);
|
||||
}
|
||||
|
||||
void close_the_application(webui_event_t* e) {
|
||||
|
||||
// Close all opened windows
|
||||
webui_exit();
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// Create a window
|
||||
my_window = webui_new_window();
|
||||
|
||||
// Bind HTML elements with functions
|
||||
webui_bind(my_window, "MyButton1", check_the_password);
|
||||
webui_bind(my_window, "MyButton2", close_the_application);
|
||||
|
||||
// Show the window
|
||||
if (!webui_show(my_window, my_html, webui.browser.chrome)) // Run the window on Chrome
|
||||
webui_show(my_window, my_html, webui.browser.any); // If not, run on any other installed web browser
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui_wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) {
|
||||
|
||||
main();
|
||||
}
|
@ -1,163 +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>{c40eddc6-cead-459b-96e6-bb859c3fd11e}</ProjectGuid>
|
||||
<RootNamespace>helloworld</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>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(OutDir);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(OutDir);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
|
||||
</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>
|
||||
<AdditionalDependencies>webui-2-static-x64.lib;webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</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>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>webui-2-static-x64.lib;webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</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;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</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>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>webui-2-static-x64.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello_world.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,22 +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="hello_world.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
@ -1,168 +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>{9a0c89cc-4f50-4364-a90d-2d6f3b1552b8}</ProjectGuid>
|
||||
<RootNamespace>webui2staticx64</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</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>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</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;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</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;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\..\..\..\include\mongoose.h" />
|
||||
<ClInclude Include="..\..\..\..\..\..\include\webui.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\..\..\src\mongoose.c" />
|
||||
<ClCompile Include="..\..\..\..\..\..\src\webui.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,33 +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>
|
||||
<ClInclude Include="..\..\..\..\..\..\include\webui.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\..\..\include\mongoose.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\..\..\src\webui.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\..\..\src\mongoose.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
@ -1,44 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32901.82
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello_world", "hello_world\hello_world.vcxproj", "{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8} = {9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webui-2-static-x64", "webui-2-static-x64\webui-2-static-x64.vcxproj", "{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x64.Build.0 = Debug|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x64.ActiveCfg = Release|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x64.Build.0 = Release|x64
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C40EDDC6-CEAD-459B-96E6-BB859C3FD11E}.Release|x86.Build.0 = Release|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x64.Build.0 = Debug|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Debug|x86.Build.0 = Debug|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x64.ActiveCfg = Release|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x64.Build.0 = Release|x64
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x86.ActiveCfg = Release|Win32
|
||||
{9A0C89CC-4F50-4364-A90D-2D6F3B1552B8}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4425B328-866A-440A-962A-41301F16C6D5}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
WebUI Library 2.x
|
||||
C++ Visual Studio Example
|
||||
|
||||
http://webui.me
|
||||
https://github.com/alifcommunity/webui
|
||||
|
||||
Licensed under GNU General Public License v3.0.
|
||||
Copyright (C)2023 Hassan DRAGA <https://github.com/hassandraga>.
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <webui.h>
|
||||
}
|
||||
|
||||
// Window struct
|
||||
webui_window_t* my_window;
|
||||
|
||||
// UI HTML
|
||||
const char* my_html = "<!DOCTYPE html>"
|
||||
"<html><head><title>WebUI 2 - C++ Visual Studio Example</title>"
|
||||
"<style>body{color: white; background: #0F2027;"
|
||||
"background: -webkit-linear-gradient(to right, #8d4887, #521b4e, #3e073a);"
|
||||
"background: linear-gradient(to right, #8d4887, #521b4e, #3e073a);"
|
||||
"text-align:center; font-size: 18px; font-family: sans-serif;}</style></head><body>"
|
||||
"<h1>WebUI 2 - C++ Visual Studio Example</h1><br>"
|
||||
"<input type=\"password\" id=\"MyInput\"><br><br>"
|
||||
"<button id=\"MyButton1\">Check Password</button> - <button id=\"MyButton2\">Exit</button>"
|
||||
"</body></html>";
|
||||
|
||||
// Check the password function
|
||||
void check_the_password(webui_event_t* e) {
|
||||
|
||||
// This function get called every time the user click on "MyButton1"
|
||||
|
||||
webui_script_t js;
|
||||
js.script = " return document.getElementById(\"MyInput\").value; ";
|
||||
js.timeout = 3;
|
||||
|
||||
// Run the JavaScript on the UI (Web Browser)
|
||||
webui_script(my_window, &js);
|
||||
|
||||
// Check if there is any JavaScript error
|
||||
if (js.result.error) {
|
||||
|
||||
printf("JavaScript Error: %s\n", js.result.data);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the password
|
||||
const char* password = js.result.data;
|
||||
printf("Password: %s\n", password);
|
||||
|
||||
// Check the password
|
||||
if (strcmp(password, "123456") == 0) {
|
||||
|
||||
// Correct password
|
||||
js.script = "alert('Good. Password is correct.')";
|
||||
webui_script(my_window, &js);
|
||||
}
|
||||
else {
|
||||
|
||||
// Wrong password
|
||||
js.script = "alert('Sorry. Wrong password.')";
|
||||
webui_script(my_window, &js);
|
||||
}
|
||||
|
||||
// Free data resources
|
||||
webui_script_cleanup(&js);
|
||||
}
|
||||
|
||||
void close_the_application(webui_event_t* e) {
|
||||
|
||||
// Close all opened windows
|
||||
webui_exit();
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// Create a window
|
||||
my_window = webui_new_window();
|
||||
|
||||
// Bind HTML elements with functions
|
||||
webui_bind(my_window, "MyButton1", check_the_password);
|
||||
webui_bind(my_window, "MyButton2", close_the_application);
|
||||
|
||||
// Show the window
|
||||
if (!webui_show(my_window, my_html, webui.browser.chrome)) // Run the window on Chrome
|
||||
webui_show(my_window, my_html, webui.browser.any); // If not, run on any other installed web browser
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui_wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) {
|
||||
|
||||
main();
|
||||
}
|
@ -1,163 +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>{c40eddc6-cead-459b-96e6-bb859c3fd11e}</ProjectGuid>
|
||||
<RootNamespace>helloworld</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>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(OutDir);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(OutDir);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
|
||||
</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>
|
||||
<AdditionalDependencies>webui-2-static-x64.lib;webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</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>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>webui-2-static-x64.lib;webui-2-static-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</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;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</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>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>webui-2-static-x64.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello_world.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,22 +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="hello_world.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
@ -1,168 +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>{9a0c89cc-4f50-4364-a90d-2d6f3b1552b8}</ProjectGuid>
|
||||
<RootNamespace>webui2staticx64</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</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>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;..\..\..\..\..\..\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\..\..\..\..\..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</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;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</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;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>
|
||||
</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\..\..\..\include\mongoose.h" />
|
||||
<ClInclude Include="..\..\..\..\..\..\include\webui.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\..\..\src\mongoose.c" />
|
||||
<ClCompile Include="..\..\..\..\..\..\src\webui.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,33 +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>
|
||||
<ClInclude Include="..\..\..\..\..\..\include\webui.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\..\..\include\mongoose.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\..\..\..\src\webui.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\..\..\src\mongoose.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
WebUI Library 2.x
|
||||
C++ Example
|
||||
|
||||
http://webui.me
|
||||
https://github.com/alifcommunity/webui
|
||||
|
||||
Licensed under GNU General Public License v3.0.
|
||||
Copyright (C)2023 Hassan DRAGA <https://github.com/hassandraga>.
|
||||
*/
|
||||
|
||||
extern "C"{
|
||||
#include "webui.h"
|
||||
}
|
||||
|
||||
// Window struct
|
||||
webui_window_t* my_window;
|
||||
|
||||
// UI HTML
|
||||
const char* my_html = "<!DOCTYPE html>"
|
||||
"<html><head><title>WebUI 2 - C++ Example</title>"
|
||||
"<style>body{color: white; background: #0F2027;"
|
||||
"background: -webkit-linear-gradient(to right, #6b5597, #5c437c, #250a36);"
|
||||
"background: linear-gradient(to right, #6b5597, #5c437c, #250a36);"
|
||||
"text-align:center; font-size: 18px; font-family: sans-serif;}</style></head><body>"
|
||||
"<h1>WebUI 2 - C++ Example</h1><br>"
|
||||
"<input type=\"password\" id=\"MyInput\"><br><br>"
|
||||
"<button id=\"MyButton1\">Check Password</button> - <button id=\"MyButton2\">Exit</button>"
|
||||
"</body></html>";
|
||||
|
||||
// Check the password function
|
||||
void check_the_password(webui_event_t* e) {
|
||||
|
||||
// This function get called every time the user click on "MyButton1"
|
||||
|
||||
webui_script_t js;
|
||||
js.script = " return document.getElementById(\"MyInput\").value; ";
|
||||
js.timeout = 3;
|
||||
|
||||
// Run the JavaScript on the UI (Web Browser)
|
||||
webui_script(my_window, &js);
|
||||
|
||||
// Check if there is any JavaScript error
|
||||
if(js.result.error) {
|
||||
|
||||
printf("JavaScript Error: %s\n", js.result.data);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the password
|
||||
const char* password = js.result.data;
|
||||
printf("Password: %s\n", password);
|
||||
|
||||
// Check the password
|
||||
if(strcmp(password, "123456") == 0) {
|
||||
|
||||
// Correct password
|
||||
js.script = "alert('Good. Password is correct.')";
|
||||
webui_script(my_window, &js);
|
||||
}
|
||||
else {
|
||||
|
||||
// Wrong password
|
||||
js.script = "alert('Sorry. Wrong password.')";
|
||||
webui_script(my_window, &js);
|
||||
}
|
||||
|
||||
// Free data resources
|
||||
webui_script_cleanup(&js);
|
||||
}
|
||||
|
||||
void close_the_application(webui_event_t* e){
|
||||
|
||||
// Close all opened windows
|
||||
webui_exit();
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// Create a window
|
||||
my_window = webui_new_window();
|
||||
|
||||
// Bind HTML elements with functions
|
||||
webui_bind(my_window, "MyButton1", check_the_password);
|
||||
webui_bind(my_window, "MyButton2", close_the_application);
|
||||
|
||||
// Show the window
|
||||
if(!webui_show(my_window, my_html, webui.browser.chrome)) // Run the window on Chrome
|
||||
webui_show(my_window, my_html, webui.browser.any); // If not, run on any other installed web browser
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui_wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) {
|
||||
main();
|
||||
}
|
||||
#endif
|
141
examples/C++/minimal/GNUmakefile
Normal file
141
examples/C++/minimal/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C++ Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
|
||||
CC = g++
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C++ Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C++ Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),g++ clang aarch64-linux-gnu-g++ arm-linux-gnueabihf-g++ musl-g++),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
63
examples/C++/minimal/Makefile
Normal file
63
examples/C++/minimal/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# WebUI C++ Example
|
||||
# Windows - Microsoft Visual C++
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Debug Static)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C++ Example (Debug Dynamic)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Release Static)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C++ Example (Release Dynamic)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
17
examples/C++/minimal/main.cpp
Normal file
17
examples/C++/minimal/main.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Release build
|
||||
int WINAPI
|
||||
wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nShowCmd) {
|
||||
return main();
|
||||
}
|
||||
#endif
|
141
examples/C++/serve_a_folder/GNUmakefile
Normal file
141
examples/C++/serve_a_folder/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C++ Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
|
||||
CC = g++
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C++ Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C++ Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C++ Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),g++ clang aarch64-linux-gnu-g++ arm-linux-gnueabihf-g++ musl-g++),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
63
examples/C++/serve_a_folder/Makefile
Normal file
63
examples/C++/serve_a_folder/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# WebUI C++ Example
|
||||
# Windows - Microsoft Visual C++
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Debug Static)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C++ Example (Debug Dynamic)...
|
||||
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C++ Example (Release Static)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C++ Example (Release Dynamic)...
|
||||
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
39
examples/C++/serve_a_folder/index.html
Normal file
39
examples/C++/serve_a_folder/index.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<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>
|
98
examples/C++/serve_a_folder/main.cpp
Normal file
98
examples/C++/serve_a_folder/main.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
// 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::window::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::window::event* e) {
|
||||
// Switch to `/second.html` in the same opened window.
|
||||
e->get_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::window::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::string url = e->get_string();
|
||||
std::cout << "Starting navigation to: " << url << std::endl;
|
||||
e->get_window().navigate(url);
|
||||
}
|
||||
}
|
||||
|
||||
// Example of a simple function (Not a method)
|
||||
void exit_app(webui::window::event* e) {
|
||||
// Close all opened windows
|
||||
webui::exit();
|
||||
}
|
||||
};
|
||||
|
||||
// -- MyClass C 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 myClassObj;
|
||||
void show_second_window_wrp(webui::window::event* e) { myClassObj.show_second_window(e); }
|
||||
void switch_to_second_page_wrp(webui::window::event* e) { myClassObj.switch_to_second_page(e); }
|
||||
void events_wrp(webui::window::event* e) { myClassObj.events(e); }
|
||||
void exit_app_wrp(webui::window::event* e) { myClassObj.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);
|
||||
my_second_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
|
26
examples/C++/serve_a_folder/second.html
Normal file
26
examples/C++/serve_a_folder/second.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<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>
|
44
examples/C/README.md
Normal file
44
examples/C/README.md
Normal file
@ -0,0 +1,44 @@
|
||||
# WebUI C Examples
|
||||
|
||||
Examples of how to create a WebUI application in C.
|
||||
|
||||
## C Examples
|
||||
|
||||
The only requirement to build the examples is a C compiler.
|
||||
|
||||
- `minimal`: Creates a minimal WebUI application.
|
||||
- `call_c_from_js`: Calls C from JavaScript.
|
||||
- `call_js_from_c`: Calls JavaScript from C.
|
||||
- `serve_a_folder`: Use WebUI to serve a folder that contains `.html`, `.css`, `.js`, or `.ts` files.
|
||||
- `custom_web_server`: Use your preferred web server like NGINX/Apache... with WebUI to serve a folder.
|
||||
|
||||
To build an example, cd into its directory and run the make command.
|
||||
|
||||
- **Windows**
|
||||
|
||||
```sh
|
||||
# GCC
|
||||
mingw32-make
|
||||
|
||||
# MSVC
|
||||
nmake
|
||||
```
|
||||
|
||||
- **Linux**
|
||||
|
||||
```sh
|
||||
# GCC
|
||||
make
|
||||
|
||||
# Clang
|
||||
make CC=clang
|
||||
```
|
||||
|
||||
- **macOS**
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
## Additional Examples
|
||||
|
||||
- [`text-editor`](https://github.com/webui-dev/webui/tree/main/examples/C/text-editor): A lightweight and portable text editor written in C using WebUI as the GUI library.
|
141
examples/C/call_c_from_js/GNUmakefile
Normal file
141
examples/C/call_c_from_js/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
|
||||
CC = gcc
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc musl-gcc),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
@ -1,42 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C99 Example
|
||||
# Linux - Clang
|
||||
|
||||
LIB=../../../../../build/Linux/Clang
|
||||
INCLUDE=../../../../../include
|
||||
SOURCE=../..
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo "Build C99 Example (Static Debug)..."
|
||||
@clang -g -static -m64 -o main "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C99 Example (Dynamic Debug)..."
|
||||
@clang -g -m64 -o main-dyn "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo "Build C99 Example (Static Release)..."
|
||||
@clang -static -Os -m64 -o main "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
@llvm-strip --strip-all main
|
||||
# Dynamic Release
|
||||
@echo "Build C99 Example (Dynamic Release)..."
|
||||
@clang -m64 -o main-dyn "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
@llvm-strip --strip-all main-dyn
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
clean:
|
||||
- rm -f *.o
|
||||
- rm -f *.so
|
||||
- rm -f *.a
|
@ -1,42 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C99 Example
|
||||
# Linux - GCC
|
||||
|
||||
LIB=../../../../../build/Linux/GCC
|
||||
INCLUDE=../../../../../include
|
||||
SOURCE=../..
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo "Build C99 Example (Static Debug)..."
|
||||
@gcc -g -static -m64 -o main "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C99 Example (Dynamic Debug)..."
|
||||
@gcc -g -m64 -o main-dyn "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo "Build C99 Example (Static Release)..."
|
||||
@gcc -static -Os -m64 -o main "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lpthread -lm
|
||||
@strip --strip-all main
|
||||
# Dynamic Release
|
||||
@echo "Build C99 Example (Dynamic Release)..."
|
||||
@gcc -m64 -o main-dyn "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.so" -lpthread -lm
|
||||
@strip --strip-all main-dyn
|
||||
# Clean
|
||||
@- rm -f *.o
|
||||
@echo "Done."
|
||||
|
||||
clean:
|
||||
- rm -f *.o
|
||||
- rm -f *.so
|
||||
- rm -f *.a
|
64
examples/C/call_c_from_js/Makefile
Normal file
64
examples/C/call_c_from_js/Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
# WebUI C Example
|
||||
# Windows - Microsoft Visual C
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Debug)...
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C Example (Dynamic Debug)...
|
||||
@copy "$(LIB_DIR)\debug\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Release)...
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C Example (Dynamic Release)...
|
||||
@copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
@ -1,43 +0,0 @@
|
||||
|
||||
# WebUI Examples - C
|
||||
|
||||
To build the C example you will need one of those C compilers, no dependencies is needed.
|
||||
|
||||
### Windows
|
||||
|
||||
- **Build Tools for Microsoft Visual Studio**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui\examples\C\call_c_from_js\Windows\MSVC
|
||||
nmake
|
||||
```
|
||||
|
||||
- **MinGW**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui\examples\C\call_c_from_js\Windows\GCC
|
||||
mingw32-make
|
||||
```
|
||||
|
||||
- **TCC**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui\examples\C\call_c_from_js\Windows\TCC
|
||||
mingw32-make
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
- **GCC**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui/examples/C/call_c_from_js/Linux/GCC
|
||||
make
|
||||
```
|
||||
|
||||
- **Clang**
|
||||
```sh
|
||||
git clone https://github.com/alifcommunity/webui.git
|
||||
cd webui/examples/C/call_c_from_js/Linux/Clang
|
||||
make
|
||||
```
|
@ -1,51 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C99 Example
|
||||
# Windows - GCC
|
||||
|
||||
SHELL=CMD
|
||||
LIB=../../../../../build/Windows/GCC
|
||||
INCLUDE=../../../../../include
|
||||
SOURCE=../..
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo Build C99 Example (Static Debug)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@gcc -g -static -m64 -o main.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" win.res -lwebui-2-static-x64 -lws2_32 -Wall -Wl,-subsystem=console -luser32
|
||||
# Dynamic with Debug info
|
||||
@echo Build C99 Example (Dynamic Debug)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@gcc -g -m64 -o main-dyn.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" win.res "$(LIB)/webui-2-x64.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@- del *.res >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo Build C99 Example (Static Release)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@gcc -static -Os -m64 -o main.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" win.res -lwebui-2-static-x64 -lws2_32 -Wall -Wl,-subsystem=windows -luser32
|
||||
@strip --strip-all main.exe
|
||||
# Dynamic Release
|
||||
@echo Build C99 Example (Dynamic Release)...
|
||||
@windres win.rc -O coff -o win.res
|
||||
@gcc -m64 -o main-dyn.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" win.res "$(LIB)/webui-2-x64.dll" -lws2_32 -Wall -Wl,-subsystem=windows -luser32
|
||||
@strip --strip-all main-dyn.exe
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@- del *.res >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.res >nul 2>&1
|
Binary file not shown.
Before Width: | Height: | Size: 105 KiB |
@ -1,24 +0,0 @@
|
||||
id ICON "win.ico"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "My Business Name"
|
||||
VALUE "LegalCopyright", "My Business Name"
|
||||
VALUE "FileDescription", "My WebUI Application"
|
||||
VALUE "InternalName", "MyApplication"
|
||||
VALUE "ProductName", "My Application"
|
||||
VALUE "FileVersion", "1.0"
|
||||
VALUE "OriginalFilename", "webui.exe"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
@ -1,49 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C99 Example
|
||||
# Windows - Microsoft Visual C
|
||||
|
||||
SHELL=CMD
|
||||
_LIB=../../../../../build/Windows/MSVC/
|
||||
_INCLUDE=../../../../../include/
|
||||
_SOURCE=../../
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(_LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo Build C99 Example (Static Debug)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl /Zi "$(_SOURCE)/main.c" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:CONSOLE win.res webui-2-static-x64.lib user32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
# Dynamic with Debug info
|
||||
@echo Build C99 Example (Dynamic Debug)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl /Zi "$(_SOURCE)/main.c" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:CONSOLE win.res webui-2-x64.lib user32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(_LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo Build C99 Example (Static Release)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl "$(_SOURCE)/main.c" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:WINDOWS win.res webui-2-static-x64.lib user32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
# Dynamic Release
|
||||
@echo Build C99 Example (Dynamic Release)...
|
||||
@rc win.rc 1>NUL 2>&1
|
||||
@cl "$(_SOURCE)/main.c" /I "$(_INCLUDE)" /link /LIBPATH:"$(_LIB)" /MACHINE:X64 /SUBSYSTEM:WINDOWS win.res webui-2-x64.lib user32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.res >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
||||
- del *.res >nul 2>&1
|
Binary file not shown.
Before Width: | Height: | Size: 105 KiB |
@ -1,24 +0,0 @@
|
||||
id ICON "win.ico"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "My Business Name"
|
||||
VALUE "LegalCopyright", "My Business Name"
|
||||
VALUE "FileDescription", "My WebUI Application"
|
||||
VALUE "InternalName", "MyApplication"
|
||||
VALUE "ProductName", "My Application"
|
||||
VALUE "FileVersion", "1.0"
|
||||
VALUE "OriginalFilename", "webui.exe"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
@ -1,43 +0,0 @@
|
||||
# WebUI Library 2.x
|
||||
# C99 Example
|
||||
# Windows - Tiny C Compiler
|
||||
|
||||
SHELL=CMD
|
||||
LIB=../../../../../build/Windows/TCC/
|
||||
INCLUDE=../../../../../include/
|
||||
SOURCE=../../
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE) debug
|
||||
# Static with Debug info
|
||||
@echo Build C99 Example (Static Debug)...
|
||||
@tcc -g -m64 -o main.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lws2_32 -Wall -Wl,-subsystem=console -luser32
|
||||
# Dynamic with Debug info
|
||||
@echo Build C99 Example (Dynamic Debug)...
|
||||
@tcc -g -m64 -o main-dyn.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.def" -lws2_32 -Wall -Wl,-subsystem=console -luser32
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@- del *.def >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
# Build Lib
|
||||
@cd "$(LIB)" && $(MAKE)
|
||||
# Static Release
|
||||
@echo Build C99 Example (Static Release)...
|
||||
@tcc -m64 -o main.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" -lwebui-2-static-x64 -lws2_32 -Wall -Wl,-subsystem=windows -luser32
|
||||
# Dynamic Release
|
||||
@echo Build C99 Example (Dynamic Release)...
|
||||
@tcc -m64 -o main-dyn.exe "$(SOURCE)/main.c" -I "$(INCLUDE)" -L "$(LIB)" "$(LIB)/webui-2-x64.def" -lws2_32 -Wall -Wl,-subsystem=windows -luser32
|
||||
# Clean
|
||||
@- del *.o >nul 2>&1
|
||||
@- del *.def >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.def >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
@ -1,106 +1,184 @@
|
||||
/*
|
||||
WebUI Library 2.x
|
||||
C99 Example
|
||||
|
||||
http://webui.me
|
||||
https://github.com/alifcommunity/webui
|
||||
|
||||
Licensed under GNU General Public License v3.0.
|
||||
Copyright (C)2023 Hassan DRAGA <https://github.com/hassandraga>.
|
||||
*/
|
||||
|
||||
// Note:
|
||||
// To see the console logs (printf) you need to build in debug mode
|
||||
// example 'make debug', or 'nmake debug', or 'mingw32-make debug'
|
||||
// Call C from JavaScript Example
|
||||
|
||||
#include "webui.h"
|
||||
|
||||
void function_one(webui_event_t* e) {
|
||||
void my_function_string(webui_event_t* e) {
|
||||
|
||||
// JavaScript: webui_fn('One', 'Hello');
|
||||
// JavaScript:
|
||||
// my_function_string('Hello', 'World`);
|
||||
|
||||
const char* str = webui_get_string(e);
|
||||
printf("function_one: %s\n", str); // Hello
|
||||
const char* str_1 = webui_get_string(e); // Or webui_get_string_at(e, 0);
|
||||
const char* str_2 = webui_get_string_at(e, 1);
|
||||
|
||||
printf("my_function_string 1: %s\n", str_1); // Hello
|
||||
printf("my_function_string 2: %s\n", str_2); // World
|
||||
}
|
||||
|
||||
void function_two(webui_event_t* e) {
|
||||
void my_function_integer(webui_event_t* e) {
|
||||
|
||||
// JavaScript: webui_fn('Two', 2022);
|
||||
// JavaScript:
|
||||
// my_function_integer(123, 456, 789, 12345.6789);
|
||||
|
||||
int number = webui_get_int(e);
|
||||
printf("function_two: %d\n", number); // 2022
|
||||
size_t count = webui_get_count(e);
|
||||
printf("my_function_integer: There is %zu arguments in this event\n", count); // 4
|
||||
|
||||
long long number_1 = webui_get_int(e); // Or webui_get_int_at(e, 0);
|
||||
long long number_2 = webui_get_int_at(e, 1);
|
||||
long long number_3 = webui_get_int_at(e, 2);
|
||||
|
||||
printf("my_function_integer 1: %lld\n", number_1); // 123
|
||||
printf("my_function_integer 2: %lld\n", number_2); // 456
|
||||
printf("my_function_integer 3: %lld\n", number_3); // 789
|
||||
|
||||
double float_1 = webui_get_float_at(e, 3);
|
||||
|
||||
printf("my_function_integer 4: %f\n", float_1); // 12345.6789
|
||||
}
|
||||
|
||||
void function_three(webui_event_t* e) {
|
||||
void my_function_boolean(webui_event_t* e) {
|
||||
|
||||
// JavaScript: webui_fn('Three', true);
|
||||
// JavaScript:
|
||||
// my_function_boolean(true, false);
|
||||
|
||||
bool status = webui_get_bool(e);
|
||||
if(status)
|
||||
printf("function_three: True\n"); // True
|
||||
else
|
||||
printf("function_three: False\n"); // False
|
||||
bool status_1 = webui_get_bool(e); // Or webui_get_bool_at(e, 0);
|
||||
bool status_2 = webui_get_bool_at(e, 1);
|
||||
|
||||
printf("my_function_boolean 1: %s\n", (status_1 ? "True" : "False")); // True
|
||||
printf("my_function_boolean 2: %s\n", (status_2 ? "True" : "False")); // False
|
||||
}
|
||||
|
||||
void function_four(webui_event_t* e) {
|
||||
void my_function_raw_binary(webui_event_t* e) {
|
||||
|
||||
// JavaScript: const result = webui_fn('Four', 2);
|
||||
// JavaScript:
|
||||
// my_function_raw_binary(new Uint8Array([0x41]), new Uint8Array([0x42, 0x43]));
|
||||
|
||||
int number = webui_get_int(e);
|
||||
number = number * 2;
|
||||
printf("function_four: %d\n", number); // 4
|
||||
const unsigned char* raw_1 = (const unsigned char*)webui_get_string(e); // Or webui_get_string_at(e, 0);
|
||||
const unsigned char* raw_2 = (const unsigned char*)webui_get_string_at(e, 1);
|
||||
|
||||
// Send back the response to JavaScript
|
||||
webui_return_int(e, number);
|
||||
int len_1 = (int)webui_get_size(e); // Or webui_get_size_at(e, 0);
|
||||
int len_2 = (int)webui_get_size_at(e, 1);
|
||||
|
||||
// Print raw_1
|
||||
printf("my_function_raw_binary 1 (%d bytes): ", len_1);
|
||||
for (size_t i = 0; i < len_1; i++)
|
||||
printf("0x%02x ", raw_1[i]);
|
||||
printf("\n");
|
||||
|
||||
// Check raw_2 (Big)
|
||||
// [0xA1, 0x00..., 0xA2]
|
||||
bool valid = false;
|
||||
if (raw_2[0] == 0xA1 && raw_2[len_2 - 1] == 0xA2)
|
||||
valid = true;
|
||||
|
||||
// Print raw_2
|
||||
printf("my_function_raw_binary 2 big (%d bytes): valid data? %s\n", len_2, (valid ? "Yes" : "No"));
|
||||
}
|
||||
|
||||
void my_function_with_response(webui_event_t* e) {
|
||||
|
||||
// JavaScript:
|
||||
// my_function_with_response(number, 2).then(...)
|
||||
|
||||
long long number = webui_get_int(e); // Or webui_get_int_at(e, 0);
|
||||
long long times = webui_get_int_at(e, 1);
|
||||
|
||||
long long res = number * times;
|
||||
printf("my_function_with_response: %lld * %lld = %lld\n", number, times, res);
|
||||
|
||||
// Send back the response to JavaScript
|
||||
webui_return_int(e, res);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// HTML
|
||||
const char* my_html = "<!DOCTYPE html>"
|
||||
"<html><head><title>WebUI 2 - C99 Example</title>"
|
||||
"<style>body{color: white; background: #0F2027;"
|
||||
"background: -webkit-linear-gradient(to right, #2C5364, #203A43, #0F2027);"
|
||||
"background: linear-gradient(to right, #2C5364, #203A43, #0F2027);"
|
||||
"text-align:center; font-size: 18px; font-family: sans-serif;}</style></head><body>"
|
||||
"<h2>WebUI 2 - C99 Example</h2>"
|
||||
"<p>Call C function with arguments (See log in the Windows console)</p><br>"
|
||||
"<button OnClick=\"webui_fn('One', 'Hello');\">Call C function one</button><br><br>"
|
||||
"<button OnClick=\"webui_fn('Two', 2022);\">Call C function two</button><br><br>"
|
||||
"<button OnClick=\"webui_fn('Three', true);\">Call C function three</button><br><br>"
|
||||
"<p>Call C function four, and wait for the result</p><br>"
|
||||
"<button OnClick=\"MyJS();\">Call C function four</button><br><br>"
|
||||
"<input type=\"text\" id=\"MyInput\" value=\"2\">"
|
||||
"<script>"
|
||||
" function MyJS() {"
|
||||
" const number = document.getElementById('MyInput').value;"
|
||||
" var result = webui_fn('Four', number);"
|
||||
" document.getElementById('MyInput').value = result;"
|
||||
" }"
|
||||
"</script>"
|
||||
"</body></html>";
|
||||
// HTML
|
||||
const char* my_html =
|
||||
"<!DOCTYPE html>"
|
||||
"<html>"
|
||||
" <head>"
|
||||
" <meta charset=\"UTF-8\">"
|
||||
" <script src=\"webui.js\"></script>"
|
||||
" <title>Call C from JavaScript Example</title>"
|
||||
" <style>"
|
||||
" body {"
|
||||
" font-family: 'Arial', sans-serif;"
|
||||
" color: white;"
|
||||
" background: linear-gradient(to right, #507d91, #1c596f, #022737);"
|
||||
" text-align: center;"
|
||||
" font-size: 18px;"
|
||||
" }"
|
||||
" button, input {"
|
||||
" padding: 10px;"
|
||||
" margin: 10px;"
|
||||
" border-radius: 3px;"
|
||||
" border: 1px solid #ccc;"
|
||||
" box-shadow: 0 3px 5px rgba(0,0,0,0.1);"
|
||||
" transition: 0.2s;"
|
||||
" }"
|
||||
" button {"
|
||||
" background: #3498db;"
|
||||
" color: #fff; "
|
||||
" cursor: pointer;"
|
||||
" font-size: 16px;"
|
||||
" }"
|
||||
" h1 { text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); }"
|
||||
" button:hover { background: #c9913d; }"
|
||||
" input:focus { outline: none; border-color: #3498db; }"
|
||||
" </style>"
|
||||
" </head>"
|
||||
" <body>"
|
||||
" <h1>WebUI - Call C from JavaScript</h1>"
|
||||
" <p>Call C functions with arguments (<em>See the logs in your terminal</em>)</p>"
|
||||
" <button onclick=\"my_function_string('Hello', 'World');\">Call my_function_string()</button>"
|
||||
" <br>"
|
||||
" <button onclick=\"my_function_integer(123, 456, 789, 12345.6789);\">Call my_function_integer()</button>"
|
||||
" <br>"
|
||||
" <button onclick=\"my_function_boolean(true, false);\">Call my_function_boolean()</button>"
|
||||
" <br>"
|
||||
" <button onclick=\"my_function_raw_binary(new Uint8Array([0x41,0x42,0x43]), big_arr);\"> "
|
||||
" Call my_function_raw_binary()</button>"
|
||||
" <br>"
|
||||
" <p>Call a C function that returns a response</p>"
|
||||
" <button onclick=\"MyJS();\">Call my_function_with_response()</button>"
|
||||
" <div>Double: <input type=\"text\" id=\"MyInputID\" value=\"2\"></div>"
|
||||
" <script>"
|
||||
" const arr_size = 512 * 1000;"
|
||||
" const big_arr = new Uint8Array(arr_size);"
|
||||
" big_arr[0] = 0xA1;"
|
||||
" big_arr[arr_size - 1] = 0xA2;"
|
||||
" function MyJS() {"
|
||||
" const MyInput = document.getElementById('MyInputID');"
|
||||
" const number = MyInput.value;"
|
||||
" my_function_with_response(number, 2).then((response) => {"
|
||||
" MyInput.value = response;"
|
||||
" });"
|
||||
" }"
|
||||
" </script>"
|
||||
" </body>"
|
||||
"</html>";
|
||||
|
||||
// Create a window
|
||||
webui_window_t* my_window = webui_new_window();
|
||||
// Create a window
|
||||
size_t my_window = webui_new_window();
|
||||
|
||||
// Bind HTML elements with functions
|
||||
webui_bind(my_window, "One", function_one);
|
||||
webui_bind(my_window, "Two", function_two);
|
||||
webui_bind(my_window, "Three", function_three);
|
||||
webui_bind(my_window, "Four", function_four);
|
||||
// Bind HTML elements with C functions
|
||||
webui_bind(my_window, "my_function_string", my_function_string);
|
||||
webui_bind(my_window, "my_function_integer", my_function_integer);
|
||||
webui_bind(my_window, "my_function_boolean", my_function_boolean);
|
||||
webui_bind(my_window, "my_function_with_response", my_function_with_response);
|
||||
webui_bind(my_window, "my_function_raw_binary", my_function_raw_binary);
|
||||
|
||||
// Show the window
|
||||
if(!webui_show(my_window, my_html, webui.browser.chrome)) // Run the window on Chrome
|
||||
webui_show(my_window, my_html, webui.browser.any); // If not, run on any other installed web browser
|
||||
// Show the window
|
||||
webui_show(my_window, my_html); // webui_show_browser(my_window, my_html, Chrome);
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui_wait();
|
||||
// Wait until all windows get closed
|
||||
webui_wait();
|
||||
|
||||
return 0;
|
||||
// Free all memory resources (Optional)
|
||||
webui_clean();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) {
|
||||
main();
|
||||
}
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) { return main(); }
|
||||
#endif
|
||||
|
141
examples/C/call_js_from_c/GNUmakefile
Normal file
141
examples/C/call_js_from_c/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
|
||||
CC = gcc
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc musl-gcc),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
64
examples/C/call_js_from_c/Makefile
Normal file
64
examples/C/call_js_from_c/Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
# WebUI C Example
|
||||
# Windows - Microsoft Visual C
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Debug)...
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C Example (Dynamic Debug)...
|
||||
@copy "$(LIB_DIR)\debug\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Release)...
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C Example (Dynamic Release)...
|
||||
@copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
125
examples/C/call_js_from_c/main.c
Normal file
125
examples/C/call_js_from_c/main.c
Normal file
@ -0,0 +1,125 @@
|
||||
// Call JavaScript from C Example
|
||||
|
||||
#include "webui.h"
|
||||
|
||||
void my_function_exit(webui_event_t* e) {
|
||||
|
||||
// Close all opened windows
|
||||
webui_exit();
|
||||
}
|
||||
|
||||
void my_function_count(webui_event_t* e) {
|
||||
|
||||
// This function gets called every time the user clicks on "my_function_count"
|
||||
|
||||
// Create a buffer to hold the response
|
||||
char response[64];
|
||||
|
||||
// Run JavaScript
|
||||
if (!webui_script(e->window, "return GetCount();", 0, response, 64)) {
|
||||
|
||||
if (!webui_is_shown(e->window))
|
||||
printf("Window closed.\n");
|
||||
else
|
||||
printf("JavaScript Error: %s\n", response);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the count
|
||||
int count = atoi(response);
|
||||
|
||||
// Increment
|
||||
count++;
|
||||
|
||||
// Generate a JavaScript
|
||||
char js[64];
|
||||
sprintf(js, "SetCount(%d);", count);
|
||||
|
||||
// Run JavaScript (Quick Way)
|
||||
webui_run(e->window, js);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// HTML
|
||||
const char* my_html = "<!DOCTYPE html>"
|
||||
"<html>"
|
||||
" <head>"
|
||||
" <meta charset=\"UTF-8\">"
|
||||
" <script src=\"webui.js\"></script>"
|
||||
" <title>Call JavaScript from C Example</title>"
|
||||
" <style>"
|
||||
" body {"
|
||||
" font-family: 'Arial', sans-serif;"
|
||||
" color: white;"
|
||||
" background: linear-gradient(to right, #507d91, #1c596f, #022737);"
|
||||
" text-align: center;"
|
||||
" font-size: 18px;"
|
||||
" }"
|
||||
" button, input {"
|
||||
" padding: 10px;"
|
||||
" margin: 10px;"
|
||||
" border-radius: 3px;"
|
||||
" border: 1px solid #ccc;"
|
||||
" box-shadow: 0 3px 5px rgba(0,0,0,0.1);"
|
||||
" transition: 0.2s;"
|
||||
" }"
|
||||
" button {"
|
||||
" background: #3498db;"
|
||||
" color: #fff; "
|
||||
" cursor: pointer;"
|
||||
" font-size: 16px;"
|
||||
" }"
|
||||
" h1 { text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); }"
|
||||
" button:hover { background: #c9913d; }"
|
||||
" input:focus { outline: none; border-color: #3498db; }"
|
||||
" </style>"
|
||||
" </head>"
|
||||
" <body>"
|
||||
" <h1>WebUI - Call JavaScript from C</h1>"
|
||||
" <br>"
|
||||
" <h1 id=\"count\">0</h1>"
|
||||
" <br>"
|
||||
" <button OnClick=\"my_function_count();\">Manual Count</button>"
|
||||
" <br>"
|
||||
" <button id=\"MyTest\" OnClick=\"AutoTest();\">Auto Count (Every 10ms)</button>"
|
||||
" <br>"
|
||||
" <button OnClick=\"my_function_exit();\">Exit</button>"
|
||||
" <script>"
|
||||
" let count = 0;"
|
||||
" function GetCount() {"
|
||||
" return count;"
|
||||
" }"
|
||||
" function SetCount(number) {"
|
||||
" document.getElementById('count').innerHTML = number;"
|
||||
" count = number;"
|
||||
" }"
|
||||
" function AutoTest(number) {"
|
||||
" setInterval(function(){ my_function_count(); }, 10);"
|
||||
" }"
|
||||
" </script>"
|
||||
" </body>"
|
||||
"</html>";
|
||||
|
||||
// Create a window
|
||||
size_t my_window = webui_new_window();
|
||||
|
||||
// Bind HTML elements with C functions
|
||||
webui_bind(my_window, "my_function_count", my_function_count);
|
||||
webui_bind(my_window, "my_function_exit", my_function_exit);
|
||||
|
||||
// Show the window
|
||||
webui_show(my_window, my_html); // webui_show_browser(my_window, my_html, Chrome);
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui_wait();
|
||||
|
||||
// Free all memory resources (Optional)
|
||||
webui_clean();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) { return main(); }
|
||||
#endif
|
141
examples/C/chatgpt_api/GNUmakefile
Normal file
141
examples/C/chatgpt_api/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
|
||||
CC = gcc
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc musl-gcc),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
64
examples/C/chatgpt_api/Makefile
Normal file
64
examples/C/chatgpt_api/Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
# WebUI C Example
|
||||
# Windows - Microsoft Visual C
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Debug)...
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C Example (Dynamic Debug)...
|
||||
@copy "$(LIB_DIR)\debug\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Release)...
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C Example (Dynamic Release)...
|
||||
@copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
98
examples/C/chatgpt_api/main.c
Normal file
98
examples/C/chatgpt_api/main.c
Normal file
@ -0,0 +1,98 @@
|
||||
// WebUI C - ChatGPT HTTPS API Example
|
||||
|
||||
#include "webui.h"
|
||||
|
||||
// ChatGPT Configuration
|
||||
#define USER_KEY "sk-proj-xxx-xxxxxxxxxxxxxxxxxxxxxxx_xxx"
|
||||
#define USER_MODEL "gpt-4o"
|
||||
#define USER_ASSISTANT "You are an assistant, answer with very short messages."
|
||||
|
||||
#define BUF_SIZE (1024)
|
||||
size_t hiddenWindow = 0;
|
||||
|
||||
// HTML
|
||||
const char* html = "<!DOCTYPE html>"
|
||||
"<html>"
|
||||
" <head>"
|
||||
" <script src=\"webui.js\"></script>"
|
||||
" </head>"
|
||||
" <body>"
|
||||
" <script>"
|
||||
" function run_gpt_api(userKey, userModel, userAssistant, userContent) {"
|
||||
" const xhr = new XMLHttpRequest();"
|
||||
" xhr.open(\"POST\", \"https://api.openai.com/v1/chat/completions\", false);"
|
||||
" xhr.setRequestHeader(\"Content-Type\", \"application/json\");"
|
||||
" xhr.setRequestHeader(\"Authorization\", \"Bearer \" + userKey);"
|
||||
" xhr.send(JSON.stringify({"
|
||||
" model: userModel,"
|
||||
" messages: ["
|
||||
" { role: \"developer\", content: userAssistant },"
|
||||
" { role: \"user\", content: userContent }"
|
||||
" ]"
|
||||
" }));"
|
||||
" const responseJson = JSON.parse(xhr.responseText);"
|
||||
" if (responseJson.error) {"
|
||||
" return 'Error: ' + responseJson.error.message;"
|
||||
" }"
|
||||
" return (responseJson.choices[0].message.content).trim();"
|
||||
" }"
|
||||
" </script>"
|
||||
" </body>"
|
||||
"</html>";
|
||||
|
||||
bool run_ai_query(const char* user_query, char* ai_response) {
|
||||
|
||||
char js[BUF_SIZE];
|
||||
memset(js, 0, BUF_SIZE);
|
||||
|
||||
// Generate JavaScript
|
||||
sprintf(js,
|
||||
"return run_gpt_api('%s', '%s', '%s', '%s');",
|
||||
USER_KEY, USER_MODEL, USER_ASSISTANT, user_query
|
||||
);
|
||||
|
||||
// Run HTTPS API
|
||||
if (webui_script(hiddenWindow, js, 30, ai_response, BUF_SIZE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Please provide a query.\nExample: %s What is the capital of Canada?\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initializing
|
||||
char ai_response[BUF_SIZE];
|
||||
char user_query[BUF_SIZE];
|
||||
memset(ai_response, 0, BUF_SIZE);
|
||||
memset(user_query, 0, BUF_SIZE);
|
||||
|
||||
// Get user query
|
||||
for (int i = 1; i < argc; i++) {
|
||||
strcat(user_query, argv[i]);
|
||||
strcat(user_query, " ");
|
||||
}
|
||||
|
||||
// Start WebUI server
|
||||
hiddenWindow = webui_new_window();
|
||||
webui_set_hide(hiddenWindow, true);
|
||||
webui_show_browser(hiddenWindow, html, ChromiumBased);
|
||||
|
||||
// Run HTTPS API
|
||||
if (run_ai_query(user_query, ai_response)) {
|
||||
printf("AI Response: %s\n", ai_response);
|
||||
} else {
|
||||
printf("Error:\n%s\n", ai_response);
|
||||
}
|
||||
|
||||
// Exit
|
||||
webui_exit();
|
||||
webui_clean();
|
||||
|
||||
return 0;
|
||||
}
|
141
examples/C/custom_web_server/GNUmakefile
Normal file
141
examples/C/custom_web_server/GNUmakefile
Normal file
@ -0,0 +1,141 @@
|
||||
# WebUI C Example
|
||||
|
||||
# == 1. VARIABLES =============================================================
|
||||
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
PROJECT_DIR := $(dir $(MAKEFILE_PATH))/../../../
|
||||
TARGET := $(firstword $(MAKECMDGOALS))
|
||||
LIB_DIR := $(PROJECT_DIR)/dist
|
||||
ifeq ($(TARGET), debug)
|
||||
LIB_DIR := $(LIB_DIR)/debug
|
||||
endif
|
||||
INCLUDE_DIR := $(PROJECT_DIR)/include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
ifeq ($(WEBUI_USE_TLS), 1)
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
endif
|
||||
|
||||
# ARGS
|
||||
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
|
||||
CC = gcc
|
||||
# Build the WebUI library if running via `make BUILD_LIB=true`
|
||||
BUILD_LIB ?=
|
||||
|
||||
# BUILD FLAGS
|
||||
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
|
||||
|
||||
# Platform conditions
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Windows
|
||||
PLATFORM := windows
|
||||
SHELL := CMD
|
||||
STATIC_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)-static -lws2_32 -Wall -luser32 -static
|
||||
COPY_LIB_CMD := @copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
DYN_BUILD_FLAGS += "$(WEBUI_LIB_NAME).dll" -lws2_32 -Wall -luser32
|
||||
STATIC_OUT := main.exe
|
||||
DYN_OUT := main-dyn.exe
|
||||
LWS2_OPT := -lws2_32 -lole32
|
||||
STRIP_OPT := --strip-all
|
||||
CONSOLE_APP := -Wl,-subsystem=console
|
||||
GUI_APP := -Wl,-subsystem=windows
|
||||
else
|
||||
STATIC_BUILD_FLAGS += -lpthread -lm -l$(WEBUI_LIB_NAME)-static
|
||||
DYN_BUILD_FLAGS += -lpthread -lm
|
||||
STATIC_OUT := main
|
||||
DYN_OUT := main-dyn
|
||||
ifeq ($(shell uname),Darwin)
|
||||
# MacOS
|
||||
PLATFORM := macos
|
||||
CC = clang
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).dylib" "lib$(WEBUI_LIB_NAME).dylib"
|
||||
DYN_BUILD_FLAGS += -l$(WEBUI_LIB_NAME)
|
||||
WKWEBKIT_LINK_FLAGS := -framework Cocoa -framework WebKit
|
||||
else
|
||||
# Linux
|
||||
PLATFORM := linux
|
||||
COPY_LIB_CMD := @cp "$(LIB_DIR)/lib$(WEBUI_LIB_NAME).so" "lib$(WEBUI_LIB_NAME).so"
|
||||
STATIC_BUILD_FLAGS += -ldl
|
||||
DYN_BUILD_FLAGS += -ldl -l$(WEBUI_LIB_NAME)
|
||||
STRIP_OPT := --strip-all
|
||||
ifeq ($(CC),clang)
|
||||
LLVM_OPT := llvm-
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# == 2.TARGETS ================================================================
|
||||
|
||||
all: release
|
||||
|
||||
debug: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE) debug
|
||||
endif
|
||||
# Static with Debug info
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) debug static)..."
|
||||
@$(CC) -g $(CONSOLE_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic with Debug info
|
||||
@echo "Build C Example ($(CC) debug dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) -g $(CONSOLE_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
release: --validate-args
|
||||
ifeq ($(BUILD_LIB),true)
|
||||
@cd "$(PROJECT_DIR)" && $(MAKE)
|
||||
endif
|
||||
# Static Release
|
||||
ifneq ($(WEBUI_USE_TLS), 1)
|
||||
@echo "Build C Example ($(CC) release static)..."
|
||||
@$(CC) -Os $(GUI_APP) $(STATIC_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(STATIC_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
|
||||
endif
|
||||
# Dynamic Release
|
||||
@echo "Build C Example ($(CC) release dynamic)..."
|
||||
$(COPY_LIB_CMD)
|
||||
@$(CC) $(GUI_APP) $(DYN_BUILD_FLAGS) $(LWS2_OPT) $(WKWEBKIT_LINK_FLAGS) -o $(DYN_OUT)
|
||||
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
|
||||
# Clean
|
||||
ifeq ($(PLATFORM),windows)
|
||||
@- del *.o >nul 2>&1
|
||||
else
|
||||
@- rm -f *.o
|
||||
@- rm -rf *.dSYM # macOS
|
||||
endif
|
||||
@echo "Done."
|
||||
|
||||
clean: --clean-$(PLATFORM)
|
||||
|
||||
# INTERNAL TARGETS
|
||||
|
||||
--validate-args:
|
||||
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc musl-gcc),$(CC))
|
||||
$(error Invalid compiler specified: `$(CC)`)
|
||||
endif
|
||||
|
||||
--clean-linux: --clean-unix
|
||||
|
||||
--clean-macos: --clean-unix
|
||||
|
||||
--clean-unix:
|
||||
- rm -f *.o
|
||||
- rm -f *.a
|
||||
- rm -f *.so
|
||||
- rm -f *.dylib
|
||||
- rm -rf *.dSYM
|
||||
|
||||
--clean-windows:
|
||||
- del *.o >nul 2>&1
|
||||
- del *.dll >nul 2>&1
|
||||
- del *.a >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
64
examples/C/custom_web_server/Makefile
Normal file
64
examples/C/custom_web_server/Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
# WebUI C Example
|
||||
# Windows - Microsoft Visual C
|
||||
|
||||
SHELL = CMD
|
||||
LIB_DIR = ../../../dist
|
||||
INCLUDE_DIR = ../../../include
|
||||
WEBUI_LIB_NAME = webui-2
|
||||
!IF "$(WEBUI_USE_TLS)" == "1"
|
||||
WEBUI_LIB_NAME = webui-2-secure
|
||||
!ENDIF
|
||||
|
||||
# Build the WebUI library if running `nmake BUILD_LIB=true`
|
||||
BUILD_LIB =
|
||||
|
||||
all: release
|
||||
|
||||
debug:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
|
||||
!ENDIF
|
||||
# Static with Debug info
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Debug)...
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic with Debug info
|
||||
@echo Build C Example (Dynamic Debug)...
|
||||
@copy "$(LIB_DIR)\debug\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)\debug" /SUBSYSTEM:CONSOLE $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
release:
|
||||
!IF "$(BUILD_LIB)" == "true"
|
||||
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
|
||||
!ENDIF
|
||||
# Static Release
|
||||
!IF "$(WEBUI_USE_TLS)" != "1"
|
||||
@echo Build C Example (Static Release)...
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME)-static.lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main.exe 1>NUL 2>&1
|
||||
!ENDIF
|
||||
# Dynamic Release
|
||||
@echo Build C Example (Dynamic Release)...
|
||||
@copy "$(LIB_DIR)\$(WEBUI_LIB_NAME).dll" "$(WEBUI_LIB_NAME).dll"
|
||||
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /SUBSYSTEM:WINDOWS $(WEBUI_LIB_NAME).lib user32.lib Advapi32.lib Shell32.lib Ole32.lib /OUT:main-dyn.exe 1>NUL 2>&1
|
||||
# Clean
|
||||
@- del *.exp >nul 2>&1
|
||||
@- del *.ilk >nul 2>&1
|
||||
@- del *.lib >nul 2>&1
|
||||
@- del *.obj >nul 2>&1
|
||||
@- del *.pdb >nul 2>&1
|
||||
@echo Done.
|
||||
|
||||
clean:
|
||||
- del *.obj >nul 2>&1
|
||||
- del *.ilk >nul 2>&1
|
||||
- del *.pdb >nul 2>&1
|
||||
- del *.exp >nul 2>&1
|
||||
- del *.exe >nul 2>&1
|
||||
- del *.lib >nul 2>&1
|
18
examples/C/custom_web_server/index.html
Normal file
18
examples/C/custom_web_server/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>WebUI - Custom Web-Server Example (C)</title>
|
||||
<!-- Connect this window to the back-end app -->
|
||||
<script src="http://localhost:8081/webui.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Custom Web-Server Example (C)</h3>
|
||||
<p>
|
||||
This HTML page is handled by a custom Web-Server other than WebUI.<br />
|
||||
This window is connected to the back-end because we used: <pre>http://localhost:8081/webui.js</pre>
|
||||
</p>
|
||||
<h4><a href="second.html">Simple link example (Local file)</a></h4>
|
||||
<button onclick="my_backend_func(123, 456, 789);">Call my_backend_func()</button>
|
||||
</body>
|
||||
</html>
|
74
examples/C/custom_web_server/main.c
Normal file
74
examples/C/custom_web_server/main.c
Normal file
@ -0,0 +1,74 @@
|
||||
// Serve a Folder Example
|
||||
|
||||
#include "webui.h"
|
||||
|
||||
void events(webui_event_t* e) {
|
||||
|
||||
// This function gets called every time
|
||||
// there is an event
|
||||
|
||||
if (e->event_type == WEBUI_EVENT_CONNECTED)
|
||||
printf("Connected. \n");
|
||||
else if (e->event_type == WEBUI_EVENT_DISCONNECTED)
|
||||
printf("Disconnected. \n");
|
||||
else if (e->event_type == WEBUI_EVENT_MOUSE_CLICK)
|
||||
printf("Click. \n");
|
||||
else if (e->event_type == WEBUI_EVENT_NAVIGATION) {
|
||||
const char* url = webui_get_string(e);
|
||||
printf("Starting navigation to: %s \n", url);
|
||||
|
||||
// Because we used `webui_bind(MyWindow, "", events);`
|
||||
// WebUI will block all `href` link clicks and sent here instead.
|
||||
// We can then control the behaviour of links as needed.
|
||||
webui_navigate(e->window, url);
|
||||
}
|
||||
}
|
||||
|
||||
void my_backend_func(webui_event_t* e) {
|
||||
|
||||
// JavaScript:
|
||||
// my_backend_func(123, 456, 789);
|
||||
// or webui.my_backend_func(...);
|
||||
|
||||
long long number_1 = webui_get_int_at(e, 0);
|
||||
long long number_2 = webui_get_int_at(e, 1);
|
||||
long long number_3 = webui_get_int_at(e, 2);
|
||||
|
||||
printf("my_backend_func 1: %lld\n", number_1); // 123
|
||||
printf("my_backend_func 2: %lld\n", number_2); // 456
|
||||
printf("my_backend_func 3: %lld\n", number_3); // 789
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
// Create new windows
|
||||
size_t window = webui_new_window();
|
||||
|
||||
// Bind all events
|
||||
webui_bind(window, "", events);
|
||||
|
||||
// Bind HTML elements with C functions
|
||||
webui_bind(window, "my_backend_func", my_backend_func);
|
||||
|
||||
// Set the web-server/WebSocket port that WebUI should
|
||||
// use. This means `webui.js` will be available at:
|
||||
// http://localhost:MY_PORT_NUMBER/webui.js
|
||||
webui_set_port(window, 8081);
|
||||
|
||||
// Show a new window and show our custom web server
|
||||
// Assuming the custom web server is running on port
|
||||
// 8080...
|
||||
webui_show(window, "http://localhost:8080/");
|
||||
|
||||
// Wait until all windows get closed
|
||||
webui_wait();
|
||||
|
||||
// Free all memory resources (Optional)
|
||||
webui_clean();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) { return main(); }
|
||||
#endif
|
13
examples/C/custom_web_server/second.html
Normal file
13
examples/C/custom_web_server/second.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>WebUI - Custom Web-Server second page (C)</title>
|
||||
<!-- Connect this window to the back-end app -->
|
||||
<script src="http://localhost:8081/webui.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h3>This is the second page !</h3>
|
||||
<h4><a href="index.html">Back</a></h4>
|
||||
</body>
|
||||
</html>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user