Skip to content

Commit 5bf3e09

Browse files
committed
fix: make wasm features implicit
1 parent 2435b60 commit 5bf3e09

File tree

17 files changed

+63
-40
lines changed

17 files changed

+63
-40
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ rust-version = "1.83.0"
7474
edition = "2021"
7575

7676
[workspace.dependencies]
77-
libp2p = { version = "0.56.0", path = "libp2p" }
77+
libp2p = { version = "0.57.0", path = "libp2p" }
7878
libp2p-allow-block-list = { version = "0.6.0", path = "misc/allow-block-list" }
7979
libp2p-autonat = { version = "0.15.0", path = "protocols/autonat" }
8080
libp2p-connection-limits = { version = "0.6.0", path = "misc/connection-limits" }
@@ -102,7 +102,7 @@ libp2p-rendezvous = { version = "0.17.0", path = "protocols/rendezvous" }
102102
libp2p-request-response = { version = "0.29.0", path = "protocols/request-response" }
103103
libp2p-server = { version = "0.12.7", path = "misc/server" }
104104
libp2p-stream = { version = "0.4.0-alpha", path = "protocols/stream" }
105-
libp2p-swarm = { version = "0.47.0", path = "swarm" }
105+
libp2p-swarm = { version = "0.48.0", path = "swarm" }
106106
libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
107107
libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" }
108108
libp2p-tcp = { version = "0.44.0", path = "transports/tcp" }
@@ -111,7 +111,7 @@ libp2p-uds = { version = "0.43.0", path = "transports/uds" }
111111
libp2p-upnp = { version = "0.5.0", path = "protocols/upnp" }
112112
libp2p-webrtc = { version = "0.9.0-alpha.1", path = "transports/webrtc" }
113113
libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" }
114-
libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" }
114+
libp2p-webrtc-websys = { version = "0.4.1", path = "transports/webrtc-websys" }
115115
libp2p-websocket = { version = "0.45.1", path = "transports/websocket" }
116116
libp2p-websocket-websys = { version = "0.5.0", path = "transports/websocket-websys" }
117117
libp2p-webtransport-websys = { version = "0.5.1", path = "transports/webtransport-websys" }
@@ -123,10 +123,12 @@ env_logger = "0.11"
123123
futures = "0.3.30"
124124
futures-bounded = { version = "0.2.4" }
125125
futures-rustls = { version = "0.26.0", default-features = false }
126-
getrandom = "0.2"
127-
if-watch = "3.2.1"
126+
futures-timer = { version = "3" }
127+
getrandom = { version = "0.2", features = ["js"] }
128+
hashlink = "0.9.0"
128129
hickory-proto = { version = "0.25.2", default-features = false }
129130
hickory-resolver = { version = "0.25.2", default-features = false }
131+
if-watch = "3.2.1"
130132
multiaddr = "0.18.1"
131133
multihash = "0.19.1"
132134
multistream-select = { version = "0.13.0", path = "misc/multistream-select" }
@@ -142,7 +144,7 @@ tracing = "0.1.41"
142144
tracing-subscriber = "0.3.19"
143145
unsigned-varint = { version = "0.8.0" }
144146
web-time = "1.1.0"
145-
hashlink = "0.9.0"
147+
wasm-bindgen-futures = "0.4"
146148

147149
[patch.crates-io]
148150

examples/browser-webrtc/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ mime_guess = "2.0.4"
3535

3636
[target.'cfg(target_arch = "wasm32")'.dependencies]
3737
js-sys = "0.3.69"
38-
libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "wasm-bindgen"] }
38+
libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping"] }
3939
libp2p-webrtc-websys = { workspace = true }
4040
tracing-wasm = "0.2.1"
4141
wasm-bindgen = "0.2.90"
42-
wasm-bindgen-futures = "0.4.42"
42+
wasm-bindgen-futures = { workspace = true}
4343
web-sys = { version = "0.3", features = ['Document', 'Element', 'HtmlElement', 'Node', 'Response', 'Window'] }
4444

4545
[lints]

interop-tests/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ tracing = { workspace = true }
3939
tracing-subscriber = { workspace = true, features = ["env-filter"] }
4040

4141
[target.'cfg(target_arch = "wasm32")'.dependencies]
42-
libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "wasm-bindgen", "identify", "websocket-websys", "yamux", "noise"] }
42+
libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "identify", "websocket-websys", "yamux", "noise"] }
4343
libp2p-mplex = { path = "../muxers/mplex" }
4444
libp2p-webrtc-websys = { workspace = true }
4545
wasm-bindgen = { version = "0.2" }
46-
wasm-bindgen-futures = { version = "0.4" }
46+
wasm-bindgen-futures = { workspace = true}
4747
wasm-logger = { version = "0.2.0" }
4848
web-time = { workspace = true }
4949
reqwest = { version = "0.12", features = ["json"] }

libp2p/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.57.0
2+
3+
- Remove `wasm-bindgen` feature and make `wasm` support implicit.
4+
See [PR 6102](https://github.com/libp2p/rust-libp2p/pull/6102)
5+
16
## 0.56.0
27

38
- Remove `async-std` support.

libp2p/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p"
33
edition.workspace = true
44
rust-version = { workspace = true }
55
description = "Peer-to-peer networking library"
6-
version = "0.56.0"
6+
version = "0.57.0"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"
@@ -42,7 +42,6 @@ full = [
4242
"tls",
4343
"tokio",
4444
"uds",
45-
"wasm-bindgen",
4645
"webrtc-websys",
4746
"websocket-websys",
4847
"websocket",
@@ -81,7 +80,6 @@ tcp = ["dep:libp2p-tcp"]
8180
tls = ["dep:libp2p-tls"]
8281
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"]
8382
uds = ["dep:libp2p-uds"]
84-
wasm-bindgen = ["futures-timer/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
8583
webrtc-websys = ['dep:libp2p-webrtc-websys']
8684
websocket-websys = ["dep:libp2p-websocket-websys"]
8785
websocket = ["dep:libp2p-websocket"]
@@ -93,8 +91,6 @@ upnp = ["dep:libp2p-upnp"]
9391
bytes = "1"
9492
either = "1.9.0"
9593
futures = { workspace = true }
96-
futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature
97-
getrandom = { workspace = true } # Explicit dependency to be used in `wasm-bindgen` feature
9894
# TODO feature flag?
9995
rw-stream-sink = { workspace = true }
10096
libp2p-allow-block-list = { workspace = true }
@@ -144,6 +140,10 @@ libp2p-mplex = { workspace = true }
144140
libp2p-tcp = { workspace = true, features = ["tokio"] }
145141
tracing-subscriber = { workspace = true, features = ["env-filter"] }
146142

143+
[target.'cfg(target_family="wasm")'.dependencies]
144+
futures-timer = { workspace = true, features = ["wasm-bindgen"] }
145+
getrandom = { workspace = true}
146+
147147
# Passing arguments to the docsrs builder in order to properly document cfg's.
148148
# More information: https://docs.rs/about/builds#cross-compiling
149149
[package.metadata.docs.rs]

libp2p/src/builder/phase/provider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum NoProviderSpecified {}
1515
/// Represents the Tokio runtime environment.
1616
pub enum Tokio {}
1717

18-
#[cfg(feature = "wasm-bindgen")]
18+
#[cfg(target_arch = "wasm32")]
1919
/// Represents the WasmBindgen environment for WebAssembly.
2020
pub enum WasmBindgen {}
2121

@@ -37,7 +37,7 @@ impl SwarmBuilder<NoProviderSpecified, ProviderPhase> {
3737

3838
/// Configures the SwarmBuilder for WebAssembly using WasmBindgen.
3939
/// This method is available when the `wasm-bindgen` feature is enabled.
40-
#[cfg(feature = "wasm-bindgen")]
40+
#[cfg(target_arch = "wasm32")]
4141
pub fn with_wasm_bindgen(self) -> SwarmBuilder<WasmBindgen, TcpPhase> {
4242
SwarmBuilder {
4343
keypair: self.keypair,

libp2p/src/builder/phase/swarm.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub struct SwarmPhase<T, B> {
1010
pub(crate) transport: T,
1111
}
1212

13+
#[cfg(any(target_arch = "wasm32", feature = "tokio"))]
1314
macro_rules! impl_with_swarm_config {
14-
($providerKebabCase:literal, $providerPascalCase:ty, $config:expr) => {
15-
#[cfg(feature = $providerKebabCase)]
15+
($providerPascalCase:ty, $config:expr) => {
1616
impl<T, B> SwarmBuilder<$providerPascalCase, SwarmPhase<T, B>> {
1717
pub fn with_swarm_config(
1818
self,
@@ -42,16 +42,14 @@ macro_rules! impl_with_swarm_config {
4242
};
4343
}
4444

45-
#[cfg(not(target_arch = "wasm32"))]
45+
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
4646
impl_with_swarm_config!(
47-
"tokio",
4847
super::provider::Tokio,
4948
libp2p_swarm::Config::with_tokio_executor()
5049
);
5150

5251
#[cfg(target_arch = "wasm32")]
5352
impl_with_swarm_config!(
54-
"wasm-bindgen",
5553
super::provider::WasmBindgen,
5654
libp2p_swarm::Config::with_wasm_executor()
5755
);

protocols/gossipsub/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
- Fix mesh not being constructed even when not adding any peer.
1313
See [PR 6100](https://github.com/libp2p/rust-libp2p/pull/6100)
1414

15+
- Remove `wasm-bindgen` feature and make `wasm` support implicit.
16+
See [PR 6102](https://github.com/libp2p/rust-libp2p/pull/6102)
17+
1518
## 0.49.0
1619

1720
- Feature gate metrics related code. This changes some `Behaviour` constructor methods.

protocols/gossipsub/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
1111
categories = ["network-programming", "asynchronous"]
1212

1313
[features]
14-
wasm-bindgen = ["getrandom/js", "futures-timer/wasm-bindgen"]
1514
metrics = ["prometheus-client"]
1615

1716
[dependencies]
@@ -23,8 +22,7 @@ bytes = "1.6"
2322
either = "1.11"
2423
fnv = "1.0.7"
2524
futures = { workspace = true }
26-
futures-timer = "3.0.2"
27-
getrandom = { workspace = true }
25+
futures-timer = { workspace = true}
2826
hashlink = { workspace = true }
2927
hex_fmt = "0.3.0"
3028
web-time = { workspace = true }
@@ -49,6 +47,10 @@ quickcheck = { workspace = true }
4947
tracing-subscriber = { workspace = true, features = ["env-filter"] }
5048
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "time", "macros"] }
5149

50+
[target.'cfg(target_family="wasm")'.dependencies]
51+
futures-timer = { workspace = true, features = ["wasm-bindgen"] }
52+
getrandom = { workspace = true }
53+
5254
# Passing arguments to the docsrs builder in order to properly document cfg's.
5355
# More information: https://docs.rs/about/builds#cross-compiling
5456
[package.metadata.docs.rs]

0 commit comments

Comments
 (0)