@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.3
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/dist/apis/device/memory.ts +10 -3
- package/dist/apis/index.ts +2 -0
- package/dist/apis/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +26 -40
- package/dist/components-harmony-ets/checkbox.ets +70 -99
- package/dist/components-harmony-ets/form.ets +29 -42
- package/dist/components-harmony-ets/icon.ets +6 -34
- package/dist/components-harmony-ets/image.ets +2 -32
- package/dist/components-harmony-ets/innerHtml.ets +2 -2
- package/dist/components-harmony-ets/input.ets +7 -27
- package/dist/components-harmony-ets/label.ets +40 -47
- package/dist/components-harmony-ets/picker.ets +66 -73
- package/dist/components-harmony-ets/radio.ets +72 -101
- package/dist/components-harmony-ets/richText.ets +4 -36
- package/dist/components-harmony-ets/scrollView.ets +34 -74
- package/dist/components-harmony-ets/slider.ets +9 -34
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +4 -34
- package/dist/components-harmony-ets/switch.ets +43 -56
- package/dist/components-harmony-ets/text.ets +7 -34
- package/dist/components-harmony-ets/textArea.ets +8 -28
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
- package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
- package/dist/components-harmony-ets/utils/helper.ets +2 -2
- package/dist/components-harmony-ets/utils/styles.ets +58 -20
- package/dist/components-harmony-ets/video.ets +4 -34
- package/dist/components-harmony-ets/view.ets +25 -67
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
- package/dist/runtime-ets/dom/document.ts +21 -4
- package/dist/runtime-ets/dom/element/element.ts +1 -0
- package/dist/runtime-ets/dom/element/form.ts +11 -2
- package/dist/runtime-ets/dom/element/index.ts +4 -1
- package/dist/runtime-ets/dom/element/normal.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +61 -0
- package/dist/runtime-ets/dom/node.ts +29 -16
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
- package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
- package/dist/runtime-ets/index.ts +1 -2
- package/dist/runtime-ets/interface/event.ts +2 -1
- package/dist/runtime-ets/utils/index.ts +6 -1
- package/dist/runtime-ets/utils/info.ts +3 -1
- package/dist/runtime-framework/react/app.ts +12 -22
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/index.ts +1 -0
- package/dist/runtime-framework/react/native-page.ts +344 -0
- package/dist/runtime-framework/react/page.ts +2 -2
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-utils.js +76 -20
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +76 -20
- package/dist/runtime.js.map +1 -1
- package/package.json +12 -11
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/runtime.d.ts +2 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
|
@@ -1,38 +1,12 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
|
|
4
5
|
|
|
5
6
|
import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
@Extend(TextArea)
|
|
8
9
|
function textStyle (style: TaroStyleType) {
|
|
9
|
-
.id(style.id)
|
|
10
|
-
.key(style.id)
|
|
11
|
-
.padding(style.padding)
|
|
12
|
-
.margin(style.margin)
|
|
13
|
-
.width(style.width)
|
|
14
|
-
.height(style.height)
|
|
15
|
-
.constraintSize(style.constraintSize)
|
|
16
|
-
.flexGrow(style.flexGrow)
|
|
17
|
-
.flexShrink(style.flexShrink)
|
|
18
|
-
.flexBasis(style.flexBasis)
|
|
19
|
-
.alignSelf(style.alignSelf)
|
|
20
|
-
.backgroundColor(style.backgroundColor)
|
|
21
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
22
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
24
|
-
.rotate(style.rotate)
|
|
25
|
-
.scale(style.scale)
|
|
26
|
-
.translate(style.translate)
|
|
27
|
-
.transform(style.transform)
|
|
28
|
-
.borderStyle(style.borderStyle)
|
|
29
|
-
.borderWidth(style.borderWidth)
|
|
30
|
-
.borderColor(style.borderColor)
|
|
31
|
-
.borderRadius(style.borderRadius)
|
|
32
|
-
.linearGradient(style.linearGradient)
|
|
33
|
-
.zIndex(style.zIndex)
|
|
34
|
-
.opacity(style.opacity)
|
|
35
|
-
.clip(style.clip)
|
|
36
10
|
.fontColor(style.color)
|
|
37
11
|
.fontSize(style.fontSize)
|
|
38
12
|
.fontWeight(style.fontWeight)
|
|
@@ -43,7 +17,7 @@ function textStyle (style: TaroStyleType) {
|
|
|
43
17
|
@Extend(TextArea)
|
|
44
18
|
function textAttr(attr: TaroTextStyleType) {
|
|
45
19
|
.textAlign(attr.textAlign)
|
|
46
|
-
.maxLines(attr.
|
|
20
|
+
.maxLines(attr.WebkitLineClamp)
|
|
47
21
|
}
|
|
48
22
|
|
|
49
23
|
function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
@@ -62,6 +36,11 @@ export default struct TaroTextArea {
|
|
|
62
36
|
if (this.node) {
|
|
63
37
|
this.value = this.node.value
|
|
64
38
|
this.node._instance = this
|
|
39
|
+
|
|
40
|
+
if (!this.node._isInit) {
|
|
41
|
+
this.node._isInit = true
|
|
42
|
+
this.node._reset = this.node.value || ''
|
|
43
|
+
}
|
|
65
44
|
}
|
|
66
45
|
}
|
|
67
46
|
|
|
@@ -71,6 +50,7 @@ export default struct TaroTextArea {
|
|
|
71
50
|
.key(this.node._nid)
|
|
72
51
|
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
73
52
|
.placeholderColor(getPlaceholderColor(this.node))
|
|
53
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
74
54
|
.textStyle(getNormalAttributes(this.node))
|
|
75
55
|
.textAttr(getFontAttributes(this.node))
|
|
76
56
|
.onChange((value: string) => {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { bindAnimation } from './helper'
|
|
1
|
+
import { TaroAny, TaroElement } from '@tarojs/runtime'
|
|
4
2
|
|
|
5
3
|
export class DynamicCenter {
|
|
6
|
-
|
|
7
4
|
install (node: TaroElement, parentNode: TaroElement) {
|
|
8
5
|
if (!parentNode._isCompileMode) return
|
|
9
6
|
|
|
@@ -25,13 +22,7 @@ export class DynamicCenter {
|
|
|
25
22
|
const dynamicID = node._attrs?._dynamicID
|
|
26
23
|
|
|
27
24
|
// dynamicID 只是为了更新到精准的 node
|
|
28
|
-
|
|
29
|
-
initComponentNodeInfo(component, node)
|
|
30
|
-
bindInstanceToNode(node, component)
|
|
31
|
-
bindFocus(node)
|
|
32
|
-
bindAnimation(node)
|
|
33
|
-
bindScrollTo(node, component)
|
|
34
|
-
|
|
25
|
+
node._instance = component
|
|
35
26
|
node._isCompileMode = true
|
|
36
27
|
|
|
37
28
|
if (dynamicID) {
|
|
@@ -1,20 +1,58 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TaroElement } from '@tarojs/runtime'
|
|
2
|
+
import { isUndefined } from '@tarojs/shared'
|
|
3
|
+
|
|
4
|
+
interface IFlexOptions {
|
|
5
|
+
direction: FlexDirection,
|
|
6
|
+
justifyContent: FlexAlign,
|
|
7
|
+
alignItems: VerticalAlign | HorizontalAlign,
|
|
8
|
+
// Row 和 Column 不支持下面两个属性
|
|
9
|
+
// wrap: FlexWrap,
|
|
10
|
+
// alignContent: FlexAlignContent
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
class FlexManager {
|
|
4
|
-
static
|
|
14
|
+
static isFlexNode (node: TaroElement): boolean {
|
|
15
|
+
return !!node.hmStyle?.display?.includes('flex')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static convertFlexAlignItemsToColumnOrRow (direction: FlexDirection, alignItems: ItemAlign | undefined): VerticalAlign | HorizontalAlign {
|
|
19
|
+
if (direction === FlexDirection.Column) {
|
|
20
|
+
switch (alignItems) {
|
|
21
|
+
case ItemAlign.Start:
|
|
22
|
+
return HorizontalAlign.Start
|
|
23
|
+
case ItemAlign.End:
|
|
24
|
+
return HorizontalAlign.End
|
|
25
|
+
default:
|
|
26
|
+
return HorizontalAlign.Center
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
switch (alignItems) {
|
|
30
|
+
case ItemAlign.Start:
|
|
31
|
+
return VerticalAlign.Top
|
|
32
|
+
case ItemAlign.End:
|
|
33
|
+
return VerticalAlign.Bottom
|
|
34
|
+
default:
|
|
35
|
+
return VerticalAlign.Center
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static flexOptions (node: TaroElement): IFlexOptions {
|
|
5
41
|
const hmStyle = node.hmStyle
|
|
42
|
+
const isFlex = FlexManager.isFlexNode(node)
|
|
43
|
+
const justifyContent: FlexAlign = isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start
|
|
6
44
|
|
|
7
|
-
let flexDirection = hmStyle.
|
|
45
|
+
let flexDirection = hmStyle.flexDirection
|
|
8
46
|
if (!flexDirection && flexDirection !== 0) {
|
|
9
47
|
flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
|
|
10
48
|
}
|
|
11
49
|
|
|
50
|
+
const alignItems = isFlex ? FlexManager.convertFlexAlignItemsToColumnOrRow(flexDirection, hmStyle.alignItems) : HorizontalAlign.Start
|
|
51
|
+
|
|
12
52
|
return {
|
|
53
|
+
alignItems,
|
|
54
|
+
justifyContent,
|
|
13
55
|
direction: flexDirection,
|
|
14
|
-
justifyContent: hmStyle.justifyContent,
|
|
15
|
-
alignItems: hmStyle.alignItems,
|
|
16
|
-
wrap: hmStyle.flexWrap,
|
|
17
|
-
alignContent: hmStyle.alignContent,
|
|
18
56
|
}
|
|
19
57
|
}
|
|
20
58
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNormalAttributes, getFontAttributes } from './styles'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { TFunc } from '@tarojs/runtime/dist/runtime.esm'
|
|
4
4
|
import type { TaroElement } from '@tarojs/runtime'
|
|
5
5
|
|
|
6
6
|
export const parseStyles = (styles = ''): Record<string, string> => {
|
|
@@ -20,7 +20,7 @@ export const parseStyles = (styles = ''): Record<string, string> => {
|
|
|
20
20
|
return styleObj
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function shouldBindEvent (cb:
|
|
23
|
+
export function shouldBindEvent (cb: TFunc, node: TaroElement | null, eventNames: string[], disabled = false) {
|
|
24
24
|
if (!node || node._attrs?.disabled || disabled) return null
|
|
25
25
|
if (!node.__listeners) {
|
|
26
26
|
return null
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { isUndefined } from '@tarojs/shared'
|
|
1
2
|
import { ObjectAssign } from '@tarojs/runtime'
|
|
2
3
|
|
|
4
|
+
import { FlexManager } from './FlexManager'
|
|
3
5
|
import { TEXT_DEFAULT_STYLE } from './constant/style'
|
|
4
6
|
|
|
5
|
-
import type { StandardProps } from '@tarojs/components/types'
|
|
7
|
+
import type { StandardProps, TextProps } from '@tarojs/components/types'
|
|
6
8
|
import type { TaroAny, TaroElement, TaroStyleType, TaroTextStyleType, HarmonyType, HarmonyStyle } from '@tarojs/runtime'
|
|
7
9
|
|
|
8
10
|
export function getFontAttributes (node: TaroElement): TaroTextStyleType {
|
|
9
11
|
const hmStyle = node.hmStyle
|
|
12
|
+
const attrs: TextProps = node._attrs || {}
|
|
10
13
|
|
|
11
14
|
const attributes: TaroAny = {
|
|
12
|
-
|
|
15
|
+
WebkitLineClamp: attrs.maxLines || hmStyle.WebkitLineClamp || Infinity,
|
|
13
16
|
// 已做处理的属性
|
|
14
17
|
letterSpacing: hmStyle.letterSpacing,
|
|
15
18
|
textAlign: hmStyle.textAlign,
|
|
@@ -19,17 +22,25 @@ export function getFontAttributes (node: TaroElement): TaroTextStyleType {
|
|
|
19
22
|
return attributes
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
// 模拟 div 自动撑满父元素的情况
|
|
26
|
+
function isMaxWidthView (node: TaroElement) {
|
|
27
|
+
const parentNode: TaroElement = node.parentNode as TaroElement
|
|
28
|
+
|
|
29
|
+
return node.tagName === 'VIEW' && parentNode && parentNode.tagName === 'VIEW' &&
|
|
30
|
+
!(FlexManager.isFlexNode(parentNode) && FlexManager.flexOptions(parentNode).direction !== FlexDirection.Column)
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
export function getNormalAttributes (node: TaroElement): TaroStyleType {
|
|
23
34
|
const hmStyle = node.hmStyle
|
|
24
35
|
|
|
25
36
|
const _nid = node._nid
|
|
26
37
|
const _attrs: StandardProps = node._attrs || {}
|
|
27
38
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
let linearGradient: HarmonyType.LinearGradient | undefined = undefined
|
|
40
|
+
// 渐变
|
|
41
|
+
if (hmStyle.backgroundImage?.colors) {
|
|
42
|
+
linearGradient = hmStyle.backgroundImage
|
|
43
|
+
}
|
|
33
44
|
|
|
34
45
|
let normalAttributes: HarmonyStyle = {
|
|
35
46
|
// Flex相关
|
|
@@ -38,28 +49,54 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
|
|
|
38
49
|
flexShrink: hmStyle.flexShrink,
|
|
39
50
|
alignSelf: hmStyle.alignSelf,
|
|
40
51
|
// 尺寸相关
|
|
41
|
-
width: hmStyle.width,
|
|
52
|
+
width: isMaxWidthView(node) && isUndefined(hmStyle.width) ? '100%' : hmStyle.width,
|
|
42
53
|
height: hmStyle.height,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
minHeight: hmStyle.minHeight,
|
|
55
|
+
maxHeight: hmStyle.maxHeight,
|
|
56
|
+
minWidth: hmStyle.minWidth,
|
|
57
|
+
maxWidth: hmStyle.maxWidth,
|
|
58
|
+
marginTop: hmStyle.marginTop,
|
|
59
|
+
marginRight: hmStyle.marginRight,
|
|
60
|
+
marginBottom: hmStyle.marginBottom,
|
|
61
|
+
marginLeft: hmStyle.marginLeft,
|
|
62
|
+
paddingTop: hmStyle.paddingTop,
|
|
63
|
+
paddingRight: hmStyle.paddingRight,
|
|
64
|
+
paddingBottom: hmStyle.paddingBottom,
|
|
65
|
+
paddingLeft: hmStyle.paddingLeft,
|
|
46
66
|
// 边框相关
|
|
47
67
|
borderStyle: hmStyle.borderStyle,
|
|
68
|
+
borderTopStyle: hmStyle.borderTopStyle,
|
|
69
|
+
borderRightStyle: hmStyle.borderRightStyle,
|
|
70
|
+
borderBottomStyle: hmStyle.borderBottomStyle,
|
|
71
|
+
borderLeftStyle: hmStyle.borderLeftStyle,
|
|
48
72
|
borderWidth: hmStyle.borderWidth,
|
|
73
|
+
borderTopWidth: hmStyle.borderTopWidth,
|
|
74
|
+
borderRightWidth: hmStyle.borderRightWidth,
|
|
75
|
+
borderBottomWidth: hmStyle.borderBottomWidth,
|
|
76
|
+
borderLeftWidth: hmStyle.borderLeftWidth,
|
|
49
77
|
borderColor: hmStyle.borderColor,
|
|
78
|
+
borderTopColor: hmStyle.borderTopColor,
|
|
79
|
+
borderRightColor: hmStyle.borderRightColor,
|
|
80
|
+
borderBottomColor: hmStyle.borderBottomColor,
|
|
81
|
+
borderLeftColor: hmStyle.borderLeftColor,
|
|
50
82
|
borderRadius: hmStyle.borderRadius,
|
|
83
|
+
borderTopLeftRadius: hmStyle.borderTopLeftRadius,
|
|
84
|
+
borderTopRightRadius: hmStyle.borderTopRightRadius,
|
|
85
|
+
borderBottomRightRadius: hmStyle.borderBottomRightRadius,
|
|
86
|
+
borderBottomLeftRadius: hmStyle.borderBottomLeftRadius,
|
|
51
87
|
// 背景相关
|
|
52
88
|
backgroundColor: hmStyle.backgroundColor,
|
|
53
89
|
backgroundImage: hmStyle.backgroundImage,
|
|
54
|
-
|
|
90
|
+
backgroundSize: hmStyle.backgroundSize,
|
|
55
91
|
backgroundRepeat: hmStyle.backgroundRepeat,
|
|
56
|
-
|
|
57
|
-
linearGradient
|
|
92
|
+
backgroundPosition: hmStyle.backgroundPosition,
|
|
93
|
+
linearGradient,
|
|
58
94
|
// 变换相关
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
transform: hmStyle.transform,
|
|
96
|
+
transformOrigin: {
|
|
97
|
+
x: hmStyle.transformOrigin?.x || 0,
|
|
98
|
+
y: hmStyle.transformOrigin?.y || 0
|
|
99
|
+
},
|
|
63
100
|
// 通用文本相关
|
|
64
101
|
color: hmStyle.color,
|
|
65
102
|
fontSize: hmStyle.fontSize,
|
|
@@ -67,11 +104,12 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
|
|
|
67
104
|
fontWeight: hmStyle.fontWeight,
|
|
68
105
|
fontFamily: hmStyle.fontFamily || TEXT_DEFAULT_STYLE.FONT_FAMILY,
|
|
69
106
|
lineHeight: hmStyle.lineHeight,
|
|
70
|
-
|
|
107
|
+
textDecoration: hmStyle.textDecoration,
|
|
71
108
|
// 其他
|
|
72
|
-
|
|
109
|
+
overflow: hmStyle.overflow,
|
|
73
110
|
id: _attrs.id || _nid,
|
|
74
111
|
opacity: hmStyle.opacity,
|
|
112
|
+
zIndex: hmStyle.zIndex
|
|
75
113
|
// focus: _attrs.focus || false,
|
|
76
114
|
}
|
|
77
115
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
4
|
-
import {
|
|
5
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
5
6
|
|
|
6
|
-
import type {
|
|
7
|
+
import type { TaroAny, TaroVideoElement, TaroEvent } from '@tarojs/runtime'
|
|
7
8
|
|
|
8
9
|
export interface VideoOptions {
|
|
9
10
|
src?: string | Resource
|
|
@@ -21,37 +22,6 @@ export interface VideoUpdateEvent {
|
|
|
21
22
|
time: number
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
@Extend(Video)
|
|
25
|
-
function attrs (style: TaroStyleType) {
|
|
26
|
-
.id(style.id)
|
|
27
|
-
.key(style.id)
|
|
28
|
-
.padding(style.padding)
|
|
29
|
-
.margin(style.margin)
|
|
30
|
-
.width(style.width)
|
|
31
|
-
.height(style.height)
|
|
32
|
-
.constraintSize(style.constraintSize)
|
|
33
|
-
.flexGrow(style.flexGrow)
|
|
34
|
-
.flexShrink(style.flexShrink)
|
|
35
|
-
.flexBasis(style.flexBasis)
|
|
36
|
-
.alignSelf(style.alignSelf)
|
|
37
|
-
.backgroundColor(style.backgroundColor)
|
|
38
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
39
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
40
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
41
|
-
.rotate(style.rotate)
|
|
42
|
-
.scale(style.scale)
|
|
43
|
-
.translate(style.translate)
|
|
44
|
-
.transform(style.transform)
|
|
45
|
-
.borderStyle(style.borderStyle)
|
|
46
|
-
.borderWidth(style.borderWidth)
|
|
47
|
-
.borderColor(style.borderColor)
|
|
48
|
-
.borderRadius(style.borderRadius)
|
|
49
|
-
.linearGradient(style.linearGradient)
|
|
50
|
-
.zIndex(style.zIndex)
|
|
51
|
-
.opacity(style.opacity)
|
|
52
|
-
.clip(style.clip)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
25
|
@Extend(Video)
|
|
56
26
|
function props(attr: VideoAttrs) {
|
|
57
27
|
.muted(attr.muted)
|
|
@@ -111,7 +81,7 @@ function handleUpdate (node: TaroVideoElement, e: VideoUpdateEvent) {
|
|
|
111
81
|
@Builder
|
|
112
82
|
export default function TaroVideo (node: TaroVideoElement) {
|
|
113
83
|
Video(getVideoData(node))
|
|
114
|
-
.
|
|
84
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
115
85
|
.props(getVideoProps(node))
|
|
116
86
|
.aspectRatio(4 / 3)
|
|
117
87
|
.onStart(shouldBindEvent(() => { emitEvent(node, 'play') }, node, ['play']))
|
|
@@ -1,96 +1,54 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { createLazyChildren } from './render'
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
6
|
import { FlexManager } from './utils/FlexManager'
|
|
6
7
|
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import type { TaroViewElement,
|
|
9
|
+
import type { TaroViewElement, TaroStyleType, TaroAny } from '@tarojs/runtime'
|
|
9
10
|
|
|
10
|
-
@Extend(
|
|
11
|
-
function
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.padding(style.padding)
|
|
19
|
-
.margin(style.margin)
|
|
20
|
-
.width(style.width)
|
|
21
|
-
.height(style.height)
|
|
22
|
-
.constraintSize(style.constraintSize)
|
|
23
|
-
.backgroundColor(style.backgroundColor)
|
|
24
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
25
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
26
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
27
|
-
.rotate(style.rotate)
|
|
28
|
-
.scale(style.scale)
|
|
29
|
-
.translate(style.translate)
|
|
30
|
-
.transform(style.transform)
|
|
31
|
-
.borderStyle(style.borderStyle)
|
|
32
|
-
.borderWidth(style.borderWidth)
|
|
33
|
-
.borderColor(style.borderColor)
|
|
34
|
-
.borderRadius(style.borderRadius)
|
|
35
|
-
.linearGradient(style.linearGradient)
|
|
36
|
-
.zIndex(style.zIndex)
|
|
37
|
-
.opacity(style.opacity)
|
|
38
|
-
.clip(style.clip)
|
|
11
|
+
@Extend(Row)
|
|
12
|
+
function rowAttrs (style: TaroStyleType) {
|
|
13
|
+
.constraintSize({
|
|
14
|
+
minWidth: style.minWidth || style.width,
|
|
15
|
+
maxWidth: style.maxWidth,
|
|
16
|
+
minHeight: style.minHeight,
|
|
17
|
+
maxHeight: style.maxHeight
|
|
18
|
+
})
|
|
39
19
|
}
|
|
40
20
|
|
|
41
|
-
|
|
42
21
|
@Extend(Column)
|
|
43
22
|
function columnAttrs (style: TaroStyleType) {
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.padding(style.padding)
|
|
51
|
-
.margin(style.margin)
|
|
52
|
-
.width(style.width)
|
|
53
|
-
.height(style.height)
|
|
54
|
-
.constraintSize(style.constraintSize)
|
|
55
|
-
.backgroundColor(style.backgroundColor)
|
|
56
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
57
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
58
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
59
|
-
.rotate(style.rotate)
|
|
60
|
-
.scale(style.scale)
|
|
61
|
-
.translate(style.translate)
|
|
62
|
-
.transform(style.transform)
|
|
63
|
-
.borderStyle(style.borderStyle)
|
|
64
|
-
.borderWidth(style.borderWidth)
|
|
65
|
-
.borderColor(style.borderColor)
|
|
66
|
-
.borderRadius(style.borderRadius)
|
|
67
|
-
.linearGradient(style.linearGradient)
|
|
68
|
-
.zIndex(style.zIndex)
|
|
69
|
-
.opacity(style.opacity)
|
|
70
|
-
.clip(style.clip)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function isFlexNode (node: TaroViewElement) {
|
|
74
|
-
return !!node.hmStyle?.display?.includes('flex')
|
|
23
|
+
.constraintSize({
|
|
24
|
+
minWidth: style.minWidth,
|
|
25
|
+
maxWidth: style.maxWidth,
|
|
26
|
+
minHeight: style.minHeight || style.height,
|
|
27
|
+
maxHeight: style.maxHeight
|
|
28
|
+
})
|
|
75
29
|
}
|
|
76
30
|
|
|
77
31
|
@Builder
|
|
78
32
|
export default function TaroView (node: TaroViewElement) {
|
|
79
|
-
if (isFlexNode(node)) {
|
|
80
|
-
|
|
33
|
+
if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
|
|
34
|
+
Row() {
|
|
81
35
|
createLazyChildren(node)
|
|
82
36
|
}
|
|
83
|
-
.
|
|
37
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
38
|
+
.rowAttrs(getNormalAttributes(node))
|
|
84
39
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
85
40
|
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
86
41
|
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
87
42
|
node._nodeInfo.areaInfo = res[1]
|
|
88
43
|
}))
|
|
89
44
|
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
45
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
|
|
46
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
90
47
|
} else {
|
|
91
48
|
Column() {
|
|
92
49
|
createLazyChildren(node)
|
|
93
50
|
}
|
|
51
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
94
52
|
.columnAttrs(getNormalAttributes(node))
|
|
95
53
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
96
54
|
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
@@ -98,7 +56,7 @@ export default function TaroView (node: TaroViewElement) {
|
|
|
98
56
|
node._nodeInfo.areaInfo = res[1]
|
|
99
57
|
}))
|
|
100
58
|
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
101
|
-
.alignItems(
|
|
102
|
-
.justifyContent(node.
|
|
59
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
60
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
103
61
|
}
|
|
104
62
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
5
|
+
|
|
6
|
+
import type { TaroAny, TaroWebViewElement, TaroStyleType, TaroEvent } from '@tarojs/runtime'
|
|
7
|
+
|
|
8
|
+
interface IPageLoad {
|
|
9
|
+
url: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface IError {
|
|
13
|
+
request: WebResourceRequest
|
|
14
|
+
error: WebResourceError
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Builder
|
|
18
|
+
export default function TaroWebView (node: TaroWebViewElement) {
|
|
19
|
+
Web({ src: node._attrs.src, controller: node.controller })
|
|
20
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
21
|
+
.onPageEnd((e: IPageLoad) => {
|
|
22
|
+
// 1. 创建消息端口
|
|
23
|
+
node.ports = node.controller.createWebMessagePorts(true)
|
|
24
|
+
// 2. 发送端口1到HTML5
|
|
25
|
+
node.controller.postMessage('init_web_messageport', [node.ports[1]], '*');
|
|
26
|
+
// 3. 保存端口0到本地
|
|
27
|
+
node.nativePort = node.ports[0]
|
|
28
|
+
// 4. 设置回调函数
|
|
29
|
+
node.nativePort.onMessageEventExt((result) => {
|
|
30
|
+
const message = node.handleMessageFromWeb(result)
|
|
31
|
+
const messageEvent: TaroEvent = createTaroEvent('message', { detail: { data: message } }, node)
|
|
32
|
+
|
|
33
|
+
eventHandler(messageEvent, 'message', node)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const onLoadEvent: TaroEvent = createTaroEvent('load', { detail: { src: node._attrs.src } }, node)
|
|
37
|
+
|
|
38
|
+
eventHandler(onLoadEvent, 'load', node)
|
|
39
|
+
})
|
|
40
|
+
.onErrorReceive(shouldBindEvent((e: IError) => {
|
|
41
|
+
const event: TaroEvent = createTaroEvent('error', { detail: { url: node._attrs.src, fullUrl: e.request.getRequestUrl() } }, node)
|
|
42
|
+
|
|
43
|
+
eventHandler(event, 'error', node)
|
|
44
|
+
}, node, ['error']))
|
|
45
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
46
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
47
|
+
node._nodeInfo.areaInfo = res[1]
|
|
48
|
+
}))
|
|
49
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
50
|
+
}
|