@tarojs/plugin-platform-harmony-ets 4.0.0-beta.0 → 4.0.0-beta.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 (54) hide show
  1. package/dist/apis/media/video/VideoContext.ts +56 -7
  2. package/dist/apis/media/video/index.ts +3 -2
  3. package/dist/components-harmony-ets/button.ets +58 -23
  4. package/dist/components-harmony-ets/checkbox.ets +154 -67
  5. package/dist/components-harmony-ets/form.ets +52 -18
  6. package/dist/components-harmony-ets/icon.ets +53 -19
  7. package/dist/components-harmony-ets/image.ets +53 -19
  8. package/dist/components-harmony-ets/input.ets +57 -18
  9. package/dist/components-harmony-ets/label.ets +52 -18
  10. package/dist/components-harmony-ets/picker.ets +139 -37
  11. package/dist/components-harmony-ets/radio.ets +157 -70
  12. package/dist/components-harmony-ets/richText.ets +52 -18
  13. package/dist/components-harmony-ets/scrollView.ets +102 -44
  14. package/dist/components-harmony-ets/slider.ets +57 -18
  15. package/dist/components-harmony-ets/swiper.ets +52 -18
  16. package/dist/components-harmony-ets/switch.ets +92 -41
  17. package/dist/components-harmony-ets/text.ets +57 -20
  18. package/dist/components-harmony-ets/textArea.ets +58 -19
  19. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  20. package/dist/components-harmony-ets/utils/flexManager.ets +1 -1
  21. package/dist/components-harmony-ets/utils/styles.ets +46 -19
  22. package/dist/components-harmony-ets/video.ets +52 -18
  23. package/dist/components-harmony-ets/view.ets +100 -32
  24. package/dist/index.js +17 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +7 -3
  27. package/dist/runtime-ets/dom/element/element.ts +1 -0
  28. package/dist/runtime-ets/dom/element/form.ts +11 -2
  29. package/dist/runtime-ets/dom/node.ts +29 -16
  30. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +551 -0
  31. package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
  32. package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
  33. package/dist/runtime-ets/dom/stylesheet/util.ts +55 -5
  34. package/dist/runtime-ets/interface/event.ts +2 -1
  35. package/dist/runtime-ets/utils/index.ts +3 -1
  36. package/dist/runtime-ets/utils/info.ts +3 -1
  37. package/dist/runtime-utils.js +48 -13
  38. package/dist/runtime-utils.js.map +1 -1
  39. package/dist/runtime.js +48 -13
  40. package/dist/runtime.js.map +1 -1
  41. package/package.json +10 -9
  42. package/static/media/cancel.svg +1 -0
  43. package/static/media/circle.svg +1 -0
  44. package/static/media/clear.svg +1 -0
  45. package/static/media/download.svg +1 -0
  46. package/static/media/info.svg +1 -0
  47. package/static/media/info_circle.svg +1 -0
  48. package/static/media/search.svg +1 -0
  49. package/static/media/success.svg +1 -0
  50. package/static/media/success_no_circle.svg +1 -0
  51. package/static/media/taro_arrow_left.svg +1 -0
  52. package/static/media/taro_home.svg +1 -0
  53. package/static/media/waiting.svg +1 -0
  54. package/static/media/warn.svg +1 -0
@@ -68,12 +68,16 @@ class CSSStyleDeclaration {
68
68
  const node = this.el
69
69
  prop = prop.includes('-') ? toCamelCase(prop) : prop
70
70
  const value = node._st[prop]
71
+ if (prop.startsWith('_')) {
72
+ prop = prop.replace('_', '')
73
+ }
71
74
  if (value === undefined) {
72
- node._st[prop] = undefined
75
+ // node._st[prop] = undefined
76
+ delete node._st.hmStyle[prop]
73
77
  return ''
74
78
  } else {
75
- // delete node._st[prop]
76
- node._st[prop] = undefined
79
+ delete node._st.hmStyle[prop]
80
+ // node._st[prop] = undefined
77
81
  // node._st = { ...node._st }
78
82
  return value
79
83
  }
@@ -20,6 +20,7 @@ export interface TaroExtraProps {
20
20
  disabled?: boolean
21
21
  }
22
22
 
23
+ @Observed
23
24
  export class TaroElement<T extends StandardProps = StandardProps> extends TaroNode {
24
25
  public _innerHTML = ''
25
26
  public _nodeInfo: TaroAny = {}
@@ -31,6 +31,8 @@ interface FormWidgetProps extends StandardProps {
31
31
  class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends TaroElement<T> {
32
32
  _instance
33
33
 
34
+ _isInit = false
35
+
34
36
  _name = ''
35
37
 
36
38
  _value: TaroAny = ''
@@ -44,7 +46,6 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
44
46
 
45
47
  this._name = this._attrs.name || ''
46
48
  this._value = this._attrs.value || ''
47
- this._reset = this._attrs.value || ''
48
49
  }
49
50
 
50
51
  public setAttribute (name: string, value: any): void {
@@ -104,7 +105,6 @@ class TaroCheckedElement<T extends StandardProps & { checked?: boolean } = Stand
104
105
  super(tagName)
105
106
 
106
107
  this._checked = this._attrs.checked || false
107
- this._reset = this._attrs.checked || false
108
108
  }
109
109
 
110
110
  public setAttribute (name: string, value: any): void {
@@ -262,6 +262,15 @@ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | Pick
262
262
  return ''
263
263
  }
264
264
  }
265
+
266
+ public reset() {
267
+ super.reset()
268
+
269
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this._reset } }, this)
270
+
271
+ event.stopPropagation()
272
+ eventHandler(event, 'change', this)
273
+ }
265
274
  }
266
275
 
267
276
  class TaroSwitchElement extends TaroCheckedElement<SwitchProps> {
@@ -31,16 +31,18 @@ export class TaroNode extends TaroDataSourceElement {
31
31
  public childNodes: TaroNode[] = []
32
32
  public parentNode: TaroNode | null = null
33
33
  public _nid: string = genId()
34
-
35
34
  public _doc: TaroDocument | null = null
35
+
36
+ private _textContent = ''
37
+
38
+ // 以下属性为半编译模式下才会赋值和使用的属性
39
+ // 半编译节点更新触发器
40
+ public _updateTrigger = 0
36
41
  // 是否为半编译模板下的节点
37
42
  public _isCompileMode = false
38
43
  // 是否为半编译模板下拥有自主更新权的节点
39
44
  public _isDynamicNode = false
40
45
 
41
- public _updateTrigger = 0
42
- private _textContent = ''
43
-
44
46
  constructor(nodeName: string, nodeType = NodeType.ELEMENT_NODE) {
45
47
  super()
46
48
 
@@ -63,15 +65,25 @@ export class TaroNode extends TaroDataSourceElement {
63
65
 
64
66
  // 更新对应的 ArkUI 组件
65
67
  public updateComponent () {
66
- if (!this.parentNode || !this.parentNode.listeners?.length) return
68
+ if (!this._isCompileMode && (!this.parentNode || !this.parentNode.listeners?.length)) return
67
69
 
68
70
  const idx = this.parentNode.findIndex(this)
69
-
70
- if (idx >= 0) {
71
- this._updateTrigger++
72
- this.parentNode.notifyDataChange(idx)
71
+
72
+ if (this._isCompileMode) {
73
+ // 半编译模式下走 @State 的更新模式
74
+ if (this._isDynamicNode) {
75
+ this._updateTrigger++
76
+ } else {
77
+ this.parentNode.updateComponent()
78
+ }
73
79
  } else {
74
- this.parentNode.notifyDataReload()
80
+ // 非半编译模式下走 LazyForEach 的更新模式
81
+ if (idx >= 0) {
82
+ this._updateTrigger++
83
+ this.parentNode.notifyDataChange(idx)
84
+ } else {
85
+ this.parentNode.notifyDataReload()
86
+ }
75
87
  }
76
88
  }
77
89
 
@@ -232,14 +244,15 @@ export class TaroTextNode extends TaroNode {
232
244
  }
233
245
  }
234
246
 
235
- function checkIsCompileModeAndInstallAfterDOMAction (_node: TaroNode, _parentNode: TaroNode) {
236
- // if (!parentNode._isCompileMode) return
247
+ function checkIsCompileModeAndInstallAfterDOMAction (node: TaroNode, parentNode: TaroNode) {
248
+ if (!parentNode._isCompileMode || !parentNode._instance) return
237
249
 
238
- // parentNode._instance?.dynamicCenter?.install?.(node, parentNode)
250
+ parentNode._instance.dynamicCenter?.install?.(node, parentNode)
251
+ node.updateComponent()
239
252
  }
240
253
 
241
- function checkIsCompileModeAndUninstallAfterDOMAction (_node: TaroNode) {
242
- // if (!node._isCompileMode) return
254
+ function checkIsCompileModeAndUninstallAfterDOMAction (node: TaroNode) {
255
+ if (!node._isCompileMode || !parentNode._instance) return
243
256
 
244
- // node._instance?.dynamicCenter?.uninstall?.(node)
257
+ node._instance.dynamicCenter?.uninstall?.(node)
245
258
  }
@@ -0,0 +1,551 @@
1
+ // @ts-nocheck
2
+
3
+ import { CSSProperties } from 'react'
4
+
5
+ import { BORDER_STYLE_MAP, capitalizeFirstLetter, FlexManager, getNodeMarginOrPaddingData, getUnit } from './util'
6
+
7
+ // 将web端的style转换为hm端的style
8
+ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
9
+ const hmStyle: Record<string, any> = {}
10
+ Object.keys(webStyle).forEach((key) => {
11
+ const value = webStyle[key]
12
+ switch (key) {
13
+ case 'padding': {
14
+ const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
15
+ hmStyle._paddingTop = top
16
+ hmStyle._paddingBottom = bottom
17
+ hmStyle._paddingLeft = left
18
+ hmStyle._paddingRight = right
19
+ break
20
+ }
21
+ case 'paddingTop': {
22
+ hmStyle._paddingTop = getUnit(value)
23
+ break
24
+ }
25
+ case 'paddingBottom': {
26
+ hmStyle._paddingBottom = getUnit(value)
27
+ break
28
+ }
29
+ case 'paddingLeft': {
30
+ hmStyle._paddingLeft = getUnit(value)
31
+ break
32
+ }
33
+ case 'paddingRight': {
34
+ hmStyle._paddingRight = getUnit(value)
35
+ break
36
+ }
37
+ case 'margin': {
38
+ const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
39
+ hmStyle._marginTop = top
40
+ hmStyle._marginBottom = bottom
41
+ hmStyle._marginLeft = left
42
+ hmStyle._marginRight = right
43
+ break
44
+ }
45
+ case 'marginTop': {
46
+ hmStyle._marginTop = getUnit(value)
47
+ break
48
+ }
49
+ case 'marginBottom': {
50
+ hmStyle._marginBottom = getUnit(value)
51
+ break
52
+ }
53
+ case 'marginLeft': {
54
+ hmStyle._marginLeft = getUnit(value)
55
+ break
56
+ }
57
+ case 'marginRight': {
58
+ hmStyle._marginRight = getUnit(value)
59
+ break
60
+ }
61
+ case 'top': {
62
+ hmStyle._top = getUnit(value)
63
+ break
64
+ }
65
+ case 'left': {
66
+ hmStyle._left = getUnit(value)
67
+ break
68
+ }
69
+ case 'flex': {
70
+ let res: [number, number, number | string] = [0, 0, 'auto']
71
+ if (typeof value === 'number') {
72
+ res = [value, 1, 0]
73
+ } else if (value === 'auto') {
74
+ res = [1, 1, 'auto']
75
+ } else if (value === 'none') {
76
+ res = [0, 0, 'auto']
77
+ } else if (typeof value === 'string') {
78
+ const FlexList = value.replace(new RegExp('/\\s+/g'), ' ').split(' ')
79
+ FlexList.forEach((item, index) => {
80
+ res[index] = index < 2 ? Number(item) : item
81
+ })
82
+ }
83
+ hmStyle._flexGrow = getUnit(res[0])
84
+ hmStyle._flexShrink = Number(res[1])
85
+ hmStyle._flexBasis = Number(res[2])
86
+ break
87
+ }
88
+ case 'flexGrow': {
89
+ hmStyle._flexGrow = getUnit(value)
90
+ break
91
+ }
92
+ case 'flexShrink': {
93
+ hmStyle._flexShrink = Number(value)
94
+ break
95
+ }
96
+ case 'flexBasis': {
97
+ hmStyle._flexBasis = Number(value)
98
+ break
99
+ }
100
+ case 'alignSelf': {
101
+ hmStyle._alignSelf = FlexManager.itemAlign(value)
102
+ break
103
+ }
104
+ case 'flexDirection': {
105
+ hmStyle._flexDirection = FlexManager.direction(value)
106
+ break
107
+ }
108
+ case 'justifyContent': {
109
+ hmStyle._justifyContent = FlexManager.flexAlign(value)
110
+ break
111
+ }
112
+ case 'alignItems': {
113
+ hmStyle._alignItems = FlexManager.itemAlign(value)
114
+ break
115
+ }
116
+ case 'alignContent': {
117
+ hmStyle._alignContent = FlexManager.flexAlign(value)
118
+ break
119
+ }
120
+ case 'flexWrap': {
121
+ hmStyle._flexWrap = FlexManager.flexWrap(value)
122
+ break
123
+ }
124
+ case 'width': {
125
+ hmStyle._width = getUnit(value)
126
+ break
127
+ }
128
+ case 'height': {
129
+ hmStyle._height = getUnit(value)
130
+ break
131
+ }
132
+ case 'minWidth': {
133
+ hmStyle._minWidth = getUnit(value)
134
+ break
135
+ }
136
+ case 'minHeight': {
137
+ hmStyle._minHeight = getUnit(value)
138
+ break
139
+ }
140
+ case 'maxWidth': {
141
+ hmStyle._maxWidth = getUnit(value)
142
+ break
143
+ }
144
+ case 'maxHeight': {
145
+ hmStyle._maxHeight = getUnit(value)
146
+ break
147
+ }
148
+ case 'background': {
149
+ // TODO: 暂未实现
150
+ break
151
+ }
152
+ case 'backgroundColor': {
153
+ hmStyle._backgroundColor = value
154
+ break
155
+ }
156
+ case 'backgroundImage': {
157
+ setBackgroundImage(hmStyle, value)
158
+ break
159
+ }
160
+ case 'backgroundRepeat': {
161
+ setBackgroundRepeat(hmStyle, value)
162
+ break
163
+ }
164
+ case 'backgroundSize': {
165
+ setBackgroundSize(hmStyle, value)
166
+ break
167
+ }
168
+ case 'backgroundPosition': {
169
+ setBackgroundPosistion(hmStyle, value)
170
+ break
171
+ }
172
+ case 'border': {
173
+ const [width, style, color] = value.split(' ')
174
+ hmStyle._borderTopWidth = getUnit(width)
175
+ hmStyle._borderRightWidth = getUnit(width)
176
+ hmStyle._borderBottomWidth = getUnit(width)
177
+ hmStyle._borderLeftWidth = getUnit(width)
178
+ hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(style)
179
+ hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(style)
180
+ hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(style)
181
+ hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(style)
182
+ hmStyle._borderTopColor = color
183
+ hmStyle._borderRightColor = color
184
+ hmStyle._borderBottomColor = color
185
+ hmStyle._borderLeftColor = color
186
+ break
187
+ }
188
+ case 'borderTop': {
189
+ const [width, style, color] = value.split(' ')
190
+ hmStyle._borderTopWidth = getUnit(width)
191
+ hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(style)
192
+ hmStyle._borderTopColor = color
193
+ break
194
+ }
195
+ case 'borderRight': {
196
+ const [width, style, color] = value.split(' ')
197
+ hmStyle._borderRightWidth = getUnit(width)
198
+ hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(style)
199
+ hmStyle._borderRightColor = color
200
+ break
201
+ }
202
+ case 'borderBottom': {
203
+ const [width, style, color] = value.split(' ')
204
+ hmStyle._borderBottomWidth = getUnit(width)
205
+ hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(style)
206
+ hmStyle._borderBottomColor = color
207
+ break
208
+ }
209
+ case 'borderLeft': {
210
+ const [width, style, color] = value.split(' ')
211
+ hmStyle._borderLeftWidth = getUnit(width)
212
+ hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(style)
213
+ hmStyle._borderLeftColor = color
214
+ break
215
+ }
216
+ case 'borderWidth': {
217
+ hmStyle._borderTopWidth = getUnit(value)
218
+ hmStyle._borderRightWidth = getUnit(value)
219
+ hmStyle._borderBottomWidth = getUnit(value)
220
+ hmStyle._borderLeftWidth = getUnit(value)
221
+ break
222
+ }
223
+ case 'borderLeftWidth': {
224
+ hmStyle._borderLeftWidth = getUnit(value)
225
+ break
226
+ }
227
+ case 'borderRightWidth': {
228
+ hmStyle._borderRightWidth = getUnit(value)
229
+ break
230
+ }
231
+ case 'borderTopWidth': {
232
+ hmStyle._borderTopWidth = getUnit(value)
233
+ break
234
+ }
235
+ case 'borderBottomWidth': {
236
+ hmStyle._borderBottomWidth = getUnit(value)
237
+ break
238
+ }
239
+ case 'borderStyle': {
240
+ hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(value)
241
+ hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(value)
242
+ hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(value)
243
+ hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(value)
244
+ break
245
+ }
246
+ case 'borderLeftStyle': {
247
+ hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(value)
248
+ break
249
+ }
250
+ case 'borderRightStyle': {
251
+ hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(value)
252
+ break
253
+ }
254
+ case 'borderTopStyle': {
255
+ hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(value)
256
+ break
257
+ }
258
+ case 'borderBottomStyle': {
259
+ hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(value)
260
+ break
261
+ }
262
+ case 'borderColor': {
263
+ hmStyle._borderTopColor = value
264
+ hmStyle._borderRightColor = value
265
+ hmStyle._borderBottomColor = value
266
+ hmStyle._borderLeftColor = value
267
+ break
268
+ }
269
+ case 'borderLeftColor': {
270
+ hmStyle._borderLeftColor = value
271
+ break
272
+ }
273
+ case 'borderRightColor': {
274
+ hmStyle._borderRightColor = value
275
+ break
276
+ }
277
+ case 'borderTopColor': {
278
+ hmStyle._borderTopColor = value
279
+ break
280
+ }
281
+ case 'borderBottomColor': {
282
+ hmStyle._borderBottomColor = value
283
+ break
284
+ }
285
+ case 'borderRadius': {
286
+ hmStyle._borderTopLeftRadius = getUnit(value)
287
+ hmStyle._borderTopRightRadius = getUnit(value)
288
+ hmStyle._borderBottomLeftRadius = getUnit(value)
289
+ hmStyle._borderBottomRightRadius = getUnit(value)
290
+ break
291
+ }
292
+ case 'borderTopLeftRadius': {
293
+ hmStyle._borderTopLeftRadius = getUnit(value)
294
+ break
295
+ }
296
+ case 'borderTopRightRadius': {
297
+ hmStyle._borderTopRightRadius = getUnit(value)
298
+ break
299
+ }
300
+ case 'borderBottomLeftRadius': {
301
+ hmStyle._borderBottomLeftRadius = getUnit(value)
302
+ break
303
+ }
304
+ case 'borderBottomRightRadius': {
305
+ hmStyle._borderBottomRightRadius = getUnit(value)
306
+ break
307
+ }
308
+ case 'color': {
309
+ hmStyle._color = value
310
+ break
311
+ }
312
+ case 'fontSize': {
313
+ hmStyle._fontSize = getUnit(value)
314
+ break
315
+ }
316
+ case 'fontWeight': {
317
+ setFontWeight(hmStyle, value)
318
+ break
319
+ }
320
+ case 'fontStyle': {
321
+ switch (value) {
322
+ case 'italic':
323
+ hmStyle._fontStyle = FontStyle.Italic
324
+ break
325
+ default:
326
+ hmStyle._fontStyle = FontStyle.Normal
327
+ }
328
+ break
329
+ }
330
+ case 'textAlign': {
331
+ switch (value) {
332
+ case 'left':
333
+ hmStyle._textAlign = TextAlign.Start
334
+ break
335
+ case 'center':
336
+ hmStyle._textAlign = TextAlign.Center
337
+ break
338
+ case 'right':
339
+ hmStyle._textAlign = TextAlign.End
340
+ break
341
+ default:
342
+ hmStyle._textAlign = TextAlign.Start
343
+ break
344
+ }
345
+ break
346
+ }
347
+ case 'lineHeight': {
348
+ hmStyle._lineHeight = getUnit(value)
349
+ break
350
+ }
351
+ case 'letterSpacing': {
352
+ hmStyle._letterSpacing = getUnit(value)
353
+ break
354
+ }
355
+ case 'textDecoration': {
356
+ if (typeof value === 'string') {
357
+ switch (value) {
358
+ case 'underline': hmStyle._textDecoration = TextDecorationType.Underline; break
359
+ case 'overline': hmStyle._textDecoration = TextDecorationType.Overline; break
360
+ case 'line-through': hmStyle._textDecoration = TextDecorationType.LineThrough; break
361
+ default: hmStyle._textDecoration = TextDecorationType.None; break
362
+ }
363
+ }
364
+ break
365
+ }
366
+ case 'textOverflow': {
367
+ if (typeof value === 'string') {
368
+ let overflow = TextOverflow.None
369
+ switch (value) {
370
+ case 'clip': overflow = TextOverflow.Clip; break
371
+ case 'ellipsis': overflow = TextOverflow.Ellipsis; break
372
+ case 'marquee': overflow = TextOverflow.MARQUEE; break
373
+ }
374
+ hmStyle._textOverflow = {
375
+ overflow
376
+ }
377
+ }
378
+ break
379
+ }
380
+ case 'WebkitLineClamp': {
381
+ hmStyle._WebkitLineClamp = Number(value)
382
+ break
383
+ }
384
+ case 'transform': {
385
+ hmStyle._transform = parseTransform(value)
386
+ break
387
+ }
388
+ default: {
389
+ hmStyle[key] = value
390
+ break
391
+ }
392
+ }
393
+ })
394
+ return hmStyle
395
+ }
396
+
397
+ function setBackgroundImage(hmStyle, value) {
398
+ if (typeof value === 'string' && value.indexOf('url(') !== -1 && value.indexOf(')') !== -1) {
399
+ // 如果包含 url(),则说明是 background-image 属性
400
+ const match = value.match(new RegExp('url\\([\'"]?(.*?)[\'"]?\\)'))
401
+ if (match) {
402
+ hmStyle._backgroundImage = [{
403
+ src: match[1]
404
+ }]
405
+ }
406
+ }
407
+ }
408
+
409
+ function setBackgroundRepeat(hmStyle, value) {
410
+ if (typeof value === 'string') {
411
+ switch (value) {
412
+ case 'repeat-x': hmStyle._backgroundRepeat = [ImageRepeat.X]; break
413
+ case 'repeat-y': hmStyle._backgroundRepeat = [ImageRepeat.Y]; break
414
+ case 'no-repeat': hmStyle._backgroundRepeat = [ImageRepeat.NoRepeat]; break
415
+ default: hmStyle._backgroundRepeat = [ImageRepeat.XY]; break
416
+ }
417
+ }
418
+ }
419
+
420
+ function setBackgroundSize(hmStyle, value) {
421
+ if (typeof value === 'string') {
422
+ const sizes = value.split(' ')
423
+ if (sizes.length === 1) {
424
+ hmStyle._backgroundSize = [{ width: getUnit(sizes[0]) }]
425
+ } else if (sizes.length === 2) {
426
+ hmStyle._backgroundSize = [{ width: getUnit(sizes[0]), height: getUnit(sizes[1]) }]
427
+ }
428
+ }
429
+ }
430
+
431
+ function setBackgroundPosistion (hmStyle, value) {
432
+ if (typeof value === 'string') {
433
+ const positions = value.split(' ')
434
+ const horizontal = positions[0].toLowerCase()
435
+ const vertical = positions[1].toLowerCase() || 'top'
436
+
437
+ if (horizontal === 'left' && vertical === 'top') {
438
+ hmStyle._backgroundPosition = [Alignment.TopStart]
439
+ } else if (horizontal === 'center' && vertical === 'top') {
440
+ hmStyle._backgroundPosition = [Alignment.Top]
441
+ } else if (horizontal === 'right' && vertical === 'top') {
442
+ hmStyle._backgroundPosition = [Alignment.TopEnd]
443
+ } else if (horizontal === 'left' && vertical === 'center') {
444
+ hmStyle._backgroundPosition = [Alignment.Start]
445
+ } else if (horizontal === 'center' && vertical === 'center') {
446
+ hmStyle._backgroundPosition = [Alignment.Center]
447
+ } else if (horizontal === 'right' && vertical === 'center') {
448
+ hmStyle._backgroundPosition = [Alignment.End]
449
+ } else if (horizontal === 'left' && vertical === 'bottom') {
450
+ hmStyle._backgroundPosition = [Alignment.BottomStart]
451
+ } else if (horizontal === 'center' && vertical === 'bottom') {
452
+ hmStyle._backgroundPosition = [Alignment.Bottom]
453
+ } else if (horizontal === 'right' && vertical === 'bottom') {
454
+ hmStyle._backgroundPosition = [Alignment.BottomEnd]
455
+ } else {
456
+ if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
457
+ hmStyle._backgroundPosition = [{ x: getUnit(horizontal) }]
458
+ if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
459
+ hmStyle._backgroundPosition = [{ x: getUnit(horizontal), y: getUnit(vertical) }]
460
+ }
461
+ }
462
+ }
463
+ }
464
+ }
465
+
466
+ function setFontWeight (hmStyle, value) {
467
+ switch (value) {
468
+ case 'normal': hmStyle._fontWeight = FontWeight.Normal; break
469
+ case 'bold': hmStyle._fontWeight = FontWeight.Bold; break
470
+ case 'bolder': hmStyle._fontWeight = FontWeight.Bolder; break
471
+ case 'lighter': hmStyle._fontWeight = FontWeight.Lighter; break
472
+ default: hmStyle._fontWeight = Number(value); break
473
+ }
474
+ }
475
+
476
+ function parseTransform(transformString) {
477
+ const transformRegex = /(\w+)\(([^)]+)\)/g
478
+ const transforms = []
479
+
480
+ let matchs
481
+ while ((matchs = transformRegex.exec(transformString)) !== null) {
482
+ const [, type, valueString] = matchs
483
+ const values = valueString.split(/\s*,\s*/).map(parseFloat)
484
+
485
+ const transformObj = {
486
+ type: capitalizeFirstLetter(type),
487
+ value: {}
488
+ }
489
+
490
+ switch (type) {
491
+ case 'translate':
492
+ case 'translate3d':
493
+ transformObj.value.x = parseFloat(getUnit(values[0])) || 0
494
+ transformObj.value.y = parseFloat(getUnit(values[1])) || 0
495
+ transformObj.value.z = parseFloat(getUnit(values[2])) || 0
496
+ break
497
+ case 'translateX':
498
+ transformObj.value.x = parseFloat(getUnit(values[0])) || 0
499
+ break
500
+ case 'translateY':
501
+ transformObj.value.y = parseFloat(getUnit(values[0])) || 0
502
+ break
503
+ case 'translateZ':
504
+ transformObj.value.z = parseFloat(getUnit(values[0])) || 0
505
+ break
506
+ case 'rotate':
507
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
508
+ transformObj.value.x = 0
509
+ transformObj.value.y = 0
510
+ transformObj.value.z = 1
511
+ break
512
+ case 'rotate3d':
513
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
514
+ transformObj.value.x = values[1] || 0
515
+ transformObj.value.y = values[2] || 0
516
+ transformObj.value.z = values[3] || 0
517
+ break
518
+ case 'rotateX':
519
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
520
+ transformObj.value.x = 1
521
+ transformObj.value.y = 0
522
+ transformObj.value.z = 0
523
+ break
524
+ case 'rotateY':
525
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
526
+ transformObj.value.x = 0
527
+ transformObj.value.y = 1
528
+ transformObj.value.z = 0
529
+ break
530
+ case 'scale':
531
+ case 'scale3d':
532
+ transformObj.value.x = values[0] || 1
533
+ transformObj.value.y = values[1] || values[0] || 1
534
+ transformObj.value.z = values[2] || 1
535
+ break
536
+ case 'scaleX':
537
+ transformObj.value.x = values[0] || 1
538
+ break
539
+ case 'scaleY':
540
+ transformObj.value.y = values[0] || 1
541
+ break
542
+ default:
543
+ // Handle unrecognized transform types or ignore them
544
+ break
545
+ }
546
+
547
+ transforms.push(transformObj)
548
+ }
549
+
550
+ return transforms
551
+ }