@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.
Files changed (3) hide show
  1. package/README.md +14 -18
  2. package/index.d.ts +7 -1
  3. package/package.json +14 -14
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 简介
4
4
 
5
- 解析 React 组件与对应的 CSS 文件,为每一个 React 节点计算样式最终样式,应用于 React Native 、鸿蒙等不支持 CSS 写法的场景
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(jsxCode, [cssCode1, cssCode2, ...], {
13
+ const { code } = parse([cssCode1, cssCode2, ...], {
14
14
  platformString: 'Harmony',
15
- isEnableNesting: true // 支持解析嵌套选择器,默认关闭
15
+ designWidth: 750
16
16
  })
17
- // code: jsx代码 string
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; // 平台:'Harmony'
25
- isEnableNesting?: boolean; // 是否支持嵌套解析
27
+ platformString: string // 平台 Harmony
28
+ output?: OutputOptions
26
29
  }
27
30
  export interface ParseResult {
28
- code: string; // 输出的jsxcode
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
- | isEnableNesting | Boolean | | 样式嵌套解析开关 |
47
+ | output | Object | { isBin: false } | 输出格式 |
45
48
 
46
49
  #### ParseResult
47
50
 
48
51
  | 配置参数 | 类型 | 说明 |
49
52
  | -------- | ------ | ------------------------- |
50
- | code | String | 经过样式解析后的 JSX 代码 |
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: string
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.0.22",
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.16.3",
28
- "ava": "^5.1.1",
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.0.22",
58
- "@tarojs/parse-css-to-stylesheet-darwin-x64": "1.0.22",
59
- "@tarojs/parse-css-to-stylesheet-linux-x64-gnu": "1.0.22",
60
- "@tarojs/parse-css-to-stylesheet-darwin-arm64": "1.0.22",
61
- "@tarojs/parse-css-to-stylesheet-android-arm64": "1.0.22",
62
- "@tarojs/parse-css-to-stylesheet-linux-arm64-gnu": "1.0.22",
63
- "@tarojs/parse-css-to-stylesheet-linux-arm64-musl": "1.0.22",
64
- "@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf": "1.0.22",
65
- "@tarojs/parse-css-to-stylesheet-linux-x64-musl": "1.0.22",
66
- "@tarojs/parse-css-to-stylesheet-android-arm-eabi": "1.0.22",
67
- "@tarojs/parse-css-to-stylesheet-darwin-universal": "1.0.22"
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
  }