@tarojs/helper 3.7.0-alpha.26 → 3.7.0-alpha.27

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