Skip to content

Commit 24f8a46

Browse files
committed
fix: 移除css变量逻辑,迁移到postcss处理
1 parent 615c8c0 commit 24f8a46

22 files changed

+191
-734
lines changed

__test__/index.spec.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ test('Harmony attrbute test font-weight', t => {
613613
font-weight: bold;
614614
}
615615
.border {
616-
font-weight: bolrder;
616+
font-weight: bolder;
617617
}
618618
.lighter {
619619
font-weight: lighter;

__test__/index.spec.mjs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ Generated by [AVA](https://avajs.dev).
10841084
fontWeight: FontWeight.Bold␊
10851085
},␊
10861086
"border": {␊
1087-
fontWeight: "bolrder"
1087+
fontWeight: FontWeight.Bolder
10881088
},␊
10891089
"lighter": {␊
10901090
fontWeight: FontWeight.Lighter␊

__test__/index.spec.mjs.snap

-5 Bytes
Binary file not shown.

__test__/variables.spec.mjs

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

__test__/variables.spec.mjs.md

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

__test__/variables.spec.mjs.snap

-555 Bytes
Binary file not shown.

index.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ export interface ParseOptions {
99
}
1010
export interface ParseResult {
1111
code: string
12-
cssVariables?: string
1312
}
1413
export function parse(component: string, styles: Array<string>, options: ParseOptions): ParseResult
15-
export function combineCssVariables(variables: Array<string>): string | null

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ if (!nativeBinding) {
252252
throw new Error(`Failed to load native binding`)
253253
}
254254

255-
const { parse, combineCssVariables } = nativeBinding
255+
const { parse } = nativeBinding
256256

257257
module.exports.parse = parse
258-
module.exports.combineCssVariables = combineCssVariables

src/constants.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ pub const COMBINE_NESTING_STYLE: &'static str = "__combine_nesting_style__";
88
pub const NESTINT_STYLE_DATA: &'static str = "__nesting_style_data__";
99
// pub const CALC_DYMAMIC_STYLE: &'static str = "calcDynamicStyle";
1010
pub const CALC_STATIC_STYLE: &'static str = "calcStaticStyle";
11-
pub const CSS_VARIABLE_MAP: &'static str = "__css_var_map__";
1211
pub const CSS_VAR_FN: &'static str = "__var_fn";
13-
pub const LAZY_CSS_VAR_FN: &'static str = "__lazy_var_fn";
1412

1513

1614

src/lib.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ mod constants;
2424
mod style_propetries;
2525
mod style_parser;
2626
mod parse_style_properties;
27-
mod parse_css_variables;
2827

2928
// component: jsx的code string
3029
// styles: css的code string
@@ -39,8 +38,7 @@ pub struct ParseOptions {
3938

4039
#[napi(object)]
4140
pub struct ParseResult {
42-
pub code: String,
43-
pub css_variables: Option<String>,
41+
pub code: String
4442
}
4543

4644
#[napi]
@@ -72,12 +70,6 @@ pub fn parse(component: String, styles: Vec<String>, options: ParseOptions) -> P
7270
is_enable_nesting = style_data.has_nesting;
7371
}
7472

75-
// 解析CSS变量
76-
let variable_code = parse_css_variables::write(
77-
parse_css_variables::parse(style_data.css_variables.borrow().clone())
78-
);
79-
80-
8173
let program = Rc::new(RefCell::new(document.program.as_ref().unwrap().clone()));
8274
let jsx_record = Rc::new(RefCell::new(document.jsx_record.as_ref().unwrap().clone()));
8375
let mut style_write = StyleWrite::new(
@@ -104,12 +96,6 @@ pub fn parse(component: String, styles: Vec<String>, options: ParseOptions) -> P
10496
let code = String::from_utf8(buf).unwrap().replace("\r\n", "\n");
10597

10698
ParseResult {
107-
code,
108-
css_variables: variable_code,
99+
code
109100
}
110-
}
111-
112-
#[napi]
113-
pub fn combine_css_variables(variables: Vec<String>) -> Option<String> {
114-
parse_css_variables::combine_css_variables(variables)
115101
}

0 commit comments

Comments
 (0)