Skip to content

Commit 66a9e1e

Browse files
authored
Merge pull request #259 from dev-five-git/filter-minus
Filter minus
2 parents ceab704 + 88f699a commit 66a9e1e

File tree

10 files changed

+87
-64
lines changed

10 files changed

+87
-64
lines changed

.changeset/all-glasses-open.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/webpack-plugin": patch
3+
---
4+
5+
Fix creating ignore logic

.changeset/curvy-walls-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/wasm": patch
3+
---
4+
5+
Optimize zero minus

Cargo.lock

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

bindings/devup-ui-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ css = { path = "../../libs/css" }
2727
console_error_panic_hook = { version = "0.1.7", optional = true }
2828
once_cell = "1.21.3"
2929
js-sys = "0.3.77"
30-
serde_json = "1.0.140"
30+
serde_json = "1.0.141"
3131
serde-wasm-bindgen = "0.6.5"
3232

3333
[dev-dependencies]

libs/css/src/constant.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,11 @@ pub(super) static DOT_ZERO_RE: Lazy<Regex> =
9595
pub(super) static COLOR_HASH: Lazy<Regex> = Lazy::new(|| Regex::new(r"#([0-9a-zA-Z]+)").unwrap());
9696
pub(super) static INNER_TRIM_RE: Lazy<Regex> =
9797
Lazy::new(|| Regex::new(r"\(\s*([^)]*?)\s*\)").unwrap());
98+
99+
pub(super) static RM_MINUS_ZERO_RE: Lazy<Regex> =
100+
Lazy::new(|| Regex::new(r"-0(px|em|rem|vh|vw|%|dvh|dvw|\)|,)").unwrap());
101+
102+
pub(super) static NUM_TRIM_RE: Lazy<Regex> =
103+
Lazy::new(|| Regex::new(r"(\d(px|em|rem|vh|vw|%|dvh|dvw)?)\s+(\d)").unwrap());
98104
pub(super) static ZERO_RE: Lazy<Regex> =
99-
Lazy::new(|| Regex::new(r"(^|\s|\(|,)-?0(px|em|rem|vh|vw|%|dvh|dvw)").unwrap());
105+
Lazy::new(|| Regex::new(r"(\b|,|\(|^|\s)-?0(px|em|rem|vh|vw|%|dvh|dvw)").unwrap());

libs/css/src/optimize_value.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
use crate::{
22
COLOR_HASH, F_SPACE_RE, ZERO_RE,
3-
constant::{DOT_ZERO_RE, F_DOT_RE, INNER_TRIM_RE, ZERO_PERCENT_FUNCTION},
3+
constant::{
4+
DOT_ZERO_RE, F_DOT_RE, INNER_TRIM_RE, NUM_TRIM_RE, RM_MINUS_ZERO_RE, ZERO_PERCENT_FUNCTION,
5+
},
46
};
57

68
pub fn optimize_value(value: &str) -> String {
79
let mut ret = value.trim().to_string();
810
ret = INNER_TRIM_RE.replace_all(&ret, "(${1})").to_string();
11+
ret = RM_MINUS_ZERO_RE.replace_all(&ret, "0${1}").to_string();
12+
ret = NUM_TRIM_RE.replace_all(&ret, "${1} ${3}").to_string();
13+
914
if ret.contains(",") {
1015
ret = F_SPACE_RE.replace_all(&ret, ",").trim().to_string();
1116
}
@@ -128,6 +133,8 @@ mod tests {
128133
#[case("0dvh", "0")]
129134
#[case("0dvw", "0")]
130135
#[case("0px 0px", "0 0")]
136+
#[case("-0px -0px", "0 0")]
137+
#[case("0.0px -0px", "0 0")]
131138
#[case("0em 0em", "0 0")]
132139
#[case("0rem 0rem", "0 0")]
133140
#[case("0vh 0vh", "0 0")]
@@ -158,6 +165,7 @@ mod tests {
158165
#[case("min(10px, 0)", "min(10px,0%)")]
159166
#[case("max(10px, 0)", "max(10px,0%)")]
160167
#[case("max(some(0), 0)", "max(some(0),0%)")]
168+
#[case("max(some(0), -0)", "max(some(0),0%)")]
161169
#[case("translate(0, min(0, 10px))", "translate(0,min(0%,10px))")]
162170
#[case("\"red\"", "\"red\"")]
163171
#[case("'red'", "'red'")]

libs/extractor/Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7-
oxc_parser = "0.77.1"
8-
oxc_syntax = "0.77.1"
9-
oxc_span = "0.77.1"
10-
oxc_allocator = "0.77.1"
11-
oxc_ast = "0.77.1"
12-
oxc_ast_visit = "0.77.1"
13-
oxc_codegen = "0.77.1"
7+
oxc_parser = "0.77.3"
8+
oxc_syntax = "0.77.3"
9+
oxc_span = "0.77.3"
10+
oxc_allocator = "0.77.3"
11+
oxc_ast = "0.77.3"
12+
oxc_ast_visit = "0.77.3"
13+
oxc_codegen = "0.77.3"
1414
css = { path = "../css" }
1515
phf = "0.12"
16-
strum = "0.27.1"
17-
strum_macros = "0.27.1"
16+
strum = "0.27.2"
17+
strum_macros = "0.27.2"
1818

1919
[dev-dependencies]
2020
insta = "1.43.1"

libs/sheet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extractor = { path = "../extractor" }
1212

1313
[dev-dependencies]
1414
insta = "1.43.1"
15-
serde_json = "1.0.140"
15+
serde_json = "1.0.141"
1616
criterion = { version = "0.6", features = ["html_reports"] }
1717

1818
[[bench]]

packages/webpack-plugin/src/__tests__/plugin.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ describe('devupUIPlugin', () => {
141141
vi.mocked(compiler.hooks.done.tap).mock.calls[0][1]({
142142
hasErrors: () => true,
143143
})
144-
expect(writeFileSync).not.toHaveBeenCalled()
145144

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

0 commit comments

Comments
 (0)