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