@tarojs/helper 4.0.0-beta.0 → 4.0.0-canary.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.
- package/dist/esbuild/index.js +2 -2
- package/dist/esbuild/index.js.map +1 -1
- package/dist/utils.js +3 -6
- package/dist/utils.js.map +1 -1
- package/package.json +4 -3
- package/swc/.gitkeep +0 -0
- package/swc/swc_plugin_compile_mode.wasm +0 -0
- package/swc/swc_plugin_define_config.wasm +0 -0
- package/swc/plugin-compile-mode/.cargo/config +0 -5
- package/swc/plugin-compile-mode/.editorconfig +0 -6
- package/swc/plugin-compile-mode/.vscode/settings.json +0 -3
- package/swc/plugin-compile-mode/Cargo.lock +0 -2021
- package/swc/plugin-compile-mode/Cargo.toml +0 -22
- package/swc/plugin-compile-mode/package.json +0 -15
- package/swc/plugin-compile-mode/src/lib.rs +0 -71
- package/swc/plugin-compile-mode/src/tests/attributes.rs +0 -54
- package/swc/plugin-compile-mode/src/tests/children.rs +0 -86
- package/swc/plugin-compile-mode/src/tests/condition.rs +0 -50
- package/swc/plugin-compile-mode/src/tests/entry.rs +0 -20
- package/swc/plugin-compile-mode/src/tests/harmony/attributes.rs +0 -45
- package/swc/plugin-compile-mode/src/tests/harmony/children.rs +0 -74
- package/swc/plugin-compile-mode/src/tests/harmony/condition.rs +0 -79
- package/swc/plugin-compile-mode/src/tests/harmony/entry.rs +0 -67
- package/swc/plugin-compile-mode/src/tests/harmony/looping.rs +0 -62
- package/swc/plugin-compile-mode/src/tests/harmony/mod.rs +0 -45
- package/swc/plugin-compile-mode/src/tests/looping.rs +0 -84
- package/swc/plugin-compile-mode/src/tests/mod.rs +0 -100
- package/swc/plugin-compile-mode/src/tests/shake.rs +0 -27
- package/swc/plugin-compile-mode/src/transform.rs +0 -474
- package/swc/plugin-compile-mode/src/transform_harmony.rs +0 -526
- package/swc/plugin-compile-mode/src/utils/constants.rs +0 -152
- package/swc/plugin-compile-mode/src/utils/harmony/components.rs +0 -61
- package/swc/plugin-compile-mode/src/utils/harmony/mod.rs +0 -1
- package/swc/plugin-compile-mode/src/utils/mod.rs +0 -347
- package/swc/plugin-compile-mode/target/wasm32-wasi/release/swc_plugin_compile_mode.wasm +0 -0
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_handle_events.js +0 -8
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_keep_static_attrs_only_in_templates.js +0 -8
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_turn_dynamic_attrs.js +0 -11
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_native_component.js +0 -7
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_react_component.js +0 -7
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_fragment.js +0 -44
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_render_fn.js +0 -8
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_and_expr.js +0 -14
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_conditional_expr.js +0 -15
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/entry.rs/should_support_multi_compile_mode.js +0 -10
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_handle_events.js +0 -183
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_turn_dynamic_attrs.js +0 -186
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_render_react_component.js +0 -76
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_fragment.js +0 -341
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_render_fn.js +0 -186
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_and_expr.js +0 -211
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_complex_condition.js +0 -244
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_and_unkonw_component.js +0 -139
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_expr.js +0 -344
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_compile_child_node.js +0 -141
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_component_not_in_config.js +0 -91
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_multi_compile_mode.js +0 -209
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_single_compile_mode.js +0 -66
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -76
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt_and_set_parent_dynamic_id.js +0 -89
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_function_expr.js +0 -86
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -8
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_expr.js +0 -6
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_function_expr.js +0 -20
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_support_nested_loop.js +0 -15
- package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/shake.rs/should_static_jsx_being_shaked.js +0 -20
- package/swc/plugin-define-config/.cargo/config +0 -5
- package/swc/plugin-define-config/Cargo.lock +0 -2110
- package/swc/plugin-define-config/Cargo.toml +0 -18
- package/swc/plugin-define-config/src/lib.rs +0 -141
- package/swc/plugin-define-config/target/wasm32-wasi/release/swc_plugin_define_config.wasm +0 -0
- package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_app.js +0 -2
- package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_page.js +0 -2
- package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_exports.js +0 -11
- package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_app.js +0 -3
- package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_page.js +0 -3
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
|
|
2
|
-
import { FlexManager } from '../utils/FlexManager'
|
|
3
|
-
import { TOUCH_EVENT_MAP } from '../utils/constant/event'
|
|
4
|
-
import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
|
|
5
|
-
import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
|
|
6
|
-
import { DynamicCenter } from '../utils/DynamicCenter'
|
|
7
|
-
|
|
8
|
-
import type { TaroViewElement } from '../element'
|
|
9
|
-
import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
|
|
10
|
-
|
|
11
|
-
@Extend(Flex)
|
|
12
|
-
function attrs (style: TaroStyleType) {
|
|
13
|
-
.id(style.id)
|
|
14
|
-
.key(style.id)
|
|
15
|
-
.padding(style.padding)
|
|
16
|
-
.margin(style.margin)
|
|
17
|
-
.width(style.width)
|
|
18
|
-
.height(style.height)
|
|
19
|
-
.constraintSize(style.constraintSize)
|
|
20
|
-
.flexGrow(style.flexGrow)
|
|
21
|
-
.flexShrink(style.flexShrink)
|
|
22
|
-
.flexBasis(style.flexBasis)
|
|
23
|
-
.alignSelf(style.alignSelf)
|
|
24
|
-
.backgroundColor(style.backgroundColor)
|
|
25
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
26
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
27
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
28
|
-
.rotate(style.rotate)
|
|
29
|
-
.scale(style.scale)
|
|
30
|
-
.translate(style.translate)
|
|
31
|
-
.transform(style.transform)
|
|
32
|
-
.borderStyle(style.borderStyle)
|
|
33
|
-
.borderWidth(style.borderWidth)
|
|
34
|
-
.borderColor(style.borderColor)
|
|
35
|
-
.borderRadius(style.borderRadius)
|
|
36
|
-
.linearGradient(style.linearGradient)
|
|
37
|
-
.zIndex(style.zIndex)
|
|
38
|
-
.opacity(style.opacity)
|
|
39
|
-
.clip(style.clip)
|
|
40
|
-
}
|
|
41
|
-
@Extend(Image)
|
|
42
|
-
function attrsImage (style: TaroStyleType) {
|
|
43
|
-
.id(style.id)
|
|
44
|
-
.key(style.id)
|
|
45
|
-
.padding(style.padding)
|
|
46
|
-
.margin(style.margin)
|
|
47
|
-
.width(style.width)
|
|
48
|
-
.height(style.height)
|
|
49
|
-
.constraintSize(style.constraintSize)
|
|
50
|
-
.flexGrow(style.flexGrow)
|
|
51
|
-
.flexShrink(style.flexShrink)
|
|
52
|
-
.flexBasis(style.flexBasis)
|
|
53
|
-
.alignSelf(style.alignSelf)
|
|
54
|
-
.backgroundColor(style.backgroundColor)
|
|
55
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
56
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
57
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
58
|
-
.rotate(style.rotate)
|
|
59
|
-
.scale(style.scale)
|
|
60
|
-
.translate(style.translate)
|
|
61
|
-
.transform(style.transform)
|
|
62
|
-
.borderStyle(style.borderStyle)
|
|
63
|
-
.borderWidth(style.borderWidth)
|
|
64
|
-
.borderColor(style.borderColor)
|
|
65
|
-
.borderRadius(style.borderRadius)
|
|
66
|
-
.linearGradient(style.linearGradient)
|
|
67
|
-
.zIndex(style.zIndex)
|
|
68
|
-
.opacity(style.opacity)
|
|
69
|
-
.clip(style.clip)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getImageMode (mode: string): ImageFit {
|
|
73
|
-
switch (mode) {
|
|
74
|
-
case 'aspectFit': return ImageFit.Contain
|
|
75
|
-
case 'aspectFill': return ImageFit.Cover
|
|
76
|
-
case 'scaleToFill': return ImageFit.Fill
|
|
77
|
-
case 'widthFix': return ImageFit.Auto
|
|
78
|
-
case 'heightFix': return ImageFit.Auto
|
|
79
|
-
default: return ImageFit.Contain
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
@Component
|
|
83
|
-
export default struct TARO_TEMPLATES_f0t0 {
|
|
84
|
-
nodeInfoMap: TaroAny = {}
|
|
85
|
-
dynamicCenter: DynamicCenter = new DynamicCenter()
|
|
86
|
-
@ObjectLink node: TaroViewElement
|
|
87
|
-
|
|
88
|
-
aboutToAppear () {
|
|
89
|
-
this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@State node0: TaroElement = new TaroIgnoreElement()
|
|
93
|
-
@State node1: TaroElement = new TaroIgnoreElement()
|
|
94
|
-
@State node2: TaroElement = new TaroIgnoreElement()
|
|
95
|
-
|
|
96
|
-
build() {
|
|
97
|
-
Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
|
|
98
|
-
Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {}
|
|
99
|
-
.attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
|
|
100
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
101
|
-
.onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
102
|
-
const eventResult: TaroAny = res.eventResult
|
|
103
|
-
this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
|
|
104
|
-
}))
|
|
105
|
-
.onClick(e => eventHandler(e, 'click', this.node0.childNodes[0] as TaroElement))
|
|
106
|
-
Flex(FlexManager.flexOptions(this.node0.childNodes[1] as TaroElement)) {}
|
|
107
|
-
.attrs(getNormalAttributes(this.node0.childNodes[1] as TaroElement))
|
|
108
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
109
|
-
.onAreaChange(getComponentEventCallback(this.node0.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
110
|
-
const eventResult: TaroAny = res.eventResult
|
|
111
|
-
this.nodeInfoMap[this.node0.childNodes[1]._nid].areaInfo = eventResult[1]
|
|
112
|
-
}))
|
|
113
|
-
.onClick(e => eventHandler(e, 'click', this.node0.childNodes[1] as TaroElement))
|
|
114
|
-
Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {}
|
|
115
|
-
.attrs(getNormalAttributes(this.node1 as TaroElement))
|
|
116
|
-
.onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
117
|
-
.onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
118
|
-
const eventResult: TaroAny = res.eventResult
|
|
119
|
-
this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
|
|
120
|
-
}))
|
|
121
|
-
.onClick(e => eventHandler(e, 'click', this.node1 as TaroElement))
|
|
122
|
-
Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {}
|
|
123
|
-
.attrs(getNormalAttributes(this.node2 as TaroElement))
|
|
124
|
-
.onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
125
|
-
.onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
126
|
-
const eventResult: TaroAny = res.eventResult
|
|
127
|
-
this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
|
|
128
|
-
}))
|
|
129
|
-
Image((this.node0.childNodes[4] as TaroElement).getAttribute('src'))
|
|
130
|
-
.objectFit(getImageMode((this.node0.childNodes[4] as TaroElement).getAttribute('mode')))
|
|
131
|
-
.attrsImage(getNormalAttributes(this.node0.childNodes[4] as TaroElement))
|
|
132
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[4] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[4] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
133
|
-
.onAreaChange(getComponentEventCallback(this.node0.childNodes[4] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
134
|
-
const eventResult: TaroAny = res.eventResult
|
|
135
|
-
this.nodeInfoMap[this.node0.childNodes[4]._nid].areaInfo = eventResult[1]
|
|
136
|
-
}))
|
|
137
|
-
.onComplete(e => eventHandler(e, 'complete', this.node0.childNodes[4] as TaroElement))
|
|
138
|
-
Flex(FlexManager.flexOptions(this.node0.childNodes[5] as TaroElement)) {}
|
|
139
|
-
.attrs(getNormalAttributes(this.node0.childNodes[5] as TaroElement))
|
|
140
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[5] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[5] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
141
|
-
.onAreaChange(getComponentEventCallback(this.node0.childNodes[5] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
142
|
-
const eventResult: TaroAny = res.eventResult
|
|
143
|
-
this.nodeInfoMap[this.node0.childNodes[5]._nid].areaInfo = eventResult[1]
|
|
144
|
-
}))
|
|
145
|
-
.onClick(e => eventHandler(e, 'click', this.node0.childNodes[5] as TaroElement))
|
|
146
|
-
.onTouch(e => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node0.childNodes[5] as TaroElement))
|
|
147
|
-
}
|
|
148
|
-
.attrs(getNormalAttributes(this.node0 as TaroElement))
|
|
149
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
150
|
-
.onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
151
|
-
const eventResult: TaroAny = res.eventResult
|
|
152
|
-
this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
|
|
153
|
-
}))
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
`;
|
|
157
|
-
function Index() {
|
|
158
|
-
return <View compileMode="f0t0" _dynamicID="node0">
|
|
159
|
-
|
|
160
|
-
<View onClick={()=>{
|
|
161
|
-
console.log("click done");
|
|
162
|
-
}}></View>
|
|
163
|
-
|
|
164
|
-
<View onClick={function clickFn() {
|
|
165
|
-
console.log("click done");
|
|
166
|
-
}}></View>
|
|
167
|
-
|
|
168
|
-
<View onClick={handleViewClick} _dynamicID="node1"></View>
|
|
169
|
-
|
|
170
|
-
<View onAnimationStart={()=>{}} id={myId} _dynamicID="node2"></View>
|
|
171
|
-
|
|
172
|
-
<Image onLoad={()=>{
|
|
173
|
-
console.log("load done");
|
|
174
|
-
}} id="myImg"/>
|
|
175
|
-
|
|
176
|
-
<View onClick={()=>{
|
|
177
|
-
console.log("click done");
|
|
178
|
-
}} onTouchStart={()=>{
|
|
179
|
-
console.log("touch start done");
|
|
180
|
-
}}/>
|
|
181
|
-
|
|
182
|
-
</View>;
|
|
183
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
|
|
2
|
-
import { FlexManager } from '../utils/FlexManager'
|
|
3
|
-
import { TOUCH_EVENT_MAP } from '../utils/constant/event'
|
|
4
|
-
import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
|
|
5
|
-
import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
|
|
6
|
-
import { DynamicCenter } from '../utils/DynamicCenter'
|
|
7
|
-
|
|
8
|
-
import type { TaroViewElement } from '../element'
|
|
9
|
-
import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
|
|
10
|
-
|
|
11
|
-
@Extend(Flex)
|
|
12
|
-
function attrs (style: TaroStyleType) {
|
|
13
|
-
.id(style.id)
|
|
14
|
-
.key(style.id)
|
|
15
|
-
.padding(style.padding)
|
|
16
|
-
.margin(style.margin)
|
|
17
|
-
.width(style.width)
|
|
18
|
-
.height(style.height)
|
|
19
|
-
.constraintSize(style.constraintSize)
|
|
20
|
-
.flexGrow(style.flexGrow)
|
|
21
|
-
.flexShrink(style.flexShrink)
|
|
22
|
-
.flexBasis(style.flexBasis)
|
|
23
|
-
.alignSelf(style.alignSelf)
|
|
24
|
-
.backgroundColor(style.backgroundColor)
|
|
25
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
26
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
27
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
28
|
-
.rotate(style.rotate)
|
|
29
|
-
.scale(style.scale)
|
|
30
|
-
.translate(style.translate)
|
|
31
|
-
.transform(style.transform)
|
|
32
|
-
.borderStyle(style.borderStyle)
|
|
33
|
-
.borderWidth(style.borderWidth)
|
|
34
|
-
.borderColor(style.borderColor)
|
|
35
|
-
.borderRadius(style.borderRadius)
|
|
36
|
-
.linearGradient(style.linearGradient)
|
|
37
|
-
.zIndex(style.zIndex)
|
|
38
|
-
.opacity(style.opacity)
|
|
39
|
-
.clip(style.clip)
|
|
40
|
-
}
|
|
41
|
-
@Extend(Image)
|
|
42
|
-
function attrsImage (style: TaroStyleType) {
|
|
43
|
-
.id(style.id)
|
|
44
|
-
.key(style.id)
|
|
45
|
-
.padding(style.padding)
|
|
46
|
-
.margin(style.margin)
|
|
47
|
-
.width(style.width)
|
|
48
|
-
.height(style.height)
|
|
49
|
-
.constraintSize(style.constraintSize)
|
|
50
|
-
.flexGrow(style.flexGrow)
|
|
51
|
-
.flexShrink(style.flexShrink)
|
|
52
|
-
.flexBasis(style.flexBasis)
|
|
53
|
-
.alignSelf(style.alignSelf)
|
|
54
|
-
.backgroundColor(style.backgroundColor)
|
|
55
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
56
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
57
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
58
|
-
.rotate(style.rotate)
|
|
59
|
-
.scale(style.scale)
|
|
60
|
-
.translate(style.translate)
|
|
61
|
-
.transform(style.transform)
|
|
62
|
-
.borderStyle(style.borderStyle)
|
|
63
|
-
.borderWidth(style.borderWidth)
|
|
64
|
-
.borderColor(style.borderColor)
|
|
65
|
-
.borderRadius(style.borderRadius)
|
|
66
|
-
.linearGradient(style.linearGradient)
|
|
67
|
-
.zIndex(style.zIndex)
|
|
68
|
-
.opacity(style.opacity)
|
|
69
|
-
.clip(style.clip)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getImageMode (mode: string): ImageFit {
|
|
73
|
-
switch (mode) {
|
|
74
|
-
case 'aspectFit': return ImageFit.Contain
|
|
75
|
-
case 'aspectFill': return ImageFit.Cover
|
|
76
|
-
case 'scaleToFill': return ImageFit.Fill
|
|
77
|
-
case 'widthFix': return ImageFit.Auto
|
|
78
|
-
case 'heightFix': return ImageFit.Auto
|
|
79
|
-
default: return ImageFit.Contain
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
@Component
|
|
83
|
-
export default struct TARO_TEMPLATES_f0t0 {
|
|
84
|
-
nodeInfoMap: TaroAny = {}
|
|
85
|
-
dynamicCenter: DynamicCenter = new DynamicCenter()
|
|
86
|
-
@ObjectLink node: TaroViewElement
|
|
87
|
-
|
|
88
|
-
aboutToAppear () {
|
|
89
|
-
this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@State node0: TaroElement = new TaroIgnoreElement()
|
|
93
|
-
@State node1: TaroElement = new TaroIgnoreElement()
|
|
94
|
-
@State node2: TaroElement = new TaroIgnoreElement()
|
|
95
|
-
@State node3: TaroElement = new TaroIgnoreElement()
|
|
96
|
-
@State node4: TaroElement = new TaroIgnoreElement()
|
|
97
|
-
@State node5: TaroElement = new TaroIgnoreElement()
|
|
98
|
-
|
|
99
|
-
build() {
|
|
100
|
-
Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
|
|
101
|
-
Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
|
|
102
|
-
Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {}
|
|
103
|
-
.attrs(getNormalAttributes(this.node2 as TaroElement))
|
|
104
|
-
.onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
105
|
-
.onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
106
|
-
const eventResult: TaroAny = res.eventResult
|
|
107
|
-
this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
|
|
108
|
-
}))
|
|
109
|
-
Flex(FlexManager.flexOptions(this.node1.childNodes[1] as TaroElement)) {}
|
|
110
|
-
.attrs(getNormalAttributes(this.node1.childNodes[1] as TaroElement))
|
|
111
|
-
.onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
112
|
-
.onAreaChange(getComponentEventCallback(this.node1.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
113
|
-
const eventResult: TaroAny = res.eventResult
|
|
114
|
-
this.nodeInfoMap[this.node1.childNodes[1]._nid].areaInfo = eventResult[1]
|
|
115
|
-
}))
|
|
116
|
-
Flex(FlexManager.flexOptions(this.node3 as TaroElement)) {
|
|
117
|
-
Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {}
|
|
118
|
-
.attrs(getNormalAttributes(this.node4 as TaroElement))
|
|
119
|
-
.onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
120
|
-
.onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
121
|
-
const eventResult: TaroAny = res.eventResult
|
|
122
|
-
this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
|
|
123
|
-
}))
|
|
124
|
-
}
|
|
125
|
-
.attrs(getNormalAttributes(this.node3 as TaroElement))
|
|
126
|
-
.onVisibleAreaChange(getNodeThresholds(this.node3 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
127
|
-
.onAreaChange(getComponentEventCallback(this.node3 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
128
|
-
const eventResult: TaroAny = res.eventResult
|
|
129
|
-
this.nodeInfoMap[this.node3._nid].areaInfo = eventResult[1]
|
|
130
|
-
}))
|
|
131
|
-
}
|
|
132
|
-
.attrs(getNormalAttributes(this.node1 as TaroElement))
|
|
133
|
-
.onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
134
|
-
.onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
135
|
-
const eventResult: TaroAny = res.eventResult
|
|
136
|
-
this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
|
|
137
|
-
}))
|
|
138
|
-
Image((this.node0.childNodes[1] as TaroElement).getAttribute('src'))
|
|
139
|
-
.objectFit(getImageMode((this.node0.childNodes[1] as TaroElement).getAttribute('mode')))
|
|
140
|
-
.attrsImage(getNormalAttributes(this.node0.childNodes[1] as TaroElement))
|
|
141
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
142
|
-
.onAreaChange(getComponentEventCallback(this.node0.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
143
|
-
const eventResult: TaroAny = res.eventResult
|
|
144
|
-
this.nodeInfoMap[this.node0.childNodes[1]._nid].areaInfo = eventResult[1]
|
|
145
|
-
}))
|
|
146
|
-
Image((this.node5 as TaroElement).getAttribute('src'))
|
|
147
|
-
.objectFit(getImageMode((this.node5 as TaroElement).getAttribute('mode')))
|
|
148
|
-
.attrsImage(getNormalAttributes(this.node5 as TaroElement))
|
|
149
|
-
.onVisibleAreaChange(getNodeThresholds(this.node5 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
150
|
-
.onAreaChange(getComponentEventCallback(this.node5 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
151
|
-
const eventResult: TaroAny = res.eventResult
|
|
152
|
-
this.nodeInfoMap[this.node5._nid].areaInfo = eventResult[1]
|
|
153
|
-
}))
|
|
154
|
-
}
|
|
155
|
-
.attrs(getNormalAttributes(this.node0 as TaroElement))
|
|
156
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
157
|
-
.onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
158
|
-
const eventResult: TaroAny = res.eventResult
|
|
159
|
-
this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
|
|
160
|
-
}))
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
`;
|
|
164
|
-
function Index() {
|
|
165
|
-
return <View compileMode="f0t0" _dynamicID="node0">
|
|
166
|
-
|
|
167
|
-
<View class={myClass} _dynamicID="node1">
|
|
168
|
-
|
|
169
|
-
<View style={myStyle} customProp={myCustomProp} _dynamicID="node2"></View>
|
|
170
|
-
|
|
171
|
-
<View class="center"/>
|
|
172
|
-
|
|
173
|
-
<View onTouch={myTime} _dynamicID="node3">
|
|
174
|
-
|
|
175
|
-
<View hoverClass={myHoverClass} _dynamicID="node4"></View>
|
|
176
|
-
|
|
177
|
-
</View>
|
|
178
|
-
|
|
179
|
-
</View>
|
|
180
|
-
|
|
181
|
-
<Image alt="占位符" src="https://www.jd.com/test.jpg"/>
|
|
182
|
-
|
|
183
|
-
<Image alt="占位符" src={src} _dynamicID="node5"/>
|
|
184
|
-
|
|
185
|
-
</View>;
|
|
186
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
|
|
2
|
-
import { FlexManager } from '../utils/FlexManager'
|
|
3
|
-
import { TOUCH_EVENT_MAP } from '../utils/constant/event'
|
|
4
|
-
import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
|
|
5
|
-
import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
|
|
6
|
-
import { DynamicCenter } from '../utils/DynamicCenter'
|
|
7
|
-
|
|
8
|
-
import type { TaroViewElement } from '../element'
|
|
9
|
-
import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
|
|
10
|
-
|
|
11
|
-
@Extend(Flex)
|
|
12
|
-
function attrs (style: TaroStyleType) {
|
|
13
|
-
.id(style.id)
|
|
14
|
-
.key(style.id)
|
|
15
|
-
.padding(style.padding)
|
|
16
|
-
.margin(style.margin)
|
|
17
|
-
.width(style.width)
|
|
18
|
-
.height(style.height)
|
|
19
|
-
.constraintSize(style.constraintSize)
|
|
20
|
-
.flexGrow(style.flexGrow)
|
|
21
|
-
.flexShrink(style.flexShrink)
|
|
22
|
-
.flexBasis(style.flexBasis)
|
|
23
|
-
.alignSelf(style.alignSelf)
|
|
24
|
-
.backgroundColor(style.backgroundColor)
|
|
25
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
26
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
27
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
28
|
-
.rotate(style.rotate)
|
|
29
|
-
.scale(style.scale)
|
|
30
|
-
.translate(style.translate)
|
|
31
|
-
.transform(style.transform)
|
|
32
|
-
.borderStyle(style.borderStyle)
|
|
33
|
-
.borderWidth(style.borderWidth)
|
|
34
|
-
.borderColor(style.borderColor)
|
|
35
|
-
.borderRadius(style.borderRadius)
|
|
36
|
-
.linearGradient(style.linearGradient)
|
|
37
|
-
.zIndex(style.zIndex)
|
|
38
|
-
.opacity(style.opacity)
|
|
39
|
-
.clip(style.clip)
|
|
40
|
-
}
|
|
41
|
-
@Component
|
|
42
|
-
export default struct TARO_TEMPLATES_f0t0 {
|
|
43
|
-
nodeInfoMap: TaroAny = {}
|
|
44
|
-
dynamicCenter: DynamicCenter = new DynamicCenter()
|
|
45
|
-
@ObjectLink node: TaroViewElement
|
|
46
|
-
|
|
47
|
-
aboutToAppear () {
|
|
48
|
-
this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@State node0: TaroElement = new TaroIgnoreElement()
|
|
52
|
-
@State node1: TaroElement = new TaroIgnoreElement()
|
|
53
|
-
|
|
54
|
-
build() {
|
|
55
|
-
Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
|
|
56
|
-
createNode(this.node0.childNodes[0] as TaroElement)
|
|
57
|
-
createNode(this.node1 as TaroElement)
|
|
58
|
-
}
|
|
59
|
-
.attrs(getNormalAttributes(this.node0 as TaroElement))
|
|
60
|
-
.onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
|
|
61
|
-
.onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
|
|
62
|
-
const eventResult: TaroAny = res.eventResult
|
|
63
|
-
this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
|
|
64
|
-
}))
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
function Index() {
|
|
69
|
-
return <View compileMode="f0t0" _dynamicID="node0">
|
|
70
|
-
|
|
71
|
-
<Foo/>
|
|
72
|
-
|
|
73
|
-
<Foo title={myTitle} loading onClick={()=>{}} _dynamicID="node1"/>
|
|
74
|
-
|
|
75
|
-
</View>;
|
|
76
|
-
}
|