Closed leiserfg closed 1 year ago
I'd count this as a duplicate of https://github.com/tauri-apps/tauri/issues/1514. The title may not suggest that but the discussion broadened/generalized a bit and especially the tauri-bindgen
and tauri-specta
projects mentioned there go in the direction you're asking for.
There is also a potentially interesting discussion in https://github.com/tauri-apps/tauri/issues/3256.
With #3256 we can theoretically generate a signature type for each command (one that tracks parameters, returns and async-ness) but I don't see what benefit that would bring in the context of tauri-core (I had thought in the past that maybe we could inject generating javascript bindings straight from Rust, but that idea isn't too useful either bc of lacking typescript support) so I think projects like what fabian mentioned are more equipped to help here and this is not something tauri core should concern itself with.
Btw your problem description sounds exactly like what I started tauri-bindgen
for. Feel free to create an issue over there and we can discuss adding codegen support for elm 👍🏻
Describe the problem
I want to make a tool to auto-generate the javascript FFI for elm (what you have in @tauri/api but for elm), including custom Commands. Having a way to get those types would be also beneficial for doing the same for other languages (rescript, purescript) and even for typescript (so you don't have to keep the api up to date by hand).
Describe the solution you'd like
A tool to extract all the Commands (names and types) in an easy processable format (maybe jsonschema, protobuf declaration or similar) so they can be used for automatic clientside code generation.
Alternatives considered
Additional context
Maybe https://docs.rs/schemars/latest/schemars/ could bring some inspiration.