@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.11

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 (139) hide show
  1. package/dist/apis/base/system.ts +73 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +16 -8
  4. package/dist/apis/device/memory.ts +10 -3
  5. package/dist/apis/framework/index.ts +1 -5
  6. package/dist/apis/index.ts +27 -17
  7. package/dist/apis/media/image/index.ts +1 -1
  8. package/dist/apis/media/video/VideoContext.ts +56 -7
  9. package/dist/apis/media/video/index.ts +3 -2
  10. package/dist/apis/network/request.ts +5 -5
  11. package/dist/apis/route/index.ts +15 -0
  12. package/dist/apis/storage/index.ts +146 -78
  13. package/dist/apis/ui/animation/animation.ts +71 -29
  14. package/dist/apis/ui/background.ts +2 -1
  15. package/dist/apis/ui/interaction/index.ts +42 -59
  16. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  17. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  18. package/dist/apis/ui/scroll/index.ts +5 -5
  19. package/dist/apis/ui/tab-bar.ts +3 -3
  20. package/dist/apis/utils/index.ts +1 -1
  21. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  22. package/dist/apis/wxml/index.ts +2 -0
  23. package/dist/apis/wxml/selectorQuery.ts +26 -13
  24. package/dist/components-harmony-ets/button.ets +68 -68
  25. package/dist/components-harmony-ets/canvas.ets +51 -0
  26. package/dist/components-harmony-ets/checkbox.ets +81 -102
  27. package/dist/components-harmony-ets/form.ets +54 -45
  28. package/dist/components-harmony-ets/icon.ets +34 -50
  29. package/dist/components-harmony-ets/image.ets +35 -45
  30. package/dist/components-harmony-ets/index.ets +92 -0
  31. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  32. package/dist/components-harmony-ets/input.ets +51 -67
  33. package/dist/components-harmony-ets/label.ets +73 -53
  34. package/dist/components-harmony-ets/listView.ets +26 -0
  35. package/dist/components-harmony-ets/movableArea.ets +124 -0
  36. package/dist/components-harmony-ets/movableView.ets +93 -0
  37. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  38. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  39. package/dist/components-harmony-ets/picker.ets +74 -77
  40. package/dist/components-harmony-ets/progress.ets +52 -0
  41. package/dist/components-harmony-ets/pseudo.ets +80 -0
  42. package/dist/components-harmony-ets/radio.ets +82 -104
  43. package/dist/components-harmony-ets/richText.ets +20 -68
  44. package/dist/components-harmony-ets/scrollList.ets +94 -0
  45. package/dist/components-harmony-ets/scrollView.ets +67 -103
  46. package/dist/components-harmony-ets/slider.ets +23 -47
  47. package/dist/components-harmony-ets/stickySection.ets +42 -0
  48. package/dist/components-harmony-ets/style.ets +396 -0
  49. package/dist/components-harmony-ets/swiper.ets +64 -53
  50. package/dist/components-harmony-ets/switch.ets +44 -55
  51. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  52. package/dist/components-harmony-ets/text.ets +134 -75
  53. package/dist/components-harmony-ets/textArea.ets +54 -62
  54. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  55. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  56. package/dist/components-harmony-ets/utils/flexManager.ets +76 -8
  57. package/dist/components-harmony-ets/utils/helper.ets +20 -7
  58. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  59. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  60. package/dist/components-harmony-ets/utils/index.ts +54 -50
  61. package/dist/components-harmony-ets/utils/styles.ets +178 -63
  62. package/dist/components-harmony-ets/video.ets +37 -54
  63. package/dist/components-harmony-ets/view.ets +63 -94
  64. package/dist/components-harmony-ets/webView.ets +56 -0
  65. package/dist/index.d.ts +152 -0
  66. package/dist/index.js +199 -58
  67. package/dist/index.js.map +1 -1
  68. package/dist/runtime-ets/bom/document.ts +6 -4
  69. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  70. package/dist/runtime-ets/bom/window.ts +9 -2
  71. package/dist/runtime-ets/current.ts +3 -0
  72. package/dist/runtime-ets/dom/bind.ts +28 -12
  73. package/dist/runtime-ets/dom/class-list.ts +2 -2
  74. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  75. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +29 -19
  76. package/dist/runtime-ets/dom/document.ts +22 -8
  77. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  78. package/dist/runtime-ets/dom/element/element.ts +334 -57
  79. package/dist/runtime-ets/dom/element/form.ts +32 -26
  80. package/dist/runtime-ets/dom/element/index.ts +33 -2
  81. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  82. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  83. package/dist/runtime-ets/dom/element/normal.ts +36 -8
  84. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  85. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  86. package/dist/runtime-ets/dom/element/text.ts +1 -8
  87. package/dist/runtime-ets/dom/element/video.ts +5 -4
  88. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  89. package/dist/runtime-ets/dom/event.ts +2 -4
  90. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  91. package/dist/runtime-ets/dom/node.ts +62 -27
  92. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  93. package/dist/runtime-ets/dom/stylesheet/index.ts +98 -518
  94. package/dist/runtime-ets/dom/stylesheet/type.ts +92 -17
  95. package/dist/runtime-ets/dom/stylesheet/util.ts +74 -16
  96. package/dist/runtime-ets/index.ts +2 -2
  97. package/dist/runtime-ets/interface/event.ts +3 -2
  98. package/dist/runtime-ets/utils/index.ts +77 -12
  99. package/dist/runtime-ets/utils/info.ts +4 -2
  100. package/dist/runtime-framework/react/app.ts +17 -22
  101. package/dist/runtime-framework/react/hooks.ts +3 -4
  102. package/dist/runtime-framework/react/index.ts +1 -2
  103. package/dist/runtime-framework/react/native-page.ts +421 -0
  104. package/dist/runtime-framework/react/page.ts +4 -9
  105. package/dist/runtime-framework/solid/app.ts +25 -45
  106. package/dist/runtime-framework/solid/connect.ts +21 -3
  107. package/dist/runtime-framework/solid/hooks.ts +17 -12
  108. package/dist/runtime-framework/solid/index.ts +6 -2
  109. package/dist/runtime-framework/solid/page.ts +84 -30
  110. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  111. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  112. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  113. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  114. package/dist/runtime-utils.d.ts +827 -0
  115. package/dist/runtime-utils.js +510 -237
  116. package/dist/runtime-utils.js.map +1 -1
  117. package/dist/runtime.d.ts +1 -0
  118. package/dist/runtime.js +510 -237
  119. package/dist/runtime.js.map +1 -1
  120. package/index.js +3 -1
  121. package/package.json +14 -15
  122. package/static/media/cancel.svg +1 -0
  123. package/static/media/circle.svg +1 -0
  124. package/static/media/clear.svg +1 -0
  125. package/static/media/download.svg +1 -0
  126. package/static/media/info.svg +1 -0
  127. package/static/media/info_circle.svg +1 -0
  128. package/static/media/search.svg +1 -0
  129. package/static/media/success.svg +1 -0
  130. package/static/media/success_no_circle.svg +1 -0
  131. package/static/media/taro_arrow_left.svg +1 -0
  132. package/static/media/taro_home.svg +1 -0
  133. package/static/media/waiting.svg +1 -0
  134. package/static/media/warn.svg +1 -0
  135. package/types/harmony.d.ts +4 -0
  136. package/types/index.d.ts +4 -0
  137. package/types/runtime.d.ts +3 -1
  138. package/dist/runtime-ets/utils/bind.ts +0 -24
  139. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -2,13 +2,14 @@ import { TaroElement } from './element'
2
2
 
3
3
  import type { VideoProps } from '@tarojs/components/types'
4
4
 
5
+ @Observed
5
6
  export class TaroVideoElement extends TaroElement<VideoProps> {
6
- _currentTime = 0
7
-
8
7
  controller: VideoController = new VideoController()
9
8
 
10
9
  constructor() {
11
10
  super('Video')
11
+
12
+ this._nodeInfo._currentTime = 0
12
13
  }
13
14
 
14
15
  async play() {
@@ -39,11 +40,11 @@ export class TaroVideoElement extends TaroElement<VideoProps> {
39
40
  }
40
41
 
41
42
  get currentTime() {
42
- return this._currentTime
43
+ return this._nodeInfo._currentTime
43
44
  }
44
45
 
45
46
  set currentTime(val: number) {
46
- this._currentTime = val
47
+ this._nodeInfo._currentTime = val
47
48
  this.controller.setCurrentTime(val)
48
49
  }
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
+ }
@@ -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)
@@ -43,6 +43,8 @@ class TaroEventTarget extends Events {
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
 
@@ -95,5 +95,4 @@ class TaroEventTarget extends Events {
95
95
  }
96
96
  }
97
97
 
98
-
99
98
  export { TaroEventTarget }
@@ -31,16 +31,19 @@ export class TaroNode extends TaroDataSourceElement {
31
31
  public childNodes: TaroNode[] = []
32
32
  public parentNode: TaroNode | null = null
33
33
  public _nid: string = genId()
34
-
35
34
  public _doc: TaroDocument | null = null
35
+ public _instance?: TaroAny
36
+
37
+ private _textContent = ''
38
+
39
+ // 以下属性为半编译模式下才会赋值和使用的属性
40
+ // 半编译节点更新触发器
41
+ public _updateTrigger = 0
36
42
  // 是否为半编译模板下的节点
37
43
  public _isCompileMode = false
38
44
  // 是否为半编译模板下拥有自主更新权的节点
39
45
  public _isDynamicNode = false
40
46
 
41
- public _updateTrigger = 0
42
- private _textContent = ''
43
-
44
47
  constructor(nodeName: string, nodeType = NodeType.ELEMENT_NODE) {
45
48
  super()
46
49
 
@@ -57,25 +60,38 @@ export class TaroNode extends TaroDataSourceElement {
57
60
  return this.childNodes[index] as TaroElement
58
61
  }
59
62
 
60
- public findIndex (refChild: TaroNode): number {
61
- return this.childNodes.findIndex(node => node._nid === refChild._nid)
63
+ public findIndex (refChild?: TaroNode): number {
64
+ return this.childNodes.findIndex(node => node._nid === refChild?._nid)
65
+ }
66
+
67
+ public updateTextNode () {
68
+ // @ts-ignore
69
+ if (this.childNodes.length <= 0 || this.tagName !== 'VIEW') return
70
+
71
+ // TextNode 不具备 props 更新能力,需要由父节点来进行触发
72
+ this.childNodes.forEach(item => {
73
+ if (item.nodeType !== NodeType.TEXT_NODE) return
74
+
75
+ item._updateTrigger++
76
+ })
62
77
  }
63
78
 
64
79
  // 更新对应的 ArkUI 组件
65
80
  public updateComponent () {
66
- if (!this.parentNode || !this.parentNode.listeners?.length) return
67
-
68
- const idx = this.parentNode.findIndex(this)
69
-
70
- if (idx >= 0) {
81
+ // 非半编译模式或者半编译模式下拥有自主更新权力的节点走 @State 的更新模式
82
+ if (this._isDynamicNode || (!this._isCompileMode && this._instance)) {
71
83
  this._updateTrigger++
72
- this.parentNode.notifyDataChange(idx)
73
84
  } else {
74
- this.parentNode.notifyDataReload()
85
+ this.parentNode?.updateComponent()
75
86
  }
76
87
  }
77
88
 
78
- public get firstChild (): TaroNode | null{
89
+ // 提供唯一标识,方便与小程序一致,能根据uid获取到对应的节点
90
+ public get uid (): string {
91
+ return this._nid
92
+ }
93
+
94
+ public get firstChild (): TaroNode | null {
79
95
  return this.childNodes[0] || null
80
96
  }
81
97
 
@@ -116,11 +132,15 @@ export class TaroNode extends TaroDataSourceElement {
116
132
  public set textContent (value: string) {
117
133
  if (this.nodeType === NodeType.TEXT_NODE) {
118
134
  this._textContent = value
119
- this.parentNode?.updateComponent()
135
+ if (!this._instance) {
136
+ this.updateComponent()
137
+ }
120
138
  } else if (this.nodeType === NodeType.ELEMENT_NODE) {
121
139
  const node = new TaroTextNode(value)
122
140
  node._doc = this.ownerDocument
123
- this.childNodes = [node]
141
+ node.parentNode = this
142
+ this.childNodes.length = 0
143
+ this.childNodes.push(node)
124
144
  }
125
145
  }
126
146
 
@@ -138,7 +158,6 @@ export class TaroNode extends TaroDataSourceElement {
138
158
  public set nodeValue (value: string | null) {
139
159
  if (this.nodeType === NodeType.TEXT_NODE && value) {
140
160
  this.textContent = value
141
- this.parentNode?.updateComponent()
142
161
  }
143
162
  }
144
163
 
@@ -151,28 +170,37 @@ export class TaroNode extends TaroDataSourceElement {
151
170
  }
152
171
 
153
172
  // TODO cloneNode()、contains()
154
-
155
- public appendChild (child: TaroNode): TaroNode {
173
+ public connectParentNode (child: TaroNode) {
156
174
  child.parentNode?.removeChild(child)
157
175
  child.parentNode = this
176
+ }
158
177
 
178
+ public appendChild (child: TaroNode): TaroNode {
179
+ this.connectParentNode(child)
159
180
  this.childNodes.push(child)
160
181
  this.notifyDataAdd(this.childNodes.length - 1)
161
182
 
183
+ // @ts-ignore
184
+ child.toggleLayer?.(true)
185
+
162
186
  checkIsCompileModeAndInstallAfterDOMAction(child, this)
163
187
  return child
164
188
  }
165
189
 
166
- public insertBefore (newNode: TaroNode, referenceNode: TaroNode | null): TaroNode {
190
+ public insertBefore (newNode: TaroNode, referenceNode?: TaroNode): TaroNode {
167
191
  newNode.parentNode?.removeChild(newNode)
168
192
 
169
- if (referenceNode === null) {
193
+ if (!referenceNode) {
170
194
  this.appendChild(newNode)
171
195
  } else {
172
196
  const idxOfRef = this.findIndex(referenceNode)
173
197
  this.childNodes.splice(idxOfRef, 0, newNode)
198
+ this.connectParentNode(newNode)
174
199
  // TODO: 优化
175
200
  this.notifyDataReload()
201
+
202
+ // @ts-ignore
203
+ newNode.toggleLayer?.(true)
176
204
  }
177
205
 
178
206
  checkIsCompileModeAndInstallAfterDOMAction(newNode, this)
@@ -191,6 +219,7 @@ export class TaroNode extends TaroDataSourceElement {
191
219
  oldChild.dispose()
192
220
  this.notifyDataChange(idxOfRef)
193
221
 
222
+ checkIsCompileModeAndUninstallAfterDOMAction(oldChild)
194
223
  checkIsCompileModeAndInstallAfterDOMAction(newChild, this)
195
224
 
196
225
  return oldChild
@@ -212,11 +241,16 @@ export class TaroNode extends TaroDataSourceElement {
212
241
  }
213
242
 
214
243
  public dispose () {
244
+ // 渲染,层级大于0的节点需要让其回到正常层级,然后删掉
245
+ // @ts-ignore
246
+ this.toggleLayer?.(false)
247
+
215
248
  this.parentNode = null
216
249
  this.childNodes = []
217
250
  }
218
251
  }
219
252
 
253
+ @Observed
220
254
  export class TaroTextNode extends TaroNode {
221
255
  constructor(value = '', nodeName = '#text', nodeType: NodeType = NodeType.TEXT_NODE) {
222
256
  super(nodeName, nodeType)
@@ -232,14 +266,15 @@ export class TaroTextNode extends TaroNode {
232
266
  }
233
267
  }
234
268
 
235
- function checkIsCompileModeAndInstallAfterDOMAction (_node: TaroNode, _parentNode: TaroNode) {
236
- // if (!parentNode._isCompileMode) return
269
+ function checkIsCompileModeAndInstallAfterDOMAction (node: TaroNode, parentNode: TaroNode) {
270
+ if (!parentNode._isCompileMode || !parentNode._instance) return
237
271
 
238
- // parentNode._instance?.dynamicCenter?.install?.(node, parentNode)
272
+ parentNode._instance.dynamicCenter?.install?.(node, parentNode)
273
+ node.updateComponent()
239
274
  }
240
275
 
241
- function checkIsCompileModeAndUninstallAfterDOMAction (_node: TaroNode) {
242
- // if (!node._isCompileMode) return
276
+ function checkIsCompileModeAndUninstallAfterDOMAction (node: TaroNode) {
277
+ if (!node._isCompileMode || !node?._instance) return
243
278
 
244
- // node._instance?.dynamicCenter?.uninstall?.(node)
279
+ node._instance.dynamicCenter?.uninstall?.(node)
245
280
  }