use sqlite for wasm
This commit is contained in:
@@ -30,6 +30,7 @@ console_error_panic_hook = "0.1"
|
||||
tracing-wasm = "0.2"
|
||||
console_log = "1.0"
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
js-sys = "0.3"
|
||||
universal-time = { git = "https://github.com/shadowylab/universal-time" }
|
||||
|
||||
|
||||
+28
-10
@@ -32,15 +32,34 @@ impl MonotonicClock for BrowserTimeProvider {
|
||||
|
||||
define_time_provider!(BrowserTimeProvider);
|
||||
|
||||
fn init_logging() {
|
||||
// Called from both entry points; the first one wins
|
||||
static ONCE: std::sync::OnceLock<()> = std::sync::OnceLock::new();
|
||||
|
||||
ONCE.get_or_init(|| {
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
// Initialize logging to browser console
|
||||
console_log::init_with_level(log::Level::Info).ok();
|
||||
|
||||
// Also initialize tracing for WASM
|
||||
tracing_wasm::set_as_global_default();
|
||||
});
|
||||
}
|
||||
|
||||
/// Open the persistent nostr database before the app starts.
|
||||
#[wasm_bindgen]
|
||||
pub async fn open_database() -> Result<(), JsValue> {
|
||||
init_logging();
|
||||
|
||||
state::web_database::open().await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run() -> Result<(), JsValue> {
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
// Initialize logging to browser console
|
||||
console_log::init_with_level(log::Level::Info).expect("Failed to initialize logger");
|
||||
|
||||
// Also initialize tracing for WASM
|
||||
tracing_wasm::set_as_global_default();
|
||||
init_logging();
|
||||
|
||||
// Sets the panic hook and GPUI's console logger
|
||||
gpui_platform::web_init();
|
||||
@@ -59,12 +78,11 @@ pub fn run() -> Result<(), JsValue> {
|
||||
|
||||
APPLICATION.with(|application| {
|
||||
*application.borrow_mut() = Some(app.run_embedded(|cx| {
|
||||
gpui_kit::init(cx);
|
||||
|
||||
load_embedded_fonts(cx);
|
||||
apply_web_fonts(cx);
|
||||
|
||||
// Initialize the framework before anything renders
|
||||
gpui_kit::init(cx);
|
||||
|
||||
// Initialize settings
|
||||
settings::init(cx);
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ async function init() {
|
||||
const wasm = await import('./wasm/coop_web.js');
|
||||
await wasm.default();
|
||||
|
||||
// Open the persistent nostr database before the app starts
|
||||
await wasm.open_database();
|
||||
|
||||
// Initialize the story gallery
|
||||
await wasm.run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user