diff --git a/index.js b/index.js index ca04d78..968fa42 100644 --- a/index.js +++ b/index.js @@ -224,14 +224,72 @@ switch (platform) { } break case 'arm': + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'parse-css-to-stylesheet.linux-arm-musleabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./parse-css-to-stylesheet.linux-arm-musleabihf.node') + } else { + nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-musleabihf') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'parse-css-to-stylesheet.linux-arm-gnueabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./parse-css-to-stylesheet.linux-arm-gnueabihf.node') + } else { + nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf') + } + } catch (e) { + loadError = e + } + } + break + case 'riscv64': + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'parse-css-to-stylesheet.linux-riscv64-musl.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./parse-css-to-stylesheet.linux-riscv64-musl.node') + } else { + nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-riscv64-musl') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'parse-css-to-stylesheet.linux-riscv64-gnu.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./parse-css-to-stylesheet.linux-riscv64-gnu.node') + } else { + nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-riscv64-gnu') + } + } catch (e) { + loadError = e + } + } + break + case 's390x': localFileExisted = existsSync( - join(__dirname, 'parse-css-to-stylesheet.linux-arm-gnueabihf.node') + join(__dirname, 'parse-css-to-stylesheet.linux-s390x-gnu.node') ) try { if (localFileExisted) { - nativeBinding = require('./parse-css-to-stylesheet.linux-arm-gnueabihf.node') + nativeBinding = require('./parse-css-to-stylesheet.linux-s390x-gnu.node') } else { - nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf') + nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-s390x-gnu') } } catch (e) { loadError = e diff --git a/src/visitor.rs b/src/visitor.rs index 72968db..7b8a7bc 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -1295,6 +1295,13 @@ impl VisitMut for ObjectFinder { ], })), })) + )); + props.insert( + 0, + PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { + key: PropName::Ident(Ident::new("__hmStyle".into(), DUMMY_SP)), + value: Box::new(ObjectFinder::get_fun_call_expr(class_attr_value.clone())), + })) )) } } @@ -1457,6 +1464,14 @@ impl<'i> VisitMut for JSXMutVisitor<'i> { }))), })), })); + n.opening.attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr { + span: DUMMY_SP, + name: JSXAttrName::Ident(Ident::new("__hmStyle".into(), DUMMY_SP)), + value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer { + span: DUMMY_SP, + expr: JSXExpr::Expr(Box::new(get_fun_call_expr(class_attr_value.clone()))), + })), + })); }, None => {}, }