diff --git a/Cargo.lock b/Cargo.lock index f881eff..1a22c35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1398,7 +1398,9 @@ dependencies = [ "tokio", "tracing-wasm", "ui", + "universal-time", "wasm-bindgen", + "web-time", "workspace", ] diff --git a/web/Cargo.toml b/web/Cargo.toml index dae84a6..bb537b8 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -4,9 +4,6 @@ version.workspace = true edition.workspace = true publish.workspace = true -[lib] -crate-type = ["cdylib"] - [dependencies] workspace = { path = "../crates/workspace" } assets = { path = "../crates/assets" } @@ -29,6 +26,8 @@ console_error_panic_hook = "0.1" tracing-wasm = "0.2" console_log = "1.0" wasm-bindgen = "0.2" +universal-time = "0.3.0" +web-time = "1.1.0" [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom_0_2 = { package = "getrandom", version = "0.2", features = ["js"] } diff --git a/web/src/lib.rs b/web/src/main.rs similarity index 69% rename from web/src/lib.rs rename to web/src/main.rs index ca86a18..4db9711 100644 --- a/web/src/lib.rs +++ b/web/src/main.rs @@ -1,7 +1,31 @@ +use std::time::Duration; + use gpui::*; use ui::Root; +use universal_time::{Instant, MonotonicClock, SystemTime, WallClock, define_time_provider}; use wasm_bindgen::prelude::*; +struct CustomTimeProvider; + +impl WallClock for CustomTimeProvider { + fn system_time(&self) -> SystemTime { + SystemTime::from_unix_duration(Duration::from_secs(0)) + } +} + +impl MonotonicClock for CustomTimeProvider { + fn instant(&self) -> Instant { + Instant::from_ticks(Duration::from_secs(0)) + } +} + +define_time_provider!(CustomTimeProvider); + +fn main() { + // Binary entry point — actual initialization happens in `run()` below, + // which is called explicitly from JavaScript after the WASM module loads. +} + #[wasm_bindgen] pub fn run() -> Result<(), JsValue> { console_error_panic_hook::set_once();