@tarojs/plugin-platform-harmony-ets 4.0.0-canary.8 → 4.0.0
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/base/system.ts +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +146 -78
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +5 -5
- package/dist/apis/ui/tab-bar.ts +3 -3
- package/dist/apis/utils/index.ts +21 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +63 -77
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +75 -258
- package/dist/components-harmony-ets/form.ets +51 -158
- package/dist/components-harmony-ets/icon.ets +33 -83
- package/dist/components-harmony-ets/image.ets +35 -79
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +64 -101
- package/dist/components-harmony-ets/label.ets +72 -174
- package/dist/components-harmony-ets/listView.ets +31 -0
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +46 -163
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +80 -264
- package/dist/components-harmony-ets/richText.ets +20 -102
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +71 -160
- package/dist/components-harmony-ets/slider.ets +22 -82
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +410 -0
- package/dist/components-harmony-ets/swiper.ets +64 -87
- package/dist/components-harmony-ets/switch.ets +39 -99
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +111 -113
- package/dist/components-harmony-ets/textArea.ets +51 -95
- package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
- package/dist/components-harmony-ets/utils/flexManager.ets +50 -19
- package/dist/components-harmony-ets/utils/helper.ets +20 -8
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +172 -92
- package/dist/components-harmony-ets/video.ets +37 -88
- package/dist/components-harmony-ets/view.ets +63 -159
- package/dist/components-harmony-ets/webView.ets +41 -98
- package/dist/index.d.ts +152 -0
- package/dist/index.js +187 -56
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +5 -1
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +419 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +376 -57
- package/dist/runtime-ets/dom/element/form.ts +31 -26
- package/dist/runtime-ets/dom/element/index.ts +30 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +248 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -4
- package/dist/runtime-ets/dom/element/webView.ts +12 -5
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +65 -32
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +74 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +25 -30
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +219 -82
- package/dist/runtime-framework/react/page.ts +6 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +30 -46
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +85 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +3 -5
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +618 -245
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +618 -245
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +5 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +3 -1
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -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,71 +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
|
-
.flexGrow(style.flexGrow)
|
|
29
|
-
.flexShrink(style.flexShrink)
|
|
30
|
-
.flexBasis(style.flexBasis)
|
|
31
|
-
.alignSelf(style.alignSelf)
|
|
32
|
-
.padding({
|
|
33
|
-
top: style.paddingTop,
|
|
34
|
-
right: style.paddingRight,
|
|
35
|
-
bottom: style.paddingBottom,
|
|
36
|
-
left: style.paddingLeft
|
|
37
|
-
})
|
|
38
|
-
.margin({
|
|
39
|
-
top: style.marginTop,
|
|
40
|
-
right: style.marginRight,
|
|
41
|
-
bottom: style.marginBottom,
|
|
42
|
-
left: style.marginLeft
|
|
43
|
-
})
|
|
44
|
-
.width(style.width)
|
|
45
|
-
.height(style.height)
|
|
46
|
-
.constraintSize({
|
|
47
|
-
minWidth: style.minWidth,
|
|
48
|
-
maxWidth: style.maxWidth,
|
|
49
|
-
minHeight: style.minHeight,
|
|
50
|
-
maxHeight: style.maxHeight
|
|
51
|
-
})
|
|
52
|
-
.backgroundColor(style.backgroundColor)
|
|
53
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
54
|
-
.backgroundImageSize(style.backgroundSize)
|
|
55
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
56
|
-
.borderStyle({
|
|
57
|
-
top: style.borderTopStyle,
|
|
58
|
-
right: style.borderRightStyle,
|
|
59
|
-
bottom: style.borderBottomStyle,
|
|
60
|
-
left: style.borderLeftStyle
|
|
61
|
-
})
|
|
62
|
-
.borderWidth({
|
|
63
|
-
top: style.borderTopWidth,
|
|
64
|
-
right: style.borderRightWidth,
|
|
65
|
-
bottom: style.borderBottomWidth,
|
|
66
|
-
left: style.borderLeftWidth
|
|
67
|
-
})
|
|
68
|
-
.borderColor({
|
|
69
|
-
top: style.borderTopColor,
|
|
70
|
-
right: style.borderRightColor,
|
|
71
|
-
bottom: style.borderBottomColor,
|
|
72
|
-
left: style.borderLeftColor
|
|
73
|
-
})
|
|
74
|
-
.borderRadius({
|
|
75
|
-
topLeft: style.borderTopLeftRadius,
|
|
76
|
-
topRight: style.borderTopRightRadius,
|
|
77
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
78
|
-
bottomRight: style.borderBottomRightRadius
|
|
79
|
-
})
|
|
80
|
-
.zIndex(style.zIndex)
|
|
81
|
-
.opacity(style.opacity)
|
|
82
|
-
.linearGradient(style.linearGradient)
|
|
83
|
-
.clip(style.overflow)
|
|
84
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
85
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
86
|
-
.transform(style.transform)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
25
|
@Extend(Video)
|
|
90
26
|
function props(attr: VideoAttrs) {
|
|
91
27
|
.muted(attr.muted)
|
|
@@ -137,30 +73,43 @@ function getVideoProps (node: TaroVideoElement): VideoAttrs {
|
|
|
137
73
|
}
|
|
138
74
|
|
|
139
75
|
function handleUpdate (node: TaroVideoElement, e: VideoUpdateEvent) {
|
|
140
|
-
node._currentTime = e.time
|
|
76
|
+
node._nodeInfo._currentTime = e.time
|
|
141
77
|
|
|
142
78
|
emitEvent(node, 'timeUpdate', { currentTime: e.time})
|
|
143
79
|
}
|
|
144
80
|
|
|
145
|
-
@
|
|
146
|
-
export default
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
.
|
|
161
|
-
.
|
|
162
|
-
.
|
|
163
|
-
|
|
81
|
+
@Component
|
|
82
|
+
export default struct TaroVideo {
|
|
83
|
+
@Builder customBuilder() {}
|
|
84
|
+
@BuilderParam createLazyChildren: (node: TaroVideoElement, layer?: number) => void = this.customBuilder
|
|
85
|
+
@ObjectLink node: TaroVideoElement
|
|
86
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
87
|
+
|
|
88
|
+
aboutToAppear(): void {
|
|
89
|
+
if (this.node) {
|
|
90
|
+
this.node._instance = this
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
build () {
|
|
95
|
+
Video(getVideoData(this.node))
|
|
96
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
97
|
+
.props(getVideoProps(this.node))
|
|
98
|
+
.onStart(shouldBindEvent(() => { emitEvent(this.node, 'play') }, this.node, ['play']))
|
|
99
|
+
.onPause(shouldBindEvent(() => { emitEvent(this.node, 'pause') }, this.node, ['pause']))
|
|
100
|
+
.onFinish(shouldBindEvent(() => { emitEvent(this.node, 'ended') }, this.node, ['ended']))
|
|
101
|
+
.onError(shouldBindEvent(() => { emitEvent(this.node, 'error') }, this.node, ['error']))
|
|
102
|
+
.onUpdate((e) => { handleUpdate(this.node, e) })
|
|
103
|
+
.onPrepared(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'loadedMetaData', { duration: e.duration }) }, this.node, ['loadedmetadata']))
|
|
104
|
+
.onSeeking(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'seeking', { duration: e.time }) }, this.node, ['seeking']))
|
|
105
|
+
.onSeeked(shouldBindEvent(() => { emitEvent(this.node, 'seeked') }, this.node, ['seeked']))
|
|
106
|
+
.onFullscreenChange(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'fullScreenChange', { fullScreen: e.fullscreen}) }, this.node, ['fullscreenchange']))
|
|
107
|
+
.onClick((e: ClickEvent) => { eventHandler(e, 'click', this.node) })
|
|
108
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
109
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
110
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
164
111
|
}))
|
|
165
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
112
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
113
|
+
}
|
|
114
|
+
|
|
166
115
|
}
|
|
@@ -1,169 +1,73 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
import PseduoChildren from './pseudo'
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
6
|
-
import { getNodeThresholds,
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import type { TaroViewElement, TaroAny
|
|
9
|
+
import type { TaroViewElement, TaroAny } from '@tarojs/runtime'
|
|
10
|
+
import { isUndefined } from '@tarojs/shared'
|
|
9
11
|
|
|
10
|
-
@
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.flexBasis(style.flexBasis)
|
|
17
|
-
.alignSelf(style.alignSelf)
|
|
18
|
-
.padding({
|
|
19
|
-
top: style.paddingTop,
|
|
20
|
-
right: style.paddingRight,
|
|
21
|
-
bottom: style.paddingBottom,
|
|
22
|
-
left: style.paddingLeft
|
|
23
|
-
})
|
|
24
|
-
.margin({
|
|
25
|
-
top: style.marginTop,
|
|
26
|
-
right: style.marginRight,
|
|
27
|
-
bottom: style.marginBottom,
|
|
28
|
-
left: style.marginLeft
|
|
29
|
-
})
|
|
30
|
-
.width(style.width)
|
|
31
|
-
.height(style.height)
|
|
32
|
-
.constraintSize({
|
|
33
|
-
minWidth: style.minWidth,
|
|
34
|
-
maxWidth: style.maxWidth,
|
|
35
|
-
minHeight: style.minHeight,
|
|
36
|
-
maxHeight: style.maxHeight
|
|
37
|
-
})
|
|
38
|
-
.backgroundColor(style.backgroundColor)
|
|
39
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
40
|
-
.backgroundImageSize(style.backgroundSize)
|
|
41
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
42
|
-
.borderStyle({
|
|
43
|
-
top: style.borderTopStyle,
|
|
44
|
-
right: style.borderRightStyle,
|
|
45
|
-
bottom: style.borderBottomStyle,
|
|
46
|
-
left: style.borderLeftStyle
|
|
47
|
-
})
|
|
48
|
-
.borderWidth({
|
|
49
|
-
top: style.borderTopWidth,
|
|
50
|
-
right: style.borderRightWidth,
|
|
51
|
-
bottom: style.borderBottomWidth,
|
|
52
|
-
left: style.borderLeftWidth
|
|
53
|
-
})
|
|
54
|
-
.borderColor({
|
|
55
|
-
top: style.borderTopColor,
|
|
56
|
-
right: style.borderRightColor,
|
|
57
|
-
bottom: style.borderBottomColor,
|
|
58
|
-
left: style.borderLeftColor
|
|
59
|
-
})
|
|
60
|
-
.borderRadius({
|
|
61
|
-
topLeft: style.borderTopLeftRadius,
|
|
62
|
-
topRight: style.borderTopRightRadius,
|
|
63
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
64
|
-
bottomRight: style.borderBottomRightRadius
|
|
65
|
-
})
|
|
66
|
-
.zIndex(style.zIndex)
|
|
67
|
-
.opacity(style.opacity)
|
|
68
|
-
.linearGradient(style.linearGradient)
|
|
69
|
-
.clip(style.overflow)
|
|
70
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
71
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
72
|
-
.transform(style.transform)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Extend(Row)
|
|
76
|
-
function rowAttrs (style: TaroStyleType) {
|
|
77
|
-
.id(style.id)
|
|
78
|
-
.key(style.id)
|
|
79
|
-
.flexGrow(style.flexGrow)
|
|
80
|
-
.flexShrink(style.flexShrink)
|
|
81
|
-
.flexBasis(style.flexBasis)
|
|
82
|
-
.alignSelf(style.alignSelf)
|
|
83
|
-
.padding({
|
|
84
|
-
top: style.paddingTop,
|
|
85
|
-
right: style.paddingRight,
|
|
86
|
-
bottom: style.paddingBottom,
|
|
87
|
-
left: style.paddingLeft
|
|
88
|
-
})
|
|
89
|
-
.margin({
|
|
90
|
-
top: style.marginTop,
|
|
91
|
-
right: style.marginRight,
|
|
92
|
-
bottom: style.marginBottom,
|
|
93
|
-
left: style.marginLeft
|
|
94
|
-
})
|
|
95
|
-
.width(style.width)
|
|
96
|
-
.height(style.height)
|
|
97
|
-
.constraintSize({
|
|
98
|
-
minWidth: style.minWidth,
|
|
99
|
-
maxWidth: style.maxWidth,
|
|
100
|
-
minHeight: style.minHeight,
|
|
101
|
-
maxHeight: style.maxHeight
|
|
102
|
-
})
|
|
103
|
-
.backgroundColor(style.backgroundColor)
|
|
104
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
105
|
-
.backgroundImageSize(style.backgroundSize)
|
|
106
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
107
|
-
.borderStyle({
|
|
108
|
-
top: style.borderTopStyle,
|
|
109
|
-
right: style.borderRightStyle,
|
|
110
|
-
bottom: style.borderBottomStyle,
|
|
111
|
-
left: style.borderLeftStyle
|
|
112
|
-
})
|
|
113
|
-
.borderWidth({
|
|
114
|
-
top: style.borderTopWidth,
|
|
115
|
-
right: style.borderRightWidth,
|
|
116
|
-
bottom: style.borderBottomWidth,
|
|
117
|
-
left: style.borderLeftWidth
|
|
118
|
-
})
|
|
119
|
-
.borderColor({
|
|
120
|
-
top: style.borderTopColor,
|
|
121
|
-
right: style.borderRightColor,
|
|
122
|
-
bottom: style.borderBottomColor,
|
|
123
|
-
left: style.borderLeftColor
|
|
124
|
-
})
|
|
125
|
-
.borderRadius({
|
|
126
|
-
topLeft: style.borderTopLeftRadius,
|
|
127
|
-
topRight: style.borderTopRightRadius,
|
|
128
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
129
|
-
bottomRight: style.borderBottomRightRadius
|
|
130
|
-
})
|
|
131
|
-
.zIndex(style.zIndex)
|
|
132
|
-
.opacity(style.opacity)
|
|
133
|
-
.linearGradient(style.linearGradient)
|
|
134
|
-
.clip(style.overflow)
|
|
135
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
136
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
137
|
-
.transform(style.transform)
|
|
138
|
-
}
|
|
12
|
+
@Component
|
|
13
|
+
export default struct TaroView {
|
|
14
|
+
@Builder customBuilder() {}
|
|
15
|
+
@BuilderParam createLazyChildren: (node: TaroViewElement, layer?: number) => void = this.customBuilder
|
|
16
|
+
@ObjectLink node: TaroViewElement
|
|
17
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
139
18
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Row() {
|
|
144
|
-
createLazyChildren(node)
|
|
19
|
+
aboutToAppear(): void {
|
|
20
|
+
if (this.node) {
|
|
21
|
+
this.node._instance = this
|
|
145
22
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
build () {
|
|
26
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
27
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
28
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
29
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
30
|
+
} else {
|
|
31
|
+
this.createLazyChildren(this.node, 0)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
35
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
36
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
37
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
38
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
39
|
+
}))
|
|
40
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
41
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
42
|
+
Row() {
|
|
43
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
44
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
45
|
+
} else {
|
|
46
|
+
this.createLazyChildren(this.node, 0)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
50
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
51
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
52
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
53
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
54
|
+
}))
|
|
55
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
56
|
+
} else {
|
|
57
|
+
Column() {
|
|
58
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
59
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
60
|
+
} else {
|
|
61
|
+
this.createLazyChildren(this.node, 0)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
65
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
66
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
67
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
68
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
69
|
+
}))
|
|
70
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
158
71
|
}
|
|
159
|
-
.columnAttrs(getNormalAttributes(node))
|
|
160
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
161
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
162
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
163
|
-
node._nodeInfo.areaInfo = res[1]
|
|
164
|
-
}))
|
|
165
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
166
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
167
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
168
72
|
}
|
|
169
73
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
5
|
|
|
5
|
-
import type { TaroAny, TaroWebViewElement,
|
|
6
|
+
import type { TaroAny, TaroWebViewElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
interface IPageLoad {
|
|
8
9
|
url: string
|
|
@@ -13,101 +14,43 @@ interface IError {
|
|
|
13
14
|
error: WebResourceError
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
@
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
.backgroundColor(style.backgroundColor)
|
|
45
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
46
|
-
.backgroundImageSize(style.backgroundSize)
|
|
47
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
48
|
-
.borderStyle({
|
|
49
|
-
top: style.borderTopStyle,
|
|
50
|
-
right: style.borderRightStyle,
|
|
51
|
-
bottom: style.borderBottomStyle,
|
|
52
|
-
left: style.borderLeftStyle
|
|
53
|
-
})
|
|
54
|
-
.borderWidth({
|
|
55
|
-
top: style.borderTopWidth,
|
|
56
|
-
right: style.borderRightWidth,
|
|
57
|
-
bottom: style.borderBottomWidth,
|
|
58
|
-
left: style.borderLeftWidth
|
|
59
|
-
})
|
|
60
|
-
.borderColor({
|
|
61
|
-
top: style.borderTopColor,
|
|
62
|
-
right: style.borderRightColor,
|
|
63
|
-
bottom: style.borderBottomColor,
|
|
64
|
-
left: style.borderLeftColor
|
|
65
|
-
})
|
|
66
|
-
.borderRadius({
|
|
67
|
-
topLeft: style.borderTopLeftRadius,
|
|
68
|
-
topRight: style.borderTopRightRadius,
|
|
69
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
70
|
-
bottomRight: style.borderBottomRightRadius
|
|
71
|
-
})
|
|
72
|
-
.zIndex(style.zIndex)
|
|
73
|
-
.opacity(style.opacity)
|
|
74
|
-
.clip(style.overflow)
|
|
75
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
76
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
77
|
-
.transform(style.transform)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@Builder
|
|
81
|
-
export default function TaroWebView (node: TaroWebViewElement) {
|
|
82
|
-
Web({ src: node._attrs.src, controller: node.controller })
|
|
83
|
-
.attrs(getNormalAttributes(node))
|
|
84
|
-
.onPageEnd((e: IPageLoad) => {
|
|
85
|
-
// 1. 创建消息端口
|
|
86
|
-
node.ports = node.controller.createWebMessagePorts(true)
|
|
87
|
-
// 2. 发送端口1到HTML5
|
|
88
|
-
node.controller.postMessage('init_web_messageport', [node.ports[1]], '*');
|
|
89
|
-
// 3. 保存端口0到本地
|
|
90
|
-
node.nativePort = node.ports[0]
|
|
91
|
-
// 4. 设置回调函数
|
|
92
|
-
node.nativePort.onMessageEventExt((result) => {
|
|
93
|
-
const message = node.handleMessageFromWeb(result)
|
|
94
|
-
const messageEvent: TaroEvent = createTaroEvent('message', { detail: { data: message } }, node)
|
|
95
|
-
|
|
96
|
-
eventHandler(messageEvent, 'message', node)
|
|
17
|
+
@Component
|
|
18
|
+
export default struct TaroWebView {
|
|
19
|
+
@Builder customBuilder() {}
|
|
20
|
+
@BuilderParam createLazyChildren: (node: TaroWebViewElement, layer?: number) => void = this.customBuilder
|
|
21
|
+
@ObjectLink node: TaroWebViewElement
|
|
22
|
+
|
|
23
|
+
build () {
|
|
24
|
+
Web({ src: this.node._attrs.src, controller: this.node.controller })
|
|
25
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
26
|
+
.onPageEnd((e: IPageLoad) => {
|
|
27
|
+
// 1. 创建消息端口
|
|
28
|
+
this.node.ports = this.node.controller.createWebMessagePorts(true)
|
|
29
|
+
// 2. 发送端口1到HTML5
|
|
30
|
+
this.node.controller.postMessage('init_web_messageport', [this.node.ports[1]], '*');
|
|
31
|
+
// 3. 保存端口0到本地
|
|
32
|
+
this.node.nativePort = this.node.ports[0]
|
|
33
|
+
// 4. 设置回调函数
|
|
34
|
+
this.node.nativePort.onMessageEventExt((result) => {
|
|
35
|
+
const message = this.node.handleMessageFromWeb(result)
|
|
36
|
+
const messageEvent: TaroEvent = createTaroEvent('message', { detail: { data: message } }, this.node)
|
|
37
|
+
|
|
38
|
+
eventHandler(messageEvent, 'message', this.node)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const onLoadEvent: TaroEvent = createTaroEvent('load', { detail: { src: this.node._attrs.src } }, this.node)
|
|
42
|
+
|
|
43
|
+
eventHandler(onLoadEvent, 'load', this.node)
|
|
97
44
|
})
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
110
|
-
node._nodeInfo.areaInfo = res[1]
|
|
111
|
-
}))
|
|
112
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
45
|
+
.onErrorReceive(shouldBindEvent((e: IError) => {
|
|
46
|
+
const event: TaroEvent = createTaroEvent('error', { detail: { url: this.node._attrs.src, fullUrl: e.request.getRequestUrl() } }, this.node)
|
|
47
|
+
|
|
48
|
+
eventHandler(event, 'error', this.node)
|
|
49
|
+
}, this.node, ['error']))
|
|
50
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
51
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
52
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
53
|
+
}))
|
|
54
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
55
|
+
}
|
|
113
56
|
}
|