-
Notifications
You must be signed in to change notification settings - Fork 264
format support for webui_run and webui_script #678
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
format support for webui_run and webui_script #678
Conversation
|
Implementation of the formatting feature proposed in #677. Added two functions However there are still a few concerns: Among all, security issues, especially when escape chars are present. And for C++ wrapper, I used template argument pack, which might have some compatibility issues. I wonder if a C++ wrapper for this is really necessary, as there are already some nice formatting utils (like fmtlib) |
Yes, I saw it, and was just thinking if those APIs may break wrappers that use automated-scripts/AI to generate code.
Those new APIs are handy and very useful, the only challenge is that almost all wrappers can't use them, and C++ doesn't need them, and the escape chars may break them. |
|
Options we have:
|
|
Hi @AlbertShown, Thanks for the quick feedback! The variadic functions are indeed pretty annoying to handle... I agree that the 3rd option (webui_extras.h) is the best path forward, as there won't be FFI-related concerns, and developers can include whenever it's necessary. Perhaps some other future util functions can be put into this file as well. I'll make this PR a draft and work on it. |
85d0fd3 to
9214d03
Compare
|
I just split the declarations to a |
|
Thank you @konakona418, but for optimization purposes I suggest this:
|
|
Thanks @AlbertShown, I've refactored the PR according to your suggestions:
And few technical notes on the implementation:
|
|
Sorry there was a typo in my last commit, and there's possibility where macro redefinition might occur... |
43867b1 to
e89ac84
Compare
|
And as for the escape chars problem, I guess maybe there could be "safe" variations of the two functions, which have some overhead, but handles chars like quotes and backslashes internally? But the major problem for this is that there can be a lot of corner cases, and a function covering all these cases could be non-trivial to implement and maintain due to the JS string literal rules. e.g., single quotes ', double quotes ", and backticks ` each have different escaping strategies. The current implementation provides a balance for common use cases where no complex strings are involved. And as long as we make the risks clear in the documentation, developers can decide whether to go with this function or use a more verbose formatter implementation. If we feel it's necessary in the future, we could potentially add something like |
e89ac84 to
bc42ffd
Compare
|
While testing it I found some issue with dynamic examples, so I'm working on an alternative approach. |
|
I tried to make extensions being compiled inside WebUI library, both static and dynamic, but this will need updating all makefiles to include Another solution is to simply make those functions always compiled in library, both static and dynamic, but exported in Therefore, I suggest to make all extensions code outside WebUI, and simply add it directly in [App] --> [ @konakona418 What do you think? |
|
Hi @AlbertShown, Thank you for the explanation! This sounds reasonable to me, as extensions should have as little side effects to the core functionalities as possible. Making the extension header-only is a brilliant way to achieve this, as it avoids forcing all language wrappers to update their build logic. Since you have a clear vision for the optimization and the overall extension architecture, please feel free to take it from here. I'm excited to see this feature integrated in a way that best fits the project's long-term roadmap! |
|
Already done 7d22079 Thank you @konakona418 for the extensions idea, now it's integrated in the WebUI. |
No description provided.