webui-dev / webui

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.
https://webui.me
MIT License
2.9k stars 164 forks source link

webui.js auto inject is removed (Wrappers examples update is needed) #184

Closed hassandraga closed 11 months ago

hassandraga commented 1 year ago

After @JOTSR converted the bridge source from JavaScript to TypeScript, the bridge was improved on many levels. But we had one fundamental issue (already existing): the bridge gets injected by WebUI non-standardly. It usually works, but not in complex DOM operations-related projects when the bridge must parsed before other UI scripts.

While working on solving this issue, I noticed that it was not worth it. All those issues can be perfectly solved by simply making the user manually add <script src="webui.js"></script> in all his embedded HTML content and local files.

Starting from this commit. All examples should add webui.js to the HTML.

Minimal Example

#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();
}
hassandraga commented 11 months ago

All wrappers are updated.