Repository navigation
feat: add support for tauri::ipc::Channel<T> - #4
Conversation
|
Hello, my friend! |
|
Hi @Dudude-bit, no worries! 🙌 This is not relevant for the core functionality of the generator as of today but adds a feature for everyone who wants to use Tauri Channels (see https://v2.tauri.app/develop/calling-frontend/#channels) for streaming data from the backend to the frontend in their project. If you want to support Channels going forward, this might be a good starting point, but keep in mind this is generated by @claude. Also keep in mind that this is opinionated (as it generates a typescript API the way I would like to use it), which means it does not necessarily align with how people or you yourself would like to use it. Feel free to try it out yourself or see it in action in my open source app lukas-runge/luminaut which uses this pr in production. If you have any further questions, feel free to get back to me. 🙌 Best regards, |
- alias is always <Command><Arg>ChannelType (stable when a command gains a second channel, follows TS naming convention) - drop generated helpers.ts: new Channel<T>(cb) already covers it, and the file went stale / could clobber a user file - fix rustfmt violation in rust_type.rs; README + CHANGELOG entries Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1ae1ed0 to
fb798ff
Compare
|
Hi @lukas-runge, thanks a lot for the contribution — and for being upfront about how it was built. The core of the PR (the
Channel support will ship with the next release. Thanks again! 🙌 |
Hi @Dudude-bit,
thank you for your great work on
tauri-ts-generator! 🙏I just wanted to use Tauri Channels (see https://v2.tauri.app/develop/calling-frontend/#channels) for streaming data from the backend to the frontend and noticed that the generator does currently not support it. With @claude's help I was able to "prompt it into existence" and make it work for my application (see https://github.com/lukas-runge/luminaut). This is the resulting PR. If you want to support Channels going forward, this might be a good starting point, but keep in mind this is:
So please take this pr with the appropriate grain of salt. 😊
Kind regards,
@lukas-runge
Summary
Adds codegen support for
tauri::ipc::Channel<T>command arguments so streaming-IPC commands can be invoked from generated TypeScript.RustType::Channel(Box<RustType>)variant; parser recognizestauri::ipc::Channel<T>andChannel<T>; type-mapper emitsChannel<T>.State/Window) and are forwarded toinvoke.types.ts:<cmd>ChannelType<cmd><Arg>ChannelTypeChannelimport added tocommands.tsonly when at least one command uses one.helpers.tsemitted next tocommands.tswhen channels are present, exportinggetChannelFor<T>(onMessage?).Test plan
cargo test— newtests/e2e/channels.rscovers:invoketypes.tshelpers.tsgeneration when channels present, omission when absentChannel<String>→string)Channel<T>commands🤖 Generated with Claude Code