Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/all-glasses-open.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/webpack-plugin": patch
---

Fix creating ignore logic
5 changes: 5 additions & 0 deletions .changeset/curvy-walls-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devup-ui/wasm": patch
---

Optimize zero minus
93 changes: 46 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/devup-ui-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ css = { path = "../../libs/css" }
console_error_panic_hook = { version = "0.1.7", optional = true }
once_cell = "1.21.3"
js-sys = "0.3.77"
serde_json = "1.0.140"
serde_json = "1.0.141"
serde-wasm-bindgen = "0.6.5"

[dev-dependencies]
Expand Down
8 changes: 7 additions & 1 deletion libs/css/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,11 @@ pub(super) static DOT_ZERO_RE: Lazy<Regex> =
pub(super) static COLOR_HASH: Lazy<Regex> = Lazy::new(|| Regex::new(r"#([0-9a-zA-Z]+)").unwrap());
pub(super) static INNER_TRIM_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"\(\s*([^)]*?)\s*\)").unwrap());

pub(super) static RM_MINUS_ZERO_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"-0(px|em|rem|vh|vw|%|dvh|dvw|\)|,)").unwrap());

pub(super) static NUM_TRIM_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(\d(px|em|rem|vh|vw|%|dvh|dvw)?)\s+(\d)").unwrap());
pub(super) static ZERO_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(^|\s|\(|,)-?0(px|em|rem|vh|vw|%|dvh|dvw)").unwrap());
Lazy::new(|| Regex::new(r"(\b|,|\(|^|\s)-?0(px|em|rem|vh|vw|%|dvh|dvw)").unwrap());
10 changes: 9 additions & 1 deletion libs/css/src/optimize_value.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use crate::{
COLOR_HASH, F_SPACE_RE, ZERO_RE,
constant::{DOT_ZERO_RE, F_DOT_RE, INNER_TRIM_RE, ZERO_PERCENT_FUNCTION},
constant::{
DOT_ZERO_RE, F_DOT_RE, INNER_TRIM_RE, NUM_TRIM_RE, RM_MINUS_ZERO_RE, ZERO_PERCENT_FUNCTION,
},
};

pub fn optimize_value(value: &str) -> String {
let mut ret = value.trim().to_string();
ret = INNER_TRIM_RE.replace_all(&ret, "(${1})").to_string();
ret = RM_MINUS_ZERO_RE.replace_all(&ret, "0${1}").to_string();
ret = NUM_TRIM_RE.replace_all(&ret, "${1} ${3}").to_string();

if ret.contains(",") {
ret = F_SPACE_RE.replace_all(&ret, ",").trim().to_string();
}
Expand Down Expand Up @@ -128,6 +133,8 @@ mod tests {
#[case("0dvh", "0")]
#[case("0dvw", "0")]
#[case("0px 0px", "0 0")]
#[case("-0px -0px", "0 0")]
#[case("0.0px -0px", "0 0")]
#[case("0em 0em", "0 0")]
#[case("0rem 0rem", "0 0")]
#[case("0vh 0vh", "0 0")]
Expand Down Expand Up @@ -158,6 +165,7 @@ mod tests {
#[case("min(10px, 0)", "min(10px,0%)")]
#[case("max(10px, 0)", "max(10px,0%)")]
#[case("max(some(0), 0)", "max(some(0),0%)")]
#[case("max(some(0), -0)", "max(some(0),0%)")]
#[case("translate(0, min(0, 10px))", "translate(0,min(0%,10px))")]
#[case("\"red\"", "\"red\"")]
#[case("'red'", "'red'")]
Expand Down
18 changes: 9 additions & 9 deletions libs/extractor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ version = "0.1.0"
edition = "2024"

[dependencies]
oxc_parser = "0.77.1"
oxc_syntax = "0.77.1"
oxc_span = "0.77.1"
oxc_allocator = "0.77.1"
oxc_ast = "0.77.1"
oxc_ast_visit = "0.77.1"
oxc_codegen = "0.77.1"
oxc_parser = "0.77.3"
oxc_syntax = "0.77.3"
oxc_span = "0.77.3"
oxc_allocator = "0.77.3"
oxc_ast = "0.77.3"
oxc_ast_visit = "0.77.3"
oxc_codegen = "0.77.3"
css = { path = "../css" }
phf = "0.12"
strum = "0.27.1"
strum_macros = "0.27.1"
strum = "0.27.2"
strum_macros = "0.27.2"

[dev-dependencies]
insta = "1.43.1"
Expand Down
2 changes: 1 addition & 1 deletion libs/sheet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extractor = { path = "../extractor" }

[dev-dependencies]
insta = "1.43.1"
serde_json = "1.0.140"
serde_json = "1.0.141"
criterion = { version = "0.6", features = ["html_reports"] }

[[bench]]
Expand Down
1 change: 0 additions & 1 deletion packages/webpack-plugin/src/__tests__/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ describe('devupUIPlugin', () => {
vi.mocked(compiler.hooks.done.tap).mock.calls[0][1]({
hasErrors: () => true,
})
expect(writeFileSync).not.toHaveBeenCalled()

vi.mocked(compiler.hooks.done.tap).mock.calls[0][1]({
hasErrors: () => false,
Expand Down
Loading