Add Dioxus code generation support (--lang dioxus)#4
Conversation
--lang dioxus)
There was a problem hiding this comment.
the build failed saying strict field is missing in BuilderOptions
There was a problem hiding this comment.
It does build for me - can you elaborate on your build environment? And post the error?
I was building on Fedora Linux.
There was a problem hiding this comment.
Sorry it's actually BundlerOptions not BuilderOptions
Look at this: https://github.com/rolldown/rolldown/blob/main/crates%2Frolldown_common%2Fsrc%2Finner_bundler_options%2Fmod.rs
The last field of BO is strict maybe it was added recently, I added it and the build succeeded, I am on arch.
There was a problem hiding this comment.
i verified, it won't be an issue for you, the strict field is not required in rolldown/tag: v1.0.0-rc.3, the one you are using, i updated it that whats caused the issue, my bad.
|
nice work~ 👍 |
Co-authored-by: enaut <290005+enaut@users.noreply.github.com>
efed210 to
dac993c
Compare
Ports the Dioxus-only changes from #2 onto current master, excluding the WASM SDK changes. Adds
spacetime generate --lang dioxusas a new codegen target that produces reactive Dioxus 0.7+ hooks and signals alongside standard Rust SDK bindings.Generated output (
dioxus.rsmodule)Connection management:
use_spacetimedb_context_provider(uri, module_name)— root-level context provideruse_spacetimedb_context(),use_connection(),use_connection_state(),use_connection_error()Per-table hooks (generated for each table):
use_table_<name>() -> SyncSignal<Vec<Row>>— reactive signal updated viaon_insert/on_update/on_deletecallbacksPer-reducer/procedure hooks:
use_reducer_<name>()/use_procedure_<name>()— returns aClonecallback invoking the reducer/procedure through the shared connectionSubscription:
use_subscription(&["SELECT * FROM ..."])Example
Implementation notes
dioxus.rsmodule and injectspub mod dioxus;intomod.rsTableSignalsstruct insideSpacetimeDbContext) to ensure they outlive child componentsSyncSignal(thread-safe) so SpacetimeDB callbacks can safely write from background threadsCodegenOptionsparameter ongenerate_global_files,CodegenVisibilityon iterators, 3-tuple(name, accessor_name, type_ref)fromiter_table_names_and_typesrustfmt; default output dir issrc/module_bindingsAPI and ABI breaking changes
None. New
--lang dioxusoption is purely additive; existing generators are unaffected.Expected complexity level and risk
2. Self-contained within the codegen module. Adds a new
Langimpl that delegates all type/table/reducer/procedure file generation toRust, only adding thedioxus.rsglobal module. No changes to existing generators, SDK, or server code.Testing
test_codegen_dioxussnapshot test added and passingtest_codegen_rust,test_codegen_csharp,test_codegen_typescript)spacetimedb-cliandspacetimedb-codegenbuild cleanlydioxus.rssnapshot looks correct for the module-test moduleOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.