Skip to content

Commit 2116e88

Browse files
committed
Update wasm
1 parent f3deb96 commit 2116e88

File tree

92 files changed

+843
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+843
-495
lines changed

.changeset/dull-paws-worry.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+
Fix global css rerender issue without components

.changeset/open-results-taste.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+
Support css comment syntax

.changeset/plain-corners-lose.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 css selector

.changeset/red-webs-draw.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 creating css

apps/next/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"type": "module",
55
"private": true,
66
"scripts": {
7-
"dev": "next dev",
8-
"build": "next build",
7+
"dev": "next dev --turbopack",
8+
"build": "next build --turbopack",
99
"start": "next start",
1010
"lint": "next lint"
1111
},

bindings/devup-ui-wasm/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct Output {
1717
code: String,
1818
styles: HashSet<ExtractStyleValue>,
1919
map: Option<String>,
20+
default_collected: bool,
2021
}
2122
#[wasm_bindgen]
2223
extern "C" {
@@ -130,7 +131,7 @@ impl Output {
130131
}
131132
}
132133

133-
if !collected {
134+
if !collected && !self.default_collected {
134135
return None;
135136
}
136137

@@ -183,7 +184,6 @@ pub fn code_extract(
183184
css_file: &str,
184185
) -> Result<Output, JsValue> {
185186
let mut sheet = GLOBAL_STYLE_SHEET.lock().unwrap();
186-
sheet.rm_global_css(filename);
187187

188188
match extract(
189189
filename,
@@ -197,6 +197,7 @@ pub fn code_extract(
197197
code: output.code,
198198
styles: output.styles,
199199
map: output.map,
200+
default_collected: sheet.rm_global_css(filename),
200201
}),
201202
Err(error) => Err(JsValue::from_str(error.to_string().as_str())),
202203
}

libs/css/src/constant.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ pub(super) static ZERO_PERCENT_FUNCTION: phf::Set<&str> = phf_set! {
119119
};
120120

121121
pub(super) static F_SPACE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"\s*,\s*").unwrap());
122+
123+
pub(super) static CSS_COMMENT_RE: Lazy<Regex> =
124+
Lazy::new(|| Regex::new(r"/\*[\s\S]*?\*/").unwrap());
125+
122126
pub(super) static F_DOT_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\b|,)0\.(\d+)").unwrap());
123127
pub(super) static DOT_ZERO_RE: Lazy<Regex> =
124128
Lazy::new(|| Regex::new(r"(\b|,)-?0\.0+([^\d])").unwrap());

libs/css/src/lib.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod constant;
33
pub mod debug;
44
pub mod is_special_property;
55
pub mod optimize_value;
6-
pub mod property_type;
6+
pub mod rm_css_comment;
77
mod selector_separator;
88
pub mod style_selector;
99
pub mod utils;
@@ -15,7 +15,7 @@ use crate::constant::{COLOR_HASH, F_SPACE_RE, GLOBAL_STYLE_PROPERTY, ZERO_RE};
1515
use crate::debug::is_debug;
1616
use crate::optimize_value::optimize_value;
1717
use crate::style_selector::StyleSelector;
18-
use crate::utils::{to_camel_case, to_kebab_case};
18+
use crate::utils::to_kebab_case;
1919

2020
pub fn merge_selector(class_name: &str, selector: Option<&StyleSelector>) -> String {
2121
if let Some(selector) = selector {
@@ -39,10 +39,25 @@ pub fn disassemble_property(property: &str) -> Vec<String> {
3939
GLOBAL_STYLE_PROPERTY
4040
.get(property)
4141
.map(|v| match v.len() {
42-
1 => vec![to_camel_case(v[0])],
43-
_ => v.iter().map(|v| to_camel_case(v)).collect(),
42+
1 => vec![v[0].to_string()],
43+
_ => v.iter().map(|v| v.to_string()).collect(),
44+
})
45+
.unwrap_or_else(|| {
46+
vec![if (property.starts_with("Webkit")
47+
&& property.len() > 6
48+
&& property.chars().nth(6).unwrap().is_uppercase())
49+
|| (property.starts_with("Moz")
50+
&& property.len() > 3
51+
&& property.chars().nth(3).unwrap().is_uppercase())
52+
|| (property.starts_with("ms")
53+
&& property.len() > 2
54+
&& property.chars().nth(2).unwrap().is_uppercase())
55+
{
56+
format!("-{}", to_kebab_case(property))
57+
} else {
58+
to_kebab_case(property)
59+
}]
4460
})
45-
.unwrap_or_else(|| vec![property.to_string()])
4661
}
4762

4863
pub fn keyframes_to_keyframes_name(keyframes: &str) -> String {

libs/css/src/property_type.rs

Lines changed: 0 additions & 253 deletions
This file was deleted.

0 commit comments

Comments
 (0)