@tarojs/parse-css-to-stylesheet 1.0.22 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -18
- package/index.d.ts +7 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 简介
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
对 CSS 代码进行解析编码处理,应用于 React Native 、鸿蒙等不支持 CSS 写法的场景
|
|
6
6
|
|
|
7
7
|
## 使用方式
|
|
8
8
|
|
|
@@ -10,27 +10,30 @@
|
|
|
10
10
|
import { parse } from '@tarojs/parse-css-to-stylesheet'
|
|
11
11
|
|
|
12
12
|
// Harmony
|
|
13
|
-
const { code } = parse(
|
|
13
|
+
const { code } = parse([cssCode1, cssCode2, ...], {
|
|
14
14
|
platformString: 'Harmony',
|
|
15
|
-
|
|
15
|
+
designWidth: 750
|
|
16
16
|
})
|
|
17
|
-
// code:
|
|
17
|
+
// code: CSS 代码 string
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## 参数说明
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
+
export interface OutputOptions {
|
|
24
|
+
isBin?: boolean
|
|
25
|
+
}
|
|
23
26
|
export interface ParseOptions {
|
|
24
|
-
platformString: string
|
|
25
|
-
|
|
27
|
+
platformString: string // 平台 Harmony
|
|
28
|
+
output?: OutputOptions
|
|
26
29
|
}
|
|
27
30
|
export interface ParseResult {
|
|
28
|
-
code
|
|
31
|
+
code?: string
|
|
32
|
+
buffer?: Buffer
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
// 样式解析
|
|
32
36
|
export function parse(
|
|
33
|
-
component: string,
|
|
34
37
|
styles: Array<string>,
|
|
35
38
|
options: ParseOptions
|
|
36
39
|
): ParseResult;
|
|
@@ -41,21 +44,14 @@ export function parse(
|
|
|
41
44
|
| 配置参数 | 类型 | 可选值 | 说明 |
|
|
42
45
|
| --------------- | ------- | ------------------------ | ---------------- |
|
|
43
46
|
| platformString | String | 'Harmony'、'ReactNative' | 平台 |
|
|
44
|
-
|
|
|
47
|
+
| output | Object | { isBin: false } | 输出格式 |
|
|
45
48
|
|
|
46
49
|
#### ParseResult
|
|
47
50
|
|
|
48
51
|
| 配置参数 | 类型 | 说明 |
|
|
49
52
|
| -------- | ------ | ------------------------- |
|
|
50
|
-
| code | String |
|
|
51
|
-
|
|
52
|
-
在 Harmony 中,编译结果会依赖`@tarojs/plugin-platform-harmony-ets`中提供的几个包方法:
|
|
53
|
-
|
|
54
|
-
1. `convertNumber2VP` 用于运行时进行单位转换
|
|
55
|
-
2. `calcStaticStyle` 用于合成类,匹配类名
|
|
56
|
-
3. `__combine_nesting_style__` 嵌套样式的合成
|
|
57
|
-
|
|
58
|
-
具体位于 [Taro 主仓](https://github.com/NervJS/taro) 路径:_/taro/packages/taro-platform-harmony/src/runtime-ets_ 中
|
|
53
|
+
| code | String | 经过样式解析后的样式代码 |
|
|
54
|
+
| buffer | Buffer | 经过样式解析后的二进制 |
|
|
59
55
|
|
|
60
56
|
## 样式支持情况
|
|
61
57
|
|
package/index.d.ts
CHANGED
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
+
export interface OutputOptions {
|
|
7
|
+
isBin?: boolean
|
|
8
|
+
}
|
|
6
9
|
export interface ParseOptions {
|
|
7
10
|
platformString: string
|
|
11
|
+
designWidth?: number
|
|
12
|
+
output?: OutputOptions
|
|
8
13
|
}
|
|
9
14
|
export interface ParseResult {
|
|
10
|
-
code
|
|
15
|
+
code?: string
|
|
16
|
+
buffer?: Buffer
|
|
11
17
|
}
|
|
12
18
|
export declare function parse(styles: Array<string>, options: ParseOptions): ParseResult
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/parse-css-to-stylesheet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"napi": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@napi-rs/cli": "^2.
|
|
28
|
-
"ava": "^5.
|
|
27
|
+
"@napi-rs/cli": "^2.18.4",
|
|
28
|
+
"ava": "^5.3.1",
|
|
29
29
|
"conventional-changelog-cli": "2.2.2",
|
|
30
30
|
"npm-run-all": "4.1.5",
|
|
31
31
|
"prettier": "2.8.8",
|
|
@@ -54,16 +54,16 @@
|
|
|
54
54
|
"packageManager": "pnpm@9.11.0",
|
|
55
55
|
"repository": "https://github.com/NervJS/parse-css-to-stylesheet",
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@tarojs/parse-css-to-stylesheet-win32-x64-msvc": "1.
|
|
58
|
-
"@tarojs/parse-css-to-stylesheet-darwin-x64": "1.
|
|
59
|
-
"@tarojs/parse-css-to-stylesheet-linux-x64-gnu": "1.
|
|
60
|
-
"@tarojs/parse-css-to-stylesheet-darwin-arm64": "1.
|
|
61
|
-
"@tarojs/parse-css-to-stylesheet-android-arm64": "1.
|
|
62
|
-
"@tarojs/parse-css-to-stylesheet-linux-arm64-gnu": "1.
|
|
63
|
-
"@tarojs/parse-css-to-stylesheet-linux-arm64-musl": "1.
|
|
64
|
-
"@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf": "1.
|
|
65
|
-
"@tarojs/parse-css-to-stylesheet-linux-x64-musl": "1.
|
|
66
|
-
"@tarojs/parse-css-to-stylesheet-android-arm-eabi": "1.
|
|
67
|
-
"@tarojs/parse-css-to-stylesheet-darwin-universal": "1.
|
|
57
|
+
"@tarojs/parse-css-to-stylesheet-win32-x64-msvc": "1.1.1",
|
|
58
|
+
"@tarojs/parse-css-to-stylesheet-darwin-x64": "1.1.1",
|
|
59
|
+
"@tarojs/parse-css-to-stylesheet-linux-x64-gnu": "1.1.1",
|
|
60
|
+
"@tarojs/parse-css-to-stylesheet-darwin-arm64": "1.1.1",
|
|
61
|
+
"@tarojs/parse-css-to-stylesheet-android-arm64": "1.1.1",
|
|
62
|
+
"@tarojs/parse-css-to-stylesheet-linux-arm64-gnu": "1.1.1",
|
|
63
|
+
"@tarojs/parse-css-to-stylesheet-linux-arm64-musl": "1.1.1",
|
|
64
|
+
"@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf": "1.1.1",
|
|
65
|
+
"@tarojs/parse-css-to-stylesheet-linux-x64-musl": "1.1.1",
|
|
66
|
+
"@tarojs/parse-css-to-stylesheet-android-arm-eabi": "1.1.1",
|
|
67
|
+
"@tarojs/parse-css-to-stylesheet-darwin-universal": "1.1.1"
|
|
68
68
|
}
|
|
69
69
|
}
|