diff --git a/CMakeLists.txt b/CMakeLists.txt index 56c79b84c..5e17eaed7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,24 +120,64 @@ if (WEBUI_BUILD_EXAMPLES) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) - add_executable(minimal ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/minimal/main.cpp) + # C++ examples + add_executable(minimal_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/minimal/main.cpp) add_executable(call_js_from_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/call_js_from_cpp/main.cpp) - add_executable(call_js_from_cpp_class ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/call_js_from_cpp_class/main.cpp) - add_executable(serve_a_folder ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/serve_a_folder/main.cpp) - add_executable(call_js_from_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/call_js_from_c/main.c) + add_executable(call_cpp_from_js ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/call_cpp_from_js/main.cpp) + add_executable(serve_a_folder_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/serve_a_folder/main.cpp) + add_executable(virtual_file_system_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/virtual_file_system/main.cpp) - target_link_libraries(minimal webui) + # C examples + add_executable(minimal_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/minimal/main.c) + add_executable(call_js_from_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/call_js_from_c/main.c) + add_executable(call_c_from_js ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/call_c_from_js/main.c) + add_executable(serve_a_folder_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/serve_a_folder/main.c) + add_executable(virtual_file_system_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/virtual_file_system/main.c) + add_executable(public_network_access ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/public_network_access/main.c) + add_executable(web_app_multi_client ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/web_app_multi_client/main.c) + add_executable(chatgpt_api ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/chatgpt_api/main.c) + add_executable(custom_web_server ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/custom_web_server/main.c) + add_executable(react ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/react/main.c) + add_executable(frameless ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/frameless/main.c) + add_executable(text_editor ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/text-editor/main.c) + + target_link_libraries(minimal_cpp webui) target_link_libraries(call_js_from_cpp webui) - target_link_libraries(call_js_from_cpp_class webui) - target_link_libraries(serve_a_folder webui) + target_link_libraries(call_cpp_from_js webui) + target_link_libraries(serve_a_folder_cpp webui) + target_link_libraries(virtual_file_system_cpp webui) + + target_link_libraries(minimal_c webui) target_link_libraries(call_js_from_c webui) + target_link_libraries(call_c_from_js webui) + target_link_libraries(serve_a_folder_c webui) + target_link_libraries(virtual_file_system_c webui) + target_link_libraries(public_network_access webui) + target_link_libraries(web_app_multi_client webui) + target_link_libraries(chatgpt_api webui) + target_link_libraries(custom_web_server webui) + target_link_libraries(react webui) + target_link_libraries(frameless webui) + target_link_libraries(text_editor webui) if (MSVC) - set_target_properties(minimal PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(minimal_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") set_target_properties(call_js_from_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") - set_target_properties(call_js_from_cpp_class PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") - set_target_properties(serve_a_folder PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(call_cpp_from_js PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(serve_a_folder_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(virtual_file_system_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(minimal_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") set_target_properties(call_js_from_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(call_c_from_js PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(serve_a_folder_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(virtual_file_system_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(public_network_access PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(web_app_multi_client PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(chatgpt_api PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(custom_web_server PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(react PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(frameless PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") + set_target_properties(text_editor PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON") endif() if (MSVC) diff --git a/bridge/README.md b/bridge/README.md index c71a3fbfe..03f2512f7 100644 --- a/bridge/README.md +++ b/bridge/README.md @@ -1,6 +1,6 @@ # 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`. +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 Node script `js2c.js` to generate `webui_bridge.h`. ### Windows @@ -9,7 +9,7 @@ The WebUI Bridge connects the UI (_Web Browser_) with the backend application th - 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` +- `node js2c.js` ### Windows PowerShell @@ -25,7 +25,7 @@ The WebUI Bridge connects the UI (_Web Browser_) with the backend application th - 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` +- `node js2c.js` ### Linux Bash @@ -39,7 +39,7 @@ The WebUI Bridge connects the UI (_Web Browser_) with the backend application th - 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` +- `node js2c.js` ### macOS Bash diff --git a/examples/C++/README.md b/examples/C++/README.md index 64bf9dc59..1bbe972d7 100644 --- a/examples/C++/README.md +++ b/examples/C++/README.md @@ -5,10 +5,10 @@ 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++. -- `call_js_from_cpp_class`: Calls JavaScript from C++ using class methods and member-function bind. +- `call_cpp_from_js`: Calls C++ from JavaScript. +- `call_js_from_cpp`: Calls JavaScript from C++ using class methods and member-function bind. - `serve_a_folder`: Uses WebUI to serve a folder with multiple files (class-based example using member-function bind). +- `virtual_file_system`: Embeds files using a virtual file system. To build an example, cd into its directory and run the make command. diff --git a/examples/C/README.md b/examples/C/README.md index 1970f8ba8..40fc25669 100644 --- a/examples/C/README.md +++ b/examples/C/README.md @@ -11,6 +11,12 @@ The only requirement to build the examples is a C compiler. - `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. +- `chatgpt_api`: Calls ChatGPT API from C. +- `frameless`: Frameless window example. +- `public_network_access`: Allows network access to external devices. +- `react`: React + WebUI example. +- `virtual_file_system`: Embeds files using a virtual file system. +- `web_app_multi_client`: Multiple clients example. To build an example, cd into its directory and run the make command.