diff --git a/Cargo.lock b/Cargo.lock index 54812aff9..c2ca14a83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1206,12 +1206,12 @@ dependencies = [ "arboard", "document-features", "egui", - "instant", "log", "puffin", "raw-window-handle", "serde", "smithay-clipboard", + "web-time", "webbrowser", "winit", ] @@ -4052,6 +4052,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa75ec260dcf59cc310827bae1d7f629809b173dbfe808a633e19754dd4282a5" +dependencies = [ + "js-sys", + "once_cell", + "wasm-bindgen", +] + [[package]] name = "webbrowser" version = "0.8.10" diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index 2d6833d91..30e206306 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -60,8 +60,9 @@ egui = { version = "0.22.0", path = "../egui", default-features = false, feature "log", ] } log = { version = "0.4", features = ["std"] } -winit = { version = "0.28", default-features = false } raw-window-handle = "0.5.0" +web-time = { version = "0.1" } # We use web-time so we can (maybe) compile for web +winit = { version = "0.28", default-features = false } #! ### Optional dependencies @@ -73,17 +74,8 @@ document-features = { version = "0.2", optional = true } puffin = { version = "0.16", optional = true } serde = { version = "1.0", optional = true, features = ["derive"] } - webbrowser = { version = "0.8.3", optional = true } -[target.'cfg(not(target_arch="wasm32"))'.dependencies] -instant = { version = "0.1" } - -[target.'cfg(target_arch="wasm32")'.dependencies] -instant = { version = "0.1", features = [ - "wasm-bindgen", -] } # We use instant so we can (maybe) compile for web - [target.'cfg(any(target_os="linux", target_os="dragonfly", target_os="freebsd", target_os="netbsd", target_os="openbsd"))'.dependencies] smithay-clipboard = { version = "0.6.3", optional = true } diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index edc51b9b6..62888588b 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -53,7 +53,7 @@ pub struct EventResponse { /// Handles the integration between egui and winit. pub struct State { - start_time: instant::Instant, + start_time: web_time::Instant, egui_input: egui::RawInput, pointer_pos_in_points: Option, any_pointer_button_down: bool, @@ -95,7 +95,7 @@ impl State { }; Self { - start_time: instant::Instant::now(), + start_time: web_time::Instant::now(), egui_input, pointer_pos_in_points: None, any_pointer_button_down: false,