@tarojs/plugin-platform-harmony-ets 4.0.0-beta.0 → 4.0.0-beta.10

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 (78) hide show
  1. package/dist/apis/device/memory.ts +10 -3
  2. package/dist/apis/index.ts +2 -0
  3. package/dist/apis/media/video/VideoContext.ts +56 -7
  4. package/dist/apis/media/video/index.ts +3 -2
  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/wxml/index.ts +2 -0
  9. package/dist/components-harmony-ets/button.ets +26 -40
  10. package/dist/components-harmony-ets/checkbox.ets +70 -99
  11. package/dist/components-harmony-ets/form.ets +29 -42
  12. package/dist/components-harmony-ets/icon.ets +6 -34
  13. package/dist/components-harmony-ets/image.ets +2 -32
  14. package/dist/components-harmony-ets/innerHtml.ets +2 -2
  15. package/dist/components-harmony-ets/input.ets +7 -27
  16. package/dist/components-harmony-ets/label.ets +40 -47
  17. package/dist/components-harmony-ets/picker.ets +66 -73
  18. package/dist/components-harmony-ets/radio.ets +72 -101
  19. package/dist/components-harmony-ets/richText.ets +4 -36
  20. package/dist/components-harmony-ets/scrollView.ets +34 -74
  21. package/dist/components-harmony-ets/slider.ets +9 -34
  22. package/dist/components-harmony-ets/style.ets +154 -0
  23. package/dist/components-harmony-ets/swiper.ets +4 -34
  24. package/dist/components-harmony-ets/switch.ets +43 -56
  25. package/dist/components-harmony-ets/text.ets +7 -34
  26. package/dist/components-harmony-ets/textArea.ets +8 -28
  27. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  28. package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
  29. package/dist/components-harmony-ets/utils/helper.ets +2 -2
  30. package/dist/components-harmony-ets/utils/styles.ets +58 -20
  31. package/dist/components-harmony-ets/video.ets +4 -34
  32. package/dist/components-harmony-ets/view.ets +25 -67
  33. package/dist/components-harmony-ets/webView.ets +50 -0
  34. package/dist/index.js +103 -5
  35. package/dist/index.js.map +1 -1
  36. package/dist/runtime-ets/bom/window.ts +2 -2
  37. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
  38. package/dist/runtime-ets/dom/document.ts +21 -4
  39. package/dist/runtime-ets/dom/element/element.ts +1 -0
  40. package/dist/runtime-ets/dom/element/form.ts +11 -2
  41. package/dist/runtime-ets/dom/element/index.ts +4 -1
  42. package/dist/runtime-ets/dom/element/normal.ts +1 -0
  43. package/dist/runtime-ets/dom/element/webView.ts +61 -0
  44. package/dist/runtime-ets/dom/node.ts +29 -16
  45. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
  46. package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
  47. package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
  48. package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
  49. package/dist/runtime-ets/index.ts +1 -2
  50. package/dist/runtime-ets/interface/event.ts +2 -1
  51. package/dist/runtime-ets/utils/index.ts +6 -1
  52. package/dist/runtime-ets/utils/info.ts +3 -1
  53. package/dist/runtime-framework/react/app.ts +12 -22
  54. package/dist/runtime-framework/react/hooks.ts +3 -3
  55. package/dist/runtime-framework/react/index.ts +1 -0
  56. package/dist/runtime-framework/react/native-page.ts +344 -0
  57. package/dist/runtime-framework/react/page.ts +2 -2
  58. package/dist/runtime-framework/solid/hooks.ts +3 -3
  59. package/dist/runtime-utils.js +181 -80
  60. package/dist/runtime-utils.js.map +1 -1
  61. package/dist/runtime.js +181 -80
  62. package/dist/runtime.js.map +1 -1
  63. package/package.json +12 -11
  64. package/static/media/cancel.svg +1 -0
  65. package/static/media/circle.svg +1 -0
  66. package/static/media/clear.svg +1 -0
  67. package/static/media/download.svg +1 -0
  68. package/static/media/info.svg +1 -0
  69. package/static/media/info_circle.svg +1 -0
  70. package/static/media/search.svg +1 -0
  71. package/static/media/success.svg +1 -0
  72. package/static/media/success_no_circle.svg +1 -0
  73. package/static/media/taro_arrow_left.svg +1 -0
  74. package/static/media/taro_home.svg +1 -0
  75. package/static/media/waiting.svg +1 -0
  76. package/static/media/warn.svg +1 -0
  77. package/types/runtime.d.ts +2 -0
  78. package/dist/runtime-ets/utils/bind.ts +0 -24
@@ -0,0 +1,624 @@
1
+ // @ts-nocheck
2
+
3
+ import { CSSProperties } from 'react'
4
+
5
+ import { BORDER_STYLE_MAP, capitalizeFirstLetter, FlexManager, getNodeMarginOrPaddingData, getUnit } from './util'
6
+
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> = {}
83
+ Object.keys(webStyle).forEach((key) => {
84
+ const value = webStyle[key]
85
+ switch (key) {
86
+ case 'padding': {
87
+ const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
88
+ hmStyle._paddingTop = top
89
+ hmStyle._paddingBottom = bottom
90
+ hmStyle._paddingLeft = left
91
+ hmStyle._paddingRight = right
92
+ break
93
+ }
94
+ case 'paddingTop': {
95
+ hmStyle._paddingTop = getUnit(value)
96
+ break
97
+ }
98
+ case 'paddingBottom': {
99
+ hmStyle._paddingBottom = getUnit(value)
100
+ break
101
+ }
102
+ case 'paddingLeft': {
103
+ hmStyle._paddingLeft = getUnit(value)
104
+ break
105
+ }
106
+ case 'paddingRight': {
107
+ hmStyle._paddingRight = getUnit(value)
108
+ break
109
+ }
110
+ case 'margin': {
111
+ const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
112
+ hmStyle._marginTop = top
113
+ hmStyle._marginBottom = bottom
114
+ hmStyle._marginLeft = left
115
+ hmStyle._marginRight = right
116
+ break
117
+ }
118
+ case 'marginTop': {
119
+ hmStyle._marginTop = getUnit(value)
120
+ break
121
+ }
122
+ case 'marginBottom': {
123
+ hmStyle._marginBottom = getUnit(value)
124
+ break
125
+ }
126
+ case 'marginLeft': {
127
+ hmStyle._marginLeft = getUnit(value)
128
+ break
129
+ }
130
+ case 'marginRight': {
131
+ hmStyle._marginRight = getUnit(value)
132
+ break
133
+ }
134
+ case 'top': {
135
+ hmStyle._top = getUnit(value)
136
+ break
137
+ }
138
+ case 'left': {
139
+ hmStyle._left = getUnit(value)
140
+ break
141
+ }
142
+ case 'flex': {
143
+ let res: [number, number, number | string] = [0, 0, 'auto']
144
+ if (typeof value === 'number') {
145
+ res = [value, 1, 0]
146
+ } else if (value === 'auto') {
147
+ res = [1, 1, 'auto']
148
+ } else if (value === 'none') {
149
+ res = [0, 0, 'auto']
150
+ } else if (typeof value === 'string') {
151
+ const FlexList = value.replace(new RegExp('/\\s+/g'), ' ').split(' ')
152
+ FlexList.forEach((item, index) => {
153
+ res[index] = index < 2 ? Number(item) : item
154
+ })
155
+ }
156
+ hmStyle._flexGrow = getUnit(res[0])
157
+ hmStyle._flexShrink = Number(res[1])
158
+ hmStyle._flexBasis = Number(res[2])
159
+ break
160
+ }
161
+ case 'flexGrow': {
162
+ hmStyle._flexGrow = getUnit(value)
163
+ break
164
+ }
165
+ case 'flexShrink': {
166
+ hmStyle._flexShrink = Number(value)
167
+ break
168
+ }
169
+ case 'flexBasis': {
170
+ hmStyle._flexBasis = Number(value)
171
+ break
172
+ }
173
+ case 'alignSelf': {
174
+ hmStyle._alignSelf = FlexManager.itemAlign(value)
175
+ break
176
+ }
177
+ case 'flexDirection': {
178
+ hmStyle._flexDirection = FlexManager.direction(value)
179
+ break
180
+ }
181
+ case 'justifyContent': {
182
+ hmStyle._justifyContent = FlexManager.flexAlign(value)
183
+ break
184
+ }
185
+ case 'alignItems': {
186
+ hmStyle._alignItems = FlexManager.itemAlign(value)
187
+ break
188
+ }
189
+ case 'alignContent': {
190
+ hmStyle._alignContent = FlexManager.flexAlign(value)
191
+ break
192
+ }
193
+ case 'flexWrap': {
194
+ hmStyle._flexWrap = FlexManager.flexWrap(value)
195
+ break
196
+ }
197
+ case 'width': {
198
+ hmStyle._width = getUnit(value)
199
+ break
200
+ }
201
+ case 'height': {
202
+ hmStyle._height = getUnit(value)
203
+ break
204
+ }
205
+ case 'minWidth': {
206
+ hmStyle._minWidth = getUnit(value)
207
+ break
208
+ }
209
+ case 'minHeight': {
210
+ hmStyle._minHeight = getUnit(value)
211
+ break
212
+ }
213
+ case 'maxWidth': {
214
+ hmStyle._maxWidth = getUnit(value)
215
+ break
216
+ }
217
+ case 'maxHeight': {
218
+ hmStyle._maxHeight = getUnit(value)
219
+ break
220
+ }
221
+ case 'background': {
222
+ // TODO: 暂未实现
223
+ break
224
+ }
225
+ case 'backgroundColor': {
226
+ hmStyle._backgroundColor = value
227
+ break
228
+ }
229
+ case 'backgroundImage': {
230
+ setBackgroundImage(hmStyle, value)
231
+ break
232
+ }
233
+ case 'backgroundRepeat': {
234
+ setBackgroundRepeat(hmStyle, value)
235
+ break
236
+ }
237
+ case 'backgroundSize': {
238
+ setBackgroundSize(hmStyle, value)
239
+ break
240
+ }
241
+ case 'backgroundPosition': {
242
+ setBackgroundPosistion(hmStyle, value)
243
+ break
244
+ }
245
+ case 'border': {
246
+ 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
259
+ break
260
+ }
261
+ case 'borderTop': {
262
+ const [width, style, color] = value.split(' ')
263
+ hmStyle._borderTopWidth = getUnit(width)
264
+ hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(style)
265
+ hmStyle._borderTopColor = color
266
+ break
267
+ }
268
+ case 'borderRight': {
269
+ const [width, style, color] = value.split(' ')
270
+ hmStyle._borderRightWidth = getUnit(width)
271
+ hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(style)
272
+ hmStyle._borderRightColor = color
273
+ break
274
+ }
275
+ case 'borderBottom': {
276
+ const [width, style, color] = value.split(' ')
277
+ hmStyle._borderBottomWidth = getUnit(width)
278
+ hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(style)
279
+ hmStyle._borderBottomColor = color
280
+ break
281
+ }
282
+ case 'borderLeft': {
283
+ const [width, style, color] = value.split(' ')
284
+ hmStyle._borderLeftWidth = getUnit(width)
285
+ hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(style)
286
+ hmStyle._borderLeftColor = color
287
+ break
288
+ }
289
+ case 'borderWidth': {
290
+ hmStyle._borderTopWidth = getUnit(value)
291
+ hmStyle._borderRightWidth = getUnit(value)
292
+ hmStyle._borderBottomWidth = getUnit(value)
293
+ hmStyle._borderLeftWidth = getUnit(value)
294
+ break
295
+ }
296
+ case 'borderLeftWidth': {
297
+ hmStyle._borderLeftWidth = getUnit(value)
298
+ break
299
+ }
300
+ case 'borderRightWidth': {
301
+ hmStyle._borderRightWidth = getUnit(value)
302
+ break
303
+ }
304
+ case 'borderTopWidth': {
305
+ hmStyle._borderTopWidth = getUnit(value)
306
+ break
307
+ }
308
+ case 'borderBottomWidth': {
309
+ hmStyle._borderBottomWidth = getUnit(value)
310
+ break
311
+ }
312
+ 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)
317
+ break
318
+ }
319
+ case 'borderLeftStyle': {
320
+ hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(value)
321
+ break
322
+ }
323
+ case 'borderRightStyle': {
324
+ hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(value)
325
+ break
326
+ }
327
+ case 'borderTopStyle': {
328
+ hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(value)
329
+ break
330
+ }
331
+ case 'borderBottomStyle': {
332
+ hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(value)
333
+ break
334
+ }
335
+ case 'borderColor': {
336
+ hmStyle._borderTopColor = value
337
+ hmStyle._borderRightColor = value
338
+ hmStyle._borderBottomColor = value
339
+ hmStyle._borderLeftColor = value
340
+ break
341
+ }
342
+ case 'borderLeftColor': {
343
+ hmStyle._borderLeftColor = value
344
+ break
345
+ }
346
+ case 'borderRightColor': {
347
+ hmStyle._borderRightColor = value
348
+ break
349
+ }
350
+ case 'borderTopColor': {
351
+ hmStyle._borderTopColor = value
352
+ break
353
+ }
354
+ case 'borderBottomColor': {
355
+ hmStyle._borderBottomColor = value
356
+ break
357
+ }
358
+ case 'borderRadius': {
359
+ hmStyle._borderTopLeftRadius = getUnit(value)
360
+ hmStyle._borderTopRightRadius = getUnit(value)
361
+ hmStyle._borderBottomLeftRadius = getUnit(value)
362
+ hmStyle._borderBottomRightRadius = getUnit(value)
363
+ break
364
+ }
365
+ case 'borderTopLeftRadius': {
366
+ hmStyle._borderTopLeftRadius = getUnit(value)
367
+ break
368
+ }
369
+ case 'borderTopRightRadius': {
370
+ hmStyle._borderTopRightRadius = getUnit(value)
371
+ break
372
+ }
373
+ case 'borderBottomLeftRadius': {
374
+ hmStyle._borderBottomLeftRadius = getUnit(value)
375
+ break
376
+ }
377
+ case 'borderBottomRightRadius': {
378
+ hmStyle._borderBottomRightRadius = getUnit(value)
379
+ break
380
+ }
381
+ case 'color': {
382
+ hmStyle._color = value
383
+ break
384
+ }
385
+ case 'fontSize': {
386
+ hmStyle._fontSize = getUnit(value)
387
+ break
388
+ }
389
+ case 'fontWeight': {
390
+ setFontWeight(hmStyle, value)
391
+ break
392
+ }
393
+ case 'fontStyle': {
394
+ switch (value) {
395
+ case 'italic':
396
+ hmStyle._fontStyle = FontStyle.Italic
397
+ break
398
+ default:
399
+ hmStyle._fontStyle = FontStyle.Normal
400
+ }
401
+ break
402
+ }
403
+ case 'textAlign': {
404
+ switch (value) {
405
+ case 'left':
406
+ hmStyle._textAlign = TextAlign.Start
407
+ break
408
+ case 'center':
409
+ hmStyle._textAlign = TextAlign.Center
410
+ break
411
+ case 'right':
412
+ hmStyle._textAlign = TextAlign.End
413
+ break
414
+ default:
415
+ hmStyle._textAlign = TextAlign.Start
416
+ break
417
+ }
418
+ break
419
+ }
420
+ case 'lineHeight': {
421
+ hmStyle._lineHeight = getUnit(value)
422
+ break
423
+ }
424
+ case 'letterSpacing': {
425
+ hmStyle._letterSpacing = getUnit(value)
426
+ break
427
+ }
428
+ case 'textDecoration': {
429
+ if (typeof value === 'string') {
430
+ 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
435
+ }
436
+ }
437
+ break
438
+ }
439
+ case 'textOverflow': {
440
+ if (typeof value === 'string') {
441
+ let overflow = TextOverflow.None
442
+ switch (value) {
443
+ case 'clip': overflow = TextOverflow.Clip; break
444
+ case 'ellipsis': overflow = TextOverflow.Ellipsis; break
445
+ case 'marquee': overflow = TextOverflow.MARQUEE; break
446
+ }
447
+ hmStyle._textOverflow = {
448
+ overflow
449
+ }
450
+ }
451
+ break
452
+ }
453
+ case 'WebkitLineClamp': {
454
+ hmStyle._WebkitLineClamp = Number(value)
455
+ break
456
+ }
457
+ case 'transform': {
458
+ hmStyle._transform = parseTransform(value)
459
+ break
460
+ }
461
+ default: {
462
+ hmStyle[key] = value
463
+ break
464
+ }
465
+ }
466
+ })
467
+ return hmStyle
468
+ }
469
+
470
+ function setBackgroundImage(hmStyle, value) {
471
+ if (typeof value === 'string' && value.indexOf('url(') !== -1 && value.indexOf(')') !== -1) {
472
+ // 如果包含 url(),则说明是 background-image 属性
473
+ const match = value.match(new RegExp('url\\([\'"]?(.*?)[\'"]?\\)'))
474
+ if (match) {
475
+ hmStyle._backgroundImage = [{
476
+ src: match[1]
477
+ }]
478
+ }
479
+ }
480
+ }
481
+
482
+ function setBackgroundRepeat(hmStyle, value) {
483
+ if (typeof value === 'string') {
484
+ 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
489
+ }
490
+ }
491
+ }
492
+
493
+ function setBackgroundSize(hmStyle, value) {
494
+ if (typeof value === 'string') {
495
+ const sizes = value.split(' ')
496
+ if (sizes.length === 1) {
497
+ hmStyle._backgroundSize = [{ width: getUnit(sizes[0]) }]
498
+ } else if (sizes.length === 2) {
499
+ hmStyle._backgroundSize = [{ width: getUnit(sizes[0]), height: getUnit(sizes[1]) }]
500
+ }
501
+ }
502
+ }
503
+
504
+ function setBackgroundPosistion (hmStyle, value) {
505
+ if (typeof value === 'string') {
506
+ const positions = value.split(' ')
507
+ const horizontal = positions[0].toLowerCase()
508
+ const vertical = positions[1].toLowerCase() || 'top'
509
+
510
+ if (horizontal === 'left' && vertical === 'top') {
511
+ hmStyle._backgroundPosition = [Alignment.TopStart]
512
+ } else if (horizontal === 'center' && vertical === 'top') {
513
+ hmStyle._backgroundPosition = [Alignment.Top]
514
+ } else if (horizontal === 'right' && vertical === 'top') {
515
+ hmStyle._backgroundPosition = [Alignment.TopEnd]
516
+ } else if (horizontal === 'left' && vertical === 'center') {
517
+ hmStyle._backgroundPosition = [Alignment.Start]
518
+ } else if (horizontal === 'center' && vertical === 'center') {
519
+ hmStyle._backgroundPosition = [Alignment.Center]
520
+ } else if (horizontal === 'right' && vertical === 'center') {
521
+ hmStyle._backgroundPosition = [Alignment.End]
522
+ } else if (horizontal === 'left' && vertical === 'bottom') {
523
+ hmStyle._backgroundPosition = [Alignment.BottomStart]
524
+ } else if (horizontal === 'center' && vertical === 'bottom') {
525
+ hmStyle._backgroundPosition = [Alignment.Bottom]
526
+ } else if (horizontal === 'right' && vertical === 'bottom') {
527
+ hmStyle._backgroundPosition = [Alignment.BottomEnd]
528
+ } else {
529
+ if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
530
+ hmStyle._backgroundPosition = [{ x: getUnit(horizontal) }]
531
+ if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
532
+ hmStyle._backgroundPosition = [{ x: getUnit(horizontal), y: getUnit(vertical) }]
533
+ }
534
+ }
535
+ }
536
+ }
537
+ }
538
+
539
+ function setFontWeight (hmStyle, value) {
540
+ 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
546
+ }
547
+ }
548
+
549
+ function parseTransform(transformString) {
550
+ const transformRegex = /(\w+)\(([^)]+)\)/g
551
+ const transforms = []
552
+
553
+ let matchs
554
+ while ((matchs = transformRegex.exec(transformString)) !== null) {
555
+ const [, type, valueString] = matchs
556
+ const values = valueString.split(/\s*,\s*/).map(parseFloat)
557
+
558
+ const transformObj = {
559
+ type: capitalizeFirstLetter(type),
560
+ value: {}
561
+ }
562
+
563
+ switch (type) {
564
+ case 'translate':
565
+ case 'translate3d':
566
+ transformObj.value.x = parseFloat(getUnit(values[0])) || 0
567
+ transformObj.value.y = parseFloat(getUnit(values[1])) || 0
568
+ transformObj.value.z = parseFloat(getUnit(values[2])) || 0
569
+ break
570
+ case 'translateX':
571
+ transformObj.value.x = parseFloat(getUnit(values[0])) || 0
572
+ break
573
+ case 'translateY':
574
+ transformObj.value.y = parseFloat(getUnit(values[0])) || 0
575
+ break
576
+ case 'translateZ':
577
+ transformObj.value.z = parseFloat(getUnit(values[0])) || 0
578
+ break
579
+ case 'rotate':
580
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
581
+ transformObj.value.x = 0
582
+ transformObj.value.y = 0
583
+ transformObj.value.z = 1
584
+ break
585
+ case 'rotate3d':
586
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
587
+ transformObj.value.x = values[1] || 0
588
+ transformObj.value.y = values[2] || 0
589
+ transformObj.value.z = values[3] || 0
590
+ break
591
+ case 'rotateX':
592
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
593
+ transformObj.value.x = 1
594
+ transformObj.value.y = 0
595
+ transformObj.value.z = 0
596
+ break
597
+ case 'rotateY':
598
+ transformObj.value.angle = parseFloat(getUnit(values[0])) || 0
599
+ transformObj.value.x = 0
600
+ transformObj.value.y = 1
601
+ transformObj.value.z = 0
602
+ break
603
+ case 'scale':
604
+ case 'scale3d':
605
+ transformObj.value.x = values[0] || 1
606
+ transformObj.value.y = values[1] || values[0] || 1
607
+ transformObj.value.z = values[2] || 1
608
+ break
609
+ case 'scaleX':
610
+ transformObj.value.x = values[0] || 1
611
+ break
612
+ case 'scaleY':
613
+ transformObj.value.y = values[0] || 1
614
+ break
615
+ default:
616
+ // Handle unrecognized transform types or ignore them
617
+ break
618
+ }
619
+
620
+ transforms.push(transformObj)
621
+ }
622
+
623
+ return transforms
624
+ }