Skip to content

Commit 8ffe240

Browse files
committed
Fix conditional compilation
1 parent 93989ea commit 8ffe240

File tree

15 files changed

+52
-48
lines changed

15 files changed

+52
-48
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [unreleased]
4+
5+
- Fix: `serde-wasm-bindgen` feature.
6+
37
## v0.9.0
48

59
- [BREAKING] Base path changed from `Rc<Vec<String>>` to `Rc<[String]>`.

src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::module_name_repetitions)]
22

33
use crate::browser::dom::virtual_dom_bridge;
4-
#[cfg(any(feature = "serde-json", feature = "swb"))]
4+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
55
use crate::browser::service::routing;
66
use crate::browser::{
77
util::{self, window, ClosureNew},
@@ -31,7 +31,7 @@ pub mod render_info;
3131
pub mod stream_manager;
3232
pub mod streams;
3333
pub mod sub_manager;
34-
#[cfg(any(feature = "serde-json", feature = "swb"))]
34+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
3535
pub mod subs;
3636

3737
pub use cfg::AppCfg;
@@ -200,14 +200,14 @@ where
200200
&mut orders,
201201
);
202202
app.data.model.replace(Some(new_model));
203-
#[cfg(any(feature = "serde-json", feature = "swb"))]
203+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
204204
app.setup_routing(&mut orders);
205205
app.process_effect_queue(orders.effects);
206206
app.rerender_vdom();
207207
app
208208
}
209209

210-
#[cfg(any(feature = "serde-json", feature = "swb"))]
210+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
211211
fn setup_routing(&self, orders: &mut impl Orders<Ms>) {
212212
use enclose::enc;
213213
routing::setup_popstate_listener(

src/app/orders.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#[cfg(any(feature = "serde-json", feature = "swb"))]
1+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
22
use super::subs;
33
use super::{App, CmdHandle, RenderInfo, StreamHandle, SubHandle};
4-
#[cfg(any(feature = "serde-json", feature = "swb"))]
4+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
55
use crate::browser::Url;
66
use crate::virtual_dom::IntoNodes;
77
use futures::stream::Stream;
@@ -321,7 +321,7 @@ pub trait Orders<Ms: 'static> {
321321
/// Simulate `<a href="[url]">` element click.
322322
///
323323
/// A thin wrapper for `orders.notify(subs::UrlRequested::new(url))`
324-
#[cfg(any(feature = "serde-json", feature = "swb"))]
324+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
325325
fn request_url(&mut self, url: Url) -> &mut Self {
326326
self.notify(subs::UrlRequested::new(url))
327327
}

src/browser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub mod dom;
22
pub mod fetch;
3-
#[cfg(any(feature = "serde-json", feature = "swb"))]
3+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
44
mod json;
55
pub mod service;
66
pub mod url;

src/browser/fetch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//! [status]: ./struct.Status.html
2929
//! [fetch-mdn]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
3030
31-
#[cfg(any(feature = "serde-json", feature = "swb"))]
31+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
3232
use crate::browser::json;
3333
use crate::util::window;
3434
use std::convert::TryInto;
@@ -90,7 +90,7 @@ pub async fn fetch<'a>(request: impl Into<Request<'a>>) -> Result<Response> {
9090
#[allow(clippy::module_name_repetitions)]
9191
#[derive(Debug)]
9292
pub enum FetchError {
93-
#[cfg(any(feature = "serde-json", feature = "swb"))]
93+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
9494
JsonError(json::Error),
9595
DomException(web_sys::DomException),
9696
PromiseError(wasm_bindgen::JsValue),
@@ -100,7 +100,7 @@ pub enum FetchError {
100100
StatusError(Status),
101101
}
102102

103-
#[cfg(any(feature = "serde-json", feature = "swb"))]
103+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
104104
impl From<json::Error> for FetchError {
105105
fn from(v: json::Error) -> Self {
106106
Self::JsonError(v)

src/browser/fetch/form_data.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
//! See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/FormData) for
2020
//! details on the behavior of the underlying API.
2121
22-
#[cfg(any(feature = "serde-json", feature = "swb"))]
22+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
2323
use crate::{browser::json, fetch::Result};
24-
#[cfg(any(feature = "serde-json", feature = "swb"))]
24+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
2525
use serde::Serialize;
2626
use wasm_bindgen::JsValue;
2727

@@ -62,7 +62,7 @@ impl FormData {
6262
/// ## Errors
6363
/// Will return `Err` if serialization fails.
6464
#[allow(clippy::missing_panics_doc)]
65-
#[cfg(any(feature = "serde-json", feature = "swb"))]
65+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
6666
pub fn append_json<T>(&mut self, name: &str, data: &T) -> Result<()>
6767
where
6868
T: Serialize + ?Sized,
@@ -76,7 +76,7 @@ impl FormData {
7676
///
7777
/// ## Errors
7878
/// Will return `Err` if serialization fails.
79-
#[cfg(any(feature = "serde-json", feature = "swb"))]
79+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
8080
pub fn with_json<T>(mut self, name: &str, data: &T) -> Result<Self>
8181
where
8282
T: Serialize + ?Sized,

src/browser/fetch/request.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
33
use super::form_data::FormData;
44
use super::{fetch, FetchError, Header, Headers, Method, Response, Result};
5-
#[cfg(any(feature = "serde-json", feature = "swb"))]
5+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
66
use crate::browser::json;
77
use crate::browser::Url;
88
use gloo_timers::callback::Timeout;
99
use js_sys::Uint8Array;
10-
#[cfg(any(feature = "serde-json", feature = "swb"))]
10+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
1111
use serde::Serialize;
1212
use std::{borrow::Cow, cell::RefCell, rc::Rc};
1313
use wasm_bindgen::JsValue;
@@ -117,7 +117,7 @@ impl<'a> Request<'a> {
117117
///
118118
/// This method can fail if JSON serialization fail. It will then
119119
/// return `FetchError::SerdeError`.
120-
#[cfg(any(feature = "serde-json", feature = "swb"))]
120+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
121121
pub fn json<T: Serialize + ?Sized>(mut self, data: &T) -> Result<Self> {
122122
let body = json::to_js_string(data)?;
123123
self.body = Some(Cow::Owned(body.into()));

src/browser/fetch/response.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! The Response interface of the Fetch API represents the response to a request.
22
33
use super::{FetchError, Headers, Result, Status};
4-
#[cfg(any(feature = "serde-json", feature = "swb"))]
4+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
55
use crate::browser::json;
6-
#[cfg(any(feature = "serde-json", feature = "swb"))]
6+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
77
use serde::de::DeserializeOwned;
8-
#[cfg(any(feature = "serde-json", feature = "swb"))]
8+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
99
use wasm_bindgen::JsValue;
1010
use wasm_bindgen_futures::JsFuture;
1111

@@ -39,7 +39,7 @@ impl Response {
3939
///
4040
/// # Errors
4141
/// Returns `FetchError::SerdeError` or `FetchError::PromiseError`.
42-
#[cfg(any(feature = "serde-json", feature = "swb"))]
42+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
4343
pub async fn json<T: DeserializeOwned + 'static>(&self) -> Result<T> {
4444
let js: JsValue = self
4545
.raw_response

src/browser/json.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub enum Error {
1010

1111
type Result<T> = std::result::Result<T, Error>;
1212

13-
#[cfg(feature = "swb")]
13+
#[cfg(feature = "serde-wasm-bindgen")]
1414
mod swb;
15-
#[cfg(feature = "swb")]
15+
#[cfg(feature = "serde-wasm-bindgen")]
1616
pub use swb::*;
1717

18-
#[cfg(all(not(feature = "swb"), feature = "serde-json"))]
18+
#[cfg(all(not(feature = "serde-wasm-bindgen"), feature = "serde-json"))]
1919
mod serde_json;
20-
#[cfg(all(not(feature = "swb"), feature = "serde-json"))]
20+
#[cfg(all(not(feature = "serde-wasm-bindgen"), feature = "serde-json"))]
2121
pub use self::serde_json::*;

src/browser/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#[cfg(any(feature = "serde-json", feature = "swb"))]
1+
#[cfg(any(feature = "serde-json", feature = "serde-wasm-bindgen"))]
22
pub(crate) mod routing;

0 commit comments

Comments
 (0)