diff --git a/Cargo.lock b/Cargo.lock index 128cf41..62a01d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,6 +426,7 @@ dependencies = [ "gloo-net 0.6.0", "leptos", "log", + "rexie", "serde", "serde-wasm-bindgen", "serde_json", @@ -1055,6 +1056,20 @@ dependencies = [ "syn", ] +[[package]] +name = "idb" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afe8830d5802f769dc0be20a87f9f116798c896650cb6266eb5c19a3c109eed" +dependencies = [ + "js-sys", + "num-traits", + "thiserror 1.0.69", + "tokio", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1386,6 +1401,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -1722,6 +1746,17 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "rexie" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "887466cfa8a12c08ee4b174998135cea8ff0fd84858627cd793e56535a045bc9" +dependencies = [ + "idb", + "thiserror 1.0.69", + "wasm-bindgen", +] + [[package]] name = "rstml" version = "0.12.1" diff --git a/Cargo.toml b/Cargo.toml index aa1f690..50eb589 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ futures-util = "0.3.31" gloo = { version = "0.11.0", features = ["futures"] } gloo-net = { version = "0.6.0" } web-sys = { version = "0.3.77", features = ["FileSystemWritableFileStream", "WorkerGlobalScope"] } +rexie = "0.6.2" [target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dev-dependencies] wasm-bindgen-test = "0.3.50" diff --git a/index.html b/index.html index 1cf7e63..ef41776 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ <html> <head> <link data-trunk rel="rust" data-type="worker" data-bin="database_worker" data-weak-refs data-loader-shim /> - <link data-trunk rel="rust" data-bin="draft-manager" data-weak-refs /> + <link data-trunk rel="rust" data-bin="collection_viewer" data-weak-refs /> </head> <body></boy> </html> diff --git a/src/main.rs b/src/bin/collection_viewer.rs similarity index 68% rename from src/main.rs rename to src/bin/collection_viewer.rs index b054981..0315b6a 100644 --- a/src/main.rs +++ b/src/bin/collection_viewer.rs @@ -14,33 +14,20 @@ // You should have received a copy of the GNU Affero General Public License // along with yugioh-binder. If not, see <https://www.gnu.org/licenses/>. -use std::time::Duration; - -use draft_manager::card_database::CardDatabase; use leptos::prelude::*; -use wasm_bindgen_futures::spawn_local; +use rexie::{ObjectStore, Rexie}; fn main() { console_error_panic_hook::set_once(); wasm_logger::init(wasm_logger::Config::default()); - log::debug!("Startin app database"); - let db = CardDatabase::new(); - log::debug!("Database initialized"); + let rexie = Rexie::builder("collections").version(1).add_object_store( + ObjectStore::new("collection") + .key_path("id") + .auto_increment(true), + ); leptos::mount::mount_to_body(|| view! { <App /> }); - - spawn_local(async move { - let db = db; - - log::info!("Running loop!"); - db.send_message(); - - // We create a loop so that listeners can be held for forever. - loop { - gloo::timers::future::sleep(Duration::from_secs(3600)).await; - } - }); } #[component]