@tarojs/plugin-platform-harmony-ets 4.0.0-beta.3 → 4.0.0-beta.30

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 (103) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/framework/index.ts +1 -5
  4. package/dist/apis/index.ts +27 -12
  5. package/dist/apis/network/request.ts +5 -5
  6. package/dist/apis/route/index.ts +15 -0
  7. package/dist/apis/storage/index.ts +124 -60
  8. package/dist/apis/ui/animation/animation.ts +2 -1
  9. package/dist/apis/utils/index.ts +1 -1
  10. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  11. package/dist/apis/wxml/index.ts +2 -0
  12. package/dist/components-harmony-ets/button.ets +50 -78
  13. package/dist/components-harmony-ets/canvas.ets +51 -0
  14. package/dist/components-harmony-ets/checkbox.ets +23 -209
  15. package/dist/components-harmony-ets/form.ets +44 -158
  16. package/dist/components-harmony-ets/icon.ets +38 -83
  17. package/dist/components-harmony-ets/image.ets +29 -78
  18. package/dist/components-harmony-ets/index.ets +53 -0
  19. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  20. package/dist/components-harmony-ets/input.ets +11 -67
  21. package/dist/components-harmony-ets/label.ets +58 -172
  22. package/dist/components-harmony-ets/movableArea.ets +96 -0
  23. package/dist/components-harmony-ets/movableView.ets +74 -0
  24. package/dist/components-harmony-ets/picker.ets +32 -147
  25. package/dist/components-harmony-ets/progress.ets +54 -0
  26. package/dist/components-harmony-ets/pseudo.ets +80 -0
  27. package/dist/components-harmony-ets/radio.ets +23 -210
  28. package/dist/components-harmony-ets/richText.ets +22 -102
  29. package/dist/components-harmony-ets/scrollView.ets +73 -169
  30. package/dist/components-harmony-ets/slider.ets +11 -72
  31. package/dist/components-harmony-ets/style.ets +280 -0
  32. package/dist/components-harmony-ets/swiper.ets +37 -87
  33. package/dist/components-harmony-ets/switch.ets +11 -71
  34. package/dist/components-harmony-ets/text.ets +57 -89
  35. package/dist/components-harmony-ets/textArea.ets +11 -67
  36. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  37. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  38. package/dist/components-harmony-ets/utils/flexManager.ets +11 -9
  39. package/dist/components-harmony-ets/utils/helper.ets +4 -5
  40. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  41. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  42. package/dist/components-harmony-ets/utils/index.ts +50 -51
  43. package/dist/components-harmony-ets/utils/styles.ets +167 -87
  44. package/dist/components-harmony-ets/video.ets +41 -89
  45. package/dist/components-harmony-ets/view.ets +53 -159
  46. package/dist/components-harmony-ets/webView.ets +44 -99
  47. package/dist/index.d.ts +151 -0
  48. package/dist/index.js +69 -32
  49. package/dist/index.js.map +1 -1
  50. package/dist/runtime-ets/bom/window.ts +7 -0
  51. package/dist/runtime-ets/current.ts +3 -0
  52. package/dist/runtime-ets/dom/bind.ts +20 -6
  53. package/dist/runtime-ets/dom/cssNesting.ts +393 -0
  54. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +12 -40
  55. package/dist/runtime-ets/dom/document.ts +22 -8
  56. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  57. package/dist/runtime-ets/dom/element/element.ts +128 -51
  58. package/dist/runtime-ets/dom/element/form.ts +15 -18
  59. package/dist/runtime-ets/dom/element/index.ts +16 -3
  60. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  61. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  62. package/dist/runtime-ets/dom/element/normal.ts +8 -3
  63. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  64. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  65. package/dist/runtime-ets/dom/element/text.ts +1 -8
  66. package/dist/runtime-ets/dom/element/video.ts +5 -3
  67. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  68. package/dist/runtime-ets/dom/event.ts +0 -1
  69. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  70. package/dist/runtime-ets/dom/node.ts +29 -27
  71. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +189 -211
  72. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  73. package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
  74. package/dist/runtime-ets/dom/stylesheet/util.ts +31 -25
  75. package/dist/runtime-ets/index.ts +2 -2
  76. package/dist/runtime-ets/interface/event.ts +1 -1
  77. package/dist/runtime-ets/utils/index.ts +43 -10
  78. package/dist/runtime-ets/utils/info.ts +1 -1
  79. package/dist/runtime-framework/react/app.ts +7 -2
  80. package/dist/runtime-framework/react/index.ts +0 -2
  81. package/dist/runtime-framework/react/native-page.ts +22 -12
  82. package/dist/runtime-framework/react/page.ts +3 -8
  83. package/dist/runtime-framework/solid/app.ts +25 -45
  84. package/dist/runtime-framework/solid/connect.ts +21 -3
  85. package/dist/runtime-framework/solid/hooks.ts +16 -11
  86. package/dist/runtime-framework/solid/index.ts +6 -2
  87. package/dist/runtime-framework/solid/page.ts +84 -30
  88. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  89. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  90. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  91. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  92. package/dist/runtime-utils.d.ts +827 -0
  93. package/dist/runtime-utils.js +210 -106
  94. package/dist/runtime-utils.js.map +1 -1
  95. package/dist/runtime.d.ts +1 -0
  96. package/dist/runtime.js +210 -106
  97. package/dist/runtime.js.map +1 -1
  98. package/index.js +3 -1
  99. package/package.json +13 -13
  100. package/types/index.d.ts +4 -0
  101. package/dist/runtime-ets/utils/bind.ts +0 -24
  102. /package/dist/components-harmony-ets/{index.ts → tag.ts} +0 -0
  103. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -2,141 +2,77 @@
2
2
 
3
3
  import { CSSProperties } from 'react'
4
4
 
5
+ import { TaroElement } from '../element/element'
5
6
  import { BORDER_STYLE_MAP, capitalizeFirstLetter, FlexManager, getNodeMarginOrPaddingData, getUnit } from './util'
6
7
 
7
- export const WEB_STYLE_MAP = {
8
- padding: ['_paddingTop', '_paddingRight', '_paddingBottom', '_paddingLeft'],
9
- paddingTop: ['_paddingTop'],
10
- paddingRight: ['_paddingRight'],
11
- paddingBottom: ['_paddingBottom'],
12
- paddingLeft: ['_paddingLeft'],
13
- margin: ['_marginTop', '_marginRight', '_marginBottom', '_marginLeft'],
14
- marginTop: ['_marginTop'],
15
- marginRight: ['_marginRight'],
16
- marginBottom: ['_marginBottom'],
17
- marginLeft: ['_marginLeft'],
18
- top: ['_top'],
19
- left: ['_left'],
20
- flex: ['_flexGrow', '_flexShrink', '_flexBasis'],
21
- flexGrow: ['_flexGrow'],
22
- flexShrink: ['_flexShrink'],
23
- flexBasis: ['_flexBasis'],
24
- alignSelf: ['_alignSelf'],
25
- flexDirection: ['_flexDirection'],
26
- justifyContent: ['_justifyContent'],
27
- alignItems: ['_alignItems'],
28
- alignContent: ['_alignContent'],
29
- flexWrap: ['_flexWrap'],
30
- width: ['_width'],
31
- height: ['_height'],
32
- minWidth: ['_minWidth'],
33
- minHeight: ['_minHeight'],
34
- maxWidth: ['_maxWidth'],
35
- maxHeight: ['_maxHeight'],
36
- background: ['_backgroundColor', '_backgroundImage', '_backgroundRepeat', '_backgroundSize', '_backgroundPosition'],
37
- backgroundColor: ['_backgroundColor'],
38
- backgroundImage: ['_backgroundImage'],
39
- backgroundRepeat: ['_backgroundRepeat'],
40
- backgroundSize: ['_backgroundSize'],
41
- backgroundPosition: ['_backgroundPosition'],
42
- border: ['_borderTopWidth', '_borderRightWidth', '_borderBottomWidth', '_borderLeftWidth', '_borderTopStyle', '_borderRightStyle', '_borderBottomStyle', '_borderLeftStyle', '_borderTopColor', '_borderRightColor', '_borderBottomColor', '_borderLeftColor'],
43
- borderTop: ['_borderTopWidth', '_borderTopStyle', '_borderTopColor'],
44
- borderRight: ['_borderRightWidth', '_borderRightStyle', '_borderRightColor'],
45
- borderBottom: ['_borderBottomWidth', '_borderBottomStyle', '_borderBottomColor'],
46
- borderLeft: ['_borderLeftWidth', '_borderLeftStyle', '_borderLeftColor'],
47
- borderWidth: ['_borderTopWidth', '_borderRightWidth', '_borderBottomWidth', '_borderLeftWidth'],
48
- borderLeftWidth: ['_borderLeftWidth'],
49
- borderRightWidth: ['_borderRightWidth'],
50
- borderTopWidth: ['_borderTopWidth'],
51
- borderBottomWidth: ['_borderBottomWidth'],
52
- borderStyle: ['_borderTopStyle', '_borderRightStyle', '_borderBottomStyle', '_borderLeftStyle'],
53
- borderLeftStyle: ['_borderLeftStyle'],
54
- borderRightStyle: ['_borderRightStyle'],
55
- borderTopStyle: ['_borderTopStyle'],
56
- borderBottomStyle: ['_borderBottomStyle'],
57
- borderColor: ['_borderTopColor', '_borderRightColor', '_borderBottomColor', '_borderLeftColor'],
58
- borderLeftColor: ['_borderLeftColor'],
59
- borderRightColor: ['_borderRightColor'],
60
- borderTopColor: ['_borderTopColor'],
61
- borderBottomColor: ['_borderBottomColor'],
62
- borderRadius: ['_borderTopLeftRadius', '_borderTopRightRadius', '_borderBottomLeftRadius', '_borderBottomRightRadius'],
63
- borderTopLeftRadius: ['_borderTopLeftRadius'],
64
- borderTopRightRadius: ['_borderTopRightRadius'],
65
- borderBottomLeftRadius: ['_borderBottomLeftRadius'],
66
- borderBottomRightRadius: ['_borderBottomRightRadius'],
67
- color: ['_color'],
68
- fontSize: ['_fontSize'],
69
- fontWeight: ['_fontWeight'],
70
- fontStyle: ['_fontStyle'],
71
- textAlign: ['_textAlign'],
72
- lineHeight: ['_lineHeight'],
73
- letterSpacing: ['_letterSpacing'],
74
- textDecoration: ['_textDecoration'],
75
- textOverflow: ['_textOverflow'],
76
- WebkitLineClamp: ['_WebkitLineClamp'],
77
- transform: ['_transform']
78
- }
79
-
80
- // 将web端的style转换为hm端的style
81
- export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
82
- const hmStyle: Record<string, any> = {}
8
+ // Note: web 端的 style 转换为 hm 端的 style
9
+ export default function convertWebStyle2HmStyle(webStyle: CSSProperties, node?: TaroElement) {
10
+ const hmStyle: Record<string, any> = node?._st?.hmStyle || {}
83
11
  Object.keys(webStyle).forEach((key) => {
84
12
  const value = webStyle[key]
85
13
  switch (key) {
86
14
  case 'padding': {
87
15
  const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
88
- hmStyle._paddingTop = top
89
- hmStyle._paddingBottom = bottom
90
- hmStyle._paddingLeft = left
91
- hmStyle._paddingRight = right
16
+ hmStyle.paddingTop = top
17
+ hmStyle.paddingBottom = bottom
18
+ hmStyle.paddingLeft = left
19
+ hmStyle.paddingRight = right
92
20
  break
93
21
  }
94
22
  case 'paddingTop': {
95
- hmStyle._paddingTop = getUnit(value)
23
+ hmStyle.paddingTop = getUnit(value)
96
24
  break
97
25
  }
98
26
  case 'paddingBottom': {
99
- hmStyle._paddingBottom = getUnit(value)
27
+ hmStyle.paddingBottom = getUnit(value)
100
28
  break
101
29
  }
102
30
  case 'paddingLeft': {
103
- hmStyle._paddingLeft = getUnit(value)
31
+ hmStyle.paddingLeft = getUnit(value)
104
32
  break
105
33
  }
106
34
  case 'paddingRight': {
107
- hmStyle._paddingRight = getUnit(value)
35
+ hmStyle.paddingRight = getUnit(value)
108
36
  break
109
37
  }
110
38
  case 'margin': {
111
39
  const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
112
- hmStyle._marginTop = top
113
- hmStyle._marginBottom = bottom
114
- hmStyle._marginLeft = left
115
- hmStyle._marginRight = right
40
+ hmStyle.marginTop = top
41
+ hmStyle.marginBottom = bottom
42
+ hmStyle.marginLeft = left
43
+ hmStyle.marginRight = right
116
44
  break
117
45
  }
118
46
  case 'marginTop': {
119
- hmStyle._marginTop = getUnit(value)
47
+ hmStyle.marginTop = getUnit(value)
120
48
  break
121
49
  }
122
50
  case 'marginBottom': {
123
- hmStyle._marginBottom = getUnit(value)
51
+ hmStyle.marginBottom = getUnit(value)
124
52
  break
125
53
  }
126
54
  case 'marginLeft': {
127
- hmStyle._marginLeft = getUnit(value)
55
+ hmStyle.marginLeft = getUnit(value)
128
56
  break
129
57
  }
130
58
  case 'marginRight': {
131
- hmStyle._marginRight = getUnit(value)
59
+ hmStyle.marginRight = getUnit(value)
132
60
  break
133
61
  }
134
62
  case 'top': {
135
- hmStyle._top = getUnit(value)
63
+ hmStyle.top = getUnit(value)
136
64
  break
137
65
  }
138
66
  case 'left': {
139
- hmStyle._left = getUnit(value)
67
+ hmStyle.left = getUnit(value)
68
+ break
69
+ }
70
+ case 'right': {
71
+ hmStyle.right = getUnit(value)
72
+ break
73
+ }
74
+ case 'bottom': {
75
+ hmStyle.bottom = getUnit(value)
140
76
  break
141
77
  }
142
78
  case 'flex': {
@@ -153,69 +89,69 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
153
89
  res[index] = index < 2 ? Number(item) : item
154
90
  })
155
91
  }
156
- hmStyle._flexGrow = getUnit(res[0])
157
- hmStyle._flexShrink = Number(res[1])
158
- hmStyle._flexBasis = Number(res[2])
92
+ hmStyle.flexGrow = getUnit(res[0])
93
+ hmStyle.flexShrink = Number(res[1])
94
+ hmStyle.flexBasis = Number(res[2])
159
95
  break
160
96
  }
161
97
  case 'flexGrow': {
162
- hmStyle._flexGrow = getUnit(value)
98
+ hmStyle.flexGrow = getUnit(value)
163
99
  break
164
100
  }
165
101
  case 'flexShrink': {
166
- hmStyle._flexShrink = Number(value)
102
+ hmStyle.flexShrink = Number(value)
167
103
  break
168
104
  }
169
105
  case 'flexBasis': {
170
- hmStyle._flexBasis = Number(value)
106
+ hmStyle.flexBasis = Number(value)
171
107
  break
172
108
  }
173
109
  case 'alignSelf': {
174
- hmStyle._alignSelf = FlexManager.itemAlign(value)
110
+ hmStyle.alignSelf = FlexManager.itemAlign(value)
175
111
  break
176
112
  }
177
113
  case 'flexDirection': {
178
- hmStyle._flexDirection = FlexManager.direction(value)
114
+ hmStyle.flexDirection = FlexManager.direction(value)
179
115
  break
180
116
  }
181
117
  case 'justifyContent': {
182
- hmStyle._justifyContent = FlexManager.flexAlign(value)
118
+ hmStyle.justifyContent = FlexManager.flexAlign(value)
183
119
  break
184
120
  }
185
121
  case 'alignItems': {
186
- hmStyle._alignItems = FlexManager.itemAlign(value)
122
+ hmStyle.alignItems = FlexManager.itemAlign(value)
187
123
  break
188
124
  }
189
125
  case 'alignContent': {
190
- hmStyle._alignContent = FlexManager.flexAlign(value)
126
+ hmStyle.alignContent = FlexManager.flexAlign(value)
191
127
  break
192
128
  }
193
129
  case 'flexWrap': {
194
- hmStyle._flexWrap = FlexManager.flexWrap(value)
130
+ hmStyle.flexWrap = FlexManager.flexWrap(value)
195
131
  break
196
132
  }
197
133
  case 'width': {
198
- hmStyle._width = getUnit(value)
134
+ hmStyle.width = getUnit(value)
199
135
  break
200
136
  }
201
137
  case 'height': {
202
- hmStyle._height = getUnit(value)
138
+ hmStyle.height = getUnit(value)
203
139
  break
204
140
  }
205
141
  case 'minWidth': {
206
- hmStyle._minWidth = getUnit(value)
142
+ hmStyle.minWidth = getUnit(value)
207
143
  break
208
144
  }
209
145
  case 'minHeight': {
210
- hmStyle._minHeight = getUnit(value)
146
+ hmStyle.minHeight = getUnit(value)
211
147
  break
212
148
  }
213
149
  case 'maxWidth': {
214
- hmStyle._maxWidth = getUnit(value)
150
+ hmStyle.maxWidth = getUnit(value)
215
151
  break
216
152
  }
217
153
  case 'maxHeight': {
218
- hmStyle._maxHeight = getUnit(value)
154
+ hmStyle.maxHeight = getUnit(value)
219
155
  break
220
156
  }
221
157
  case 'background': {
@@ -223,7 +159,7 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
223
159
  break
224
160
  }
225
161
  case 'backgroundColor': {
226
- hmStyle._backgroundColor = value
162
+ hmStyle.backgroundColor = value
227
163
  break
228
164
  }
229
165
  case 'backgroundImage': {
@@ -244,146 +180,146 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
244
180
  }
245
181
  case 'border': {
246
182
  const [width, style, color] = value.split(' ')
247
- hmStyle._borderTopWidth = getUnit(width)
248
- hmStyle._borderRightWidth = getUnit(width)
249
- hmStyle._borderBottomWidth = getUnit(width)
250
- hmStyle._borderLeftWidth = getUnit(width)
251
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(style)
252
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(style)
253
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(style)
254
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(style)
255
- hmStyle._borderTopColor = color
256
- hmStyle._borderRightColor = color
257
- hmStyle._borderBottomColor = color
258
- hmStyle._borderLeftColor = color
183
+ hmStyle.borderTopWidth = getUnit(width)
184
+ hmStyle.borderRightWidth = getUnit(width)
185
+ hmStyle.borderBottomWidth = getUnit(width)
186
+ hmStyle.borderLeftWidth = getUnit(width)
187
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(style)
188
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(style)
189
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(style)
190
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(style)
191
+ hmStyle.borderTopColor = color
192
+ hmStyle.borderRightColor = color
193
+ hmStyle.borderBottomColor = color
194
+ hmStyle.borderLeftColor = color
259
195
  break
260
196
  }
261
197
  case 'borderTop': {
262
198
  const [width, style, color] = value.split(' ')
263
- hmStyle._borderTopWidth = getUnit(width)
264
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(style)
265
- hmStyle._borderTopColor = color
199
+ hmStyle.borderTopWidth = getUnit(width)
200
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(style)
201
+ hmStyle.borderTopColor = color
266
202
  break
267
203
  }
268
204
  case 'borderRight': {
269
205
  const [width, style, color] = value.split(' ')
270
- hmStyle._borderRightWidth = getUnit(width)
271
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(style)
272
- hmStyle._borderRightColor = color
206
+ hmStyle.borderRightWidth = getUnit(width)
207
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(style)
208
+ hmStyle.borderRightColor = color
273
209
  break
274
210
  }
275
211
  case 'borderBottom': {
276
212
  const [width, style, color] = value.split(' ')
277
- hmStyle._borderBottomWidth = getUnit(width)
278
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(style)
279
- hmStyle._borderBottomColor = color
213
+ hmStyle.borderBottomWidth = getUnit(width)
214
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(style)
215
+ hmStyle.borderBottomColor = color
280
216
  break
281
217
  }
282
218
  case 'borderLeft': {
283
219
  const [width, style, color] = value.split(' ')
284
- hmStyle._borderLeftWidth = getUnit(width)
285
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(style)
286
- hmStyle._borderLeftColor = color
220
+ hmStyle.borderLeftWidth = getUnit(width)
221
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(style)
222
+ hmStyle.borderLeftColor = color
287
223
  break
288
224
  }
289
225
  case 'borderWidth': {
290
- hmStyle._borderTopWidth = getUnit(value)
291
- hmStyle._borderRightWidth = getUnit(value)
292
- hmStyle._borderBottomWidth = getUnit(value)
293
- hmStyle._borderLeftWidth = getUnit(value)
226
+ hmStyle.borderTopWidth = getUnit(value)
227
+ hmStyle.borderRightWidth = getUnit(value)
228
+ hmStyle.borderBottomWidth = getUnit(value)
229
+ hmStyle.borderLeftWidth = getUnit(value)
294
230
  break
295
231
  }
296
232
  case 'borderLeftWidth': {
297
- hmStyle._borderLeftWidth = getUnit(value)
233
+ hmStyle.borderLeftWidth = getUnit(value)
298
234
  break
299
235
  }
300
236
  case 'borderRightWidth': {
301
- hmStyle._borderRightWidth = getUnit(value)
237
+ hmStyle.borderRightWidth = getUnit(value)
302
238
  break
303
239
  }
304
240
  case 'borderTopWidth': {
305
- hmStyle._borderTopWidth = getUnit(value)
241
+ hmStyle.borderTopWidth = getUnit(value)
306
242
  break
307
243
  }
308
244
  case 'borderBottomWidth': {
309
- hmStyle._borderBottomWidth = getUnit(value)
245
+ hmStyle.borderBottomWidth = getUnit(value)
310
246
  break
311
247
  }
312
248
  case 'borderStyle': {
313
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(value)
314
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(value)
315
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(value)
316
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(value)
249
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(value)
250
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(value)
251
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(value)
252
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(value)
317
253
  break
318
254
  }
319
255
  case 'borderLeftStyle': {
320
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(value)
256
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(value)
321
257
  break
322
258
  }
323
259
  case 'borderRightStyle': {
324
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(value)
260
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(value)
325
261
  break
326
262
  }
327
263
  case 'borderTopStyle': {
328
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(value)
264
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(value)
329
265
  break
330
266
  }
331
267
  case 'borderBottomStyle': {
332
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(value)
268
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(value)
333
269
  break
334
270
  }
335
271
  case 'borderColor': {
336
- hmStyle._borderTopColor = value
337
- hmStyle._borderRightColor = value
338
- hmStyle._borderBottomColor = value
339
- hmStyle._borderLeftColor = value
272
+ hmStyle.borderTopColor = value
273
+ hmStyle.borderRightColor = value
274
+ hmStyle.borderBottomColor = value
275
+ hmStyle.borderLeftColor = value
340
276
  break
341
277
  }
342
278
  case 'borderLeftColor': {
343
- hmStyle._borderLeftColor = value
279
+ hmStyle.borderLeftColor = value
344
280
  break
345
281
  }
346
282
  case 'borderRightColor': {
347
- hmStyle._borderRightColor = value
283
+ hmStyle.borderRightColor = value
348
284
  break
349
285
  }
350
286
  case 'borderTopColor': {
351
- hmStyle._borderTopColor = value
287
+ hmStyle.borderTopColor = value
352
288
  break
353
289
  }
354
290
  case 'borderBottomColor': {
355
- hmStyle._borderBottomColor = value
291
+ hmStyle.borderBottomColor = value
356
292
  break
357
293
  }
358
294
  case 'borderRadius': {
359
- hmStyle._borderTopLeftRadius = getUnit(value)
360
- hmStyle._borderTopRightRadius = getUnit(value)
361
- hmStyle._borderBottomLeftRadius = getUnit(value)
362
- hmStyle._borderBottomRightRadius = getUnit(value)
295
+ hmStyle.borderTopLeftRadius = getUnit(value)
296
+ hmStyle.borderTopRightRadius = getUnit(value)
297
+ hmStyle.borderBottomLeftRadius = getUnit(value)
298
+ hmStyle.borderBottomRightRadius = getUnit(value)
363
299
  break
364
300
  }
365
301
  case 'borderTopLeftRadius': {
366
- hmStyle._borderTopLeftRadius = getUnit(value)
302
+ hmStyle.borderTopLeftRadius = getUnit(value)
367
303
  break
368
304
  }
369
305
  case 'borderTopRightRadius': {
370
- hmStyle._borderTopRightRadius = getUnit(value)
306
+ hmStyle.borderTopRightRadius = getUnit(value)
371
307
  break
372
308
  }
373
309
  case 'borderBottomLeftRadius': {
374
- hmStyle._borderBottomLeftRadius = getUnit(value)
310
+ hmStyle.borderBottomLeftRadius = getUnit(value)
375
311
  break
376
312
  }
377
313
  case 'borderBottomRightRadius': {
378
- hmStyle._borderBottomRightRadius = getUnit(value)
314
+ hmStyle.borderBottomRightRadius = getUnit(value)
379
315
  break
380
316
  }
381
317
  case 'color': {
382
- hmStyle._color = value
318
+ hmStyle.color = value
383
319
  break
384
320
  }
385
321
  case 'fontSize': {
386
- hmStyle._fontSize = getUnit(value)
322
+ hmStyle.fontSize = getUnit(value)
387
323
  break
388
324
  }
389
325
  case 'fontWeight': {
@@ -393,45 +329,63 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
393
329
  case 'fontStyle': {
394
330
  switch (value) {
395
331
  case 'italic':
396
- hmStyle._fontStyle = FontStyle.Italic
332
+ hmStyle.fontStyle = FontStyle.Italic
397
333
  break
398
334
  default:
399
- hmStyle._fontStyle = FontStyle.Normal
335
+ hmStyle.fontStyle = FontStyle.Normal
400
336
  }
401
337
  break
402
338
  }
403
339
  case 'textAlign': {
404
340
  switch (value) {
405
341
  case 'left':
406
- hmStyle._textAlign = TextAlign.Start
342
+ hmStyle.textAlign = TextAlign.Start
407
343
  break
408
344
  case 'center':
409
- hmStyle._textAlign = TextAlign.Center
345
+ hmStyle.textAlign = TextAlign.Center
410
346
  break
411
347
  case 'right':
412
- hmStyle._textAlign = TextAlign.End
348
+ hmStyle.textAlign = TextAlign.End
413
349
  break
414
350
  default:
415
- hmStyle._textAlign = TextAlign.Start
351
+ hmStyle.textAlign = TextAlign.Start
352
+ break
353
+ }
354
+ break
355
+ }
356
+ case 'verticalAlign': {
357
+ switch (value) {
358
+ case 'supper':
359
+ case 'top':
360
+ case 'text-top':
361
+ hmStyle.verticalAlign = Alignment.Top
362
+ break
363
+ case 'middle':
364
+ hmStyle.verticalAlign = Alignment.Center
365
+ break
366
+ case 'sub':
367
+ case 'text-bottom':
368
+ case 'bottom':
369
+ hmStyle.verticalAlign = Alignment.Bottom
416
370
  break
417
371
  }
418
372
  break
419
373
  }
420
374
  case 'lineHeight': {
421
- hmStyle._lineHeight = getUnit(value)
375
+ hmStyle.lineHeight = getUnit(value)
422
376
  break
423
377
  }
424
378
  case 'letterSpacing': {
425
- hmStyle._letterSpacing = getUnit(value)
379
+ hmStyle.letterSpacing = getUnit(value)
426
380
  break
427
381
  }
428
382
  case 'textDecoration': {
429
383
  if (typeof value === 'string') {
430
384
  switch (value) {
431
- case 'underline': hmStyle._textDecoration = TextDecorationType.Underline; break
432
- case 'overline': hmStyle._textDecoration = TextDecorationType.Overline; break
433
- case 'line-through': hmStyle._textDecoration = TextDecorationType.LineThrough; break
434
- default: hmStyle._textDecoration = TextDecorationType.None; break
385
+ case 'underline': hmStyle.textDecoration = TextDecorationType.Underline; break
386
+ case 'overline': hmStyle.textDecoration = TextDecorationType.Overline; break
387
+ case 'line-through': hmStyle.textDecoration = TextDecorationType.LineThrough; break
388
+ default: hmStyle.textDecoration = TextDecorationType.None; break
435
389
  }
436
390
  }
437
391
  break
@@ -444,18 +398,40 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
444
398
  case 'ellipsis': overflow = TextOverflow.Ellipsis; break
445
399
  case 'marquee': overflow = TextOverflow.MARQUEE; break
446
400
  }
447
- hmStyle._textOverflow = {
401
+ hmStyle.textOverflow = {
448
402
  overflow
449
403
  }
450
404
  }
451
405
  break
452
406
  }
453
407
  case 'WebkitLineClamp': {
454
- hmStyle._WebkitLineClamp = Number(value)
455
- break
408
+ hmStyle.WebkitLineClamp = Number(value)
409
+ break
456
410
  }
457
411
  case 'transform': {
458
- hmStyle._transform = parseTransform(value)
412
+ // todo: 需要更新
413
+ // hmStyle.transform = parseTransform(value)
414
+ break
415
+ }
416
+ case 'position': {
417
+ hmStyle.position = value
418
+ break
419
+ }
420
+ case 'display': {
421
+ hmStyle.display = value
422
+ break
423
+ }
424
+ case 'zIndex': {
425
+ hmStyle.zIndex = Number(value)
426
+ break
427
+ }
428
+ case 'opacity': {
429
+ const val = Number(value)
430
+ hmStyle.opacity = Number.isNaN(val) ? 1 : val
431
+ break
432
+ }
433
+ case 'overflow': {
434
+ hmStyle.overflow = value
459
435
  break
460
436
  }
461
437
  default: {
@@ -472,20 +448,21 @@ function setBackgroundImage(hmStyle, value) {
472
448
  // 如果包含 url(),则说明是 background-image 属性
473
449
  const match = value.match(new RegExp('url\\([\'"]?(.*?)[\'"]?\\)'))
474
450
  if (match) {
475
- hmStyle._backgroundImage = [{
451
+ hmStyle.backgroundImage = {
476
452
  src: match[1]
477
- }]
453
+ }
478
454
  }
479
455
  }
456
+ // todo 渐变需要处理
480
457
  }
481
458
 
482
459
  function setBackgroundRepeat(hmStyle, value) {
483
460
  if (typeof value === 'string') {
484
461
  switch (value) {
485
- case 'repeat-x': hmStyle._backgroundRepeat = [ImageRepeat.X]; break
486
- case 'repeat-y': hmStyle._backgroundRepeat = [ImageRepeat.Y]; break
487
- case 'no-repeat': hmStyle._backgroundRepeat = [ImageRepeat.NoRepeat]; break
488
- default: hmStyle._backgroundRepeat = [ImageRepeat.XY]; break
462
+ case 'repeat-x': hmStyle.backgroundRepeat = ImageRepeat.X; break
463
+ case 'repeat-y': hmStyle.backgroundRepeat = ImageRepeat.Y; break
464
+ case 'no-repeat': hmStyle.backgroundRepeat = ImageRepeat.NoRepeat; break
465
+ default: hmStyle.backgroundRepeat = ImageRepeat.XY; break
489
466
  }
490
467
  }
491
468
  }
@@ -494,9 +471,9 @@ function setBackgroundSize(hmStyle, value) {
494
471
  if (typeof value === 'string') {
495
472
  const sizes = value.split(' ')
496
473
  if (sizes.length === 1) {
497
- hmStyle._backgroundSize = [{ width: getUnit(sizes[0]) }]
474
+ hmStyle.backgroundSize = { width: getUnit(sizes[0]) }
498
475
  } else if (sizes.length === 2) {
499
- hmStyle._backgroundSize = [{ width: getUnit(sizes[0]), height: getUnit(sizes[1]) }]
476
+ hmStyle.backgroundSize = { width: getUnit(sizes[0]), height: getUnit(sizes[1]) }
500
477
  }
501
478
  }
502
479
  }
@@ -508,28 +485,28 @@ function setBackgroundPosistion (hmStyle, value) {
508
485
  const vertical = positions[1].toLowerCase() || 'top'
509
486
 
510
487
  if (horizontal === 'left' && vertical === 'top') {
511
- hmStyle._backgroundPosition = [Alignment.TopStart]
488
+ hmStyle.backgroundPosition = Alignment.TopStart
512
489
  } else if (horizontal === 'center' && vertical === 'top') {
513
- hmStyle._backgroundPosition = [Alignment.Top]
490
+ hmStyle.backgroundPosition = Alignment.Top
514
491
  } else if (horizontal === 'right' && vertical === 'top') {
515
- hmStyle._backgroundPosition = [Alignment.TopEnd]
492
+ hmStyle.backgroundPosition = Alignment.TopEnd
516
493
  } else if (horizontal === 'left' && vertical === 'center') {
517
- hmStyle._backgroundPosition = [Alignment.Start]
494
+ hmStyle.backgroundPosition = Alignment.Start
518
495
  } else if (horizontal === 'center' && vertical === 'center') {
519
- hmStyle._backgroundPosition = [Alignment.Center]
496
+ hmStyle.backgroundPosition = Alignment.Center
520
497
  } else if (horizontal === 'right' && vertical === 'center') {
521
- hmStyle._backgroundPosition = [Alignment.End]
498
+ hmStyle.backgroundPosition = Alignment.End
522
499
  } else if (horizontal === 'left' && vertical === 'bottom') {
523
- hmStyle._backgroundPosition = [Alignment.BottomStart]
500
+ hmStyle.backgroundPosition = Alignment.BottomStart
524
501
  } else if (horizontal === 'center' && vertical === 'bottom') {
525
- hmStyle._backgroundPosition = [Alignment.Bottom]
502
+ hmStyle.backgroundPosition = Alignment.Bottom
526
503
  } else if (horizontal === 'right' && vertical === 'bottom') {
527
- hmStyle._backgroundPosition = [Alignment.BottomEnd]
504
+ hmStyle.backgroundPosition = Alignment.BottomEnd
528
505
  } else {
529
506
  if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
530
- hmStyle._backgroundPosition = [{ x: getUnit(horizontal) }]
507
+ hmStyle.backgroundPosition = { x: getUnit(horizontal) }
531
508
  if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
532
- hmStyle._backgroundPosition = [{ x: getUnit(horizontal), y: getUnit(vertical) }]
509
+ hmStyle.backgroundPosition = { x: getUnit(horizontal), y: getUnit(vertical) }
533
510
  }
534
511
  }
535
512
  }
@@ -538,14 +515,15 @@ function setBackgroundPosistion (hmStyle, value) {
538
515
 
539
516
  function setFontWeight (hmStyle, value) {
540
517
  switch (value) {
541
- case 'normal': hmStyle._fontWeight = FontWeight.Normal; break
542
- case 'bold': hmStyle._fontWeight = FontWeight.Bold; break
543
- case 'bolder': hmStyle._fontWeight = FontWeight.Bolder; break
544
- case 'lighter': hmStyle._fontWeight = FontWeight.Lighter; break
545
- default: hmStyle._fontWeight = Number(value); break
518
+ case 'normal': hmStyle.fontWeight = FontWeight.Normal; break
519
+ case 'bold': hmStyle.fontWeight = FontWeight.Bold; break
520
+ case 'bolder': hmStyle.fontWeight = FontWeight.Bolder; break
521
+ case 'lighter': hmStyle.fontWeight = FontWeight.Lighter; break
522
+ default: hmStyle.fontWeight = Number(value); break
546
523
  }
547
524
  }
548
525
 
526
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
549
527
  function parseTransform(transformString) {
550
528
  const transformRegex = /(\w+)\(([^)]+)\)/g
551
529
  const transforms = []