Skip to content

Commit ee59733

Browse files
committed
0.0.1
1 parent 19a6f31 commit ee59733

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[target.aarch64-unknown-linux-musl]
2+
linker = "aarch64-linux-musl-gcc"
3+
rustflags = ["-C", "target-feature=-crt-static"]

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CI
22
env:
33
DEBUG: napi:*
4-
APP_NAME: napi-project
4+
APP_NAME: parse-css-to-stylesheet
55
MACOSX_DEPLOYMENT_TARGET: '10.13'
66
permissions:
77
contents: write
@@ -10,6 +10,7 @@ permissions:
1010
push:
1111
branches:
1212
- main
13+
- master
1314
tags-ignore:
1415
- '**'
1516
paths-ignore:

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## 0.0.1 (2023-10-10)
2+
3+
4+
### Features
5+
6+
* 处理不可继承的样式的情况,同时支持样式值为 inherit 的情况 ([13ae716](https://github.com/NervJS/parse-css-to-stylesheet/commit/13ae7167d4cbeb6fc880d764301320909530f236))
7+
* 根据选择器特异性排序计算出每个节点的最终样式 ([070ce57](https://github.com/NervJS/parse-css-to-stylesheet/commit/070ce57bf24a197e614a2885913818e46ec4be50))
8+
* 基于 napi-rs 改造 ([19a6f31](https://github.com/NervJS/parse-css-to-stylesheet/commit/19a6f3168a5e9719962ab389266af27cb2192aca))
9+
* 计算出每一个节点的所有样式规则 ([0082034](https://github.com/NervJS/parse-css-to-stylesheet/commit/008203446135c8c6dbc7795bce957a8826d0bb47))
10+
* 将 ast 中的 jsx tree 转为 ego tree ([34a1be5](https://github.com/NervJS/parse-css-to-stylesheet/commit/34a1be58c9466c6f6b1a141efbd225268d10ce89))
11+
* 解析 JSX 构建 ego tree ([949a1ec](https://github.com/NervJS/parse-css-to-stylesheet/commit/949a1ecf1fc9f660e998db8e68be374786e1717a))
12+
* 实现根据选择器查找 rust 文本节点,同时梳理代码 ([e850496](https://github.com/NervJS/parse-css-to-stylesheet/commit/e8504965842280b86a9f23d3b0c6040bf6123343))
13+
* 实现样式继承 ([d508d15](https://github.com/NervJS/parse-css-to-stylesheet/commit/d508d1569878ec41abb1ca2d1567c39a8108258b))
14+
* 增加 ElementRef ([710d95c](https://github.com/NervJS/parse-css-to-stylesheet/commit/710d95c199e15641bf05e04bea0b6ca5965f4bca))
15+
* 增加 style parser ([a4e3f11](https://github.com/NervJS/parse-css-to-stylesheet/commit/a4e3f11eb9bc3e909c616cee03865304e304c9f1))
16+
* 增加对 JSX 子树的支持 ([c73bbe5](https://github.com/NervJS/parse-css-to-stylesheet/commit/c73bbe5e4f9234fed2b582de1f1883dc84cd0d3d))
17+
* 增加记录每段样式的特异性 ([7c6b9c3](https://github.com/NervJS/parse-css-to-stylesheet/commit/7c6b9c3c49109fc1dbcf6a63ce54839bec748c73))
18+
* 支持 JSX 节点没有 style 属性情况下,将节点对应的样式写入到 style 属性中 ([d9eb803](https://github.com/NervJS/parse-css-to-stylesheet/commit/d9eb803259e895c8332e379aae0209e184f37a19))
19+
* 支持 React.Fragment 用法 ([ac404c8](https://github.com/NervJS/parse-css-to-stylesheet/commit/ac404c8d69f9a0ca252fb9c12b5b0d3ba6e410a9))
20+
* 支持函数调用方式的子 JSX 拆分写法 ([73a5bcb](https://github.com/NervJS/parse-css-to-stylesheet/commit/73a5bcbf34bea9e3301ab0f3d88fa9f1de561ad2))
21+
* 支持将样式节点记录写入 ast 中 ([c35cbdf](https://github.com/NervJS/parse-css-to-stylesheet/commit/c35cbdf15e02a773cc912b1eedeaf29922225ac4))
22+
* 支持将样式文件中样式与 JSX 节点的 style 属性值合并 ([1beb45a](https://github.com/NervJS/parse-css-to-stylesheet/commit/1beb45a114c2a649bd46417afe0efb8d74b85f91))
23+
* 支持类组件 ([416e595](https://github.com/NervJS/parse-css-to-stylesheet/commit/416e59575c1ad6c58f19e2cd6f34cec3b38db436))
24+
* update ([ca39a94](https://github.com/NervJS/parse-css-to-stylesheet/commit/ca39a94e3da22b737b079cf34e9383591313519c))
25+
26+
27+

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "parse-css-to-stylesheet"
33
version = "0.1.0"
44
edition = "2021"
5+
include = ["asset/**"]
56

67
[lib]
78
crate-type = ["cdylib"]

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ pub fn parse(component: String, styles: Vec<String>) -> String {
5050
};
5151
emitter.emit_module(&module.borrow()).unwrap();
5252
}
53-
let code = String::from_utf8(buf).unwrap();
53+
let code = String::from_utf8(buf).unwrap().replace("\r\n", "\n");
5454
code
5555
}

src/scraper.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ use std::{cell::OnceCell, collections::HashMap, ops::Deref, slice::Iter as Slice
55

66
use cssparser::{serialize_string, ToCss, Token, ParseError, ParseErrorKind, BasicParseErrorKind, Parser as CSSParser, ParserInput};
77
use ego_tree::NodeRef;
8-
use html5ever::{QualName, tendril::{StrTendril, fmt::imp}, LocalName, Namespace, ns, namespace_url, Attribute};
8+
use html5ever::{QualName, tendril::StrTendril, LocalName, Namespace, ns, namespace_url, Attribute};
99
use selectors::{SelectorImpl, parser::{self, SelectorParseErrorKind}, Element as SelectorElement, OpaqueElement, attr::{NamespaceConstraint, AttrSelectorOperation, CaseSensitivity}, matching::{self}, SelectorList};
1010
use smallvec::SmallVec;
1111

12-
use crate::utils::create_qualname;
13-
1412
pub struct Classes<'a> {
1513
inner: SliceIter<'a, LocalName>
1614
}
@@ -93,10 +91,6 @@ impl Element {
9391
Classes { inner: classes.iter() }
9492
}
9593

96-
pub fn attr(&self, attr: &str) -> Option<&str> {
97-
self.attrs.get(&&create_qualname(attr)).map(Deref::deref)
98-
}
99-
10094
pub fn attrs(&self) -> Attrs {
10195
Attrs { inner: self.attrs.iter() }
10296
}

0 commit comments

Comments
 (0)