@tarojs/helper 3.8.0-canary.0 → 4.0.0-beta.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,91 @@
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
+
53
+ build() {
54
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
55
+ Flex(FlexManager.flexOptions(this.node0.childNodes[0] as TaroElement)) {
56
+ createNode(this.node0.childNodes[0].childNodes[0] as TaroElement)
57
+ }
58
+ .attrs(getNormalAttributes(this.node0.childNodes[0] as TaroElement))
59
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[0] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[0] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
60
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
61
+ const eventResult: TaroAny = res.eventResult
62
+ this.nodeInfoMap[this.node0.childNodes[0]._nid].areaInfo = eventResult[1]
63
+ }))
64
+ Flex(FlexManager.flexOptions(this.node0.childNodes[1] as TaroElement)) {
65
+ createNode(this.node0.childNodes[1].childNodes[0] as TaroElement)
66
+ }
67
+ .attrs(getNormalAttributes(this.node0.childNodes[1] as TaroElement))
68
+ .onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
69
+ .onAreaChange(getComponentEventCallback(this.node0.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
70
+ const eventResult: TaroAny = res.eventResult
71
+ this.nodeInfoMap[this.node0.childNodes[1]._nid].areaInfo = eventResult[1]
72
+ }))
73
+ }
74
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
75
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
76
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
77
+ const eventResult: TaroAny = res.eventResult
78
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
79
+ }))
80
+ }
81
+ }
82
+ `;
83
+ function Index() {
84
+ return <View compileMode="f0t0" _dynamicID="node0">
85
+
86
+ <View><Slider/></View>
87
+
88
+ <View><Test1/></View>
89
+
90
+ </View>;
91
+ }
@@ -0,0 +1,209 @@
1
+ const TARO_TEMPLATES_f0t0 = `import { createNode } from '../render'
2
+ import { FlexManager } from '../utils/FlexManager'
3
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
4
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
5
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
6
+ import { DynamicCenter } from '../utils/DynamicCenter'
7
+
8
+ import type { TaroViewElement } from '../element'
9
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
10
+
11
+ @Extend(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
+ .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
+
42
+ function getImageMode (mode: string): ImageFit {
43
+ switch (mode) {
44
+ case 'aspectFit': return ImageFit.Contain
45
+ case 'aspectFill': return ImageFit.Cover
46
+ case 'scaleToFill': return ImageFit.Fill
47
+ case 'widthFix': return ImageFit.Auto
48
+ case 'heightFix': return ImageFit.Auto
49
+ default: return ImageFit.Contain
50
+ }
51
+ }
52
+ @Component
53
+ export default struct TARO_TEMPLATES_f0t0 {
54
+ nodeInfoMap: TaroAny = {}
55
+ dynamicCenter: DynamicCenter = new DynamicCenter()
56
+ @ObjectLink node: TaroViewElement
57
+
58
+ aboutToAppear () {
59
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
60
+ }
61
+
62
+ @State node0: TaroElement = new TaroIgnoreElement()
63
+
64
+ build() {
65
+ Image((this.node0 as TaroElement).getAttribute('src'))
66
+ .objectFit(getImageMode((this.node0 as TaroElement).getAttribute('mode')))
67
+ .attrsImage(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
+ const TARO_TEMPLATES_f0t1 = `import { createNode } from '../render'
77
+ import { FlexManager } from '../utils/FlexManager'
78
+ import { TOUCH_EVENT_MAP } from '../utils/constant/event'
79
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from '../utils/helper'
80
+ import { TaroIgnoreElement, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '../../runtime'
81
+ import { DynamicCenter } from '../utils/DynamicCenter'
82
+
83
+ import type { TaroViewElement } from '../element'
84
+ import type { TaroElement, TaroAny, TaroStyleType, TaroTextStyleType } from '../../runtime'
85
+
86
+ @Extend(Flex)
87
+ function attrs (style: TaroStyleType) {
88
+ .id(style.id)
89
+ .key(style.id)
90
+ .padding(style.padding)
91
+ .margin(style.margin)
92
+ .width(style.width)
93
+ .height(style.height)
94
+ .constraintSize(style.constraintSize)
95
+ .flexGrow(style.flexGrow)
96
+ .flexShrink(style.flexShrink)
97
+ .flexBasis(style.flexBasis)
98
+ .alignSelf(style.alignSelf)
99
+ .backgroundColor(style.backgroundColor)
100
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
101
+ .backgroundImageSize(style.backgroundImageSize)
102
+ .backgroundImagePosition(style.backgroundImagePosition)
103
+ .rotate(style.rotate)
104
+ .scale(style.scale)
105
+ .translate(style.translate)
106
+ .transform(style.transform)
107
+ .borderStyle(style.borderStyle)
108
+ .borderWidth(style.borderWidth)
109
+ .borderColor(style.borderColor)
110
+ .borderRadius(style.borderRadius)
111
+ .linearGradient(style.linearGradient)
112
+ .zIndex(style.zIndex)
113
+ .opacity(style.opacity)
114
+ .clip(style.clip)
115
+ }
116
+ @Extend(Text)
117
+ function textStyle (style: TaroStyleType) {
118
+ .id(style.id)
119
+ .key(style.id)
120
+ .padding(style.padding)
121
+ .margin(style.margin)
122
+ .width(style.width)
123
+ .height(style.height)
124
+ .constraintSize(style.constraintSize)
125
+ .flexGrow(style.flexGrow)
126
+ .flexShrink(style.flexShrink)
127
+ .flexBasis(style.flexBasis)
128
+ .alignSelf(style.alignSelf)
129
+ .backgroundColor(style.backgroundColor)
130
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
131
+ .backgroundImageSize(style.backgroundImageSize)
132
+ .backgroundImagePosition(style.backgroundImagePosition)
133
+ .rotate(style.rotate)
134
+ .scale(style.scale)
135
+ .translate(style.translate)
136
+ .transform(style.transform)
137
+ .borderStyle(style.borderStyle)
138
+ .borderWidth(style.borderWidth)
139
+ .borderColor(style.borderColor)
140
+ .borderRadius(style.borderRadius)
141
+ .linearGradient(style.linearGradient)
142
+ .zIndex(style.zIndex)
143
+ .opacity(style.opacity)
144
+ .clip(style.clip)
145
+ .fontColor(style.color)
146
+ .fontSize(style.fontSize)
147
+ .fontWeight(style.fontWeight)
148
+ .fontStyle(style.fontStyle)
149
+ .fontFamily(style.fontFamily)
150
+ .lineHeight(style.lineHeight)
151
+ .decoration({
152
+ type: style.decoration,
153
+ color: style.color
154
+ })
155
+ }
156
+
157
+ @Extend(Text)
158
+ function textAttr(attr: TaroTextStyleType) {
159
+ .textAlign(attr.textAlign)
160
+ .textOverflow(attr.textOverflow)
161
+ .maxLines(attr.maxLines)
162
+ .letterSpacing(attr.letterSpacing)
163
+ }
164
+ @Component
165
+ export default struct TARO_TEMPLATES_f0t1 {
166
+ nodeInfoMap: TaroAny = {}
167
+ dynamicCenter: DynamicCenter = new DynamicCenter()
168
+ @ObjectLink node: TaroViewElement
169
+
170
+ aboutToAppear () {
171
+ this.dynamicCenter.bindComponentToNodeWithDFS(this.node, this)
172
+ }
173
+
174
+ @State node0: TaroElement = new TaroIgnoreElement()
175
+ @State node1: TaroElement = new TaroIgnoreElement()
176
+
177
+ build() {
178
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
179
+ Text(this.node1.textContent)
180
+ .textStyle(getNormalAttributes(this.node1 as TaroElement))
181
+ .textAttr(getFontAttributes(this.node1 as TaroElement))
182
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
183
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
184
+ const eventResult: TaroAny = res.eventResult
185
+ this.nodeInfoMap[this.node1._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>
199
+
200
+ <Image src={mySrc} compileMode="f0t0" _dynamicID="node0"/>
201
+
202
+ <View compileMode="f0t1" _dynamicID="node0">
203
+
204
+ <Text _dynamicID="node1">{myText}</Text>
205
+
206
+ </View>
207
+
208
+ </View>;
209
+ }
@@ -0,0 +1,66 @@
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
+
53
+ build() {
54
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {}
55
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
56
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
57
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
58
+ const eventResult: TaroAny = res.eventResult
59
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
60
+ }))
61
+ }
62
+ }
63
+ `;
64
+ function Index() {
65
+ return <View compileMode="f0t0" _dynamicID="node0"></View>;
66
+ }
@@ -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
+
53
+ build() {
54
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
55
+ ForEach(this.node0.childNodes, (item: TaroElement) => {
56
+ createNode(item)
57
+ }, (item: TaroElement) => item._nid)
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
+ {list.map((item)=>{
72
+ return <View>{item}</View>;
73
+ })}
74
+
75
+ </View>;
76
+ }
@@ -0,0 +1,89 @@
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
+ Flex(FlexManager.flexOptions(this.node1 as TaroElement)) {
57
+ ForEach(this.node1.childNodes, (item: TaroElement) => {
58
+ createNode(item)
59
+ }, (item: TaroElement) => item._nid)
60
+ }
61
+ .attrs(getNormalAttributes(this.node1 as TaroElement))
62
+ .onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
63
+ .onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
64
+ const eventResult: TaroAny = res.eventResult
65
+ this.nodeInfoMap[this.node1._nid].areaInfo = eventResult[1]
66
+ }))
67
+ }
68
+ .attrs(getNormalAttributes(this.node0 as TaroElement))
69
+ .onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
70
+ .onAreaChange(getComponentEventCallback(this.node0 as TaroElement, AREA_CHANGE_EVENT_NAME, res => {
71
+ const eventResult: TaroAny = res.eventResult
72
+ this.nodeInfoMap[this.node0._nid].areaInfo = eventResult[1]
73
+ }))
74
+ }
75
+ }
76
+ `;
77
+ function Index() {
78
+ return <View compileMode="f0t0" _dynamicID="node0">
79
+
80
+ <View _dynamicID="node1">
81
+
82
+ {list.map((item)=>{
83
+ return <View>{item}</View>;
84
+ })}
85
+
86
+ </View>
87
+
88
+ </View>;
89
+ }
@@ -0,0 +1,86 @@
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
+
53
+ build() {
54
+ Flex(FlexManager.flexOptions(this.node0 as TaroElement)) {
55
+ ForEach(this.node0.childNodes, (item: TaroElement) => {
56
+ createNode(item)
57
+ }, (item: TaroElement) => item._nid)
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
+ {list.map(function(item, index) {
72
+ return <View hoverClass={myClass}>
73
+
74
+ <Text>index:</Text>
75
+
76
+ <Text>{index}</Text>
77
+
78
+ <Text>item:</Text>
79
+
80
+ <Text>{item}</Text>
81
+
82
+ </View>;
83
+ })}
84
+
85
+ </View>;
86
+ }
@@ -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
+ }