Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8546694
Replace SDK File struct with StorageEntry for web
thlsrms Apr 24, 2025
27abe95
Enable web build for the SDK crate
thlsrms Apr 24, 2025
e1d88e6
Enable run_threaded on the web with spawn_local
thlsrms Apr 25, 2025
8ae1110
Improve Rust SDK websocket message handling on wasm32
thlsrms May 1, 2025
832b03d
Add cookie API and re-export gloo storage wrappers for the web SDK
thlsrms May 2, 2025
a79a798
Remove some redundancies from wasm32 rust sdk
thlsrms May 5, 2025
c03cdce
Add `web` feature flag to the rust sdk
thlsrms May 11, 2025
506d78f
Add token verification for the wasm sdk websocket connection
thlsrms May 7, 2025
b126cae
Rename misleading `run_threaded` to `run_background` on wasm32
thlsrms May 7, 2025
f8b3a77
Reduce cfg noise by simplifying mutex handling in the sdk crate
thlsrms May 11, 2025
9149bc1
Remove tokio dependency from the rust web sdk
thlsrms May 11, 2025
937d498
Improve error handling for the wasm sdk's Cookie builder
thlsrms May 16, 2025
68a2eb4
Use conditional type aliases to reduce cfg noise on structs
thlsrms Oct 28, 2025
5da7a5b
Consolidate web/non-web `build_impl` functions
thlsrms Oct 28, 2025
7598eba
Enforce compile error on non-portable `DbConnection` methods
thlsrms Oct 28, 2025
042c05b
Bump `getrandom` to 0.3.4, remove legacy `RUSTFLAGS` requirement
thlsrms Oct 28, 2025
4f913d5
Minor formatting and code simplification for clippy
thlsrms Oct 28, 2025
ebbd09f
Rename run_background to run_background_task for clarity
thlsrms Nov 22, 2025
6e5951a
Hide wasm-only DbConnection methods in native docs
thlsrms Nov 22, 2025
26cd1b5
Fix wasm32 SDK build against latest master
drdozer Feb 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 124 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions crates/codegen/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,10 +1645,11 @@ impl __sdk::InModule for RemoteTables {{
/// You must explicitly advance the connection by calling any one of:
///
/// - [`DbConnection::frame_tick`].
/// - [`DbConnection::run_threaded`].
#[cfg_attr(not(target_arch = \"wasm32\"), doc = \"- [`DbConnection::run_threaded`].\")]
#[cfg_attr(target_arch = \"wasm32\", doc = \"- [`DbConnection::run_background_task`].\")]
/// - [`DbConnection::run_async`].
/// - [`DbConnection::advance_one_message`].
/// - [`DbConnection::advance_one_message_blocking`].
#[cfg_attr(not(target_arch = \"wasm32\"), doc = \"- [`DbConnection::advance_one_message_blocking`].\")]
/// - [`DbConnection::advance_one_message_async`].
///
/// Which of these methods you should call depends on the specific needs of your application,
Expand Down Expand Up @@ -1746,6 +1747,7 @@ impl DbConnection {{
/// This is a low-level primitive exposed for power users who need significant control over scheduling.
/// Most applications should call [`Self::run_threaded`] to spawn a thread
/// which advances the connection automatically.
#[cfg(not(target_arch = \"wasm32\"))]
pub fn advance_one_message_blocking(&self) -> __sdk::Result<()> {{
self.imp.advance_one_message_blocking()
}}
Expand All @@ -1771,10 +1773,17 @@ impl DbConnection {{
}}

/// Spawn a thread which processes WebSocket messages as they are received.
#[cfg(not(target_arch = \"wasm32\"))]
pub fn run_threaded(&self) -> std::thread::JoinHandle<()> {{
self.imp.run_threaded()
}}

/// Spawn a background task which processes WebSocket messages as they are received.
#[cfg(target_arch = \"wasm32\")]
pub fn run_background_task(&self) {{
self.imp.run_background_task()
}}

/// Run an `async` loop which processes WebSocket messages when polled.
pub async fn run_async(&self) -> __sdk::Result<()> {{
self.imp.run_async().await
Expand Down
13 changes: 11 additions & 2 deletions crates/codegen/tests/snapshots/codegen__codegen_rust.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1390,10 +1390,11 @@ impl __sdk::InModule for RemoteTables {
/// You must explicitly advance the connection by calling any one of:
///
/// - [`DbConnection::frame_tick`].
/// - [`DbConnection::run_threaded`].
#[cfg_attr(not(target_arch = "wasm32"), doc = "- [`DbConnection::run_threaded`].")]
#[cfg_attr(target_arch = "wasm32", doc = "- [`DbConnection::run_background_task`].")]
/// - [`DbConnection::run_async`].
/// - [`DbConnection::advance_one_message`].
/// - [`DbConnection::advance_one_message_blocking`].
#[cfg_attr(not(target_arch = "wasm32"), doc = "- [`DbConnection::advance_one_message_blocking`].")]
/// - [`DbConnection::advance_one_message_async`].
///
/// Which of these methods you should call depends on the specific needs of your application,
Expand Down Expand Up @@ -1491,6 +1492,7 @@ impl DbConnection {
/// This is a low-level primitive exposed for power users who need significant control over scheduling.
/// Most applications should call [`Self::run_threaded`] to spawn a thread
/// which advances the connection automatically.
#[cfg(not(target_arch = "wasm32"))]
pub fn advance_one_message_blocking(&self) -> __sdk::Result<()> {
self.imp.advance_one_message_blocking()
}
Expand All @@ -1516,10 +1518,17 @@ impl DbConnection {
}

/// Spawn a thread which processes WebSocket messages as they are received.
#[cfg(not(target_arch = "wasm32"))]
pub fn run_threaded(&self) -> std::thread::JoinHandle<()> {
self.imp.run_threaded()
}

/// Spawn a background task which processes WebSocket messages as they are received.
#[cfg(target_arch = "wasm32")]
pub fn run_background_task(&self) {
self.imp.run_background_task()
}

/// Run an `async` loop which processes WebSocket messages when polled.
pub async fn run_async(&self) -> __sdk::Result<()> {
self.imp.run_async().await
Expand Down
2 changes: 2 additions & 0 deletions crates/sql-parser/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ pub(crate) fn parse_proj(expr: Expr) -> SqlParseResult<ProjectExpr> {

// These types determine the size of [`parse_expr`]'s stack frame.
// Changing their sizes will require updating the recursion limit to avoid stack overflows.
#[cfg(target_pointer_width = "64")]
const _: () = assert!(size_of::<Expr>() == 168);
#[cfg(target_pointer_width = "64")]
const _: () = assert!(size_of::<SqlParseResult<SqlExpr>>() == 40);

/// Parse a scalar expression
Expand Down
28 changes: 27 additions & 1 deletion sdks/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = []
allow_loopback_http_for_tests = ["spacetimedb-testing/allow_loopback_http_for_tests"]
web = [
"dep:getrandom",
"dep:gloo-console",
"dep:gloo-net",
"dep:gloo-storage",
"dep:gloo-utils",
"dep:js-sys",
"dep:tokio-tungstenite-wasm",
"dep:wasm-bindgen",
"dep:wasm-bindgen-futures",
"dep:web-sys",
]

[dependencies]
spacetimedb-data-structures.workspace = true
Expand All @@ -28,12 +41,25 @@ bytes.workspace = true
flate2.workspace = true
futures.workspace = true
futures-channel.workspace = true
home.workspace = true
http.workspace = true
log.workspace = true
once_cell.workspace = true
prometheus.workspace = true
rand.workspace = true

getrandom = { version = "0.3.4", features = ["wasm_js"], optional = true }
gloo-console = { version = "0.3.0", optional = true }
gloo-net = { version = "0.6.0", optional = true }
gloo-storage = { version = "0.3.0", optional = true }
gloo-utils = { version = "0.2.0", optional = true }
js-sys = { version = "0.3", optional = true }
tokio-tungstenite-wasm = { version = "0.6.0", optional = true }
wasm-bindgen = { version = "0.2.100", optional = true }
wasm-bindgen-futures = { version = "0.4.45", optional = true }
web-sys = { version = "0.3.77", features = ["HtmlDocument"], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
home.workspace = true
tokio.workspace = true
tokio-tungstenite.workspace = true

Expand Down
Loading