Skip to content

Commit 3193cd6

Browse files
langyofutursolo
andauthored
Remove the flags what to expect WASI targets. (#425)
* Remove the flags what to expect WASI targets. * Try to fix web_sys imports. * Fix pub mod. * Remove macro on the header. It's my fault... * Update crates/history/Cargo.toml Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com> --------- Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com>
1 parent 5f96627 commit 3193cd6

File tree

4 files changed

+14
-40
lines changed

4 files changed

+14
-40
lines changed

crates/history/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ serde = { version = "1", features = ["derive"] }
1818
serde-wasm-bindgen = "0.6.0"
1919
serde_urlencoded = { version = "0.7", optional = true }
2020
thiserror = { version = "1.0", optional = true }
21+
wasm-bindgen = "0.2.88"
2122

22-
[target.'cfg(not(target_os = "wasi"))'.dependencies]
23-
wasm-bindgen = "0.2"
24-
25-
[target.'cfg(not(target_os = "wasi"))'.dependencies.web-sys]
23+
[dependencies.web-sys]
2624
version = "0.3"
2725
features = ["History", "Window", "Location", "Url"]
2826

crates/history/src/any.rs

+12-30
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::borrow::Cow;
22

3-
#[cfg(not(target_os = "wasi"))]
43
use crate::browser::BrowserHistory;
5-
#[cfg(not(target_os = "wasi"))]
64
use crate::hash::HashHistory;
75
use crate::history::History;
86
use crate::listener::HistoryListener;
@@ -15,10 +13,8 @@ use crate::{error::HistoryResult, query::ToQuery};
1513
#[derive(Clone, PartialEq, Debug)]
1614
pub enum AnyHistory {
1715
/// A Browser History.
18-
#[cfg(not(target_os = "wasi"))]
1916
Browser(BrowserHistory),
2017
/// A Hash History
21-
#[cfg(not(target_os = "wasi"))]
2218
Hash(HashHistory),
2319
/// A Memory History
2420
Memory(MemoryHistory),
@@ -27,39 +23,35 @@ pub enum AnyHistory {
2723
impl History for AnyHistory {
2824
fn len(&self) -> usize {
2925
match self {
30-
#[cfg(not(target_os = "wasi"))]
3126
Self::Browser(m) => m.len(),
32-
#[cfg(not(target_os = "wasi"))]
27+
3328
Self::Hash(m) => m.len(),
3429
Self::Memory(m) => m.len(),
3530
}
3631
}
3732

3833
fn go(&self, delta: isize) {
3934
match self {
40-
#[cfg(not(target_os = "wasi"))]
4135
Self::Browser(m) => m.go(delta),
42-
#[cfg(not(target_os = "wasi"))]
36+
4337
Self::Hash(m) => m.go(delta),
4438
Self::Memory(m) => m.go(delta),
4539
}
4640
}
4741

4842
fn push<'a>(&self, route: impl Into<Cow<'a, str>>) {
4943
match self {
50-
#[cfg(not(target_os = "wasi"))]
5144
Self::Browser(m) => m.push(route),
52-
#[cfg(not(target_os = "wasi"))]
45+
5346
Self::Hash(m) => m.push(route),
5447
Self::Memory(m) => m.push(route),
5548
}
5649
}
5750

5851
fn replace<'a>(&self, route: impl Into<Cow<'a, str>>) {
5952
match self {
60-
#[cfg(not(target_os = "wasi"))]
6153
Self::Browser(m) => m.replace(route),
62-
#[cfg(not(target_os = "wasi"))]
54+
6355
Self::Hash(m) => m.replace(route),
6456
Self::Memory(m) => m.replace(route),
6557
}
@@ -70,9 +62,8 @@ impl History for AnyHistory {
7062
T: 'static,
7163
{
7264
match self {
73-
#[cfg(not(target_os = "wasi"))]
7465
Self::Browser(m) => m.push_with_state(route, state),
75-
#[cfg(not(target_os = "wasi"))]
66+
7667
Self::Hash(m) => m.push_with_state(route, state),
7768
Self::Memory(m) => m.push_with_state(route, state),
7869
}
@@ -83,9 +74,8 @@ impl History for AnyHistory {
8374
T: 'static,
8475
{
8576
match self {
86-
#[cfg(not(target_os = "wasi"))]
8777
Self::Browser(m) => m.replace_with_state(route, state),
88-
#[cfg(not(target_os = "wasi"))]
78+
8979
Self::Hash(m) => m.replace_with_state(route, state),
9080
Self::Memory(m) => m.replace_with_state(route, state),
9181
}
@@ -101,9 +91,8 @@ impl History for AnyHistory {
10191
Q: ToQuery,
10292
{
10393
match self {
104-
#[cfg(not(target_os = "wasi"))]
10594
Self::Browser(m) => m.push_with_query(route, query),
106-
#[cfg(not(target_os = "wasi"))]
95+
10796
Self::Hash(m) => m.push_with_query(route, query),
10897
Self::Memory(m) => m.push_with_query(route, query),
10998
}
@@ -118,9 +107,8 @@ impl History for AnyHistory {
118107
Q: ToQuery,
119108
{
120109
match self {
121-
#[cfg(not(target_os = "wasi"))]
122110
Self::Browser(m) => m.replace_with_query(route, query),
123-
#[cfg(not(target_os = "wasi"))]
111+
124112
Self::Hash(m) => m.replace_with_query(route, query),
125113
Self::Memory(m) => m.replace_with_query(route, query),
126114
}
@@ -138,9 +126,8 @@ impl History for AnyHistory {
138126
T: 'static,
139127
{
140128
match self {
141-
#[cfg(not(target_os = "wasi"))]
142129
Self::Browser(m) => m.push_with_query_and_state(route, query, state),
143-
#[cfg(not(target_os = "wasi"))]
130+
144131
Self::Hash(m) => m.push_with_query_and_state(route, query, state),
145132
Self::Memory(m) => m.push_with_query_and_state(route, query, state),
146133
}
@@ -158,9 +145,8 @@ impl History for AnyHistory {
158145
T: 'static,
159146
{
160147
match self {
161-
#[cfg(not(target_os = "wasi"))]
162148
Self::Browser(m) => m.replace_with_query_and_state(route, query, state),
163-
#[cfg(not(target_os = "wasi"))]
149+
164150
Self::Hash(m) => m.replace_with_query_and_state(route, query, state),
165151
Self::Memory(m) => m.replace_with_query_and_state(route, query, state),
166152
}
@@ -171,33 +157,29 @@ impl History for AnyHistory {
171157
CB: Fn() + 'static,
172158
{
173159
match self {
174-
#[cfg(not(target_os = "wasi"))]
175160
Self::Browser(m) => m.listen(callback),
176-
#[cfg(not(target_os = "wasi"))]
161+
177162
Self::Hash(m) => m.listen(callback),
178163
Self::Memory(m) => m.listen(callback),
179164
}
180165
}
181166

182167
fn location(&self) -> Location {
183168
match self {
184-
#[cfg(not(target_os = "wasi"))]
185169
Self::Browser(m) => m.location(),
186-
#[cfg(not(target_os = "wasi"))]
170+
187171
Self::Hash(m) => m.location(),
188172
Self::Memory(m) => m.location(),
189173
}
190174
}
191175
}
192176

193-
#[cfg(not(target_os = "wasi"))]
194177
impl From<BrowserHistory> for AnyHistory {
195178
fn from(m: BrowserHistory) -> AnyHistory {
196179
AnyHistory::Browser(m)
197180
}
198181
}
199182

200-
#[cfg(not(target_os = "wasi"))]
201183
impl From<HashHistory> for AnyHistory {
202184
fn from(m: HashHistory) -> AnyHistory {
203185
AnyHistory::Hash(m)

crates/history/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
#![deny(missing_docs, missing_debug_implementations)]
55

66
mod any;
7-
#[cfg(not(target_os = "wasi"))]
87
mod browser;
98
#[cfg(feature = "query")]
109
mod error;
11-
#[cfg(not(target_os = "wasi"))]
1210
mod hash;
1311
mod history;
1412
mod listener;
@@ -20,9 +18,7 @@ mod state;
2018
mod utils;
2119

2220
pub use any::AnyHistory;
23-
#[cfg(not(target_os = "wasi"))]
2421
pub use browser::BrowserHistory;
25-
#[cfg(not(target_os = "wasi"))]
2622
pub use hash::HashHistory;
2723
pub use memory::MemoryHistory;
2824

crates/history/src/state.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(target_os = "wasi"))]
2-
31
use std::any::Any;
42
use std::collections::HashMap;
53
use std::rc::Rc;

0 commit comments

Comments
 (0)