@tarojs/helper 4.0.0-beta.0 → 4.0.0-beta.2

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 (78) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +4 -1
  3. package/dist/esbuild/index.js +2 -2
  4. package/dist/esbuild/index.js.map +1 -1
  5. package/dist/utils.js +5 -9
  6. package/dist/utils.js.map +1 -1
  7. package/package.json +6 -4
  8. package/swc/.gitkeep +0 -0
  9. package/swc/swc_plugin_compile_mode.wasm +0 -0
  10. package/swc/swc_plugin_define_config.wasm +0 -0
  11. package/swc/plugin-compile-mode/.cargo/config +0 -5
  12. package/swc/plugin-compile-mode/.editorconfig +0 -6
  13. package/swc/plugin-compile-mode/.vscode/settings.json +0 -3
  14. package/swc/plugin-compile-mode/Cargo.lock +0 -2021
  15. package/swc/plugin-compile-mode/Cargo.toml +0 -22
  16. package/swc/plugin-compile-mode/package.json +0 -15
  17. package/swc/plugin-compile-mode/src/lib.rs +0 -71
  18. package/swc/plugin-compile-mode/src/tests/attributes.rs +0 -54
  19. package/swc/plugin-compile-mode/src/tests/children.rs +0 -86
  20. package/swc/plugin-compile-mode/src/tests/condition.rs +0 -50
  21. package/swc/plugin-compile-mode/src/tests/entry.rs +0 -20
  22. package/swc/plugin-compile-mode/src/tests/harmony/attributes.rs +0 -45
  23. package/swc/plugin-compile-mode/src/tests/harmony/children.rs +0 -74
  24. package/swc/plugin-compile-mode/src/tests/harmony/condition.rs +0 -79
  25. package/swc/plugin-compile-mode/src/tests/harmony/entry.rs +0 -67
  26. package/swc/plugin-compile-mode/src/tests/harmony/looping.rs +0 -62
  27. package/swc/plugin-compile-mode/src/tests/harmony/mod.rs +0 -45
  28. package/swc/plugin-compile-mode/src/tests/looping.rs +0 -84
  29. package/swc/plugin-compile-mode/src/tests/mod.rs +0 -100
  30. package/swc/plugin-compile-mode/src/tests/shake.rs +0 -27
  31. package/swc/plugin-compile-mode/src/transform.rs +0 -474
  32. package/swc/plugin-compile-mode/src/transform_harmony.rs +0 -526
  33. package/swc/plugin-compile-mode/src/utils/constants.rs +0 -152
  34. package/swc/plugin-compile-mode/src/utils/harmony/components.rs +0 -61
  35. package/swc/plugin-compile-mode/src/utils/harmony/mod.rs +0 -1
  36. package/swc/plugin-compile-mode/src/utils/mod.rs +0 -347
  37. package/swc/plugin-compile-mode/target/wasm32-wasi/release/swc_plugin_compile_mode.wasm +0 -0
  38. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_handle_events.js +0 -8
  39. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_keep_static_attrs_only_in_templates.js +0 -8
  40. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_turn_dynamic_attrs.js +0 -11
  41. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_native_component.js +0 -7
  42. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_react_component.js +0 -7
  43. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_fragment.js +0 -44
  44. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_render_fn.js +0 -8
  45. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_and_expr.js +0 -14
  46. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_conditional_expr.js +0 -15
  47. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/entry.rs/should_support_multi_compile_mode.js +0 -10
  48. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_handle_events.js +0 -183
  49. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_turn_dynamic_attrs.js +0 -186
  50. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_render_react_component.js +0 -76
  51. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_fragment.js +0 -341
  52. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_render_fn.js +0 -186
  53. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_and_expr.js +0 -211
  54. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_complex_condition.js +0 -244
  55. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_and_unkonw_component.js +0 -139
  56. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_expr.js +0 -344
  57. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_compile_child_node.js +0 -141
  58. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_component_not_in_config.js +0 -91
  59. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_multi_compile_mode.js +0 -209
  60. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_single_compile_mode.js +0 -66
  61. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -76
  62. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt_and_set_parent_dynamic_id.js +0 -89
  63. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_function_expr.js +0 -86
  64. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +0 -8
  65. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_expr.js +0 -6
  66. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_function_expr.js +0 -20
  67. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_support_nested_loop.js +0 -15
  68. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/shake.rs/should_static_jsx_being_shaked.js +0 -20
  69. package/swc/plugin-define-config/.cargo/config +0 -5
  70. package/swc/plugin-define-config/Cargo.lock +0 -2110
  71. package/swc/plugin-define-config/Cargo.toml +0 -18
  72. package/swc/plugin-define-config/src/lib.rs +0 -141
  73. package/swc/plugin-define-config/target/wasm32-wasi/release/swc_plugin_define_config.wasm +0 -0
  74. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_app.js +0 -2
  75. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_page.js +0 -2
  76. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_exports.js +0 -11
  77. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_app.js +0 -3
  78. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_page.js +0 -3
@@ -1,211 +0,0 @@
1
- const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
- import { FlexManager } from '../utils/FlexManager'
3
- import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
- import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
- import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
- import { DynamicCenter } from '../utils/DynamicCenter'
7
-
8
- import type { TaroViewElement } from '../element'
9
- import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
-
11
- @Extend(Flex)
12
- function attrs (style: TaroStyleType) {
13
- .id(style.id)
14
- .key(style.id)
15
- .padding(style.padding)
16
- .margin(style.margin)
17
- .width(style.width)
18
- .height(style.height)
19
- .constraintSize(style.constraintSize)
20
- .flexGrow(style.flexGrow)
21
- .flexShrink(style.flexShrink)
22
- .flexBasis(style.flexBasis)
23
- .alignSelf(style.alignSelf)
24
- .backgroundColor(style.backgroundColor)
25
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
- .backgroundImageSize(style.backgroundImageSize)
27
- .backgroundImagePosition(style.backgroundImagePosition)
28
- .rotate(style.rotate)
29
- .scale(style.scale)
30
- .translate(style.translate)
31
- .transform(style.transform)
32
- .borderStyle(style.borderStyle)
33
- .borderWidth(style.borderWidth)
34
- .borderColor(style.borderColor)
35
- .borderRadius(style.borderRadius)
36
- .linearGradient(style.linearGradient)
37
- .zIndex(style.zIndex)
38
- .opacity(style.opacity)
39
- .clip(style.clip)
40
- }
41
- @Extend(Text)
42
- function textStyle (style: TaroStyleType) {
43
- .id(style.id)
44
- .key(style.id)
45
- .padding(style.padding)
46
- .margin(style.margin)
47
- .width(style.width)
48
- .height(style.height)
49
- .constraintSize(style.constraintSize)
50
- .flexGrow(style.flexGrow)
51
- .flexShrink(style.flexShrink)
52
- .flexBasis(style.flexBasis)
53
- .alignSelf(style.alignSelf)
54
- .backgroundColor(style.backgroundColor)
55
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
56
- .backgroundImageSize(style.backgroundImageSize)
57
- .backgroundImagePosition(style.backgroundImagePosition)
58
- .rotate(style.rotate)
59
- .scale(style.scale)
60
- .translate(style.translate)
61
- .transform(style.transform)
62
- .borderStyle(style.borderStyle)
63
- .borderWidth(style.borderWidth)
64
- .borderColor(style.borderColor)
65
- .borderRadius(style.borderRadius)
66
- .linearGradient(style.linearGradient)
67
- .zIndex(style.zIndex)
68
- .opacity(style.opacity)
69
- .clip(style.clip)
70
- .fontColor(style.color)
71
- .fontSize(style.fontSize)
72
- .fontWeight(style.fontWeight)
73
- .fontStyle(style.fontStyle)
74
- .fontFamily(style.fontFamily)
75
- .lineHeight(style.lineHeight)
76
- .decoration({
77
- type: style.decoration,
78
- color: style.color
79
- })
80
- }
81
-
82
- @Extend(Text)
83
- function textAttr(attr: TaroTextStyleType) {
84
- .textAlign(attr.textAlign)
85
- .textOverflow(attr.textOverflow)
86
- .maxLines(attr.maxLines)
87
- .letterSpacing(attr.letterSpacing)
88
- }
89
- @Component
90
- export default struct TARO_TEMPLATES_f0t0 {
91
- nodeInfoMap: TaroAny = {}
92
- dynamicCenter: DynamicCenter = new DynamicCenter()
93
- @ObjectLink node: TaroViewElement
94
-
95
- aboutToAppear () {
96
- this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
97
- }
98
-
99
- @State node0: TaroElement = new TaroIgnoreElement()
100
- @State node1: TaroElement = new TaroIgnoreElement()
101
- @State node2: TaroElement = new TaroIgnoreElement()
102
- @State node3: TaroElement = new TaroIgnoreElement()
103
- @State node4: TaroElement = new TaroIgnoreElement()
104
-
105
- build() {
106
- Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
107
- if ((this.node0.childNodes[0] as TaroElement)._attrs.compileIf) {
108
- Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
109
- Text(this.node1.childNodes[0].textContent)
110
- .textStyle(getNormalAttributes(this.node1.childNodes[0] as TaroElement))
111
- .textAttr(getFontAttributes(this.node1.childNodes[0] as TaroElement))
112
- .onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
113
- .onAreaChange(getComponentEventCallback(this.node1.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
114
- const eventResult: TaroAny = res.eventResult
115
- this.nodeInfoMap[this.node1.childNodes[0]._nid].areaInfo = eventResult[1]
116
- }))
117
- }
118
- .attrs(getNormalAttributes(this.node1 as TaroElement))
119
- .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
120
- .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
121
- const eventResult: TaroAny = res.eventResult
122
- this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
123
- }))
124
- }
125
- if ((this.node0.childNodes[1] as TaroElement)._attrs.compileIf) {
126
- Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {
127
- Text(this.node2.childNodes[0].textContent)
128
- .textStyle(getNormalAttributes(this.node2.childNodes[0] as TaroElement))
129
- .textAttr(getFontAttributes(this.node2.childNodes[0] as TaroElement))
130
- .onVisibleAreaChange(getNodeThresholds(this.node2.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
131
- .onAreaChange(getComponentEventCallback(this.node2.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
132
- const eventResult: TaroAny = res.eventResult
133
- this.nodeInfoMap[this.node2.childNodes[0]._nid].areaInfo = eventResult[1]
134
- }))
135
- }
136
- .attrs(getNormalAttributes(this.node2 as TaroElement))
137
- .onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
138
- .onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
139
- const eventResult: TaroAny = res.eventResult
140
- this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
141
- }))
142
- }
143
- if ((this.node0.childNodes[2] as TaroElement)._attrs.compileIf) {
144
- Flex(FlexManager.flexOptions(this.node3 as TaroElement)) {
145
- Text(this.node3.childNodes[0].textContent)
146
- .textStyle(getNormalAttributes(this.node3.childNodes[0] as TaroElement))
147
- .textAttr(getFontAttributes(this.node3.childNodes[0] as TaroElement))
148
- .onVisibleAreaChange(getNodeThresholds(this.node3.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
149
- .onAreaChange(getComponentEventCallback(this.node3.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
150
- const eventResult: TaroAny = res.eventResult
151
- this.nodeInfoMap[this.node3.childNodes[0]._nid].areaInfo = eventResult[1]
152
- }))
153
- }
154
- .attrs(getNormalAttributes(this.node3 as TaroElement))
155
- .onVisibleAreaChange(getNodeThresholds(this.node3 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
156
- .onAreaChange(getComponentEventCallback(this.node3 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
157
- const eventResult: TaroAny = res.eventResult
158
- this.nodeInfoMap[this.node3._nid].areaInfo = eventResult[1]
159
- }))
160
- }
161
- if ((this.node0.childNodes[3] as TaroElement)._attrs.compileIf) {
162
- Text(this.node0.childNodes[3].textContent)
163
- .textStyle(getNormalAttributes(this.node0.childNodes[3] as TaroElement))
164
- .textAttr(getFontAttributes(this.node0.childNodes[3] as TaroElement))
165
- .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[3] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[3] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
166
- .onAreaChange(getComponentEventCallback(this.node0.childNodes[3] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
167
- const eventResult: TaroAny = res.eventResult
168
- this.nodeInfoMap[this.node0.childNodes[3]._nid].areaInfo = eventResult[1]
169
- }))
170
- } else {
171
- Text(this.node0.childNodes[3].textContent)
172
- .textStyle(getNormalAttributes(this.node0.childNodes[3] as TaroElement))
173
- .textAttr(getFontAttributes(this.node0.childNodes[3] as TaroElement))
174
- .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[3] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[3] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
175
- .onAreaChange(getComponentEventCallback(this.node0.childNodes[3] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
176
- const eventResult: TaroAny = res.eventResult
177
- this.nodeInfoMap[this.node0.childNodes[3]._nid].areaInfo = eventResult[1]
178
- }))
179
- }
180
- Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {}
181
- .attrs(getNormalAttributes(this.node4 as TaroElement))
182
- .onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
183
- .onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
184
- const eventResult: TaroAny = res.eventResult
185
- this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
186
- }))
187
- }
188
- .attrs(getNormalAttributes(this.node0 as TaroElement))
189
- .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
190
- .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
191
- const eventResult: TaroAny = res.eventResult
192
- this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
193
- }))
194
- }
195
- }
196
- `;
197
- function Index() {
198
- return <View compileMode="f0t0" _dynamicID="node0">
199
-
200
- {condition ? <View hoverClass={myClass} compileIf={condition} _dynamicID="node1">{content}</View> : <View compileIgnore/>}
201
-
202
- {condition ? <View hoverClass={myClass} compileIf={condition} _dynamicID="node2">{content}</View> : <View compileIgnore/>}
203
-
204
- {condition1 && "condition2" && condition3 ? <View hoverClass={myClass} compileIf={condition1 && "condition2" && condition3} _dynamicID="node3">{content}</View> : <View compileIgnore/>}
205
-
206
- {condition1 ? 'Hello' : ""}
207
-
208
- <View hoverClass={myClass} _dynamicID="node4"></View>
209
-
210
- </View>;
211
- }
@@ -1,244 +0,0 @@
1
- const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
- import { FlexManager } from '../utils/FlexManager'
3
- import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
- import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
- import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
- import { DynamicCenter } from '../utils/DynamicCenter'
7
-
8
- import type { TaroViewElement } from '../element'
9
- import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
-
11
- @Extend(Flex)
12
- function attrs (style: TaroStyleType) {
13
- .id(style.id)
14
- .key(style.id)
15
- .padding(style.padding)
16
- .margin(style.margin)
17
- .width(style.width)
18
- .height(style.height)
19
- .constraintSize(style.constraintSize)
20
- .flexGrow(style.flexGrow)
21
- .flexShrink(style.flexShrink)
22
- .flexBasis(style.flexBasis)
23
- .alignSelf(style.alignSelf)
24
- .backgroundColor(style.backgroundColor)
25
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
- .backgroundImageSize(style.backgroundImageSize)
27
- .backgroundImagePosition(style.backgroundImagePosition)
28
- .rotate(style.rotate)
29
- .scale(style.scale)
30
- .translate(style.translate)
31
- .transform(style.transform)
32
- .borderStyle(style.borderStyle)
33
- .borderWidth(style.borderWidth)
34
- .borderColor(style.borderColor)
35
- .borderRadius(style.borderRadius)
36
- .linearGradient(style.linearGradient)
37
- .zIndex(style.zIndex)
38
- .opacity(style.opacity)
39
- .clip(style.clip)
40
- }
41
- @Extend(Text)
42
- function textStyle (style: TaroStyleType) {
43
- .id(style.id)
44
- .key(style.id)
45
- .padding(style.padding)
46
- .margin(style.margin)
47
- .width(style.width)
48
- .height(style.height)
49
- .constraintSize(style.constraintSize)
50
- .flexGrow(style.flexGrow)
51
- .flexShrink(style.flexShrink)
52
- .flexBasis(style.flexBasis)
53
- .alignSelf(style.alignSelf)
54
- .backgroundColor(style.backgroundColor)
55
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
56
- .backgroundImageSize(style.backgroundImageSize)
57
- .backgroundImagePosition(style.backgroundImagePosition)
58
- .rotate(style.rotate)
59
- .scale(style.scale)
60
- .translate(style.translate)
61
- .transform(style.transform)
62
- .borderStyle(style.borderStyle)
63
- .borderWidth(style.borderWidth)
64
- .borderColor(style.borderColor)
65
- .borderRadius(style.borderRadius)
66
- .linearGradient(style.linearGradient)
67
- .zIndex(style.zIndex)
68
- .opacity(style.opacity)
69
- .clip(style.clip)
70
- .fontColor(style.color)
71
- .fontSize(style.fontSize)
72
- .fontWeight(style.fontWeight)
73
- .fontStyle(style.fontStyle)
74
- .fontFamily(style.fontFamily)
75
- .lineHeight(style.lineHeight)
76
- .decoration({
77
- type: style.decoration,
78
- color: style.color
79
- })
80
- }
81
-
82
- @Extend(Text)
83
- function textAttr(attr: TaroTextStyleType) {
84
- .textAlign(attr.textAlign)
85
- .textOverflow(attr.textOverflow)
86
- .maxLines(attr.maxLines)
87
- .letterSpacing(attr.letterSpacing)
88
- }
89
- @Component
90
- export default struct TARO_TEMPLATES_f0t0 {
91
- nodeInfoMap: TaroAny = {}
92
- dynamicCenter: DynamicCenter = new DynamicCenter()
93
- @ObjectLink node: TaroViewElement
94
-
95
- aboutToAppear () {
96
- this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
97
- }
98
-
99
- @State node0: TaroElement = new TaroIgnoreElement()
100
- @State node1: TaroElement = new TaroIgnoreElement()
101
- @State node2: TaroElement = new TaroIgnoreElement()
102
- @State node3: TaroElement = new TaroIgnoreElement()
103
- @State node4: TaroElement = new TaroIgnoreElement()
104
- @State node5: TaroElement = new TaroIgnoreElement()
105
-
106
- build() {
107
- Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
108
- if ((this.node0.childNodes[0] as TaroElement)._attrs.compileIf) {
109
- Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {}
110
- .attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
111
- .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
112
- .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
113
- const eventResult: TaroAny = res.eventResult
114
- this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
115
- }))
116
- .onClick(e => eventHandler(e, 'click', this.node0.childNodes[0] as TaroElement))
117
- }
118
- Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
119
- Text(this.node1.childNodes[0].textContent)
120
- .textStyle(getNormalAttributes(this.node1.childNodes[0] as TaroElement))
121
- .textAttr(getFontAttributes(this.node1.childNodes[0] as TaroElement))
122
- .onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
123
- .onAreaChange(getComponentEventCallback(this.node1.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
124
- const eventResult: TaroAny = res.eventResult
125
- this.nodeInfoMap[this.node1.childNodes[0]._nid].areaInfo = eventResult[1]
126
- }))
127
- }
128
- .attrs(getNormalAttributes(this.node1 as TaroElement))
129
- .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
130
- .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
131
- const eventResult: TaroAny = res.eventResult
132
- this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
133
- }))
134
- Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {
135
- Text(this.node2.childNodes[0].textContent)
136
- .textStyle(getNormalAttributes(this.node2.childNodes[0] as TaroElement))
137
- .textAttr(getFontAttributes(this.node2.childNodes[0] as TaroElement))
138
- .onVisibleAreaChange(getNodeThresholds(this.node2.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
139
- .onAreaChange(getComponentEventCallback(this.node2.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
140
- const eventResult: TaroAny = res.eventResult
141
- this.nodeInfoMap[this.node2.childNodes[0]._nid].areaInfo = eventResult[1]
142
- }))
143
- }
144
- .attrs(getNormalAttributes(this.node2 as TaroElement))
145
- .onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
146
- .onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
147
- const eventResult: TaroAny = res.eventResult
148
- this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
149
- }))
150
- Flex(FlexManager.flexOptions(this.node3 as TaroElement)) {
151
- Text(this.node3.childNodes[0].textContent)
152
- .textStyle(getNormalAttributes(this.node3.childNodes[0] as TaroElement))
153
- .textAttr(getFontAttributes(this.node3.childNodes[0] as TaroElement))
154
- .onVisibleAreaChange(getNodeThresholds(this.node3.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
155
- .onAreaChange(getComponentEventCallback(this.node3.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
156
- const eventResult: TaroAny = res.eventResult
157
- this.nodeInfoMap[this.node3.childNodes[0]._nid].areaInfo = eventResult[1]
158
- }))
159
- }
160
- .attrs(getNormalAttributes(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
- if ((this.node0.childNodes[4] as TaroElement)._attrs.compileIf) {
167
- Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {}
168
- .attrs(getNormalAttributes(this.node4 as TaroElement))
169
- .onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
170
- .onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
171
- const eventResult: TaroAny = res.eventResult
172
- this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
173
- }))
174
- } else {
175
- Flex(FlexManager.flexOptions(this.node0.childNodes[4] as TaroElement)) {}
176
- .attrs(getNormalAttributes(this.node0.childNodes[4] as TaroElement))
177
- .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[4] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[4] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
178
- .onAreaChange(getComponentEventCallback(this.node0.childNodes[4] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
179
- const eventResult: TaroAny = res.eventResult
180
- this.nodeInfoMap[this.node0.childNodes[4]._nid].areaInfo = eventResult[1]
181
- }))
182
- }
183
- if ((this.node0.childNodes[5] as TaroElement)._attrs.compileIf) {
184
- Flex(FlexManager.flexOptions(this.node5 as TaroElement)) {
185
- if ((this.node5.childNodes[0] as TaroElement)._attrs.compileIf) {
186
- Flex(FlexManager.flexOptions(this.node5.childNodes[0] as TaroElement)) {}
187
- .attrs(getNormalAttributes(this.node5.childNodes[0] as TaroElement))
188
- .onVisibleAreaChange(getNodeThresholds(this.node5.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
189
- .onAreaChange(getComponentEventCallback(this.node5.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
190
- const eventResult: TaroAny = res.eventResult
191
- this.nodeInfoMap[this.node5.childNodes[0]._nid].areaInfo = eventResult[1]
192
- }))
193
- } else {
194
- Flex(FlexManager.flexOptions(this.node5.childNodes[0] as TaroElement)) {}
195
- .attrs(getNormalAttributes(this.node5.childNodes[0] as TaroElement))
196
- .onVisibleAreaChange(getNodeThresholds(this.node5.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
197
- .onAreaChange(getComponentEventCallback(this.node5.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
198
- const eventResult: TaroAny = res.eventResult
199
- this.nodeInfoMap[this.node5.childNodes[0]._nid].areaInfo = eventResult[1]
200
- }))
201
- }
202
- }
203
- .attrs(getNormalAttributes(this.node5 as TaroElement))
204
- .onVisibleAreaChange(getNodeThresholds(this.node5 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
205
- .onAreaChange(getComponentEventCallback(this.node5 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
206
- const eventResult: TaroAny = res.eventResult
207
- this.nodeInfoMap[this.node5._nid].areaInfo = eventResult[1]
208
- }))
209
- } else {
210
- Flex(FlexManager.flexOptions(this.node0.childNodes[5] as TaroElement)) {}
211
- .attrs(getNormalAttributes(this.node0.childNodes[5] as TaroElement))
212
- .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[5] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[5] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
213
- .onAreaChange(getComponentEventCallback(this.node0.childNodes[5] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
214
- const eventResult: TaroAny = res.eventResult
215
- this.nodeInfoMap[this.node0.childNodes[5]._nid].areaInfo = eventResult[1]
216
- }))
217
- }
218
- }
219
- .attrs(getNormalAttributes(this.node0 as TaroElement))
220
- .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
221
- .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
222
- const eventResult: TaroAny = res.eventResult
223
- this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
224
- }))
225
- }
226
- }
227
- `;
228
- function Index() {
229
- return <View compileMode="f0t0" _dynamicID="node0">
230
-
231
- {condition1 ? <View onClick={()=>condition2 && doSth()} compileIf={condition1}/> : <View compileIgnore/>}
232
-
233
- <View _dynamicID="node1">{condition1 && ident}</View>
234
-
235
- <View _dynamicID="node2">{condition1 && obj.property}</View>
236
-
237
- <View _dynamicID="node3">{condition1 && fn()}</View>
238
-
239
- {condition1 ? <View className={condition2 ? '' : ''} compileIf={condition1} _dynamicID="node4"/> : <View/>}
240
-
241
- {condition1 ? <View compileIf={condition1} _dynamicID="node5">{condition2 ? <View compileIf={condition2}/> : <View/>}</View> : <View/>}
242
-
243
- </View>;
244
- }
@@ -1,139 +0,0 @@
1
- const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
- import { FlexManager } from '../utils/FlexManager'
3
- import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
- import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
- import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
- import { DynamicCenter } from '../utils/DynamicCenter'
7
-
8
- import type { TaroViewElement } from '../element'
9
- import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
-
11
- @Extend(Flex)
12
- function attrs (style: TaroStyleType) {
13
- .id(style.id)
14
- .key(style.id)
15
- .padding(style.padding)
16
- .margin(style.margin)
17
- .width(style.width)
18
- .height(style.height)
19
- .constraintSize(style.constraintSize)
20
- .flexGrow(style.flexGrow)
21
- .flexShrink(style.flexShrink)
22
- .flexBasis(style.flexBasis)
23
- .alignSelf(style.alignSelf)
24
- .backgroundColor(style.backgroundColor)
25
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
- .backgroundImageSize(style.backgroundImageSize)
27
- .backgroundImagePosition(style.backgroundImagePosition)
28
- .rotate(style.rotate)
29
- .scale(style.scale)
30
- .translate(style.translate)
31
- .transform(style.transform)
32
- .borderStyle(style.borderStyle)
33
- .borderWidth(style.borderWidth)
34
- .borderColor(style.borderColor)
35
- .borderRadius(style.borderRadius)
36
- .linearGradient(style.linearGradient)
37
- .zIndex(style.zIndex)
38
- .opacity(style.opacity)
39
- .clip(style.clip)
40
- }
41
- @Extend(Text)
42
- function textStyle (style: TaroStyleType) {
43
- .id(style.id)
44
- .key(style.id)
45
- .padding(style.padding)
46
- .margin(style.margin)
47
- .width(style.width)
48
- .height(style.height)
49
- .constraintSize(style.constraintSize)
50
- .flexGrow(style.flexGrow)
51
- .flexShrink(style.flexShrink)
52
- .flexBasis(style.flexBasis)
53
- .alignSelf(style.alignSelf)
54
- .backgroundColor(style.backgroundColor)
55
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
56
- .backgroundImageSize(style.backgroundImageSize)
57
- .backgroundImagePosition(style.backgroundImagePosition)
58
- .rotate(style.rotate)
59
- .scale(style.scale)
60
- .translate(style.translate)
61
- .transform(style.transform)
62
- .borderStyle(style.borderStyle)
63
- .borderWidth(style.borderWidth)
64
- .borderColor(style.borderColor)
65
- .borderRadius(style.borderRadius)
66
- .linearGradient(style.linearGradient)
67
- .zIndex(style.zIndex)
68
- .opacity(style.opacity)
69
- .clip(style.clip)
70
- .fontColor(style.color)
71
- .fontSize(style.fontSize)
72
- .fontWeight(style.fontWeight)
73
- .fontStyle(style.fontStyle)
74
- .fontFamily(style.fontFamily)
75
- .lineHeight(style.lineHeight)
76
- .decoration({
77
- type: style.decoration,
78
- color: style.color
79
- })
80
- }
81
-
82
- @Extend(Text)
83
- function textAttr(attr: TaroTextStyleType) {
84
- .textAlign(attr.textAlign)
85
- .textOverflow(attr.textOverflow)
86
- .maxLines(attr.maxLines)
87
- .letterSpacing(attr.letterSpacing)
88
- }
89
- @Component
90
- export default struct TARO_TEMPLATES_f0t0 {
91
- nodeInfoMap: TaroAny = {}
92
- dynamicCenter: DynamicCenter = new DynamicCenter()
93
- @ObjectLink node: TaroViewElement
94
-
95
- aboutToAppear () {
96
- this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
97
- }
98
-
99
- @State node0: TaroElement = new TaroIgnoreElement()
100
-
101
- build() {
102
- Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
103
- if ((this.node0.childNodes[0] as TaroElement)._attrs.compileIf) {
104
- Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {
105
- Text(this.node0.childNodes[0].childNodes[0].textContent)
106
- .textStyle(getNormalAttributes(this.node0.childNodes[0].childNodes[0] as TaroElement))
107
- .textAttr(getFontAttributes(this.node0.childNodes[0].childNodes[0] as TaroElement))
108
- .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))
109
- .onAreaChange(getComponentEventCallback(this.node0.childNodes[0].childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
110
- const eventResult: TaroAny = res.eventResult
111
- this.nodeInfoMap[this.node0.childNodes[0].childNodes[0]._nid].areaInfo = eventResult[1]
112
- }))
113
- }
114
- .attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
115
- .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
116
- .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
117
- const eventResult: TaroAny = res.eventResult
118
- this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
119
- }))
120
- } else {
121
- createNode(this.node0.childNodes[0] as TaroElement)
122
- }
123
- }
124
- .attrs(getNormalAttributes(this.node0 as TaroElement))
125
- .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
126
- .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
127
- const eventResult: TaroAny = res.eventResult
128
- this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
129
- }))
130
- }
131
- }
132
- `;
133
- function Index() {
134
- return <View compileMode="f0t0" _dynamicID="node0">
135
-
136
- {condition ? <View hoverClass='test' compileIf={condition}>hello</View> : <UnKnow selectable>hello</UnKnow>}
137
-
138
- </View>;
139
- }