@tarojs/helper 3.8.0-canary.0 → 4.0.0-alpha.0

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 (85) hide show
  1. package/README.md +22 -0
  2. package/dist/constants.d.ts +5 -3
  3. package/dist/constants.js +24 -22
  4. package/dist/constants.js.map +1 -1
  5. package/dist/dotenv.js.map +1 -1
  6. package/dist/esbuild/index.js +6 -4
  7. package/dist/esbuild/index.js.map +1 -1
  8. package/dist/npm.d.ts +2 -2
  9. package/dist/npm.js +6 -6
  10. package/dist/npm.js.map +1 -1
  11. package/dist/swcRegister.d.ts +0 -6
  12. package/dist/swcRegister.js +0 -15
  13. package/dist/swcRegister.js.map +1 -1
  14. package/dist/utils.d.ts +33 -1
  15. package/dist/utils.js +87 -34
  16. package/dist/utils.js.map +1 -1
  17. package/package.json +19 -15
  18. package/swc/plugin-compile-mode/.cargo/config +5 -0
  19. package/swc/plugin-compile-mode/.editorconfig +6 -0
  20. package/swc/plugin-compile-mode/.vscode/settings.json +3 -0
  21. package/swc/plugin-compile-mode/Cargo.lock +195 -260
  22. package/swc/plugin-compile-mode/Cargo.toml +6 -4
  23. package/swc/plugin-compile-mode/package.json +15 -0
  24. package/swc/plugin-compile-mode/src/lib.rs +21 -2
  25. package/swc/plugin-compile-mode/src/tests/attributes.rs +1 -32
  26. package/swc/plugin-compile-mode/src/tests/children.rs +86 -0
  27. package/swc/plugin-compile-mode/src/tests/condition.rs +8 -29
  28. package/swc/plugin-compile-mode/src/tests/entry.rs +1 -13
  29. package/swc/plugin-compile-mode/src/tests/harmony/attributes.rs +45 -0
  30. package/swc/plugin-compile-mode/src/tests/harmony/children.rs +74 -0
  31. package/swc/plugin-compile-mode/src/tests/harmony/condition.rs +79 -0
  32. package/swc/plugin-compile-mode/src/tests/harmony/entry.rs +67 -0
  33. package/swc/plugin-compile-mode/src/tests/harmony/looping.rs +62 -0
  34. package/swc/plugin-compile-mode/src/tests/harmony/mod.rs +45 -0
  35. package/swc/plugin-compile-mode/src/tests/looping.rs +1 -51
  36. package/swc/plugin-compile-mode/src/tests/mod.rs +11 -9
  37. package/swc/plugin-compile-mode/src/tests/shake.rs +1 -15
  38. package/swc/plugin-compile-mode/src/transform.rs +142 -134
  39. package/swc/plugin-compile-mode/src/transform_harmony.rs +526 -0
  40. package/swc/plugin-compile-mode/src/utils/constants.rs +141 -0
  41. package/swc/plugin-compile-mode/src/utils/harmony/components.rs +61 -0
  42. package/swc/plugin-compile-mode/src/utils/harmony/mod.rs +1 -0
  43. package/swc/plugin-compile-mode/src/utils/mod.rs +126 -15
  44. package/swc/plugin-compile-mode/target/wasm32-wasi/release/swc_plugin_compile_mode.wasm +0 -0
  45. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_handle_events.js +8 -0
  46. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_keep_static_attrs_only_in_templates.js +8 -0
  47. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/attributes.rs/should_turn_dynamic_attrs.js +11 -0
  48. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_native_component.js +7 -0
  49. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_render_react_component.js +7 -0
  50. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_fragment.js +44 -0
  51. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/children.rs/should_support_render_fn.js +8 -0
  52. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_and_expr.js +14 -0
  53. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/condition.rs/should_support_conditional_expr.js +15 -0
  54. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/entry.rs/should_support_multi_compile_mode.js +10 -0
  55. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_handle_events.js +183 -0
  56. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/attributes.rs/should_turn_dynamic_attrs.js +186 -0
  57. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_render_react_component.js +76 -0
  58. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_fragment.js +341 -0
  59. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/children.rs/should_support_render_fn.js +186 -0
  60. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_and_expr.js +211 -0
  61. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_complex_condition.js +244 -0
  62. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_and_unkonw_component.js +139 -0
  63. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/condition.rs/should_support_conditional_expr.js +344 -0
  64. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_compile_child_node.js +141 -0
  65. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_component_not_in_config.js +91 -0
  66. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_multi_compile_mode.js +209 -0
  67. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/entry.rs/should_support_single_compile_mode.js +66 -0
  68. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +76 -0
  69. 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 +89 -0
  70. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/harmony/looping.rs/should_loop_with_function_expr.js +86 -0
  71. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_blockstmt.js +8 -0
  72. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_arrow_function_with_expr.js +6 -0
  73. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_loop_with_function_expr.js +20 -0
  74. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/looping.rs/should_support_nested_loop.js +15 -0
  75. package/swc/plugin-compile-mode/tests/__swc_snapshots__/src/tests/shake.rs/should_static_jsx_being_shaked.js +20 -0
  76. package/swc/plugin-define-config/.cargo/config +5 -0
  77. package/swc/plugin-define-config/Cargo.lock +582 -506
  78. package/swc/plugin-define-config/Cargo.toml +2 -11
  79. package/swc/plugin-define-config/src/lib.rs +81 -128
  80. package/swc/plugin-define-config/target/wasm32-wasi/release/swc_plugin_define_config.wasm +0 -0
  81. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_app.js +2 -0
  82. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_decl_default_page.js +2 -0
  83. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/module_exports.js +11 -0
  84. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_app.js +3 -0
  85. package/swc/plugin-define-config/tests/__swc_snapshots__/src/lib.rs/var_decl_page.js +3 -0
@@ -0,0 +1,186 @@
1
+ const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
+ import { FlexManager } from '../utils/FlexManager'
3
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
+ import { DynamicCenter } from '../utils/DynamicCenter'
7
+
8
+ import type { TaroViewElement } from '../element'
9
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
+
11
+ @Extend(Flex)
12
+ function attrs (style: TaroStyleType) {
13
+ .id(style.id)
14
+ .key(style.id)
15
+ .padding(style.padding)
16
+ .margin(style.margin)
17
+ .width(style.width)
18
+ .height(style.height)
19
+ .constraintSize(style.constraintSize)
20
+ .flexGrow(style.flexGrow)
21
+ .flexShrink(style.flexShrink)
22
+ .flexBasis(style.flexBasis)
23
+ .alignSelf(style.alignSelf)
24
+ .backgroundColor(style.backgroundColor)
25
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
+ .backgroundImageSize(style.backgroundImageSize)
27
+ .backgroundImagePosition(style.backgroundImagePosition)
28
+ .rotate(style.rotate)
29
+ .scale(style.scale)
30
+ .translate(style.translate)
31
+ .transform(style.transform)
32
+ .borderStyle(style.borderStyle)
33
+ .borderWidth(style.borderWidth)
34
+ .borderColor(style.borderColor)
35
+ .borderRadius(style.borderRadius)
36
+ .linearGradient(style.linearGradient)
37
+ .zIndex(style.zIndex)
38
+ .opacity(style.opacity)
39
+ .clip(style.clip)
40
+ }
41
+ @Extend(Image)
42
+ function attrsImage (style: TaroStyleType) {
43
+ .id(style.id)
44
+ .key(style.id)
45
+ .padding(style.padding)
46
+ .margin(style.margin)
47
+ .width(style.width)
48
+ .height(style.height)
49
+ .constraintSize(style.constraintSize)
50
+ .flexGrow(style.flexGrow)
51
+ .flexShrink(style.flexShrink)
52
+ .flexBasis(style.flexBasis)
53
+ .alignSelf(style.alignSelf)
54
+ .backgroundColor(style.backgroundColor)
55
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
56
+ .backgroundImageSize(style.backgroundImageSize)
57
+ .backgroundImagePosition(style.backgroundImagePosition)
58
+ .rotate(style.rotate)
59
+ .scale(style.scale)
60
+ .translate(style.translate)
61
+ .transform(style.transform)
62
+ .borderStyle(style.borderStyle)
63
+ .borderWidth(style.borderWidth)
64
+ .borderColor(style.borderColor)
65
+ .borderRadius(style.borderRadius)
66
+ .linearGradient(style.linearGradient)
67
+ .zIndex(style.zIndex)
68
+ .opacity(style.opacity)
69
+ .clip(style.clip)
70
+ }
71
+
72
+ function getImageMode (mode: string): ImageFit {
73
+ switch (mode) {
74
+ case 'aspectFit': return ImageFit.Contain
75
+ case 'aspectFill': return ImageFit.Cover
76
+ case 'scaleToFill': return ImageFit.Fill
77
+ case 'widthFix': return ImageFit.Auto
78
+ case 'heightFix': return ImageFit.Auto
79
+ default: return ImageFit.Contain
80
+ }
81
+ }
82
+ @Component
83
+ export default struct TARO_TEMPLATES_f0t0 {
84
+ nodeInfoMap: TaroAny = {}
85
+ dynamicCenter: DynamicCenter = new DynamicCenter()
86
+ @ObjectLink node: TaroViewElement
87
+
88
+ aboutToAppear () {
89
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
90
+ }
91
+
92
+ @State node0: TaroElement = new TaroIgnoreElement()
93
+ @State node1: TaroElement = new TaroIgnoreElement()
94
+ @State node2: TaroElement = new TaroIgnoreElement()
95
+ @State node3: TaroElement = new TaroIgnoreElement()
96
+ @State node4: TaroElement = new TaroIgnoreElement()
97
+ @State node5: TaroElement = new TaroIgnoreElement()
98
+
99
+ build() {
100
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
101
+ Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
102
+ Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {}
103
+ .attrs(getNormalAttributes(this.node2 as TaroElement))
104
+ .onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
105
+ .onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
106
+ const eventResult: TaroAny = res.eventResult
107
+ this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
108
+ }))
109
+ Flex(FlexManager.flexOptions(this.node1.childNodes[1] as TaroElement)) {}
110
+ .attrs(getNormalAttributes(this.node1.childNodes[1] as TaroElement))
111
+ .onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
112
+ .onAreaChange(getComponentEventCallback(this.node1.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
113
+ const eventResult: TaroAny = res.eventResult
114
+ this.nodeInfoMap[this.node1.childNodes[1]._nid].areaInfo = eventResult[1]
115
+ }))
116
+ Flex(FlexManager.flexOptions(this.node3 as TaroElement)) {
117
+ Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {}
118
+ .attrs(getNormalAttributes(this.node4 as TaroElement))
119
+ .onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
120
+ .onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
121
+ const eventResult: TaroAny = res.eventResult
122
+ this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
123
+ }))
124
+ }
125
+ .attrs(getNormalAttributes(this.node3 as TaroElement))
126
+ .onVisibleAreaChange(getNodeThresholds(this.node3 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
127
+ .onAreaChange(getComponentEventCallback(this.node3 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
128
+ const eventResult: TaroAny = res.eventResult
129
+ this.nodeInfoMap[this.node3._nid].areaInfo = eventResult[1]
130
+ }))
131
+ }
132
+ .attrs(getNormalAttributes(this.node1 as TaroElement))
133
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
134
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
135
+ const eventResult: TaroAny = res.eventResult
136
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
137
+ }))
138
+ Image((this.node0.childNodes[1] as TaroElement).getAttribute('src'))
139
+ .objectFit(getImageMode((this.node0.childNodes[1] as TaroElement).getAttribute('mode')))
140
+ .attrsImage(getNormalAttributes(this.node0.childNodes[1] as TaroElement))
141
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
142
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
143
+ const eventResult: TaroAny = res.eventResult
144
+ this.nodeInfoMap[this.node0.childNodes[1]._nid].areaInfo = eventResult[1]
145
+ }))
146
+ Image((this.node5 as TaroElement).getAttribute('src'))
147
+ .objectFit(getImageMode((this.node5 as TaroElement).getAttribute('mode')))
148
+ .attrsImage(getNormalAttributes(this.node5 as TaroElement))
149
+ .onVisibleAreaChange(getNodeThresholds(this.node5 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
150
+ .onAreaChange(getComponentEventCallback(this.node5 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
151
+ const eventResult: TaroAny = res.eventResult
152
+ this.nodeInfoMap[this.node5._nid].areaInfo = eventResult[1]
153
+ }))
154
+ }
155
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
156
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
157
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
158
+ const eventResult: TaroAny = res.eventResult
159
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
160
+ }))
161
+ }
162
+ }
163
+ `;
164
+ function Index() {
165
+ return <View compileMode="f0t0" _dynamicID="node0">
166
+
167
+ <View class={myClass} _dynamicID="node1">
168
+
169
+ <View style={myStyle} customProp={myCustomProp} _dynamicID="node2"></View>
170
+
171
+ <View class="center"/>
172
+
173
+ <View onTouch={myTime} _dynamicID="node3">
174
+
175
+ <View hoverClass={myHoverClass} _dynamicID="node4"></View>
176
+
177
+ </View>
178
+
179
+ </View>
180
+
181
+ <Image alt="占位符" src="https://www.jd.com/test.jpg"/>
182
+
183
+ <Image alt="占位符" src={src} _dynamicID="node5"/>
184
+
185
+ </View>;
186
+ }
@@ -0,0 +1,76 @@
1
+ const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
+ import { FlexManager } from '../utils/FlexManager'
3
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
+ import { DynamicCenter } from '../utils/DynamicCenter'
7
+
8
+ import type { TaroViewElement } from '../element'
9
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
+
11
+ @Extend(Flex)
12
+ function attrs (style: TaroStyleType) {
13
+ .id(style.id)
14
+ .key(style.id)
15
+ .padding(style.padding)
16
+ .margin(style.margin)
17
+ .width(style.width)
18
+ .height(style.height)
19
+ .constraintSize(style.constraintSize)
20
+ .flexGrow(style.flexGrow)
21
+ .flexShrink(style.flexShrink)
22
+ .flexBasis(style.flexBasis)
23
+ .alignSelf(style.alignSelf)
24
+ .backgroundColor(style.backgroundColor)
25
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
+ .backgroundImageSize(style.backgroundImageSize)
27
+ .backgroundImagePosition(style.backgroundImagePosition)
28
+ .rotate(style.rotate)
29
+ .scale(style.scale)
30
+ .translate(style.translate)
31
+ .transform(style.transform)
32
+ .borderStyle(style.borderStyle)
33
+ .borderWidth(style.borderWidth)
34
+ .borderColor(style.borderColor)
35
+ .borderRadius(style.borderRadius)
36
+ .linearGradient(style.linearGradient)
37
+ .zIndex(style.zIndex)
38
+ .opacity(style.opacity)
39
+ .clip(style.clip)
40
+ }
41
+ @Component
42
+ export default struct TARO_TEMPLATES_f0t0 {
43
+ nodeInfoMap: TaroAny = {}
44
+ dynamicCenter: DynamicCenter = new DynamicCenter()
45
+ @ObjectLink node: TaroViewElement
46
+
47
+ aboutToAppear () {
48
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
49
+ }
50
+
51
+ @State node0: TaroElement = new TaroIgnoreElement()
52
+ @State node1: TaroElement = new TaroIgnoreElement()
53
+
54
+ build() {
55
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
56
+ createNode(this.node0.childNodes[0] as TaroElement)
57
+ createNode(this.node1 as TaroElement)
58
+ }
59
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
60
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
61
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
62
+ const eventResult: TaroAny = res.eventResult
63
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
64
+ }))
65
+ }
66
+ }
67
+ `;
68
+ function Index() {
69
+ return <View compileMode="f0t0" _dynamicID="node0">
70
+
71
+ <Foo/>
72
+
73
+ <Foo title={myTitle} loading onClick={()=>{}} _dynamicID="node1"/>
74
+
75
+ </View>;
76
+ }
@@ -0,0 +1,341 @@
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
+ @State node6: TaroElement = new TaroIgnoreElement()
106
+
107
+ build() {
108
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
109
+ Text(this.node0.childNodes[0].textContent)
110
+ .textStyle(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
111
+ .textAttr(getFontAttributes(this.node0.childNodes[0] as TaroElement))
112
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
113
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
114
+ const eventResult: TaroAny = res.eventResult
115
+ this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
116
+ }))
117
+ Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
118
+ Text(this.node1.childNodes[0].textContent)
119
+ .textStyle(getNormalAttributes(this.node1.childNodes[0] as TaroElement))
120
+ .textAttr(getFontAttributes(this.node1.childNodes[0] as TaroElement))
121
+ .onVisibleAreaChange(getNodeThresholds(this.node1.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
122
+ .onAreaChange(getComponentEventCallback(this.node1.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
123
+ const eventResult: TaroAny = res.eventResult
124
+ this.nodeInfoMap[this.node1.childNodes[0]._nid].areaInfo = eventResult[1]
125
+ }))
126
+ }
127
+ .attrs(getNormalAttributes(this.node1 as TaroElement))
128
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
129
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
130
+ const eventResult: TaroAny = res.eventResult
131
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
132
+ }))
133
+ Flex(FlexManager.flexOptions(this.node0.childNodes[2] as TaroElement)) {
134
+ Text(this.node0.childNodes[2].childNodes[0].textContent)
135
+ .textStyle(getNormalAttributes(this.node0.childNodes[2].childNodes[0] as TaroElement))
136
+ .textAttr(getFontAttributes(this.node0.childNodes[2].childNodes[0] as TaroElement))
137
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[2].childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[2].childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
138
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[2].childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
139
+ const eventResult: TaroAny = res.eventResult
140
+ this.nodeInfoMap[this.node0.childNodes[2].childNodes[0]._nid].areaInfo = eventResult[1]
141
+ }))
142
+ }
143
+ .attrs(getNormalAttributes(this.node0.childNodes[2] as TaroElement))
144
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[2] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[2] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
145
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[2] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
146
+ const eventResult: TaroAny = res.eventResult
147
+ this.nodeInfoMap[this.node0.childNodes[2]._nid].areaInfo = eventResult[1]
148
+ }))
149
+ Flex(FlexManager.flexOptions(this.node0.childNodes[3] as TaroElement)) {
150
+ Flex(FlexManager.flexOptions(this.node2 as TaroElement)) {
151
+ Text(this.node2.childNodes[0].textContent)
152
+ .textStyle(getNormalAttributes(this.node2.childNodes[0] as TaroElement))
153
+ .textAttr(getFontAttributes(this.node2.childNodes[0] as TaroElement))
154
+ .onVisibleAreaChange(getNodeThresholds(this.node2.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
155
+ .onAreaChange(getComponentEventCallback(this.node2.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
156
+ const eventResult: TaroAny = res.eventResult
157
+ this.nodeInfoMap[this.node2.childNodes[0]._nid].areaInfo = eventResult[1]
158
+ }))
159
+ }
160
+ .attrs(getNormalAttributes(this.node2 as TaroElement))
161
+ .onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
162
+ .onAreaChange(getComponentEventCallback(this.node2 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
163
+ const eventResult: TaroAny = res.eventResult
164
+ this.nodeInfoMap[this.node2._nid].areaInfo = eventResult[1]
165
+ }))
166
+ Flex(FlexManager.flexOptions(this.node0.childNodes[3].childNodes[1] as TaroElement)) {
167
+ Text(this.node0.childNodes[3].childNodes[1].childNodes[0].textContent)
168
+ .textStyle(getNormalAttributes(this.node0.childNodes[3].childNodes[1].childNodes[0] as TaroElement))
169
+ .textAttr(getFontAttributes(this.node0.childNodes[3].childNodes[1].childNodes[0] as TaroElement))
170
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[3].childNodes[1].childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[3].childNodes[1].childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
171
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[3].childNodes[1].childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
172
+ const eventResult: TaroAny = res.eventResult
173
+ this.nodeInfoMap[this.node0.childNodes[3].childNodes[1].childNodes[0]._nid].areaInfo = eventResult[1]
174
+ }))
175
+ }
176
+ .attrs(getNormalAttributes(this.node0.childNodes[3].childNodes[1] as TaroElement))
177
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[3].childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[3].childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
178
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[3].childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
179
+ const eventResult: TaroAny = res.eventResult
180
+ this.nodeInfoMap[this.node0.childNodes[3].childNodes[1]._nid].areaInfo = eventResult[1]
181
+ }))
182
+ }
183
+ .attrs(getNormalAttributes(this.node0.childNodes[3] as TaroElement))
184
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[3] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[3] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
185
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[3] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
186
+ const eventResult: TaroAny = res.eventResult
187
+ this.nodeInfoMap[this.node0.childNodes[3]._nid].areaInfo = eventResult[1]
188
+ }))
189
+ Flex(FlexManager.flexOptions(this.node3 as TaroElement)) {
190
+ Text(this.node3.childNodes[0].textContent)
191
+ .textStyle(getNormalAttributes(this.node3.childNodes[0] as TaroElement))
192
+ .textAttr(getFontAttributes(this.node3.childNodes[0] as TaroElement))
193
+ .onVisibleAreaChange(getNodeThresholds(this.node3.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
194
+ .onAreaChange(getComponentEventCallback(this.node3.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
195
+ const eventResult: TaroAny = res.eventResult
196
+ this.nodeInfoMap[this.node3.childNodes[0]._nid].areaInfo = eventResult[1]
197
+ }))
198
+ }
199
+ .attrs(getNormalAttributes(this.node3 as TaroElement))
200
+ .onVisibleAreaChange(getNodeThresholds(this.node3 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node3 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
201
+ .onAreaChange(getComponentEventCallback(this.node3 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
202
+ const eventResult: TaroAny = res.eventResult
203
+ this.nodeInfoMap[this.node3._nid].areaInfo = eventResult[1]
204
+ }))
205
+ Flex(FlexManager.flexOptions(this.node4 as TaroElement)) {
206
+ Text(this.node4.childNodes[0].textContent)
207
+ .textStyle(getNormalAttributes(this.node4.childNodes[0] as TaroElement))
208
+ .textAttr(getFontAttributes(this.node4.childNodes[0] as TaroElement))
209
+ .onVisibleAreaChange(getNodeThresholds(this.node4.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
210
+ .onAreaChange(getComponentEventCallback(this.node4.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
211
+ const eventResult: TaroAny = res.eventResult
212
+ this.nodeInfoMap[this.node4.childNodes[0]._nid].areaInfo = eventResult[1]
213
+ }))
214
+ }
215
+ .attrs(getNormalAttributes(this.node4 as TaroElement))
216
+ .onVisibleAreaChange(getNodeThresholds(this.node4 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node4 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
217
+ .onAreaChange(getComponentEventCallback(this.node4 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
218
+ const eventResult: TaroAny = res.eventResult
219
+ this.nodeInfoMap[this.node4._nid].areaInfo = eventResult[1]
220
+ }))
221
+ Flex(FlexManager.flexOptions(this.node5 as TaroElement)) {
222
+ Text(this.node5.childNodes[0].textContent)
223
+ .textStyle(getNormalAttributes(this.node5.childNodes[0] as TaroElement))
224
+ .textAttr(getFontAttributes(this.node5.childNodes[0] as TaroElement))
225
+ .onVisibleAreaChange(getNodeThresholds(this.node5.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
226
+ .onAreaChange(getComponentEventCallback(this.node5.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
227
+ const eventResult: TaroAny = res.eventResult
228
+ this.nodeInfoMap[this.node5.childNodes[0]._nid].areaInfo = eventResult[1]
229
+ }))
230
+ }
231
+ .attrs(getNormalAttributes(this.node5 as TaroElement))
232
+ .onVisibleAreaChange(getNodeThresholds(this.node5 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node5 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
233
+ .onAreaChange(getComponentEventCallback(this.node5 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
234
+ const eventResult: TaroAny = res.eventResult
235
+ this.nodeInfoMap[this.node5._nid].areaInfo = eventResult[1]
236
+ }))
237
+ Flex(FlexManager.flexOptions(this.node0.childNodes[7] as TaroElement)) {
238
+ Text(this.node0.childNodes[7].childNodes[0].textContent)
239
+ .textStyle(getNormalAttributes(this.node0.childNodes[7].childNodes[0] as TaroElement))
240
+ .textAttr(getFontAttributes(this.node0.childNodes[7].childNodes[0] as TaroElement))
241
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[7].childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[7].childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
242
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[7].childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
243
+ const eventResult: TaroAny = res.eventResult
244
+ this.nodeInfoMap[this.node0.childNodes[7].childNodes[0]._nid].areaInfo = eventResult[1]
245
+ }))
246
+ }
247
+ .attrs(getNormalAttributes(this.node0.childNodes[7] as TaroElement))
248
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[7] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[7] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
249
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[7] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
250
+ const eventResult: TaroAny = res.eventResult
251
+ this.nodeInfoMap[this.node0.childNodes[7]._nid].areaInfo = eventResult[1]
252
+ }))
253
+ Flex(FlexManager.flexOptions(this.node0.childNodes[8] as TaroElement)) {
254
+ Text(this.node0.childNodes[8].childNodes[0].textContent)
255
+ .textStyle(getNormalAttributes(this.node0.childNodes[8].childNodes[0] as TaroElement))
256
+ .textAttr(getFontAttributes(this.node0.childNodes[8].childNodes[0] as TaroElement))
257
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[8].childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[8].childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
258
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[8].childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
259
+ const eventResult: TaroAny = res.eventResult
260
+ this.nodeInfoMap[this.node0.childNodes[8].childNodes[0]._nid].areaInfo = eventResult[1]
261
+ }))
262
+ }
263
+ .attrs(getNormalAttributes(this.node0.childNodes[8] as TaroElement))
264
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[8] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[8] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
265
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[8] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
266
+ const eventResult: TaroAny = res.eventResult
267
+ this.nodeInfoMap[this.node0.childNodes[8]._nid].areaInfo = eventResult[1]
268
+ }))
269
+ Flex(FlexManager.flexOptions(this.node6 as TaroElement)) {
270
+ Text(this.node6.childNodes[0].textContent)
271
+ .textStyle(getNormalAttributes(this.node6.childNodes[0] as TaroElement))
272
+ .textAttr(getFontAttributes(this.node6.childNodes[0] as TaroElement))
273
+ .onVisibleAreaChange(getNodeThresholds(this.node6.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node6.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
274
+ .onAreaChange(getComponentEventCallback(this.node6.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
275
+ const eventResult: TaroAny = res.eventResult
276
+ this.nodeInfoMap[this.node6.childNodes[0]._nid].areaInfo = eventResult[1]
277
+ }))
278
+ }
279
+ .attrs(getNormalAttributes(this.node6 as TaroElement))
280
+ .onVisibleAreaChange(getNodeThresholds(this.node6 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node6 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
281
+ .onAreaChange(getComponentEventCallback(this.node6 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
282
+ const eventResult: TaroAny = res.eventResult
283
+ this.nodeInfoMap[this.node6._nid].areaInfo = eventResult[1]
284
+ }))
285
+ }
286
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
287
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
288
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
289
+ const eventResult: TaroAny = res.eventResult
290
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
291
+ }))
292
+ }
293
+ }
294
+ `;
295
+ function Index() {
296
+ return <View compileMode="f0t0" _dynamicID="node0">
297
+
298
+ {content0}
299
+
300
+ <>
301
+
302
+ <View _dynamicID="node1">{content1}</View>
303
+
304
+ <View>hello</View>
305
+
306
+ <View>
307
+
308
+ <>
309
+
310
+ <View _dynamicID="node2">{content2}</View>
311
+
312
+ <View>hello!</View>
313
+
314
+ </>
315
+
316
+ </View>
317
+
318
+ <View _dynamicID="node3">{content3}</View>
319
+
320
+ </>
321
+
322
+ <View _dynamicID="node4">{content4}</View>
323
+
324
+ <>
325
+
326
+ <View _dynamicID="node5">{content5}</View>
327
+
328
+ </>
329
+
330
+ <>
331
+
332
+ <View>hello!!</View>
333
+
334
+ </>
335
+
336
+ <View>hello!!!</View>
337
+
338
+ <View _dynamicID="node6">{content6}</View>
339
+
340
+ </View>;
341
+ }