-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: split js bridge source code from lib source code #131
Conversation
Move js bridge outiside of webui.c source code to improve dev experience and simplify editing. It also allow to write types def for client. Use xxd to inject bridge into source code.
Change html structure order to force js bridge to execute before any user content. Fix js possibly undefined listener that can crash the app if bridge is loaded earlier.
Use xxd to build js file into C-String. Todo, add a script to simplify action and allow multiple text file to be embedded
Improve discoverability and integration within a project.
The idea of spitting the main code into multiple files is a great idea, but it comes with a cost. I don't know what we should do honestly, but yes, splitting files is a good improvement. |
I'm not sure that xxd is not installed. It seem's to be preinstalled on many linux distrib and came natevely on macos. It is also a part of git for windows (part of git bash tools). I actually working on the js bridge (there is some errors, deprecated APIs, overcomplicated code, ...). And to simplify its maintenance and its integration for user I asking if typescript would be a good idea. So for compiling ts I propose to setup a devcontainer, it can be useful to ensure all dev have all necessary tools. As there is actually no linting or code formatter in the project, a devcontainer with adequat tools can be a good idea to homogenize and support development. I don't known how the support of TCC matter (I'm not a C dev so I am not aware of current usage) but |
The Deno wrapper is written in TypeScript. So, no one will have an issue switching the WebUI-Bridge from JavaScript to TypeScript.
I vote for the devcontainer to be optional, as many developers prefer to edit
TCC is for users who want to produce a complete working GUI executable using WebUI in less than 1024 Kb. Also, TCC is used as a backend in V-WebUI. |
Bridge
The JS bridge inside the c lib is totally independent from the Deno wrapper. For instance if you use TSX for your UI, as the client API is not typed it lack of usability. Using typescript (or at least providing a d.ts definition file) can be a good improvement for discoverability, interoperability and simplify project integration. As it only used in source code it don't change the final execution (only js i embedded). Moreover, using typescript bring checking tools for internal use (there is several issues in the bridge that are catched by typescript in my tests). DevcontainerYes .devcontainer is only for simplify startup and project tools sharing (not mandatory). For instance there is no default formater or linter for the project and requiring from contributors to install project choosen tools can be complicated. Future CI/build improvements can take profit of it. |
Yes, I meant that the original creator of WebUI already used TypeScript, so I don't see any issue in switching the bridge completely from JavaScript to TypeScript. It should just simply work in the browsers.
I totally agree with you. I guess this will be a very good improvement 👍 |
Motivation
Embedding js bridge source code into c make it hard to read and edit. Moving it appart was made possible by using xxd tool.
Possible improvements