@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,206 @@
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(Image)
12
+ function attrsImage (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
+
41
+ function getImageMode (mode: string): ImageFit {
42
+ switch (mode) {
43
+ case 'aspectFit': return ImageFit.Contain
44
+ case 'aspectFill': return ImageFit.Cover
45
+ case 'scaleToFill': return ImageFit.Fill
46
+ case 'widthFix': return ImageFit.Auto
47
+ case 'heightFix': return ImageFit.Auto
48
+ default: return ImageFit.Contain
49
+ }
50
+ }
51
+ @Component
52
+ export default struct TARO_TEMPLATES_f0t0 {
53
+ nodeInfoMap: TaroAny = {}
54
+ dynamicCenter: DynamicCenter = new DynamicCenter()
55
+ @ObjectLink node: TaroViewElement
56
+
57
+ aboutToAppear () {
58
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
59
+ }
60
+
61
+ @State node0: TaroElement = new TaroIgnoreElement()
62
+
63
+ build() {
64
+ Image((this.node0 as TaroElement).getAttribute('src'))
65
+ .objectFit(getImageMode((this.node0 as TaroElement).getAttribute('mode')))
66
+ .attrsImage(getNormalAttributes(this.node0 as TaroElement))
67
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
68
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
69
+ const eventResult: TaroAny = res.eventResult
70
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
71
+ }))
72
+ }
73
+ }
74
+ `;
75
+ const TARO_TEMPLATES_f0t1 = `import { createNode } from '../render'
76
+ import { FlexManager } from '../utils/FlexManager'
77
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
78
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
79
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
80
+ import { DynamicCenter } from '../utils/DynamicCenter'
81
+
82
+ import type { TaroViewElement } from '../element'
83
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
84
+
85
+ @Extend(Flex)
86
+ function attrs (style: TaroStyleType) {
87
+ .id(style.id)
88
+ .key(style.id)
89
+ .padding(style.padding)
90
+ .margin(style.margin)
91
+ .width(style.width)
92
+ .height(style.height)
93
+ .constraintSize(style.constraintSize)
94
+ .flexGrow(style.flexGrow)
95
+ .flexShrink(style.flexShrink)
96
+ .flexBasis(style.flexBasis)
97
+ .alignSelf(style.alignSelf)
98
+ .backgroundColor(style.backgroundColor)
99
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
100
+ .backgroundImageSize(style.backgroundImageSize)
101
+ .rotate(style.rotate)
102
+ .scale(style.scale)
103
+ .translate(style.translate)
104
+ .transform(style.transform)
105
+ .borderStyle(style.borderStyle)
106
+ .borderWidth(style.borderWidth)
107
+ .borderColor(style.borderColor)
108
+ .borderRadius(style.borderRadius)
109
+ .linearGradient(style.linearGradient)
110
+ .zIndex(style.zIndex)
111
+ .opacity(style.opacity)
112
+ .clip(style.clip)
113
+ }
114
+ @Extend(Text)
115
+ function textStyle (style: TaroStyleType) {
116
+ .id(style.id)
117
+ .key(style.id)
118
+ .padding(style.padding)
119
+ .margin(style.margin)
120
+ .width(style.width)
121
+ .height(style.height)
122
+ .constraintSize(style.constraintSize)
123
+ .flexGrow(style.flexGrow)
124
+ .flexShrink(style.flexShrink)
125
+ .flexBasis(style.flexBasis)
126
+ .alignSelf(style.alignSelf)
127
+ .backgroundColor(style.backgroundColor)
128
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
129
+ .backgroundImageSize(style.backgroundImageSize)
130
+ .rotate(style.rotate)
131
+ .scale(style.scale)
132
+ .translate(style.translate)
133
+ .transform(style.transform)
134
+ .borderStyle(style.borderStyle)
135
+ .borderWidth(style.borderWidth)
136
+ .borderColor(style.borderColor)
137
+ .borderRadius(style.borderRadius)
138
+ .linearGradient(style.linearGradient)
139
+ .zIndex(style.zIndex)
140
+ .opacity(style.opacity)
141
+ .clip(style.clip)
142
+ .fontColor(style.color)
143
+ .fontSize(style.fontSize)
144
+ .fontWeight(style.fontWeight)
145
+ .fontStyle(style.fontStyle)
146
+ .fontFamily(style.fontFamily)
147
+ .lineHeight(style.lineHeight)
148
+ .decoration({
149
+ type: style.decoration,
150
+ color: style.color
151
+ })
152
+ }
153
+
154
+ @Extend(Text)
155
+ function textAttr(attr: TaroTextStyleType) {
156
+ .textAlign(attr.textAlign)
157
+ .textOverflow(attr.textOverflow)
158
+ .maxLines(attr.maxLines)
159
+ .letterSpacing(attr.letterSpacing)
160
+ }
161
+ @Component
162
+ export default struct TARO_TEMPLATES_f0t1 {
163
+ nodeInfoMap: TaroAny = {}
164
+ dynamicCenter: DynamicCenter = new DynamicCenter()
165
+ @ObjectLink node: TaroViewElement
166
+
167
+ aboutToAppear () {
168
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
169
+ }
170
+
171
+ @State node0: TaroElement = new TaroIgnoreElement()
172
+ @State node1: TaroElement = new TaroIgnoreElement()
173
+
174
+ build() {
175
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
176
+ Text(this.node1.textContent)
177
+ .textStyle(getNormalAttributes(this.node1 as TaroElement))
178
+ .textAttr(getFontAttributes(this.node1 as TaroElement))
179
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
180
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
181
+ const eventResult: TaroAny = res.eventResult
182
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
183
+ }))
184
+ }
185
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
186
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
187
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
188
+ const eventResult: TaroAny = res.eventResult
189
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
190
+ }))
191
+ }
192
+ }
193
+ `;
194
+ function Index() {
195
+ return <View>
196
+
197
+ <Image src={mySrc} compileMode="f0t0" _dynamicID="node0"/>
198
+
199
+ <View compileMode="f0t1" _dynamicID="node0">
200
+
201
+ <Text _dynamicID="node1">{myText}</Text>
202
+
203
+ </View>
204
+
205
+ </View>;
206
+ }
@@ -0,0 +1,65 @@
1
+ const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
+ import { FlexManager } from '../utils/FlexManager'
3
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
+ import { DynamicCenter } from '../utils/DynamicCenter'
7
+
8
+ import type { TaroViewElement } from '../element'
9
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
+
11
+ @Extend(Flex)
12
+ function attrs (style: TaroStyleType) {
13
+ .id(style.id)
14
+ .key(style.id)
15
+ .padding(style.padding)
16
+ .margin(style.margin)
17
+ .width(style.width)
18
+ .height(style.height)
19
+ .constraintSize(style.constraintSize)
20
+ .flexGrow(style.flexGrow)
21
+ .flexShrink(style.flexShrink)
22
+ .flexBasis(style.flexBasis)
23
+ .alignSelf(style.alignSelf)
24
+ .backgroundColor(style.backgroundColor)
25
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
+ .backgroundImageSize(style.backgroundImageSize)
27
+ .rotate(style.rotate)
28
+ .scale(style.scale)
29
+ .translate(style.translate)
30
+ .transform(style.transform)
31
+ .borderStyle(style.borderStyle)
32
+ .borderWidth(style.borderWidth)
33
+ .borderColor(style.borderColor)
34
+ .borderRadius(style.borderRadius)
35
+ .linearGradient(style.linearGradient)
36
+ .zIndex(style.zIndex)
37
+ .opacity(style.opacity)
38
+ .clip(style.clip)
39
+ }
40
+ @Component
41
+ export default struct TARO_TEMPLATES_f0t0 {
42
+ nodeInfoMap: TaroAny = {}
43
+ dynamicCenter: DynamicCenter = new DynamicCenter()
44
+ @ObjectLink node: TaroViewElement
45
+
46
+ aboutToAppear () {
47
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
48
+ }
49
+
50
+ @State node0: TaroElement = new TaroIgnoreElement()
51
+
52
+ build() {
53
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {}
54
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
55
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
56
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
57
+ const eventResult: TaroAny = res.eventResult
58
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
59
+ }))
60
+ }
61
+ }
62
+ `;
63
+ function Index() {
64
+ return <View compileMode="f0t0" _dynamicID="node0"></View>;
65
+ }
@@ -0,0 +1,75 @@
1
+ const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
+ import { FlexManager } from '../utils/FlexManager'
3
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
+ import { DynamicCenter } from '../utils/DynamicCenter'
7
+
8
+ import type { TaroViewElement } from '../element'
9
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
+
11
+ @Extend(Flex)
12
+ function attrs (style: TaroStyleType) {
13
+ .id(style.id)
14
+ .key(style.id)
15
+ .padding(style.padding)
16
+ .margin(style.margin)
17
+ .width(style.width)
18
+ .height(style.height)
19
+ .constraintSize(style.constraintSize)
20
+ .flexGrow(style.flexGrow)
21
+ .flexShrink(style.flexShrink)
22
+ .flexBasis(style.flexBasis)
23
+ .alignSelf(style.alignSelf)
24
+ .backgroundColor(style.backgroundColor)
25
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
+ .backgroundImageSize(style.backgroundImageSize)
27
+ .rotate(style.rotate)
28
+ .scale(style.scale)
29
+ .translate(style.translate)
30
+ .transform(style.transform)
31
+ .borderStyle(style.borderStyle)
32
+ .borderWidth(style.borderWidth)
33
+ .borderColor(style.borderColor)
34
+ .borderRadius(style.borderRadius)
35
+ .linearGradient(style.linearGradient)
36
+ .zIndex(style.zIndex)
37
+ .opacity(style.opacity)
38
+ .clip(style.clip)
39
+ }
40
+ @Component
41
+ export default struct TARO_TEMPLATES_f0t0 {
42
+ nodeInfoMap: TaroAny = {}
43
+ dynamicCenter: DynamicCenter = new DynamicCenter()
44
+ @ObjectLink node: TaroViewElement
45
+
46
+ aboutToAppear () {
47
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
48
+ }
49
+
50
+ @State node0: TaroElement = new TaroIgnoreElement()
51
+
52
+ build() {
53
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
54
+ ForEach(this.node0.childNodes, (item: TaroElement) => {
55
+ createNode(item)
56
+ }, (item: TaroElement) => item._nid)
57
+ }
58
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
59
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
60
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
61
+ const eventResult: TaroAny = res.eventResult
62
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
63
+ }))
64
+ }
65
+ }
66
+ `;
67
+ function Index() {
68
+ return <View compileMode="f0t0" _dynamicID="node0">
69
+
70
+ {list.map((item)=>{
71
+ return <View>{item}</View>;
72
+ })}
73
+
74
+ </View>;
75
+ }
@@ -0,0 +1,88 @@
1
+ const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
+ import { FlexManager } from '../utils/FlexManager'
3
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
+ import { DynamicCenter } from '../utils/DynamicCenter'
7
+
8
+ import type { TaroViewElement } from '../element'
9
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
+
11
+ @Extend(Flex)
12
+ function attrs (style: TaroStyleType) {
13
+ .id(style.id)
14
+ .key(style.id)
15
+ .padding(style.padding)
16
+ .margin(style.margin)
17
+ .width(style.width)
18
+ .height(style.height)
19
+ .constraintSize(style.constraintSize)
20
+ .flexGrow(style.flexGrow)
21
+ .flexShrink(style.flexShrink)
22
+ .flexBasis(style.flexBasis)
23
+ .alignSelf(style.alignSelf)
24
+ .backgroundColor(style.backgroundColor)
25
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
+ .backgroundImageSize(style.backgroundImageSize)
27
+ .rotate(style.rotate)
28
+ .scale(style.scale)
29
+ .translate(style.translate)
30
+ .transform(style.transform)
31
+ .borderStyle(style.borderStyle)
32
+ .borderWidth(style.borderWidth)
33
+ .borderColor(style.borderColor)
34
+ .borderRadius(style.borderRadius)
35
+ .linearGradient(style.linearGradient)
36
+ .zIndex(style.zIndex)
37
+ .opacity(style.opacity)
38
+ .clip(style.clip)
39
+ }
40
+ @Component
41
+ export default struct TARO_TEMPLATES_f0t0 {
42
+ nodeInfoMap: TaroAny = {}
43
+ dynamicCenter: DynamicCenter = new DynamicCenter()
44
+ @ObjectLink node: TaroViewElement
45
+
46
+ aboutToAppear () {
47
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
48
+ }
49
+
50
+ @State node0: TaroElement = new TaroIgnoreElement()
51
+ @State node1: TaroElement = new TaroIgnoreElement()
52
+
53
+ build() {
54
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
55
+ Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
56
+ ForEach(this.node1.childNodes, (item: TaroElement) => {
57
+ createNode(item)
58
+ }, (item: TaroElement) => item._nid)
59
+ }
60
+ .attrs(getNormalAttributes(this.node1 as TaroElement))
61
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
62
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
63
+ const eventResult: TaroAny = res.eventResult
64
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
65
+ }))
66
+ }
67
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
68
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
69
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
70
+ const eventResult: TaroAny = res.eventResult
71
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
72
+ }))
73
+ }
74
+ }
75
+ `;
76
+ function Index() {
77
+ return <View compileMode="f0t0" _dynamicID="node0">
78
+
79
+ <View _dynamicID="node1">
80
+
81
+ {list.map((item)=>{
82
+ return <View>{item}</View>;
83
+ })}
84
+
85
+ </View>
86
+
87
+ </View>;
88
+ }
@@ -0,0 +1,85 @@
1
+ const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
+ import { FlexManager } from '../utils/FlexManager'
3
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
+ import { DynamicCenter } from '../utils/DynamicCenter'
7
+
8
+ import type { TaroViewElement } from '../element'
9
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
+
11
+ @Extend(Flex)
12
+ function attrs (style: TaroStyleType) {
13
+ .id(style.id)
14
+ .key(style.id)
15
+ .padding(style.padding)
16
+ .margin(style.margin)
17
+ .width(style.width)
18
+ .height(style.height)
19
+ .constraintSize(style.constraintSize)
20
+ .flexGrow(style.flexGrow)
21
+ .flexShrink(style.flexShrink)
22
+ .flexBasis(style.flexBasis)
23
+ .alignSelf(style.alignSelf)
24
+ .backgroundColor(style.backgroundColor)
25
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
+ .backgroundImageSize(style.backgroundImageSize)
27
+ .rotate(style.rotate)
28
+ .scale(style.scale)
29
+ .translate(style.translate)
30
+ .transform(style.transform)
31
+ .borderStyle(style.borderStyle)
32
+ .borderWidth(style.borderWidth)
33
+ .borderColor(style.borderColor)
34
+ .borderRadius(style.borderRadius)
35
+ .linearGradient(style.linearGradient)
36
+ .zIndex(style.zIndex)
37
+ .opacity(style.opacity)
38
+ .clip(style.clip)
39
+ }
40
+ @Component
41
+ export default struct TARO_TEMPLATES_f0t0 {
42
+ nodeInfoMap: TaroAny = {}
43
+ dynamicCenter: DynamicCenter = new DynamicCenter()
44
+ @ObjectLink node: TaroViewElement
45
+
46
+ aboutToAppear () {
47
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
48
+ }
49
+
50
+ @State node0: TaroElement = new TaroIgnoreElement()
51
+
52
+ build() {
53
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
54
+ ForEach(this.node0.childNodes, (item: TaroElement) => {
55
+ createNode(item)
56
+ }, (item: TaroElement) => item._nid)
57
+ }
58
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
59
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
60
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
61
+ const eventResult: TaroAny = res.eventResult
62
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
63
+ }))
64
+ }
65
+ }
66
+ `;
67
+ function Index() {
68
+ return <View compileMode="f0t0" _dynamicID="node0">
69
+
70
+ {list.map(function(item, index) {
71
+ return <View hoverClass={myClass}>
72
+
73
+ <Text>index:</Text>
74
+
75
+ <Text>{index}</Text>
76
+
77
+ <Text>item:</Text>
78
+
79
+ <Text>{item}</Text>
80
+
81
+ </View>;
82
+ })}
83
+
84
+ </View>;
85
+ }
@@ -0,0 +1,8 @@
1
+ const TARO_TEMPLATES_f0t0 = '<template name="tmpl_0_f0t0"><view><view wx:for="{{i.cn}}" wx:key="sid">{{item.cn[0].v}}</view></view></template>';
2
+ function Index() {
3
+ return <View compileMode="f0t0">
4
+ {list.map(item => {
5
+ return <View>{item}</View>
6
+ })}
7
+ </View>;
8
+ }
@@ -0,0 +1,6 @@
1
+ const TARO_TEMPLATES_f0t0 = '<template name="tmpl_0_f0t0"><view><view wx:for="{{i.cn}}" wx:key="sid">{{item.cn[0].v}}</view></view></template>';
2
+ function Index () {
3
+ return <View compileMode="f0t0">
4
+ {list.map(item => <View>{item}</View>)}
5
+ </View>;
6
+ }
@@ -0,0 +1,20 @@
1
+ const TARO_TEMPLATES_f0t0 = '<template name="tmpl_0_f0t0"><view><view hover-class="{{xs.b(item.p1,\'none\')}}" wx:for="{{i.cn}}" wx:key="sid"><text>index:</text><text>{{item.cn[0].cn[0].v}}</text><text>item:</text><text>{{item.cn[1].cn[0].v}}</text></view></view></template>';
2
+ function Index() {
3
+ return <View compileMode="f0t0">
4
+
5
+ {list.map(function(item, index) {
6
+ return <View hoverClass={myClass}>
7
+
8
+
9
+
10
+ <Text>{index}</Text>
11
+
12
+
13
+
14
+ <Text>{item}</Text>
15
+
16
+ </View>;
17
+ })}
18
+
19
+ </View>;
20
+ }
@@ -0,0 +1,15 @@
1
+ const TARO_TEMPLATES_f0t0 = '<template name="tmpl_0_f0t0"><view><view hover-class="{{xs.b(item.p1,\'none\')}}" wx:for="{{i.cn}}" wx:key="sid"><view>title: {{item.cn[0].cn[0].v}}</view><view><text selectable="{{xs.b(item.p1,!1)}}" wx:for="{{item.cn[1].cn}}" wx:key="sid">content: {{item.cn[0].v}}</text></view></view></view></template>';
2
+ function Index() {
3
+ return <View compileMode="f0t0">
4
+ {list.map(function(item, index) {
5
+ return <View hoverClass={myClass} key={index}>
6
+ <View>{item}</View>
7
+ <View>
8
+ {sublist.map(function(c) {
9
+ return <Text selectable={isSelectable}>{c}</Text>
10
+ })}
11
+ </View>
12
+ </View>
13
+ })}
14
+ </View>;
15
+ }
@@ -0,0 +1,20 @@
1
+ const TARO_TEMPLATES_f0t0 = '<template name="tmpl_0_f0t0"><view><text>Hello World!</text><text>Hello{{i.cn[0].cn[0].v}}World{{i.cn[0].cn[1].v}}!</text><view><text></text></view><view hover-stop-propagation="true" style="color: red"><text>Hello World!</text></view><view style="{{i.cn[1].st}}"><text>Hello World!</text></view></view></template>';
2
+ function Index() {
3
+ return <View compileMode="f0t0">
4
+
5
+
6
+
7
+ <Text>{T1}{T2}</Text>
8
+
9
+
10
+
11
+
12
+
13
+ <View style={myStyle}>
14
+
15
+
16
+
17
+ </View>
18
+
19
+ </View>;
20
+ }
@@ -0,0 +1,5 @@
1
+ # These command aliases are not final, may change
2
+ [alias]
3
+ # Alias to build actual plugin binary for the specified target.
4
+ build-wasi = "build --target wasm32-wasi"
5
+ build-wasm32 = "build --target wasm32-unknown-unknown"