@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,209 @@
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
+
103
+ build() {
104
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
105
+ if ((this.node0.childNodes[0] as TaroElement)._attrs.compileIf) {
106
+ Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
107
+ Text(this.node1.childNodes[0].textContent)
108
+ .textStyle(getNormalAttributes(this.node1.childNodes[0] as TaroElement))
109
+ .textAttr(getFontAttributes(this.node1.childNodes[0] as TaroElement))
110
+ .onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
111
+ .onAreaChange(getComponentEventCallback(this.node1.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
112
+ const eventResult: TaroAny = res.eventResult
113
+ this.nodeInfoMap[this.node1.childNodes[0]._nid].areaInfo = eventResult[1]
114
+ }))
115
+ }
116
+ .attrs(getNormalAttributes(this.node1 as TaroElement))
117
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
118
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
119
+ const eventResult: TaroAny = res.eventResult
120
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
121
+ }))
122
+ }
123
+ if ((this.node0.childNodes[1] as TaroElement)._attrs.compileIf) {
124
+ Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {
125
+ Text(this.node2.childNodes[0].textContent)
126
+ .textStyle(getNormalAttributes(this.node2.childNodes[0] as TaroElement))
127
+ .textAttr(getFontAttributes(this.node2.childNodes[0] as TaroElement))
128
+ .onVisibleAreaChange(getNodeThresholds(this.node2.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
129
+ .onAreaChange(getComponentEventCallback(this.node2.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
130
+ const eventResult: TaroAny = res.eventResult
131
+ this.nodeInfoMap[this.node2.childNodes[0]._nid].areaInfo = eventResult[1]
132
+ }))
133
+ }
134
+ .attrs(getNormalAttributes(this.node2 as TaroElement))
135
+ .onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
136
+ .onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
137
+ const eventResult: TaroAny = res.eventResult
138
+ this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
139
+ }))
140
+ }
141
+ if ((this.node0.childNodes[2] as TaroElement)._attrs.compileIf) {
142
+ Flex(FlexManager.flexOptions(this.node3 as TaroElement)) {
143
+ Text(this.node3.childNodes[0].textContent)
144
+ .textStyle(getNormalAttributes(this.node3.childNodes[0] as TaroElement))
145
+ .textAttr(getFontAttributes(this.node3.childNodes[0] as TaroElement))
146
+ .onVisibleAreaChange(getNodeThresholds(this.node3.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
147
+ .onAreaChange(getComponentEventCallback(this.node3.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
148
+ const eventResult: TaroAny = res.eventResult
149
+ this.nodeInfoMap[this.node3.childNodes[0]._nid].areaInfo = eventResult[1]
150
+ }))
151
+ }
152
+ .attrs(getNormalAttributes(this.node3 as TaroElement))
153
+ .onVisibleAreaChange(getNodeThresholds(this.node3 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
154
+ .onAreaChange(getComponentEventCallback(this.node3 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
155
+ const eventResult: TaroAny = res.eventResult
156
+ this.nodeInfoMap[this.node3._nid].areaInfo = eventResult[1]
157
+ }))
158
+ }
159
+ if ((this.node0.childNodes[3] as TaroElement)._attrs.compileIf) {
160
+ Text(this.node0.childNodes[3].textContent)
161
+ .textStyle(getNormalAttributes(this.node0.childNodes[3] as TaroElement))
162
+ .textAttr(getFontAttributes(this.node0.childNodes[3] as TaroElement))
163
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[3] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[3] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
164
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[3] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
165
+ const eventResult: TaroAny = res.eventResult
166
+ this.nodeInfoMap[this.node0.childNodes[3]._nid].areaInfo = eventResult[1]
167
+ }))
168
+ } else {
169
+ Text(this.node0.childNodes[3].textContent)
170
+ .textStyle(getNormalAttributes(this.node0.childNodes[3] as TaroElement))
171
+ .textAttr(getFontAttributes(this.node0.childNodes[3] as TaroElement))
172
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[3] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[3] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
173
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[3] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
174
+ const eventResult: TaroAny = res.eventResult
175
+ this.nodeInfoMap[this.node0.childNodes[3]._nid].areaInfo = eventResult[1]
176
+ }))
177
+ }
178
+ Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {}
179
+ .attrs(getNormalAttributes(this.node4 as TaroElement))
180
+ .onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
181
+ .onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
182
+ const eventResult: TaroAny = res.eventResult
183
+ this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
184
+ }))
185
+ }
186
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
187
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
188
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
189
+ const eventResult: TaroAny = res.eventResult
190
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
191
+ }))
192
+ }
193
+ }
194
+ `;
195
+ function Index() {
196
+ return <View compileMode="f0t0" _dynamicID="node0">
197
+
198
+ {condition ? <View hoverClass={myClass} compileIf={condition} _dynamicID="node1">{content}</View> : <View compileIgnore/>}
199
+
200
+ {condition ? <View hoverClass={myClass} compileIf={condition} _dynamicID="node2">{content}</View> : <View compileIgnore/>}
201
+
202
+ {condition1 && "condition2" && condition3 ? <View hoverClass={myClass} compileIf={condition1 && "condition2" && condition3} _dynamicID="node3">{content}</View> : <View compileIgnore/>}
203
+
204
+ {condition1 ? 'Hello' : ""}
205
+
206
+ <View hoverClass={myClass} _dynamicID="node4"></View>
207
+
208
+ </View>;
209
+ }
@@ -0,0 +1,242 @@
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
+
104
+ build() {
105
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
106
+ if ((this.node0.childNodes[0] as TaroElement)._attrs.compileIf) {
107
+ Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {}
108
+ .attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
109
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
110
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
111
+ const eventResult: TaroAny = res.eventResult
112
+ this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
113
+ }))
114
+ .onClick(e => eventHandler(e, 'click', this.node0.childNodes[0] as TaroElement))
115
+ }
116
+ Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
117
+ Text(this.node1.childNodes[0].textContent)
118
+ .textStyle(getNormalAttributes(this.node1.childNodes[0] as TaroElement))
119
+ .textAttr(getFontAttributes(this.node1.childNodes[0] as TaroElement))
120
+ .onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
121
+ .onAreaChange(getComponentEventCallback(this.node1.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
122
+ const eventResult: TaroAny = res.eventResult
123
+ this.nodeInfoMap[this.node1.childNodes[0]._nid].areaInfo = eventResult[1]
124
+ }))
125
+ }
126
+ .attrs(getNormalAttributes(this.node1 as TaroElement))
127
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
128
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
129
+ const eventResult: TaroAny = res.eventResult
130
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
131
+ }))
132
+ Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {
133
+ Text(this.node2.childNodes[0].textContent)
134
+ .textStyle(getNormalAttributes(this.node2.childNodes[0] as TaroElement))
135
+ .textAttr(getFontAttributes(this.node2.childNodes[0] as TaroElement))
136
+ .onVisibleAreaChange(getNodeThresholds(this.node2.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
137
+ .onAreaChange(getComponentEventCallback(this.node2.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
138
+ const eventResult: TaroAny = res.eventResult
139
+ this.nodeInfoMap[this.node2.childNodes[0]._nid].areaInfo = eventResult[1]
140
+ }))
141
+ }
142
+ .attrs(getNormalAttributes(this.node2 as TaroElement))
143
+ .onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
144
+ .onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
145
+ const eventResult: TaroAny = res.eventResult
146
+ this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
147
+ }))
148
+ Flex(FlexManager.flexOptions(this.node3 as TaroElement)) {
149
+ Text(this.node3.childNodes[0].textContent)
150
+ .textStyle(getNormalAttributes(this.node3.childNodes[0] as TaroElement))
151
+ .textAttr(getFontAttributes(this.node3.childNodes[0] as TaroElement))
152
+ .onVisibleAreaChange(getNodeThresholds(this.node3.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
153
+ .onAreaChange(getComponentEventCallback(this.node3.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
154
+ const eventResult: TaroAny = res.eventResult
155
+ this.nodeInfoMap[this.node3.childNodes[0]._nid].areaInfo = eventResult[1]
156
+ }))
157
+ }
158
+ .attrs(getNormalAttributes(this.node3 as TaroElement))
159
+ .onVisibleAreaChange(getNodeThresholds(this.node3 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
160
+ .onAreaChange(getComponentEventCallback(this.node3 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
161
+ const eventResult: TaroAny = res.eventResult
162
+ this.nodeInfoMap[this.node3._nid].areaInfo = eventResult[1]
163
+ }))
164
+ if ((this.node0.childNodes[4] as TaroElement)._attrs.compileIf) {
165
+ Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {}
166
+ .attrs(getNormalAttributes(this.node4 as TaroElement))
167
+ .onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
168
+ .onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
169
+ const eventResult: TaroAny = res.eventResult
170
+ this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
171
+ }))
172
+ } else {
173
+ Flex(FlexManager.flexOptions(this.node0.childNodes[4] as TaroElement)) {}
174
+ .attrs(getNormalAttributes(this.node0.childNodes[4] as TaroElement))
175
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[4] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[4] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
176
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[4] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
177
+ const eventResult: TaroAny = res.eventResult
178
+ this.nodeInfoMap[this.node0.childNodes[4]._nid].areaInfo = eventResult[1]
179
+ }))
180
+ }
181
+ if ((this.node0.childNodes[5] as TaroElement)._attrs.compileIf) {
182
+ Flex(FlexManager.flexOptions(this.node5 as TaroElement)) {
183
+ if ((this.node5.childNodes[0] as TaroElement)._attrs.compileIf) {
184
+ Flex(FlexManager.flexOptions(this.node5.childNodes[0] as TaroElement)) {}
185
+ .attrs(getNormalAttributes(this.node5.childNodes[0] as TaroElement))
186
+ .onVisibleAreaChange(getNodeThresholds(this.node5.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
187
+ .onAreaChange(getComponentEventCallback(this.node5.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
188
+ const eventResult: TaroAny = res.eventResult
189
+ this.nodeInfoMap[this.node5.childNodes[0]._nid].areaInfo = eventResult[1]
190
+ }))
191
+ } else {
192
+ Flex(FlexManager.flexOptions(this.node5.childNodes[0] as TaroElement)) {}
193
+ .attrs(getNormalAttributes(this.node5.childNodes[0] as TaroElement))
194
+ .onVisibleAreaChange(getNodeThresholds(this.node5.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
195
+ .onAreaChange(getComponentEventCallback(this.node5.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
196
+ const eventResult: TaroAny = res.eventResult
197
+ this.nodeInfoMap[this.node5.childNodes[0]._nid].areaInfo = eventResult[1]
198
+ }))
199
+ }
200
+ }
201
+ .attrs(getNormalAttributes(this.node5 as TaroElement))
202
+ .onVisibleAreaChange(getNodeThresholds(this.node5 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
203
+ .onAreaChange(getComponentEventCallback(this.node5 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
204
+ const eventResult: TaroAny = res.eventResult
205
+ this.nodeInfoMap[this.node5._nid].areaInfo = eventResult[1]
206
+ }))
207
+ } else {
208
+ Flex(FlexManager.flexOptions(this.node0.childNodes[5] as TaroElement)) {}
209
+ .attrs(getNormalAttributes(this.node0.childNodes[5] as TaroElement))
210
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[5] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[5] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
211
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[5] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
212
+ const eventResult: TaroAny = res.eventResult
213
+ this.nodeInfoMap[this.node0.childNodes[5]._nid].areaInfo = eventResult[1]
214
+ }))
215
+ }
216
+ }
217
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
218
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
219
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
220
+ const eventResult: TaroAny = res.eventResult
221
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
222
+ }))
223
+ }
224
+ }
225
+ `;
226
+ function Index() {
227
+ return <View compileMode="f0t0" _dynamicID="node0">
228
+
229
+ {condition1 ? <View onClick={()=>condition2 && doSth()} compileIf={condition1}/> : <View compileIgnore/>}
230
+
231
+ <View _dynamicID="node1">{condition1 && ident}</View>
232
+
233
+ <View _dynamicID="node2">{condition1 && obj.property}</View>
234
+
235
+ <View _dynamicID="node3">{condition1 && fn()}</View>
236
+
237
+ {condition1 ? <View className={condition2 ? '' : ''} compileIf={condition1} _dynamicID="node4"/> : <View/>}
238
+
239
+ {condition1 ? <View compileIf={condition1} _dynamicID="node5">{condition2 ? <View compileIf={condition2}/> : <View/>}</View> : <View/>}
240
+
241
+ </View>;
242
+ }
@@ -0,0 +1,137 @@
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
+
99
+ build() {
100
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
101
+ if ((this.node0.childNodes[0] as TaroElement)._attrs.compileIf) {
102
+ Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {
103
+ Text(this.node0.childNodes[0].childNodes[0].textContent)
104
+ .textStyle(getNormalAttributes(this.node0.childNodes[0].childNodes[0] as TaroElement))
105
+ .textAttr(getFontAttributes(this.node0.childNodes[0].childNodes[0] as TaroElement))
106
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0].childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0].childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
107
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0].childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
108
+ const eventResult: TaroAny = res.eventResult
109
+ this.nodeInfoMap[this.node0.childNodes[0].childNodes[0]._nid].areaInfo = eventResult[1]
110
+ }))
111
+ }
112
+ .attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
113
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
114
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
115
+ const eventResult: TaroAny = res.eventResult
116
+ this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
117
+ }))
118
+ } else {
119
+ createNode(this.node0.childNodes[0] as TaroElement)
120
+ }
121
+ }
122
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
123
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
124
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
125
+ const eventResult: TaroAny = res.eventResult
126
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
127
+ }))
128
+ }
129
+ }
130
+ `;
131
+ function Index() {
132
+ return <View compileMode="f0t0" _dynamicID="node0">
133
+
134
+ {condition ? <View hoverClass='test' compileIf={condition}>hello</View> : <UnKnow selectable>hello</UnKnow>}
135
+
136
+ </View>;
137
+ }