diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d2e9f1..c98cfaef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ And please only add new entries to the top of this list, right below the `# Unre - On Web, fix pointer button events not being processed when a buttons is already pressed. - **Breaking:** Updated `bitflags` crate version to `2`, which changes the API on exposed types. - On Web, handle coalesced pointer events, which increases the resolution of pointer inputs. +- **Breaking:** On Web, `instant` is now replaced by `web_time`. # 0.28.6 diff --git a/Cargo.toml b/Cargo.toml index df6dddfc..571ab698 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,6 @@ cfg_aliases = "0.1.1" [dependencies] bitflags = "2" cursor-icon = "1.0.0" -instant = { version = "0.1", features = ["wasm-bindgen"] } log = "0.4" mint = { version = "0.5.6", optional = true } once_cell = "1.12" @@ -159,6 +158,7 @@ features = [ js-sys = "0.3" wasm-bindgen = "0.2.45" wasm-bindgen-futures = "0.4" +web-time = "0.2" [target.'cfg(target_family = "wasm")'.dev-dependencies] console_log = "1" diff --git a/examples/control_flow.rs b/examples/control_flow.rs index 541f13ad..835ab642 100644 --- a/examples/control_flow.rs +++ b/examples/control_flow.rs @@ -1,6 +1,10 @@ #![allow(clippy::single_match)] -use std::{thread, time}; +use std::thread; +#[cfg(not(wasm_platform))] +use std::time; +#[cfg(wasm_platform)] +use web_time as time; use simple_logger::SimpleLogger; use winit::{ @@ -102,7 +106,7 @@ fn main() { Mode::Wait => control_flow.set_wait(), Mode::WaitUntil => { if !wait_cancelled { - control_flow.set_wait_until(instant::Instant::now() + WAIT_TIME); + control_flow.set_wait_until(time::Instant::now() + WAIT_TIME); } } Mode::Poll => { diff --git a/examples/timer.rs b/examples/timer.rs index 4d609bef..a5c713a0 100644 --- a/examples/timer.rs +++ b/examples/timer.rs @@ -1,7 +1,10 @@ #![allow(clippy::single_match)] -use instant::Instant; use std::time::Duration; +#[cfg(not(wasm_platform))] +use std::time::Instant; +#[cfg(wasm_platform)] +use web_time::Instant; use simple_logger::SimpleLogger; use winit::{ diff --git a/src/event.rs b/src/event.rs index cd7944c1..a658dc4d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -34,9 +34,12 @@ //! //! [`EventLoop::run(...)`]: crate::event_loop::EventLoop::run //! [`ControlFlow::WaitUntil`]: crate::event_loop::ControlFlow::WaitUntil -use instant::Instant; use smol_str::SmolStr; use std::path::PathBuf; +#[cfg(not(wasm_platform))] +use std::time::Instant; +#[cfg(wasm_platform)] +use web_time::Instant; #[cfg(doc)] use crate::window::Window; diff --git a/src/event_loop.rs b/src/event_loop.rs index effbd15c..d3fe3248 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -11,9 +11,12 @@ use std::marker::PhantomData; use std::ops::Deref; use std::{error, fmt}; -use instant::{Duration, Instant}; use once_cell::sync::OnceCell; use raw_window_handle::{HasRawDisplayHandle, RawDisplayHandle}; +#[cfg(not(wasm_platform))] +use std::time::{Duration, Instant}; +#[cfg(wasm_platform)] +use web_time::{Duration, Instant}; use crate::{event::Event, monitor::MonitorHandle, platform_impl}; diff --git a/src/platform_impl/web/event_loop/runner.rs b/src/platform_impl/web/event_loop/runner.rs index 66ac78c2..c28a28e5 100644 --- a/src/platform_impl/web/event_loop/runner.rs +++ b/src/platform_impl/web/event_loop/runner.rs @@ -3,7 +3,6 @@ use crate::event::{Event, StartCause}; use crate::event_loop::ControlFlow; use crate::window::WindowId; -use instant::{Duration, Instant}; use std::{ cell::RefCell, clone::Clone, @@ -12,6 +11,7 @@ use std::{ ops::Deref, rc::{Rc, Weak}, }; +use web_time::{Duration, Instant}; pub struct Shared(Rc>); diff --git a/src/platform_impl/web/event_loop/state.rs b/src/platform_impl/web/event_loop/state.rs index d7c7fb65..dabf0cb5 100644 --- a/src/platform_impl/web/event_loop/state.rs +++ b/src/platform_impl/web/event_loop/state.rs @@ -1,7 +1,7 @@ use super::backend; use crate::event_loop::ControlFlow; -use instant::Instant; +use web_time::Instant; #[derive(Debug)] pub enum State {