1use wasm_bindgen::prelude::*;
2
3#[wasm_bindgen(module = "/src/build/index.js")]
4extern "C" {
5 #[cfg(feature = "bundled")]
6 #[wasm_bindgen(js_name = createBundledDbWorker)]
7 async fn create_db_blob_worker(configs: Vec<JsValue>, worker_blob: &[u8], wasm_blob: &[u8]);
8
9 #[wasm_bindgen(js_name = createUrlDbWorker)]
13 pub async fn create_db_worker(configs: Vec<JsValue>, worker_url: &str, wasm_url: &str);
14
15 #[wasm_bindgen(catch, js_name = execQuery)]
18 pub async fn exec_query(query: String) -> Result<JsValue, JsValue>;
19
20 #[wasm_bindgen(js_name = isInitialized)]
22 pub fn is_worker_initialized() -> bool;
23
24}
25
26#[cfg(feature = "bundled")]
31pub async fn create_bundled_db_worker(configs: Vec<JsValue>) {
32 const WORKER_BLOB: &[u8] = include_bytes!("./build/assets/sqlite.worker.js");
33 const WASM_BLOB: &[u8] = include_bytes!("./build/assets/sql-wasm.wasm");
34
35 create_db_blob_worker(configs, WORKER_BLOB, WASM_BLOB).await;
36}