@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.2 → 4.0.0-alpha.21

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