@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10

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 (239) hide show
  1. package/dist/apis/apis.ts +6 -2
  2. package/dist/apis/base/crypto.ts +4 -0
  3. package/dist/apis/base/debug.ts +5 -0
  4. package/dist/apis/base/index.ts +9 -1
  5. package/dist/apis/base/performance.ts +8 -0
  6. package/dist/apis/base/system.ts +74 -21
  7. package/dist/apis/base/update.ts +5 -0
  8. package/dist/apis/base/weapp/app-event.ts +75 -0
  9. package/dist/apis/base/weapp/life-cycle.ts +21 -0
  10. package/dist/apis/canvas/index.ts +27 -0
  11. package/dist/apis/data-analysis/index.ts +6 -0
  12. package/dist/apis/device/accelerometer.ts +2 -1
  13. package/dist/apis/device/accessibility.ts +4 -0
  14. package/dist/apis/device/battery.ts +2 -2
  15. package/dist/apis/device/bluetooth-ble.ts +19 -0
  16. package/dist/apis/device/bluetooth-peripheral.ts +6 -0
  17. package/dist/apis/device/bluetooth.ts +16 -0
  18. package/dist/apis/device/calendar.ts +5 -0
  19. package/dist/apis/device/clipboard.ts +17 -9
  20. package/dist/apis/device/compass.ts +21 -0
  21. package/dist/apis/device/contact.ts +5 -0
  22. package/dist/apis/device/crypto.ts +4 -0
  23. package/dist/apis/device/gyroscope.ts +7 -0
  24. package/dist/apis/device/iBeacon.ts +10 -0
  25. package/dist/apis/device/index.ts +15 -0
  26. package/dist/apis/device/keyboard.ts +2 -1
  27. package/dist/apis/device/memory.ts +10 -3
  28. package/dist/apis/device/motion.ts +6 -0
  29. package/dist/apis/device/network.ts +26 -9
  30. package/dist/apis/device/nfc.ts +10 -0
  31. package/dist/apis/device/phone.ts +2 -1
  32. package/dist/apis/device/scan.ts +4 -0
  33. package/dist/apis/device/screen.ts +2 -1
  34. package/dist/apis/device/sms.ts +4 -0
  35. package/dist/apis/device/vibrate.ts +19 -11
  36. package/dist/apis/device/wifi.ts +15 -0
  37. package/dist/apis/ext/index.ts +5 -0
  38. package/dist/apis/files/index.ts +2 -1
  39. package/dist/apis/files/manager.ts +2 -1
  40. package/dist/apis/framework/index.ts +3 -8
  41. package/dist/apis/index.ts +27 -17
  42. package/dist/apis/location/index.ts +61 -68
  43. package/dist/apis/media/EditorContext.ts +32 -0
  44. package/dist/apis/media/audio/index.ts +18 -0
  45. package/dist/apis/media/background-audio/index.ts +16 -0
  46. package/dist/apis/media/camera.ts +16 -0
  47. package/dist/apis/media/common.ts +2 -1
  48. package/dist/apis/media/{image.ts → image/index.ts} +4 -3
  49. package/dist/apis/media/index.ts +10 -0
  50. package/dist/apis/media/live.ts +5 -0
  51. package/dist/apis/media/map.ts +4 -0
  52. package/dist/apis/media/media-recorder.ts +4 -0
  53. package/dist/apis/media/recorder.ts +6 -0
  54. package/dist/apis/media/video/VideoContext.ts +68 -0
  55. package/dist/apis/media/{video.ts → video/index.ts} +13 -2
  56. package/dist/apis/media/video-decoder.ts +4 -0
  57. package/dist/apis/media/video-processing.ts +4 -0
  58. package/dist/apis/media/voip.ts +19 -0
  59. package/dist/apis/network/index.ts +3 -0
  60. package/dist/apis/network/mdns.ts +13 -0
  61. package/dist/apis/network/request.ts +7 -6
  62. package/dist/apis/network/tcp.ts +4 -0
  63. package/dist/apis/network/udp.ts +4 -0
  64. package/dist/apis/network/webSocket.ts +2 -6
  65. package/dist/apis/open-api/account.ts +4 -0
  66. package/dist/apis/open-api/address.ts +4 -0
  67. package/dist/apis/open-api/authorize.ts +5 -0
  68. package/dist/apis/open-api/card.ts +5 -0
  69. package/dist/apis/open-api/channels-live.ts +11 -0
  70. package/dist/apis/open-api/customer-service.ts +4 -0
  71. package/dist/apis/open-api/device-voip.ts +5 -0
  72. package/dist/apis/open-api/facial.ts +7 -0
  73. package/dist/apis/open-api/favorites.ts +5 -0
  74. package/dist/apis/open-api/group.ts +4 -0
  75. package/dist/apis/open-api/index.ts +20 -6
  76. package/dist/apis/open-api/invoice.ts +5 -0
  77. package/dist/apis/open-api/license-plate.ts +4 -0
  78. package/dist/apis/open-api/login.ts +6 -0
  79. package/dist/apis/open-api/my-miniprogram.ts +4 -0
  80. package/dist/apis/open-api/privacy.ts +7 -0
  81. package/dist/apis/open-api/red-package.ts +4 -0
  82. package/dist/apis/open-api/settings.ts +5 -0
  83. package/dist/apis/open-api/soter.ts +6 -0
  84. package/dist/apis/open-api/subscribe-message.ts +6 -0
  85. package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
  86. package/dist/apis/open-api/werun.ts +5 -0
  87. package/dist/apis/payment/index.ts +6 -0
  88. package/dist/apis/route/index.ts +19 -28
  89. package/dist/apis/share/index.ts +33 -0
  90. package/dist/apis/storage/background-fetch.ts +7 -0
  91. package/dist/apis/storage/cache-manager.ts +4 -0
  92. package/dist/apis/storage/index.ts +158 -88
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +4 -19
  96. package/dist/apis/ui/custom-component.ts +8 -0
  97. package/dist/apis/ui/fonts.ts +4 -0
  98. package/dist/apis/ui/index.ts +8 -10
  99. package/dist/apis/ui/interaction/index.ts +45 -59
  100. package/dist/apis/ui/menu.ts +4 -0
  101. package/dist/apis/ui/navigation-bar/index.ts +60 -21
  102. package/dist/apis/ui/pull-down-refresh.ts +10 -4
  103. package/dist/apis/{page → ui/scroll}/index.ts +32 -27
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/utils/index.ts +1 -1
  109. package/dist/apis/worker/index.ts +4 -0
  110. package/dist/apis/wxml/IntersectionObserver.ts +24 -25
  111. package/dist/apis/wxml/index.ts +7 -2
  112. package/dist/apis/wxml/nodesRef.ts +2 -2
  113. package/dist/apis/wxml/selectorQuery.ts +29 -17
  114. package/dist/components-harmony-ets/button.ets +106 -80
  115. package/dist/components-harmony-ets/canvas.ets +51 -0
  116. package/dist/components-harmony-ets/checkbox.ets +82 -148
  117. package/dist/components-harmony-ets/form.ets +45 -132
  118. package/dist/components-harmony-ets/icon.ets +66 -69
  119. package/dist/components-harmony-ets/image.ets +26 -61
  120. package/dist/components-harmony-ets/index.ets +92 -0
  121. package/dist/components-harmony-ets/innerHtml.ets +7 -70
  122. package/dist/components-harmony-ets/input.ets +60 -146
  123. package/dist/components-harmony-ets/label.ets +86 -92
  124. package/dist/components-harmony-ets/listView.ets +26 -0
  125. package/dist/components-harmony-ets/movableArea.ets +124 -0
  126. package/dist/components-harmony-ets/movableView.ets +93 -0
  127. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  128. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  129. package/dist/components-harmony-ets/picker.ets +172 -198
  130. package/dist/components-harmony-ets/progress.ets +52 -0
  131. package/dist/components-harmony-ets/pseudo.ets +80 -0
  132. package/dist/components-harmony-ets/radio.ets +85 -155
  133. package/dist/components-harmony-ets/richText.ets +15 -87
  134. package/dist/components-harmony-ets/scrollList.ets +94 -0
  135. package/dist/components-harmony-ets/scrollView.ets +81 -149
  136. package/dist/components-harmony-ets/slider.ets +47 -94
  137. package/dist/components-harmony-ets/stickySection.ets +42 -0
  138. package/dist/components-harmony-ets/style.ets +396 -0
  139. package/dist/components-harmony-ets/swiper.ets +51 -151
  140. package/dist/components-harmony-ets/switch.ets +35 -76
  141. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  142. package/dist/components-harmony-ets/text.ets +131 -76
  143. package/dist/components-harmony-ets/textArea.ets +64 -140
  144. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  145. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  146. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  147. package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
  148. package/dist/components-harmony-ets/utils/helper.ets +18 -65
  149. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  150. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  151. package/dist/components-harmony-ets/utils/index.ts +55 -51
  152. package/dist/components-harmony-ets/utils/styles.ets +177 -65
  153. package/dist/components-harmony-ets/video.ets +70 -116
  154. package/dist/components-harmony-ets/view.ets +58 -64
  155. package/dist/components-harmony-ets/webView.ets +56 -0
  156. package/dist/index.d.ts +152 -0
  157. package/dist/index.js +230 -60
  158. package/dist/index.js.map +1 -1
  159. package/dist/runtime-ets/bom/document.ts +6 -4
  160. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  161. package/dist/runtime-ets/bom/window.ts +9 -2
  162. package/dist/runtime-ets/current.ts +3 -0
  163. package/dist/runtime-ets/dom/bind.ts +96 -0
  164. package/dist/runtime-ets/dom/class-list.ts +4 -6
  165. package/dist/runtime-ets/dom/comment.ts +1 -2
  166. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  167. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
  168. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  169. package/dist/runtime-ets/dom/document.ts +36 -51
  170. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  171. package/dist/runtime-ets/dom/element/element.ts +439 -0
  172. package/dist/runtime-ets/dom/element/form.ts +403 -0
  173. package/dist/runtime-ets/dom/element/index.ts +120 -0
  174. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  175. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  176. package/dist/runtime-ets/dom/element/normal.ts +103 -0
  177. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  178. package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
  179. package/dist/runtime-ets/dom/element/text.ts +10 -0
  180. package/dist/runtime-ets/dom/element/video.ts +50 -0
  181. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  182. package/dist/runtime-ets/dom/event.ts +26 -5
  183. package/dist/runtime-ets/dom/eventTarget.ts +3 -3
  184. package/dist/runtime-ets/dom/node.ts +114 -49
  185. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  186. package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
  187. package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
  188. package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
  189. package/dist/runtime-ets/index.ts +2 -3
  190. package/dist/runtime-ets/interface/event.ts +3 -2
  191. package/dist/runtime-ets/utils/index.ts +87 -17
  192. package/dist/runtime-ets/utils/info.ts +21 -47
  193. package/dist/runtime-framework/react/app.ts +20 -28
  194. package/dist/runtime-framework/react/hooks.ts +3 -4
  195. package/dist/runtime-framework/react/index.ts +1 -2
  196. package/dist/runtime-framework/react/native-page.ts +421 -0
  197. package/dist/runtime-framework/react/page.ts +5 -17
  198. package/dist/runtime-framework/solid/app.ts +25 -45
  199. package/dist/runtime-framework/solid/connect.ts +21 -3
  200. package/dist/runtime-framework/solid/hooks.ts +17 -12
  201. package/dist/runtime-framework/solid/index.ts +6 -2
  202. package/dist/runtime-framework/solid/page.ts +84 -36
  203. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  204. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  205. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  206. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  207. package/dist/runtime-utils.d.ts +827 -0
  208. package/dist/runtime-utils.js +1633 -549
  209. package/dist/runtime-utils.js.map +1 -1
  210. package/dist/runtime.d.ts +1 -0
  211. package/dist/runtime.js +1633 -549
  212. package/dist/runtime.js.map +1 -1
  213. package/index.js +3 -1
  214. package/package.json +14 -15
  215. package/static/media/cancel.svg +1 -0
  216. package/static/media/circle.svg +1 -0
  217. package/static/media/clear.svg +1 -0
  218. package/static/media/download.svg +1 -0
  219. package/static/media/info.svg +1 -0
  220. package/static/media/info_circle.svg +1 -0
  221. package/static/media/search.svg +1 -0
  222. package/static/media/success.svg +1 -0
  223. package/static/media/success_no_circle.svg +1 -0
  224. package/static/media/taro_arrow_left.svg +1 -0
  225. package/static/media/taro_home.svg +1 -0
  226. package/static/media/waiting.svg +1 -0
  227. package/static/media/warn.svg +1 -0
  228. package/types/harmony.d.ts +4 -0
  229. package/types/index.d.ts +4 -0
  230. package/types/runtime.d.ts +7 -1
  231. package/LICENSE +0 -160
  232. package/dist/components-harmony-ets/base.ets +0 -63
  233. package/dist/components-harmony-ets/element.ets +0 -223
  234. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  235. package/dist/runtime-ets/dom/element.ts +0 -457
  236. package/dist/runtime-ets/dom/text.ts +0 -19
  237. package/dist/runtime-ets/utils/bind.ts +0 -35
  238. package/types/api.d.ts +0 -4
  239. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -0,0 +1,242 @@
1
+ import { TaroElement } from './element'
2
+
3
+ import type { MovableViewProps } from '@tarojs/components/types'
4
+ import type { TaroAny } from '../../utils'
5
+
6
+ type Tsize = {
7
+ w: number
8
+ h: number
9
+ }
10
+ type Tpoint = {
11
+ x: number
12
+ y: number
13
+ }
14
+
15
+ function calcPosition(postion: number, start: number, end: number) {
16
+ if (postion <= end && postion >= start) {
17
+ return postion
18
+ } else if (postion < start) {
19
+ return start
20
+ } else {
21
+ return end
22
+ }
23
+ }
24
+
25
+ export function isTaroMovableViewElement (item: TaroAny): item is TaroMovableViewElement {
26
+ return item instanceof TaroMovableViewElement
27
+ }
28
+ @Observed
29
+ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { animation: undefined }> {
30
+ _scaleValue = 1
31
+ _scalevalueTemp = 1
32
+
33
+ // 父级区别的大小
34
+ _area?: Tsize
35
+ // 自己元素的大小
36
+ _selfSize?: Tsize
37
+ _areaInited: false
38
+ _selfSizeInited: false
39
+
40
+ // 元素的位置
41
+ _position: Tpoint = {
42
+ x: 0,
43
+ y: 0,
44
+ }
45
+
46
+ _positionTemp: Tpoint = {
47
+ x: 0,
48
+ y: 0,
49
+ }
50
+
51
+ constructor() {
52
+ super('MovableView')
53
+ }
54
+
55
+ get _outOfBounds() {
56
+ if (this.getAttribute('outOfBounds')) {
57
+ return this.selfSize ? this.selfSize.w / 3 : 0
58
+ }
59
+ return 0
60
+ }
61
+
62
+ startScale() {
63
+ this._scalevalueTemp = this._scaleValue
64
+ }
65
+
66
+ doScale(val: number) {
67
+ const scale = this.getAttribute('scale')
68
+
69
+ // 禁止缩放的时候不生效
70
+ if (scale) {
71
+ this.scaleValue = val * this._scalevalueTemp
72
+ }
73
+ }
74
+
75
+ set scaleValue(val: number) {
76
+ if (this.checkScaleValueInBounds(val)) {
77
+ this._scaleValue = val
78
+
79
+ this.checkPositionBoundary(this.position, val)
80
+
81
+ const scaleFns = this?.__listeners?.scale || []
82
+ scaleFns.forEach((fn) => {
83
+ fn({ ...this.position, scale: this.scaleValue })
84
+ })
85
+ }
86
+ }
87
+
88
+ get visibility () {
89
+ return this._areaInited && this._selfSizeInited ? Visibility.Visible : Visibility.Hidden
90
+ }
91
+
92
+ get scaleValue() {
93
+ return this._scaleValue
94
+ }
95
+
96
+ startMove() {
97
+ this._positionTemp = this._position
98
+ }
99
+
100
+ doMove(val: Tpoint) {
101
+ if (!this.area || !this.selfSize) {
102
+ return
103
+ }
104
+ if (this.getAttribute('disabled')) {
105
+ return
106
+ }
107
+ const direction = this.getAttribute('direction')
108
+
109
+ // 容器的宽高终点
110
+ const areaWidthEnd = this.area.w - this.selfSize.w * this.scaleValue
111
+ const areaHeightEnd = this.area.h - this.selfSize.h * this.scaleValue
112
+
113
+ const incrementWidth = (this.scaleValue - 1) * this.selfSize.w
114
+ const incrementHeight = (this.scaleValue - 1) * this.selfSize.h
115
+
116
+ let x = this._positionTemp.x
117
+ let y = this._positionTemp.y
118
+ if (['all', 'horizontal'].includes(direction)) {
119
+ const nextX = this._positionTemp.x + val.x * this.scaleValue
120
+ x = calcPosition(
121
+ nextX,
122
+ incrementWidth * 0.5 - this._outOfBounds,
123
+ areaWidthEnd + incrementWidth * 0.5 + this._outOfBounds
124
+ )
125
+ }
126
+
127
+ if (['all', 'vertical'].includes(direction)) {
128
+ const nextY = this._positionTemp.y + val.y * this.scaleValue
129
+ y = calcPosition(
130
+ nextY,
131
+ incrementHeight * 0.5 - this._outOfBounds,
132
+ areaHeightEnd + incrementHeight * 0.5 + this._outOfBounds
133
+ )
134
+ }
135
+
136
+ const changeFns = this?.__listeners?.change || []
137
+ changeFns.forEach((fn) => {
138
+ fn({ x, y, source: 'touch' })
139
+ })
140
+
141
+ this.position = {
142
+ x: x,
143
+ y: y,
144
+ }
145
+ }
146
+
147
+ get position() {
148
+ return this._position
149
+ }
150
+
151
+ set position(val: Tpoint) {
152
+ this._position = val
153
+ }
154
+
155
+ set area(val: Tsize) {
156
+ if (val.w === this._area?.w && val.h === this._area?.h) return
157
+ this._area = val
158
+ if (!this._areaInited) {
159
+ this._areaInited = true
160
+ this.initPositionFromAttribute()
161
+ }
162
+ }
163
+
164
+ get area(): Tsize | undefined {
165
+ return this._area
166
+ }
167
+
168
+ set selfSize(val: Tsize) {
169
+ if (val.w === this._selfSize?.w && val.h === this._selfSize?.h) return
170
+ this._selfSize = val
171
+ if (!this._selfSizeInited) {
172
+ this._selfSizeInited = true
173
+ this.initPositionFromAttribute()
174
+ }
175
+ }
176
+
177
+ get selfSize(): Tsize | undefined {
178
+ return this._selfSize
179
+ }
180
+
181
+ initPositionFromAttribute () {
182
+ if (!this.area || !this.selfSize) {
183
+ return
184
+ }
185
+ const x = this.getAttribute('x') ? Number(this.getAttribute('x')) : 0
186
+ const y = this.getAttribute('y') ? Number(this.getAttribute('y')) : 0
187
+ this.checkPositionBoundary({ x, y }, this.scaleValue)
188
+ }
189
+
190
+ checkPositionBoundary(position: Tpoint, scale: number) {
191
+ if (!this.area || !this.selfSize) {
192
+ return { x: 0, y: 0 }
193
+ }
194
+
195
+ const areaWidthEnd = this.area.w - this.selfSize.w * scale
196
+ const areaHeightEnd = this.area.h - this.selfSize.h * scale
197
+
198
+ const incrementWidth = (scale - 1) * this.selfSize.w
199
+ const incrementHeight = (scale - 1) * this.selfSize.h
200
+
201
+ this.position = {
202
+ x: calcPosition(position.x, incrementWidth * 0.5, areaWidthEnd + incrementWidth * 0.5),
203
+ y: calcPosition(position.y, incrementHeight * 0.5, areaHeightEnd + incrementHeight * 0.5),
204
+ }
205
+ }
206
+
207
+ checkScaleValueInBounds(currentScale: number) {
208
+ const scaleMin = this.getAttribute('scaleMin')
209
+ const scaleMax = this.getAttribute('scaleMax')
210
+
211
+ if (scaleMin && Number(scaleMin) >= 0.1 && currentScale < Number(scaleMin)) {
212
+ return false
213
+ } else if (scaleMax && Number(scaleMax) >= 0.1 && currentScale > Number(scaleMax)) {
214
+ return false
215
+ }
216
+
217
+ return true
218
+ }
219
+
220
+ public setAttribute(name: string, value: any): void {
221
+ if (name === 'x') {
222
+ this.checkPositionBoundary({ x: value, y: this.position.y }, this.scaleValue)
223
+ }
224
+ if (name === 'y') {
225
+ this.checkPositionBoundary({ x: this.position.x, y: value }, this.scaleValue)
226
+ }
227
+
228
+ super.setAttribute(name, value)
229
+ }
230
+
231
+ public callTouchEventFnFromGesture(eventName: string, gestureEvent: GestureEvent) {
232
+ const touchFns = (this?.__listeners?.[eventName] || []) as Function[]
233
+ touchFns.forEach(fn => {
234
+ fn({
235
+ changedTouches: gestureEvent.fingerList.map(finger => ({
236
+ clientX: finger.globalX,
237
+ clientY: finger.globalY
238
+ }))
239
+ })
240
+ })
241
+ }
242
+ }
@@ -0,0 +1,103 @@
1
+
2
+ import { TaroElement } from './element'
3
+
4
+ import type {
5
+ ButtonProps,
6
+ IconProps,
7
+ ImageProps,
8
+ LabelProps,
9
+ NavigationBarProps,
10
+ PageMetaProps,
11
+ RichTextProps,
12
+ SwiperItemProps,
13
+ SwiperProps,
14
+ ViewProps
15
+ } from '@tarojs/components/types'
16
+
17
+ @Observed
18
+ class TaroOtherElement extends TaroElement<ViewProps> {}
19
+
20
+ @Observed
21
+ class TaroViewElement extends TaroElement<ViewProps> {
22
+ constructor() {
23
+ super('View')
24
+ }
25
+ }
26
+
27
+ @Observed
28
+ class TaroImageElement extends TaroElement<ImageProps> {
29
+ constructor() {
30
+ super('Image')
31
+ }
32
+ }
33
+
34
+ @Observed
35
+ class TaroButtonElement extends TaroElement<ButtonProps> {
36
+ constructor() {
37
+ super('Button')
38
+ }
39
+ }
40
+
41
+ @Observed
42
+ class TaroIconElement extends TaroElement<IconProps> {
43
+ constructor() {
44
+ super('Icon')
45
+ }
46
+ }
47
+ @Observed
48
+ class TaroLabelElement extends TaroElement<LabelProps> {
49
+ constructor() {
50
+ super('Label')
51
+ }
52
+ }
53
+
54
+ @Observed
55
+ class TaroRichTextElement extends TaroElement<RichTextProps> {
56
+ constructor() {
57
+ super('RichText')
58
+ }
59
+ }
60
+
61
+ @Observed
62
+ class TaroSwiperElement extends TaroElement<SwiperProps> {
63
+ controller: SwiperController = new SwiperController()
64
+
65
+ constructor() {
66
+ super('Swiper')
67
+ }
68
+ }
69
+
70
+ @Observed
71
+ class TaroSwiperItemElement extends TaroElement<SwiperItemProps> {
72
+ constructor() {
73
+ super('SwiperItem')
74
+ }
75
+ }
76
+
77
+ @Observed
78
+ class TaroPageMetaElement extends TaroElement<PageMetaProps> {
79
+ constructor() {
80
+ super('PageMeta')
81
+ }
82
+ }
83
+
84
+ @Observed
85
+ class TaroNavigationBarElement extends TaroElement<NavigationBarProps> {
86
+ constructor() {
87
+ super('NavigationBar')
88
+ }
89
+ }
90
+
91
+ export {
92
+ TaroButtonElement,
93
+ TaroIconElement,
94
+ TaroImageElement,
95
+ TaroLabelElement,
96
+ TaroNavigationBarElement,
97
+ TaroOtherElement,
98
+ TaroPageMetaElement,
99
+ TaroRichTextElement,
100
+ TaroSwiperElement,
101
+ TaroSwiperItemElement,
102
+ TaroViewElement
103
+ }
@@ -0,0 +1,11 @@
1
+
2
+ import { TaroElement } from './element'
3
+
4
+ import type { ProgressProps } from '@tarojs/components/types'
5
+
6
+ @Observed
7
+ export class TaroProgressElement extends TaroElement<ProgressProps> {
8
+ constructor() {
9
+ super('Progress')
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ import { bindScrollTo } from '../bind'
2
+ import { TaroElement } from './element'
3
+
4
+ import type { ScrollViewProps } from '@tarojs/components/types'
5
+
6
+ @Observed
7
+ export class TaroScrollViewElement extends TaroElement<ScrollViewProps> {
8
+ scroller: Scroller = new Scroller()
9
+
10
+ constructor() {
11
+ super('ScrollView')
12
+
13
+ bindScrollTo(this)
14
+ }
15
+ }
@@ -0,0 +1,10 @@
1
+ import { TaroElement } from './element'
2
+
3
+ import type { TextProps } from '@tarojs/components/types'
4
+
5
+ @Observed
6
+ export class TaroTextElement extends TaroElement<TextProps> {
7
+ constructor() {
8
+ super('Text')
9
+ }
10
+ }
@@ -0,0 +1,50 @@
1
+ import { TaroElement } from './element'
2
+
3
+ import type { VideoProps } from '@tarojs/components/types'
4
+
5
+ @Observed
6
+ export class TaroVideoElement extends TaroElement<VideoProps> {
7
+ controller: VideoController = new VideoController()
8
+
9
+ constructor() {
10
+ super('Video')
11
+
12
+ this._nodeInfo._currentTime = 0
13
+ }
14
+
15
+ async play() {
16
+ try {
17
+ this.controller.start()
18
+ return Promise.resolve()
19
+ } catch (e) {
20
+ return Promise.reject(e)
21
+ }
22
+ }
23
+
24
+ pause() {
25
+ try {
26
+ this.controller.pause()
27
+ return Promise.resolve()
28
+ } catch (e) {
29
+ return Promise.reject(e)
30
+ }
31
+ }
32
+
33
+ stop() {
34
+ try {
35
+ this.controller.stop()
36
+ return Promise.resolve()
37
+ } catch (e) {
38
+ return Promise.reject(e)
39
+ }
40
+ }
41
+
42
+ get currentTime() {
43
+ return this._nodeInfo._currentTime
44
+ }
45
+
46
+ set currentTime(val: number) {
47
+ this._nodeInfo._currentTime = val
48
+ this.controller.setCurrentTime(val)
49
+ }
50
+ }
@@ -0,0 +1,68 @@
1
+ import business_error from '@ohos.base'
2
+ import web_webview from '@ohos.web.webview'
3
+
4
+ import { TaroElement } from './element'
5
+
6
+ import type { WebViewProps } from '@tarojs/components/types'
7
+
8
+ @Observed
9
+ export class TaroInnerHtmlElement extends TaroElement {
10
+ constructor() {
11
+ super('InnerHtml')
12
+ }
13
+ }
14
+
15
+ @Observed
16
+ export class TaroWebViewElement extends TaroElement<WebViewProps> {
17
+ ports: web_webview.WebMessagePort[] = []
18
+
19
+ nativePort: web_webview.WebMessagePort | null = null
20
+
21
+ message: web_webview.WebMessageExt = new web_webview.WebMessageExt()
22
+
23
+ controller: web_webview.WebviewController = new web_webview.WebviewController()
24
+
25
+ constructor() {
26
+ super('WebView')
27
+ }
28
+
29
+ postMessage (value: string) {
30
+ if (!this.nativePort) return
31
+
32
+ this.message.setString(value)
33
+ this.nativePort.postMessageEventExt(this.message)
34
+ }
35
+
36
+ handleMessageFromWeb (result: web_webview.WebMessageExt) {
37
+ try {
38
+ const type = result.getType()
39
+ switch (type) {
40
+ case web_webview.WebMessageType.STRING: {
41
+ return result.getString()
42
+ }
43
+ case web_webview.WebMessageType.NUMBER: {
44
+ return result.getNumber()
45
+ }
46
+ case web_webview.WebMessageType.BOOLEAN: {
47
+ return result.getBoolean()
48
+ }
49
+ case web_webview.WebMessageType.ARRAY_BUFFER: {
50
+ return result.getArrayBuffer()
51
+ }
52
+ case web_webview.WebMessageType.ARRAY: {
53
+ return result.getArray()
54
+ }
55
+ case web_webview.WebMessageType.ERROR: {
56
+ return result.getError()
57
+ }
58
+ default: {
59
+ return null
60
+ }
61
+ }
62
+ } catch (error) {
63
+ const e: business_error.BusinessError = error as business_error.BusinessError
64
+
65
+ console.error(`ErrorCode: ${e.code}, Message: ${e.message}`)
66
+ }
67
+ }
68
+ }
@@ -1,7 +1,7 @@
1
1
  import { hooks } from '@tarojs/shared'
2
2
 
3
3
  import { CONFIRM, CURRENT_TARGET, INPUT, KEY_CODE, TARGET, TIME_STAMP, TYPE } from '../constant'
4
- import { TaroElement } from './element'
4
+ import { TaroElement } from './element/element'
5
5
 
6
6
  import type { EventOptions } from '../interface'
7
7
 
@@ -55,7 +55,6 @@ export class TaroEvent<T = any> {
55
55
  }
56
56
  }
57
57
 
58
-
59
58
  export function createEvent (event: TaroEvent | string, type?: string, node?: TaroElement) {
60
59
  if (typeof event === 'string') {
61
60
  // For Vue3 using document.createEvent
@@ -87,7 +86,6 @@ function stopOrTriggerPropagation (event: TaroEvent, node: TaroElement) {
87
86
 
88
87
  // eslint-disable-next-line no-unmodified-loop-condition
89
88
  while ((target = target.parentNode as TaroElement)) {
90
- event.currentTarget = target
91
89
  const listeners = target.__listeners[event.type]
92
90
 
93
91
  if (!Array.isArray(listeners) || target._attrs?.disabled) {
@@ -111,7 +109,7 @@ const BUBBLE_EVENTS = new Set([
111
109
  'longTap',
112
110
  'change',
113
111
  'submit',
114
- 'submit-btn',
112
+ 'submit-btn',
115
113
  'reset-btn'
116
114
  ])
117
115
 
@@ -144,7 +142,7 @@ export function eventHandler (event, type: string, node: TaroElement) {
144
142
 
145
143
  // hooks.call('dispatchTaroEventFinish', e, node)
146
144
  }
147
-
145
+
148
146
  dispatch()
149
147
  if (isBatchUpdates) {
150
148
  // collectBatchFunction(type, dispatch)
@@ -162,3 +160,26 @@ export function eventHandler (event, type: string, node: TaroElement) {
162
160
  })
163
161
  }
164
162
  }
163
+
164
+ export function createTaroEvent(type: string, opts: Partial<EventOptions> = {}, node?: TaroElement) {
165
+ opts.bubbles ||= true
166
+ opts.cancelable ||= true
167
+ const e = new TaroEvent(type, opts as Required<EventOptions>)
168
+
169
+ if (node) {
170
+ const properties: Record<string, PropertyDescriptor> = {}
171
+ properties.target = properties.currentTarget = {
172
+ get() {
173
+ return node
174
+ }
175
+ }
176
+ Object.defineProperties(e, properties)
177
+ }
178
+ for (const key in opts) {
179
+ if (['bubbles', 'cancelable'].includes(key)) {
180
+ continue
181
+ }
182
+ e[key] = opts[key]
183
+ }
184
+ return e
185
+ }
@@ -37,12 +37,14 @@ class TaroEventTarget extends Events {
37
37
 
38
38
  public removeEventListener (type: string, listener: fn) {
39
39
  const listeners = this.__listeners[type]
40
- if (listeners.length) {
40
+ if (listeners?.length) {
41
41
  this.__listeners[type] = listeners.filter(item => item !== listener)
42
42
  }
43
43
  }
44
44
 
45
45
  public dispatchEvent (event: TaroEvent) {
46
+ // @ts-ignore
47
+ event.currentTarget = this
46
48
  const cancelable = event.cancelable
47
49
  const listeners = this.__listeners[event.type]
48
50
 
@@ -68,12 +70,10 @@ class TaroEventTarget extends Events {
68
70
  }
69
71
  }
70
72
 
71
-
72
73
  if (event._stop) {
73
74
  this._stopPropagation(event)
74
75
  }
75
76
 
76
-
77
77
  return listeners != null
78
78
  }
79
79