@tarojs/helper 3.7.0-alpha.25 → 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,342 @@
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(Text)
41
+ function textStyle (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
+ .fontColor(style.color)
69
+ .fontSize(style.fontSize)
70
+ .fontWeight(style.fontWeight)
71
+ .fontStyle(style.fontStyle)
72
+ .fontFamily(style.fontFamily)
73
+ .lineHeight(style.lineHeight)
74
+ .decoration({
75
+ type: style.decoration,
76
+ color: style.color
77
+ })
78
+ }
79
+
80
+ @Extend(Text)
81
+ function textAttr(attr: TaroTextStyleType) {
82
+ .textAlign(attr.textAlign)
83
+ .textOverflow(attr.textOverflow)
84
+ .maxLines(attr.maxLines)
85
+ .letterSpacing(attr.letterSpacing)
86
+ }
87
+ @Component
88
+ export default struct TARO_TEMPLATES_f0t0 {
89
+ nodeInfoMap: TaroAny = {}
90
+ dynamicCenter: DynamicCenter = new DynamicCenter()
91
+ @ObjectLink node: TaroViewElement
92
+
93
+ aboutToAppear () {
94
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
95
+ }
96
+
97
+ @State node0: TaroElement = new TaroIgnoreElement()
98
+ @State node1: TaroElement = new TaroIgnoreElement()
99
+ @State node2: TaroElement = new TaroIgnoreElement()
100
+ @State node3: TaroElement = new TaroIgnoreElement()
101
+ @State node4: TaroElement = new TaroIgnoreElement()
102
+ @State node5: TaroElement = new TaroIgnoreElement()
103
+ @State node6: TaroElement = new TaroIgnoreElement()
104
+ @State node7: TaroElement = new TaroIgnoreElement()
105
+ @State node8: TaroElement = new TaroIgnoreElement()
106
+ @State node9: TaroElement = new TaroIgnoreElement()
107
+ @State node10: TaroElement = new TaroIgnoreElement()
108
+ @State node11: TaroElement = new TaroIgnoreElement()
109
+
110
+ build() {
111
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
112
+ if ((this.node0.childNodes[0] as TaroElement)._attrs.compileIf) {
113
+ Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
114
+ Text(this.node1.childNodes[0].textContent)
115
+ .textStyle(getNormalAttributes(this.node1.childNodes[0] as TaroElement))
116
+ .textAttr(getFontAttributes(this.node1.childNodes[0] as TaroElement))
117
+ .onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
118
+ .onAreaChange(getComponentEventCallback(this.node1.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
119
+ const eventResult: TaroAny = res.eventResult
120
+ this.nodeInfoMap[this.node1.childNodes[0]._nid].areaInfo = eventResult[1]
121
+ }))
122
+ }
123
+ .attrs(getNormalAttributes(this.node1 as TaroElement))
124
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
125
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
126
+ const eventResult: TaroAny = res.eventResult
127
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
128
+ }))
129
+ } else {
130
+ Text(this.node0.childNodes[0].textContent)
131
+ .textStyle(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
132
+ .textAttr(getFontAttributes(this.node0.childNodes[0] as TaroElement))
133
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
134
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
135
+ const eventResult: TaroAny = res.eventResult
136
+ this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
137
+ }))
138
+ }
139
+ if ((this.node0.childNodes[1] as TaroElement)._attrs.compileIf) {
140
+ if ((this.node0.childNodes[1] as TaroElement)._attrs.compileIf) {
141
+ Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {
142
+ Text(this.node4.childNodes[0].textContent)
143
+ .textStyle(getNormalAttributes(this.node4.childNodes[0] as TaroElement))
144
+ .textAttr(getFontAttributes(this.node4.childNodes[0] as TaroElement))
145
+ .onVisibleAreaChange(getNodeThresholds(this.node4.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
146
+ .onAreaChange(getComponentEventCallback(this.node4.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
147
+ const eventResult: TaroAny = res.eventResult
148
+ this.nodeInfoMap[this.node4.childNodes[0]._nid].areaInfo = eventResult[1]
149
+ }))
150
+ }
151
+ .attrs(getNormalAttributes(this.node4 as TaroElement))
152
+ .onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
153
+ .onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
154
+ const eventResult: TaroAny = res.eventResult
155
+ this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
156
+ }))
157
+ } else {
158
+ Text(this.node3.textContent)
159
+ .textStyle(getNormalAttributes(this.node3 as TaroElement))
160
+ .textAttr(getFontAttributes(this.node3 as TaroElement))
161
+ .onVisibleAreaChange(getNodeThresholds(this.node3 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
162
+ .onAreaChange(getComponentEventCallback(this.node3 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
163
+ const eventResult: TaroAny = res.eventResult
164
+ this.nodeInfoMap[this.node3._nid].areaInfo = eventResult[1]
165
+ }))
166
+ }
167
+ } else {
168
+ Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {
169
+ Text(this.node2.childNodes[0].textContent)
170
+ .textStyle(getNormalAttributes(this.node2.childNodes[0] as TaroElement))
171
+ .textAttr(getFontAttributes(this.node2.childNodes[0] as TaroElement))
172
+ .onVisibleAreaChange(getNodeThresholds(this.node2.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
173
+ .onAreaChange(getComponentEventCallback(this.node2.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
174
+ const eventResult: TaroAny = res.eventResult
175
+ this.nodeInfoMap[this.node2.childNodes[0]._nid].areaInfo = eventResult[1]
176
+ }))
177
+ }
178
+ .attrs(getNormalAttributes(this.node2 as TaroElement))
179
+ .onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
180
+ .onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
181
+ const eventResult: TaroAny = res.eventResult
182
+ this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
183
+ }))
184
+ }
185
+ if ((this.node0.childNodes[2] as TaroElement)._attrs.compileIf) {
186
+ Flex(FlexManager.flexOptions(this.node7 as TaroElement)) {
187
+ Text(this.node7.childNodes[0].textContent)
188
+ .textStyle(getNormalAttributes(this.node7.childNodes[0] as TaroElement))
189
+ .textAttr(getFontAttributes(this.node7.childNodes[0] as TaroElement))
190
+ .onVisibleAreaChange(getNodeThresholds(this.node7.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node7.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
191
+ .onAreaChange(getComponentEventCallback(this.node7.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
192
+ const eventResult: TaroAny = res.eventResult
193
+ this.nodeInfoMap[this.node7.childNodes[0]._nid].areaInfo = eventResult[1]
194
+ }))
195
+ }
196
+ .attrs(getNormalAttributes(this.node7 as TaroElement))
197
+ .onVisibleAreaChange(getNodeThresholds(this.node7 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node7 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
198
+ .onAreaChange(getComponentEventCallback(this.node7 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
199
+ const eventResult: TaroAny = res.eventResult
200
+ this.nodeInfoMap[this.node7._nid].areaInfo = eventResult[1]
201
+ }))
202
+ } else {
203
+ if ((this.node0.childNodes[2] as TaroElement)._attrs.compileIf) {
204
+ Flex(FlexManager.flexOptions(this.node6 as TaroElement)) {
205
+ Text(this.node6.childNodes[0].textContent)
206
+ .textStyle(getNormalAttributes(this.node6.childNodes[0] as TaroElement))
207
+ .textAttr(getFontAttributes(this.node6.childNodes[0] as TaroElement))
208
+ .onVisibleAreaChange(getNodeThresholds(this.node6.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node6.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
209
+ .onAreaChange(getComponentEventCallback(this.node6.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
210
+ const eventResult: TaroAny = res.eventResult
211
+ this.nodeInfoMap[this.node6.childNodes[0]._nid].areaInfo = eventResult[1]
212
+ }))
213
+ }
214
+ .attrs(getNormalAttributes(this.node6 as TaroElement))
215
+ .onVisibleAreaChange(getNodeThresholds(this.node6 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node6 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
216
+ .onAreaChange(getComponentEventCallback(this.node6 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
217
+ const eventResult: TaroAny = res.eventResult
218
+ this.nodeInfoMap[this.node6._nid].areaInfo = eventResult[1]
219
+ }))
220
+ } else {
221
+ Text(this.node5.textContent)
222
+ .textStyle(getNormalAttributes(this.node5 as TaroElement))
223
+ .textAttr(getFontAttributes(this.node5 as TaroElement))
224
+ .onVisibleAreaChange(getNodeThresholds(this.node5 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
225
+ .onAreaChange(getComponentEventCallback(this.node5 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
226
+ const eventResult: TaroAny = res.eventResult
227
+ this.nodeInfoMap[this.node5._nid].areaInfo = eventResult[1]
228
+ }))
229
+ }
230
+ }
231
+ if ((this.node0.childNodes[3] as TaroElement)._attrs.compileIf) {
232
+ Flex(FlexManager.flexOptions(this.node8 as TaroElement)) {
233
+ Text(this.node8.childNodes[0].textContent)
234
+ .textStyle(getNormalAttributes(this.node8.childNodes[0] as TaroElement))
235
+ .textAttr(getFontAttributes(this.node8.childNodes[0] as TaroElement))
236
+ .onVisibleAreaChange(getNodeThresholds(this.node8.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node8.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
237
+ .onAreaChange(getComponentEventCallback(this.node8.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
238
+ const eventResult: TaroAny = res.eventResult
239
+ this.nodeInfoMap[this.node8.childNodes[0]._nid].areaInfo = eventResult[1]
240
+ }))
241
+ }
242
+ .attrs(getNormalAttributes(this.node8 as TaroElement))
243
+ .onVisibleAreaChange(getNodeThresholds(this.node8 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node8 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
244
+ .onAreaChange(getComponentEventCallback(this.node8 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
245
+ const eventResult: TaroAny = res.eventResult
246
+ this.nodeInfoMap[this.node8._nid].areaInfo = eventResult[1]
247
+ }))
248
+ }
249
+ if ((this.node0.childNodes[4] as TaroElement)._attrs.compileIf) {
250
+ } else {
251
+ Flex(FlexManager.flexOptions(this.node9 as TaroElement)) {
252
+ Text(this.node9.childNodes[0].textContent)
253
+ .textStyle(getNormalAttributes(this.node9.childNodes[0] as TaroElement))
254
+ .textAttr(getFontAttributes(this.node9.childNodes[0] as TaroElement))
255
+ .onVisibleAreaChange(getNodeThresholds(this.node9.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node9.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
256
+ .onAreaChange(getComponentEventCallback(this.node9.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
257
+ const eventResult: TaroAny = res.eventResult
258
+ this.nodeInfoMap[this.node9.childNodes[0]._nid].areaInfo = eventResult[1]
259
+ }))
260
+ }
261
+ .attrs(getNormalAttributes(this.node9 as TaroElement))
262
+ .onVisibleAreaChange(getNodeThresholds(this.node9 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node9 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
263
+ .onAreaChange(getComponentEventCallback(this.node9 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
264
+ const eventResult: TaroAny = res.eventResult
265
+ this.nodeInfoMap[this.node9._nid].areaInfo = eventResult[1]
266
+ }))
267
+ }
268
+ if ((this.node0.childNodes[5] as TaroElement)._attrs.compileIf) {
269
+ Flex(FlexManager.flexOptions(this.node10 as TaroElement)) {
270
+ Text(this.node10.childNodes[0].textContent)
271
+ .textStyle(getNormalAttributes(this.node10.childNodes[0] as TaroElement))
272
+ .textAttr(getFontAttributes(this.node10.childNodes[0] as TaroElement))
273
+ .onVisibleAreaChange(getNodeThresholds(this.node10.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node10.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
274
+ .onAreaChange(getComponentEventCallback(this.node10.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
275
+ const eventResult: TaroAny = res.eventResult
276
+ this.nodeInfoMap[this.node10.childNodes[0]._nid].areaInfo = eventResult[1]
277
+ }))
278
+ }
279
+ .attrs(getNormalAttributes(this.node10 as TaroElement))
280
+ .onVisibleAreaChange(getNodeThresholds(this.node10 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node10 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
281
+ .onAreaChange(getComponentEventCallback(this.node10 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
282
+ const eventResult: TaroAny = res.eventResult
283
+ this.nodeInfoMap[this.node10._nid].areaInfo = eventResult[1]
284
+ }))
285
+ }
286
+ if ((this.node0.childNodes[6] as TaroElement)._attrs.compileIf) {
287
+ Text(this.node0.childNodes[6].textContent)
288
+ .textStyle(getNormalAttributes(this.node0.childNodes[6] as TaroElement))
289
+ .textAttr(getFontAttributes(this.node0.childNodes[6] as TaroElement))
290
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[6] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[6] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
291
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[6] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
292
+ const eventResult: TaroAny = res.eventResult
293
+ this.nodeInfoMap[this.node0.childNodes[6]._nid].areaInfo = eventResult[1]
294
+ }))
295
+ } else {
296
+ Text(this.node0.childNodes[6].textContent)
297
+ .textStyle(getNormalAttributes(this.node0.childNodes[6] as TaroElement))
298
+ .textAttr(getFontAttributes(this.node0.childNodes[6] as TaroElement))
299
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[6] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[6] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
300
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[6] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
301
+ const eventResult: TaroAny = res.eventResult
302
+ this.nodeInfoMap[this.node0.childNodes[6]._nid].areaInfo = eventResult[1]
303
+ }))
304
+ }
305
+ Flex(FlexManager.flexOptions(this.node11 as TaroElement)) {}
306
+ .attrs(getNormalAttributes(this.node11 as TaroElement))
307
+ .onVisibleAreaChange(getNodeThresholds(this.node11 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node11 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
308
+ .onAreaChange(getComponentEventCallback(this.node11 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
309
+ const eventResult: TaroAny = res.eventResult
310
+ this.nodeInfoMap[this.node11._nid].areaInfo = eventResult[1]
311
+ }))
312
+ }
313
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
314
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
315
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
316
+ const eventResult: TaroAny = res.eventResult
317
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
318
+ }))
319
+ }
320
+ }
321
+ `;
322
+ function Index() {
323
+ return <View compileMode="f0t0" _dynamicID="node0">
324
+
325
+ {condition ? <View hoverClass={myClass} compileIf={condition} _dynamicID="node1">{content}</View> : <Text selectable>hello</Text>}
326
+
327
+ {condition1 ? condition2 ? <View compileIf={condition2} _dynamicID="node4">{a}</View> : <Text _dynamicID="node3">{b}</Text> : <View _dynamicID="node2">{c}</View>}
328
+
329
+ {condition1 ? <View compileIf={condition1} _dynamicID="node7">{a}</View> : condition2 ? <View _dynamicID="node6">{b}</View> : <Text _dynamicID="node5">{c}</Text>}
330
+
331
+ {condition1 ? <View compileIf={condition1} _dynamicID="node8">{a}</View> : condition2 ? <View>{b}</View> : <Text>{c}</Text>}
332
+
333
+ {condition1 ? condition2 && <View>{a}</View> : <View _dynamicID="node9">{b}</View>}
334
+
335
+ {condition1 ? <View compileIf={condition1} _dynamicID="node10">{a}</View> : condition2 && <View>{b}</View>}
336
+
337
+ {condition1 ? "someText" : 789}
338
+
339
+ <View hoverClass={myClass} _dynamicID="node11"></View>
340
+
341
+ </View>;
342
+ }
@@ -0,0 +1,139 @@
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
+
92
+ build() {
93
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
94
+ Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {}
95
+ .attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
96
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
97
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
98
+ const eventResult: TaroAny = res.eventResult
99
+ this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
100
+ }))
101
+ Flex(FlexManager.flexOptions(this.node0.childNodes[1] as TaroElement)) {
102
+ Image((this.node0.childNodes[1].childNodes[0] as TaroElement).getAttribute('src'))
103
+ .objectFit(getImageMode((this.node0.childNodes[1].childNodes[0] as TaroElement).getAttribute('mode')))
104
+ .attrsImage(getNormalAttributes(this.node0.childNodes[1].childNodes[0] as TaroElement))
105
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1].childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1].childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
106
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[1].childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
107
+ const eventResult: TaroAny = res.eventResult
108
+ this.nodeInfoMap[this.node0.childNodes[1].childNodes[0]._nid].areaInfo = eventResult[1]
109
+ }))
110
+ }
111
+ .attrs(getNormalAttributes(this.node0.childNodes[1] as TaroElement))
112
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
113
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
114
+ const eventResult: TaroAny = res.eventResult
115
+ this.nodeInfoMap[this.node0.childNodes[1]._nid].areaInfo = eventResult[1]
116
+ }))
117
+ }
118
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
119
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
120
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
121
+ const eventResult: TaroAny = res.eventResult
122
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
123
+ }))
124
+ }
125
+ }
126
+ `;
127
+ function Index() {
128
+ return <View compileMode="f0t0" _dynamicID="node0">
129
+
130
+ <View/>
131
+
132
+ <View>
133
+
134
+ <Image/>
135
+
136
+ </View>
137
+
138
+ </View>;
139
+ }
@@ -0,0 +1,90 @@
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
+
52
+ build() {
53
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
54
+ Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {
55
+ createNode(this.node0.childNodes[0].childNodes[0] as TaroElement)
56
+ }
57
+ .attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
58
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
59
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
60
+ const eventResult: TaroAny = res.eventResult
61
+ this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
62
+ }))
63
+ Flex(FlexManager.flexOptions(this.node0.childNodes[1] as TaroElement)) {
64
+ createNode(this.node0.childNodes[1].childNodes[0] as TaroElement)
65
+ }
66
+ .attrs(getNormalAttributes(this.node0.childNodes[1] as TaroElement))
67
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
68
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
69
+ const eventResult: TaroAny = res.eventResult
70
+ this.nodeInfoMap[this.node0.childNodes[1]._nid].areaInfo = eventResult[1]
71
+ }))
72
+ }
73
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
74
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
75
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
76
+ const eventResult: TaroAny = res.eventResult
77
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
78
+ }))
79
+ }
80
+ }
81
+ `;
82
+ function Index() {
83
+ return <View compileMode="f0t0" _dynamicID="node0">
84
+
85
+ <View><Slider/></View>
86
+
87
+ <View><Test1/></View>
88
+
89
+ </View>;
90
+ }