@@ -25,15 +25,24 @@ mod parse_style_properties;
2525// component: jsx的code string
2626// styles: css的code string
2727// platform_string: "ReactNative" | "Harmony"
28+
29+ #[ napi( object) ]
30+ pub struct ParseOptions {
31+ pub platform_string : String ,
32+ pub is_enable_nesting : Option < bool > ,
33+ }
34+
2835#[ napi]
29- pub fn parse ( component : String , styles : Vec < String > , platform_string : String ) -> String {
36+ pub fn parse ( component : String , styles : Vec < String > , options : ParseOptions ) -> String {
3037
31- let platform = match platform_string. as_str ( ) {
38+ let platform = match options . platform_string . as_str ( ) {
3239 "ReactNative" => Platform :: ReactNative ,
3340 "Harmony" => Platform :: Harmony ,
3441 _ => Platform :: Harmony
3542 } ;
3643
44+ let is_enable_nesting = options. is_enable_nesting . map_or ( false , |item| item) ;
45+
3746 // 解析组件文件
3847 let cm: Lrc < SourceMap > = Default :: default ( ) ;
3948 let comments = SingleThreadedComments :: default ( ) ;
@@ -54,6 +63,7 @@ pub fn parse(component: String, styles: Vec<String>, platform_string: String) ->
5463 style_data. style_record . clone ( ) ,
5564 style_data. pesudo_style_record . clone ( ) ,
5665 style_data. all_style . clone ( ) ,
66+ is_enable_nesting,
5767 ) ;
5868 style_write. write ( platform) ;
5969
@@ -72,4 +82,3 @@ pub fn parse(component: String, styles: Vec<String>, platform_string: String) ->
7282 let code = String :: from_utf8 ( buf) . unwrap ( ) . replace ( "\r \n " , "\n " ) ;
7383 code
7484}
75-
0 commit comments