diff --git a/CHANGELOG.md b/CHANGELOG.md index 228c9b5..8822c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ # Changelog +### v0.12.1 + +- Implemented a workaround that mitigates the linker error from Rust compiler (https://github.com/rust-lang/rust/issues/111888). + ## v0.12.0 ### Other Changes: + - Added Server-side Rendering Support. - Fixed a reference cycle between `Style` and `StyleManager`. - Added `StyleManager::new()` to create a style manager with default configuration. @@ -10,6 +15,7 @@ ## v0.11.0 ### Breaking Changes: + - Yew version is bumped to v0.20. - Remove `YieldStyle`. This API can be easily reproduced in user code, if need be, but often leads to clumsy code in struct components. Use alternative API and prefer @@ -24,6 +30,7 @@ runtime. ### Other Changes: + - The `Style::new_*` API is more open for accepted types of the `Css` parameter. - The name of styled components now defaults to the name of the function, like in `function_component`. @@ -31,15 +38,18 @@ ## v0.10.1 ### Other Changes: + - Added an impl of `IntoPropValue` for `Style` and `StyleSource` when the `yew_integration` feature is active. ## v0.10.0 ### Breaking Changes: + - Yew version is bumped to 0.19. ### Other Changes: + - Added an API to style Yew Function Component. - `random` features is now provided with `fastrand`. - Added Yew hooks for Media Query. @@ -48,16 +58,19 @@ ## v0.9.2 ### Other Changes: + - Fixed a misconfiguration causing documentation fails to build on `docs.rs`. ## v0.9.1 ### Other Changes: + - Removed an unused import. ## v0.9 ### Breaking Changes: + - `Style` and `GlobalStyle` no longer implements `FromStr`. - `Style` and `GlobalStyle` now takes any type that implements `Into` as a source for a stylesheet. @@ -67,6 +80,7 @@ `@media`. ### Other Changes: + - Added a Procedural Macro API that parses the Stylesheet at the compile time. - Parser will now check stylesheets more strictly. @@ -82,9 +96,10 @@ ## v0.8 ### Breaking Changes: + - `Style::new()` and `Style::create()` now takes a new trait `IntoSheet` for Stylesheet which is implemented by default for both -`stylist::ast::Sheet` and everything that implements `AsRef`. + `stylist::ast::Sheet` and everything that implements `AsRef`. - Feature `yew` has been renamed back to `yew_integration`. - Selectors list now gets a class name added for each selector. - `Style` is now `!Send` and `!Sync`. @@ -92,6 +107,7 @@ and styled-components. ### Other Changes: + - Added a `GlobalStyle` struct to register global styles. - Added a `` Component for global styling for yew applications. - Supported `@supports` CSS at-rule. @@ -107,6 +123,7 @@ ## v0.7 ### Breaking Changes: + - `Style::new()` now takes an `Into>` instead of `Into` and returns `stylist::Error` instead of `String` when encountering an error. @@ -116,6 +133,7 @@ - `Style` no longer implements `ToString`. ### Other Changes: + - Added a new API `YieldStyle`. - Added theming examples. - Styles are now cached by default. @@ -125,15 +143,16 @@ - Removed Unnecessary Clones. - Optimised for Performance. - ## v0.6 ### Breaking Changes: + - `style.get_class_name()` no longer consumes the style and returns a `&str` instead of an owned string. - Seed Integration is Removed. ### Other Changes: + - Added `Style::new` which does not require a component name. - Aesthetically pleasing Class Name. - Replaced `lazy_static` with `once_cell`. diff --git a/packages/stylist-core/Cargo.toml b/packages/stylist-core/Cargo.toml index 19c801d..d5901ea 100644 --- a/packages/stylist-core/Cargo.toml +++ b/packages/stylist-core/Cargo.toml @@ -37,3 +37,4 @@ wasm-bindgen-test = "0.3.33" [features] parser = ["dep:nom"] +__proc_macro_workaround = [] diff --git a/packages/stylist-core/src/ast/context.rs b/packages/stylist-core/src/ast/context.rs index 53dffe0..ce36c96 100644 --- a/packages/stylist-core/src/ast/context.rs +++ b/packages/stylist-core/src/ast/context.rs @@ -73,9 +73,7 @@ impl<'a> StyleContext<'a> { /// Calculate the layers that current context differs from the parent context fn unique_conditions(&self) -> impl Iterator { - self.conditions() - .into_iter() - .skip(self.common_conditions().count()) + self.conditions().skip(self.common_conditions().count()) } /// Calculate the layers that parent context differs from current context diff --git a/packages/stylist-core/src/error.rs b/packages/stylist-core/src/error.rs index ff64393..dabb9d4 100644 --- a/packages/stylist-core/src/error.rs +++ b/packages/stylist-core/src/error.rs @@ -1,5 +1,23 @@ use thiserror::Error; +// This is a mitigation to a compiler bug: https://github.com/rust-lang/rust/issues/111888 +// +// Feature `__proc_macro_workaround` is enabled for the workspace as `stylist-macros` enables it. +// This is the workspace feature merging behaviour even if resolver 2 is enabled. +// Enabling this feature for workspace will render browser tests uncompilable. +// +// To mitigate this side effect, we do not enable this feature on stylist-macros for wasm32 targets +// to make sure tests can run with default feature merging behaviour. +// +// For crates outside of this workspace, `__proc_macro_workaround` will not be enabled +// when they use version = "2021" or resolver = "2" as procedural macros can have different feature +// flags. This should be OK for all downstream crates as stylist requires Rust 1.60 which supports +// both. +#[cfg(not(feature = "__proc_macro_workaround"))] +type JsValue = wasm_bindgen::JsValue; +#[cfg(feature = "__proc_macro_workaround")] +type JsValue = (); + #[derive(Debug, Error, PartialEq)] pub enum Error { /// Failed to parse CSS. @@ -16,7 +34,7 @@ pub enum Error { /// /// This is usually raised when the style element failed to mount. #[error("Failed to Interact with Web API. Are you running in Browser?")] - Web(Option), + Web(Option), /// Failed to read styles from the StyleManager. /// diff --git a/packages/stylist-macros/Cargo.toml b/packages/stylist-macros/Cargo.toml index db6e308..259b96a 100644 --- a/packages/stylist-macros/Cargo.toml +++ b/packages/stylist-macros/Cargo.toml @@ -25,8 +25,6 @@ rust-version = "1.60" proc-macro = true [dependencies] -stylist-core = { path = "../stylist-core", version = "0.12", features = ["parser"] } - litrs = "0.4.0" proc-macro-error = "1.0.4" proc-macro2 = "1.0.47" @@ -36,5 +34,11 @@ syn = { version = "1.0.105", features = ["full", "extra-traits"] } itertools = "0.10.5" log = "0.4.17" +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +stylist-core = { path = "../stylist-core", version = "0.12", features = ["parser", "__proc_macro_workaround"] } + +[target.'cfg(target_arch = "wasm32")'.dependencies] +stylist-core = { path = "../stylist-core", version = "0.12", features = ["parser"] } + [dev-dependencies] env_logger = "0.10.0"