lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit d08255a21aff993fd6f0808304204e8401bcbc67
parent 7d79347fa19a6fff82344647b1ac5f1bde54e820
Author: triesap <tyson@radroots.org>
Date:   Sun, 18 Jan 2026 21:41:53 +0000

sql-wasm-core: scaffold embedded wasm backend


- add bridge and embedded feature flags with bridge default
- make `radroots-sql-wasm-bridge` dependency optional and gated
- add embedded engine stub module for future backend
- gate wasm exports behind bridge feature

Diffstat:
Mevents/bindings/ts/src/types.ts | 2++
Msql-wasm-core/Cargo.toml | 6++++--
Asql-wasm-core/src/embedded.rs | 12++++++++++++
Msql-wasm-core/src/lib.rs | 17+++++++++++------
Mtrade/bindings/ts/src/types.ts | 4++++
5 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/events/bindings/ts/src/types.ts b/events/bindings/ts/src/types.ts @@ -1,3 +1,5 @@ +import type { RadrootsCoreDecimal, RadrootsCoreDiscount, RadrootsCoreDiscountValue, RadrootsCoreMoney, RadrootsCorePercent, RadrootsCoreQuantity, RadrootsCoreQuantityPrice, RadrootsCoreUnit } from "@radroots/core-bindings"; + // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. export type JobFeedbackStatus = "payment_required" | "processing" | "error" | "success" | "partial"; diff --git a/sql-wasm-core/Cargo.toml b/sql-wasm-core/Cargo.toml @@ -10,11 +10,13 @@ license.workspace = true crate-type = ["cdylib", "rlib"] [features] -default = [] +default = ["bridge"] +bridge = ["dep:radroots-sql-wasm-bridge"] +embedded = [] [dependencies] radroots-sql-core = { workspace = true } -radroots-sql-wasm-bridge = { workspace = true } +radroots-sql-wasm-bridge = { workspace = true, optional = true } chrono = { workspace = true, features = ["serde"] } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } diff --git a/sql-wasm-core/src/embedded.rs b/sql-wasm-core/src/embedded.rs @@ -0,0 +1,12 @@ +#![forbid(unsafe_code)] + +use radroots_sql_core::error::SqlError; + +#[derive(Clone, Copy, Debug, Default)] +pub struct EmbeddedSqlEngine; + +impl EmbeddedSqlEngine { + pub fn new() -> Result<Self, SqlError> { + Err(SqlError::UnsupportedPlatform) + } +} diff --git a/sql-wasm-core/src/lib.rs b/sql-wasm-core/src/lib.rs @@ -12,6 +12,11 @@ use wasm_bindgen::JsValue; #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::*; +#[cfg(all(feature = "embedded", target_arch = "wasm32"))] +mod embedded; +#[cfg(all(feature = "embedded", target_arch = "wasm32"))] +pub use embedded::EmbeddedSqlEngine; + #[cfg(target_arch = "wasm32")] pub fn parse_json<T: DeserializeOwned>(s: &str) -> Result<T, SqlError> { utils::parse_json(s) @@ -26,36 +31,36 @@ pub fn err_js(err: SqlError) -> JsValue { } } -#[cfg(target_arch = "wasm32")] +#[cfg(all(feature = "bridge", target_arch = "wasm32"))] #[wasm_bindgen(js_name = exec_sql)] pub fn exec_sql(sql: &str, params_json: &str) -> JsValue { radroots_sql_wasm_bridge::exec(sql, params_json) } -#[cfg(target_arch = "wasm32")] +#[cfg(all(feature = "bridge", target_arch = "wasm32"))] #[wasm_bindgen(js_name = query_sql)] pub fn query_sql(sql: &str, params_json: &str) -> JsValue { radroots_sql_wasm_bridge::query(sql, params_json) } -#[cfg(target_arch = "wasm32")] +#[cfg(all(feature = "bridge", target_arch = "wasm32"))] pub fn export_bytes() -> JsValue { radroots_sql_wasm_bridge::export_bytes() } -#[cfg(target_arch = "wasm32")] +#[cfg(all(feature = "bridge", target_arch = "wasm32"))] #[wasm_bindgen(js_name = begin_tx)] pub fn begin_tx() { radroots_sql_wasm_bridge::begin_tx() } -#[cfg(target_arch = "wasm32")] +#[cfg(all(feature = "bridge", target_arch = "wasm32"))] #[wasm_bindgen(js_name = commit_tx)] pub fn commit_tx() { radroots_sql_wasm_bridge::commit_tx() } -#[cfg(target_arch = "wasm32")] +#[cfg(all(feature = "bridge", target_arch = "wasm32"))] #[wasm_bindgen(js_name = rollback_tx)] pub fn rollback_tx() { radroots_sql_wasm_bridge::rollback_tx() diff --git a/trade/bindings/ts/src/types.ts b/trade/bindings/ts/src/types.ts @@ -1,3 +1,7 @@ +import type { RadrootsListingImage, RadrootsNostrEventPtr, RadrootsPlotRef, RadrootsResourceAreaRef } from "@radroots/events-bindings"; + +import type { RadrootsCoreCurrency, RadrootsCoreDecimal, RadrootsCoreDiscount, RadrootsCoreDiscountValue, RadrootsCoreMoney, RadrootsCoreQuantity, RadrootsCoreQuantityPrice, RadrootsCoreUnit } from "@radroots/core-bindings"; + // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. export type RadrootsListing = { d_tag: string, farm: RadrootsListingFarmRef, product: RadrootsListingProduct, primary_bin_id: string, bins: Array<RadrootsListingBin>, resource_area?: RadrootsResourceAreaRef | null, plot?: RadrootsPlotRef | null, discounts?: RadrootsCoreDiscount[] | null, inventory_available?: RadrootsCoreDecimal | null, availability?: RadrootsListingAvailability | null, delivery_method?: RadrootsListingDeliveryMethod | null, location?: RadrootsListingLocation | null, images?: RadrootsListingImage[] | null, };