Skip to content

Commit 51d284f

Browse files
SvenFinndjc
authored andcommitted
Introduce wasmbind feature
1 parent ee057e5 commit 51d284f

File tree

7 files changed

+11
-7
lines changed

7 files changed

+11
-7
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ futures = "0.3" # so the doctest for wrap_stream is nice
3232
pretty_assertions = "1.4.0"
3333

3434
[target.'cfg(target_arch = "wasm32")'.dependencies]
35-
web-time = "1.1.0"
35+
web-time = { version = "1.1.0", optional = true }
3636

3737
[features]
38-
default = ["unicode-width", "console/unicode-width"]
38+
default = ["unicode-width", "console/unicode-width", "wasmbind"]
3939
improved_unicode = ["unicode-segmentation", "unicode-width", "console/unicode-width"]
4040
in_memory = ["vt100"]
4141
futures = ["dep:futures-core"]
42+
wasmbind = ["dep:web-time"]
4243

4344
[package.metadata.docs.rs]
4445
all-features = true

src/draw_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::time::Duration;
88
use std::time::Instant;
99

1010
use console::{Term, TermTarget};
11-
#[cfg(target_arch = "wasm32")]
11+
#[cfg(all(target_arch = "wasm32", feature = "wasmbind"))]
1212
use web_time::Instant;
1313

1414
use crate::multi::{MultiProgressAlignment, MultiState};

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@
244244
#![cfg_attr(docsrs, feature(doc_cfg))]
245245
#![warn(unreachable_pub)]
246246

247+
#[cfg(all(target_arch = "wasm32", not(feature = "wasmbind")))]
248+
compile_error!("The 'wasmbind' feature must be enabled when compiling for wasm32.");
249+
247250
mod draw_target;
248251
mod format;
249252
#[cfg(feature = "in_memory")]

src/multi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::draw_target::{
1010
VisualLines,
1111
};
1212
use crate::progress_bar::ProgressBar;
13-
#[cfg(target_arch = "wasm32")]
13+
#[cfg(all(target_arch = "wasm32", feature = "wasmbind"))]
1414
use web_time::Instant;
1515

1616
/// Manages multiple progress bars from different threads

src/progress_bar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{fmt, io, thread};
99

1010
#[cfg(test)]
1111
use once_cell::sync::Lazy;
12-
#[cfg(target_arch = "wasm32")]
12+
#[cfg(all(target_arch = "wasm32", feature = "wasmbind"))]
1313
use web_time::Instant;
1414

1515
use crate::draw_target::ProgressDrawTarget;

src/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::time::Duration;
66
use std::time::Instant;
77

88
use portable_atomic::{AtomicU64, AtomicU8, Ordering};
9-
#[cfg(target_arch = "wasm32")]
9+
#[cfg(all(target_arch = "wasm32", feature = "wasmbind"))]
1010
use web_time::Instant;
1111

1212
use crate::draw_target::{LineType, ProgressDrawTarget};

src/style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use unicode_width::UnicodeWidthChar;
99
use console::{measure_text_width, AnsiCodeIterator, Style};
1010
#[cfg(feature = "unicode-segmentation")]
1111
use unicode_segmentation::UnicodeSegmentation;
12-
#[cfg(target_arch = "wasm32")]
12+
#[cfg(all(target_arch = "wasm32", feature = "wasmbind"))]
1313
use web_time::Instant;
1414

1515
use crate::draw_target::LineType;

0 commit comments

Comments
 (0)