-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[Proposal]: Modular core APIs #3029
Comments
There's one downside going with this approach and removing the allowlist entirely: people need to touch the Rust code to enable APIs, and a lot of users are scared of it. |
But turning the APIs into plugins is something I have in mind for quite some time, specially since it's the only way to have an allowlist when we have bindings (each core plugin could have its own binding, then e.g. a Deno user can install each plugin individually). |
can't the allowlist include the plugins |
Do you think it is that bad? Adding plugins to a vec doesn't touch lifetimes or any other part of rust that people find scary 🤔 Or: |
If there are no feature flags, will Rust skip the unused dependencies when compiling? Definitely would like to specify the allowlist in code, and avoid tauri writing feature flags to |
Yes, of course! Rust binaries are large, but without dead code elimination and other optimizations the size would be measured in gigabytes 😉 |
I think this is actually an antipattern to be honest. Having your configuration in exactly one place makes it auditable. If you can set this kind of thing anywhere in code, then where do you look to know what you have set? |
Totally agree, having the config in one place is good and the closer we can get to that the better. But I know that a lot of people interested in/using tauri don't know rust and making the project accessible is important. |
Actually it can be in one place in rust, with the proposed API, all plugins (user defined) and core plugins (our plugins proposed in this issue) can only be passed through |
I think the point brought up about users having to touch Rust code is very daunting, even if it a very simple operation. I think the option for users to choose one system over another is preferable. So for example, have the project when initialized, include the Another important note, if we wanted to go with the above route, of allowing users to choose, it would be a very good idea to emit an But I 100% love the idea of modularizing the core API's. |
As a notice to anyone coming along, work on this will continue after the release of v1. But just for context (and so I can remember later) I like the idea of a macro that pulls in the |
@JonasKruckenberg If comments are a desirable feature, is |
rc.0 introduced JSON5 support for the conf file in February :) |
With the migration of the API endpoints to separated plugins this has been implemented (though there's a lot more we can do, which are tracked in other issues). |
Is your feature request related to a problem? Please describe.
The backend currently has two different ways of exposing ApIs to the frontend: Commands (and Plugins) as well as the core APIs. Commands are very modular while the core APIs are not.
Describe the solution you'd like
Modularizing the core api using a similar system to #2959, inspired by deno's extensions.
So a tauri app could look like this:
Why?:
When reading the code it's immediately obvious what APIs are available to the frontend.
The current allowlist system split's feature configuration between the app, the
Cargo.toml
file and thetauri.conf.json
file.There is also no opportunity to add comments in the
tauri.conf.json
file, where dev could explain why an API is enabled.Tauri apps would be as slim as possible without the copious amounts of feature flags we employ right now. (Of course more involved features like systray would still use them on top)
This makes the cli waay simpler and less error prone.
The
init
function is a very natural way to pass capabilities to APIs enabling capability oriented design.@amrbashir pioneered this with the vibrancy plugin. Similar to rust itself, we could develop new APIs in separately versioned plugins, that can be iterated upon more easily. Once they reached sufficient stability can be merged into the core. This is maybe the most compelling reason IMO.
Core APIs can be deprecated and still be accessible to users who didn't upgrade yet, while not taking up space for users who did. (I could see
withGlobalTauri
going this route for example. It would still be there for users who need it, but would never end up in the binary for users who don't)Open Questions
tauri::Builder
about plugins?tauri::Builder::default()
come with default plugins?The text was updated successfully, but these errors were encountered: