@tarojs/plugin-platform-harmony-ets 4.0.0-beta.5 → 4.0.0-beta.50

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 (122) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +4 -0
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/network/request.ts +5 -5
  7. package/dist/apis/route/index.ts +15 -0
  8. package/dist/apis/storage/index.ts +148 -80
  9. package/dist/apis/ui/animation/animation.ts +71 -28
  10. package/dist/apis/ui/background.ts +2 -1
  11. package/dist/apis/ui/interaction/index.ts +40 -49
  12. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  13. package/dist/apis/utils/index.ts +1 -1
  14. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  15. package/dist/apis/wxml/index.ts +2 -0
  16. package/dist/apis/wxml/selectorQuery.ts +18 -9
  17. package/dist/components-harmony-ets/button.ets +48 -34
  18. package/dist/components-harmony-ets/canvas.ets +51 -0
  19. package/dist/components-harmony-ets/checkbox.ets +69 -61
  20. package/dist/components-harmony-ets/form.ets +51 -29
  21. package/dist/components-harmony-ets/icon.ets +31 -19
  22. package/dist/components-harmony-ets/image.ets +27 -14
  23. package/dist/components-harmony-ets/index.ets +85 -0
  24. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  25. package/dist/components-harmony-ets/input.ets +41 -40
  26. package/dist/components-harmony-ets/label.ets +69 -42
  27. package/dist/components-harmony-ets/movableArea.ets +126 -0
  28. package/dist/components-harmony-ets/movableView.ets +73 -0
  29. package/dist/components-harmony-ets/navigationBar.ets +25 -0
  30. package/dist/components-harmony-ets/pageMeta.ets +28 -0
  31. package/dist/components-harmony-ets/picker.ets +42 -38
  32. package/dist/components-harmony-ets/progress.ets +52 -0
  33. package/dist/components-harmony-ets/pseudo.ets +80 -0
  34. package/dist/components-harmony-ets/radio.ets +71 -64
  35. package/dist/components-harmony-ets/richText.ets +14 -30
  36. package/dist/components-harmony-ets/scrollView.ets +61 -57
  37. package/dist/components-harmony-ets/slider.ets +15 -14
  38. package/dist/components-harmony-ets/style.ets +390 -130
  39. package/dist/components-harmony-ets/swiper.ets +38 -20
  40. package/dist/components-harmony-ets/switch.ets +30 -28
  41. package/dist/components-harmony-ets/{index.ts → tag.ts} +2 -0
  42. package/dist/components-harmony-ets/text.ets +121 -51
  43. package/dist/components-harmony-ets/textArea.ets +35 -34
  44. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  45. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  46. package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
  47. package/dist/components-harmony-ets/utils/helper.ets +17 -5
  48. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  49. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  50. package/dist/components-harmony-ets/utils/index.ts +50 -51
  51. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  52. package/dist/components-harmony-ets/video.ets +34 -20
  53. package/dist/components-harmony-ets/view.ets +63 -52
  54. package/dist/components-harmony-ets/webView.ets +40 -34
  55. package/dist/index.d.ts +152 -0
  56. package/dist/index.js +82 -39
  57. package/dist/index.js.map +1 -1
  58. package/dist/runtime-ets/bom/document.ts +6 -4
  59. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  60. package/dist/runtime-ets/bom/window.ts +7 -0
  61. package/dist/runtime-ets/current.ts +3 -0
  62. package/dist/runtime-ets/dom/bind.ts +31 -13
  63. package/dist/runtime-ets/dom/cssNesting.ts +393 -0
  64. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +25 -39
  65. package/dist/runtime-ets/dom/document.ts +22 -8
  66. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  67. package/dist/runtime-ets/dom/element/element.ts +317 -51
  68. package/dist/runtime-ets/dom/element/form.ts +23 -26
  69. package/dist/runtime-ets/dom/element/index.ts +24 -2
  70. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  71. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  72. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  73. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  74. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  75. package/dist/runtime-ets/dom/element/text.ts +1 -8
  76. package/dist/runtime-ets/dom/element/video.ts +5 -3
  77. package/dist/runtime-ets/dom/element/webView.ts +11 -3
  78. package/dist/runtime-ets/dom/event.ts +0 -1
  79. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  80. package/dist/runtime-ets/dom/node.ts +46 -28
  81. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +334 -230
  82. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  83. package/dist/runtime-ets/dom/stylesheet/type.ts +40 -9
  84. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  85. package/dist/runtime-ets/index.ts +2 -2
  86. package/dist/runtime-ets/interface/event.ts +1 -1
  87. package/dist/runtime-ets/utils/index.ts +66 -11
  88. package/dist/runtime-ets/utils/info.ts +1 -1
  89. package/dist/runtime-framework/react/app.ts +7 -2
  90. package/dist/runtime-framework/react/index.ts +0 -2
  91. package/dist/runtime-framework/react/native-page.ts +32 -14
  92. package/dist/runtime-framework/react/page.ts +3 -8
  93. package/dist/runtime-framework/solid/app.ts +25 -45
  94. package/dist/runtime-framework/solid/connect.ts +21 -3
  95. package/dist/runtime-framework/solid/hooks.ts +16 -11
  96. package/dist/runtime-framework/solid/index.ts +6 -2
  97. package/dist/runtime-framework/solid/page.ts +84 -30
  98. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  99. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  100. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  101. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  102. package/dist/runtime-utils.d.ts +827 -0
  103. package/dist/runtime-utils.js +399 -188
  104. package/dist/runtime-utils.js.map +1 -1
  105. package/dist/runtime.d.ts +1 -0
  106. package/dist/runtime.js +399 -188
  107. package/dist/runtime.js.map +1 -1
  108. package/index.js +3 -1
  109. package/package.json +13 -13
  110. package/static/media/cancel.svg +1 -1
  111. package/static/media/circle.svg +1 -1
  112. package/static/media/clear.svg +1 -1
  113. package/static/media/download.svg +1 -1
  114. package/static/media/info.svg +1 -1
  115. package/static/media/info_circle.svg +1 -1
  116. package/static/media/search.svg +1 -1
  117. package/static/media/success.svg +1 -1
  118. package/static/media/success_no_circle.svg +1 -1
  119. package/static/media/warn.svg +1 -1
  120. package/types/harmony.d.ts +4 -0
  121. package/types/index.d.ts +4 -0
  122. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,5 +1,6 @@
1
1
  import { Current } from '../../current'
2
2
  import { TaroTextNode } from '../node'
3
+ import { TaroCanvasElement } from './canvas'
3
4
  import { TaroElement } from './element'
4
5
  import {
5
6
  FormElement,
@@ -14,20 +15,26 @@ import {
14
15
  TaroSwitchElement,
15
16
  TaroTextAreaElement
16
17
  } from './form'
18
+ import { TaroMovableAreaElement } from './movableArea'
19
+ import { TaroMovableViewElement } from './movableView'
17
20
  import {
18
21
  TaroButtonElement,
19
22
  TaroIconElement,
20
23
  TaroImageElement,
21
24
  TaroLabelElement,
25
+ TaroNavigationBarElement,
26
+ TaroOtherElement,
27
+ TaroPageMetaElement,
22
28
  TaroRichTextElement,
23
29
  TaroSwiperElement,
24
30
  TaroSwiperItemElement,
25
31
  TaroViewElement
26
32
  } from './normal'
33
+ import { TaroProgressElement } from './progress'
27
34
  import { TaroScrollViewElement } from './scrollView'
28
35
  import { TaroTextElement } from './text'
29
36
  import { TaroVideoElement } from './video'
30
- import { TaroWebViewElement } from './webView'
37
+ import { TaroInnerHtmlElement, TaroWebViewElement } from './webView'
31
38
 
32
39
  export function initHarmonyElement () {
33
40
  Current.createHarmonyElement = (tagName: string) => {
@@ -36,6 +43,9 @@ export function initHarmonyElement () {
36
43
  case 'image': return new TaroImageElement()
37
44
  case 'text': return new TaroTextElement()
38
45
  case 'button': return new TaroButtonElement()
46
+ case 'movable-area': return new TaroMovableAreaElement()
47
+ case 'movable-view': return new TaroMovableViewElement()
48
+ case 'progress': return new TaroProgressElement()
39
49
  case 'scroll-view': return new TaroScrollViewElement()
40
50
  case 'checkbox-group': return new TaroCheckboxGroupElement()
41
51
  case 'input': return new TaroInputElement()
@@ -49,12 +59,16 @@ export function initHarmonyElement () {
49
59
  case 'icon': return new TaroIconElement()
50
60
  case 'label': return new TaroLabelElement()
51
61
  case 'rich-text': return new TaroRichTextElement()
62
+ case 'canvas': return new TaroCanvasElement()
52
63
  case 'swiper': return new TaroSwiperElement()
53
64
  case 'swiper-item': return new TaroSwiperItemElement()
54
65
  case 'textarea': return new TaroTextAreaElement()
55
66
  case 'form': return new TaroFormElement()
56
67
  case 'web-view': return new TaroWebViewElement()
57
- default: return new TaroElement(tagName)
68
+ case 'inner-html': return new TaroInnerHtmlElement()
69
+ case 'page-meta': return new TaroPageMetaElement()
70
+ case 'navigation-bar': return new TaroNavigationBarElement()
71
+ default: return new TaroOtherElement(tagName)
58
72
  }
59
73
  }
60
74
 
@@ -67,15 +81,23 @@ export function initHarmonyElement () {
67
81
  export {
68
82
  FormElement,
69
83
  TaroButtonElement,
84
+ TaroCanvasElement,
70
85
  TaroCheckboxElement,
71
86
  TaroCheckboxGroupElement,
72
87
  TaroElement,
73
88
  TaroFormElement,
74
89
  TaroIconElement,
75
90
  TaroImageElement,
91
+ TaroInnerHtmlElement,
76
92
  TaroInputElement,
77
93
  TaroLabelElement,
94
+ TaroMovableAreaElement,
95
+ TaroMovableViewElement,
96
+ TaroNavigationBarElement,
97
+ TaroOtherElement,
98
+ TaroPageMetaElement,
78
99
  TaroPickerElement,
100
+ TaroProgressElement,
79
101
  TaroRadioElement,
80
102
  TaroRadioGroupElement,
81
103
  TaroRichTextElement,
@@ -0,0 +1,12 @@
1
+
2
+ import { TaroElement } from './element'
3
+
4
+ import type { MovableAreaProps } from '@tarojs/components/types'
5
+
6
+ @Observed
7
+ export class TaroMovableAreaElement extends TaroElement<MovableAreaProps> {
8
+
9
+ constructor() {
10
+ super('MovableArea')
11
+ }
12
+ }
@@ -0,0 +1,193 @@
1
+ import { TaroElement } from './element'
2
+
3
+ import type { MovableViewProps } from '@tarojs/components/types'
4
+
5
+ type Tsize = {
6
+ w: number
7
+ h: number
8
+ }
9
+ type Tpoint = {
10
+ x: number
11
+ y: number
12
+ }
13
+
14
+ function calcPosition(postion: number, start: number, end: number) {
15
+ if (postion <= end && postion >= start) {
16
+ return postion
17
+ } else if (postion < start) {
18
+ return start
19
+ } else {
20
+ return end
21
+ }
22
+ }
23
+
24
+ @Observed
25
+ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { animation: undefined }> {
26
+ _scaleValue = 1
27
+ _scalevalueTemp = 1
28
+
29
+ // 父级区别的大小
30
+ _area?: Tsize
31
+ // 自己元素的大小
32
+ _selfSize?: Tsize
33
+
34
+ // 元素的位置
35
+ _position: Tpoint = {
36
+ x: 0,
37
+ y: 0,
38
+ }
39
+
40
+ _positionTemp: Tpoint = {
41
+ x: 0,
42
+ y: 0,
43
+ }
44
+
45
+ constructor() {
46
+ super('MovableView')
47
+ }
48
+
49
+ get _outOfBounds() {
50
+ if (this.getAttribute('outOfBounds')) {
51
+ return this.selfSize ? this.selfSize.w / 3 : 0
52
+ }
53
+ return 0
54
+ }
55
+
56
+ set area(val: Tsize) {
57
+ this._area = val
58
+ }
59
+
60
+ get area(): Tsize | undefined {
61
+ return this._area
62
+ }
63
+
64
+ startScale() {
65
+ this._scalevalueTemp = this._scaleValue
66
+ }
67
+
68
+ doScale(val: number) {
69
+ const scale = this.getAttribute('scale')
70
+
71
+ // 禁止缩放的时候不生效
72
+ if (scale) {
73
+ this.scaleValue = val * this._scalevalueTemp
74
+ }
75
+ }
76
+
77
+ set scaleValue(val: number) {
78
+ if (this.checkScaleValueInBounds(val)) {
79
+ this._scaleValue = val
80
+
81
+ this.checkPositionBoundary(this.position, val)
82
+
83
+ const bindscale = this.getAttribute('bindscale')
84
+ typeof bindscale === 'function' && bindscale({ ...this.position, scale: this.scaleValue })
85
+ }
86
+ }
87
+
88
+ get scaleValue() {
89
+ return this._scaleValue
90
+ }
91
+
92
+ startMove() {
93
+ this._positionTemp = this._position
94
+ }
95
+
96
+ doMove(val: Tpoint) {
97
+ if (!this.area || !this.selfSize) return
98
+ if (this.getAttribute('disabled')) return
99
+ const direction = this.getAttribute('direction')
100
+
101
+ // 容器的宽高终点
102
+ const areaWidthEnd = this.area.w - this.selfSize.w * this.scaleValue
103
+ const areaHeightEnd = this.area.h - this.selfSize.h * this.scaleValue
104
+
105
+ const incrementWidth = (this.scaleValue - 1) * this.selfSize.w
106
+ const incrementHeight = (this.scaleValue - 1) * this.selfSize.h
107
+
108
+ let x = this._positionTemp.x
109
+ let y = this._positionTemp.y
110
+ if (['all', 'horizontal'].includes(direction)) {
111
+ const nextX = this._positionTemp.x + val.x * this.scaleValue
112
+ x = calcPosition(
113
+ nextX,
114
+ incrementWidth * 0.5 - this._outOfBounds,
115
+ areaWidthEnd + incrementWidth * 0.5 + this._outOfBounds
116
+ )
117
+ }
118
+
119
+ if (['all', 'vertical'].includes(direction)) {
120
+ const nextY = this._positionTemp.y + val.y * this.scaleValue
121
+ y = calcPosition(
122
+ nextY,
123
+ incrementHeight * 0.5 - this._outOfBounds,
124
+ areaHeightEnd + incrementHeight * 0.5 + this._outOfBounds
125
+ )
126
+ }
127
+ const bindchange = this.getAttribute('bindchange')
128
+ if (typeof bindchange === 'function') {
129
+ bindchange({ x, y, source: 'touch' })
130
+ }
131
+ this.position = {
132
+ x: x,
133
+ y: y,
134
+ }
135
+ }
136
+
137
+ get position() {
138
+ return this._position
139
+ }
140
+
141
+ set position(val: Tpoint) {
142
+ this._position = val
143
+ }
144
+
145
+ set selfSize(val: Tsize) {
146
+ this._selfSize = val
147
+ }
148
+
149
+ get selfSize(): Tsize | undefined {
150
+ return this._selfSize
151
+ }
152
+
153
+ checkPositionBoundary(position: Tpoint, scale: number) {
154
+ if (!this.area || !this.selfSize) {
155
+ return { x: 0, y: 0 }
156
+ }
157
+
158
+ const areaWidthEnd = this.area.w - this.selfSize.w * scale
159
+ const areaHeightEnd = this.area.h - this.selfSize.h * scale
160
+
161
+ const incrementWidth = (scale - 1) * this.selfSize.w
162
+ const incrementHeight = (scale - 1) * this.selfSize.h
163
+
164
+ this.position = {
165
+ x: calcPosition(position.x, incrementWidth * 0.5, areaWidthEnd + incrementWidth * 0.5),
166
+ y: calcPosition(position.y, incrementHeight * 0.5, areaHeightEnd + incrementHeight * 0.5),
167
+ }
168
+ }
169
+
170
+ checkScaleValueInBounds(currentScale: number) {
171
+ const scaleMin = this.getAttribute('scaleMin')
172
+ const scaleMax = this.getAttribute('scaleMax')
173
+
174
+ if (scaleMin && Number(scaleMin) >= 0.1 && currentScale < Number(scaleMin)) {
175
+ return false
176
+ } else if (scaleMax && Number(scaleMax) >= 0.1 && currentScale > Number(scaleMax)) {
177
+ return false
178
+ }
179
+
180
+ return true
181
+ }
182
+
183
+ public setAttribute(name: string, value: any): void {
184
+ if (name === 'x') {
185
+ this.checkPositionBoundary({ x: value, y: this.position.y }, this.scaleValue)
186
+ }
187
+ if (name === 'y') {
188
+ this.checkPositionBoundary({ x: this.position.x, y: value }, this.scaleValue)
189
+ }
190
+
191
+ super.setAttribute(name, value)
192
+ }
193
+ }
@@ -6,50 +6,60 @@ import type {
6
6
  IconProps,
7
7
  ImageProps,
8
8
  LabelProps,
9
+ NavigationBarProps,
10
+ PageMetaProps,
9
11
  RichTextProps,
10
12
  SwiperItemProps,
11
13
  SwiperProps,
12
14
  ViewProps
13
15
  } from '@tarojs/components/types'
14
16
 
17
+ @Observed
18
+ class TaroOtherElement extends TaroElement<ViewProps> {}
19
+
20
+ @Observed
15
21
  class TaroViewElement extends TaroElement<ViewProps> {
16
22
  constructor() {
17
23
  super('View')
18
24
  }
19
25
  }
20
26
 
27
+ @Observed
21
28
  class TaroImageElement extends TaroElement<ImageProps> {
22
29
  constructor() {
23
30
  super('Image')
24
31
  }
25
32
  }
26
33
 
34
+ @Observed
27
35
  class TaroButtonElement extends TaroElement<ButtonProps> {
28
36
  constructor() {
29
37
  super('Button')
30
38
  }
31
39
  }
32
40
 
33
-
34
- class TaroIconElement extends TaroElement<IconProps>{
41
+ @Observed
42
+ class TaroIconElement extends TaroElement<IconProps> {
35
43
  constructor() {
36
44
  super('Icon')
37
45
  }
38
46
  }
39
-
40
- class TaroLabelElement extends TaroElement<LabelProps>{
47
+ @Observed
48
+ class TaroLabelElement extends TaroElement<LabelProps> {
41
49
  constructor() {
42
50
  super('Label')
43
51
  }
44
52
  }
45
53
 
46
- class TaroRichTextElement extends TaroElement<RichTextProps>{
54
+ @Observed
55
+ class TaroRichTextElement extends TaroElement<RichTextProps> {
47
56
  constructor() {
48
57
  super('RichText')
49
58
  }
50
59
  }
51
60
 
52
- class TaroSwiperElement extends TaroElement<SwiperProps>{
61
+ @Observed
62
+ class TaroSwiperElement extends TaroElement<SwiperProps> {
53
63
  controller: SwiperController = new SwiperController()
54
64
 
55
65
  constructor() {
@@ -57,20 +67,37 @@ class TaroSwiperElement extends TaroElement<SwiperProps>{
57
67
  }
58
68
  }
59
69
 
60
- class TaroSwiperItemElement extends TaroElement<SwiperItemProps>{
70
+ @Observed
71
+ class TaroSwiperItemElement extends TaroElement<SwiperItemProps> {
61
72
  constructor() {
62
73
  super('SwiperItem')
63
74
  }
64
75
  }
65
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
+ }
66
90
 
67
91
  export {
68
92
  TaroButtonElement,
69
93
  TaroIconElement,
70
94
  TaroImageElement,
71
95
  TaroLabelElement,
96
+ TaroNavigationBarElement,
97
+ TaroOtherElement,
98
+ TaroPageMetaElement,
72
99
  TaroRichTextElement,
73
100
  TaroSwiperElement,
74
101
  TaroSwiperItemElement,
75
- TaroViewElement,
102
+ TaroViewElement
76
103
  }
@@ -0,0 +1,12 @@
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
+
9
+ constructor() {
10
+ super('Progress')
11
+ }
12
+ }
@@ -3,6 +3,7 @@ import { TaroElement } from './element'
3
3
 
4
4
  import type { ScrollViewProps } from '@tarojs/components/types'
5
5
 
6
+ @Observed
6
7
  export class TaroScrollViewElement extends TaroElement<ScrollViewProps> {
7
8
  scroller: Scroller = new Scroller()
8
9
 
@@ -1,17 +1,10 @@
1
- import { TaroNode } from '../node'
2
1
  import { TaroElement } from './element'
3
2
 
4
3
  import type { TextProps } from '@tarojs/components/types'
5
4
 
5
+ @Observed
6
6
  export class TaroTextElement extends TaroElement<TextProps> {
7
7
  constructor() {
8
8
  super('Text')
9
9
  }
10
-
11
- public appendChild (child: TaroNode): TaroNode {
12
- super.appendChild(child)
13
-
14
- this.updateComponent()
15
- return child
16
- }
17
10
  }
@@ -2,13 +2,15 @@ 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
7
 
8
8
  controller: VideoController = new VideoController()
9
9
 
10
10
  constructor() {
11
11
  super('Video')
12
+
13
+ this._nodeInfo._currentTime = 0
12
14
  }
13
15
 
14
16
  async play() {
@@ -39,11 +41,11 @@ export class TaroVideoElement extends TaroElement<VideoProps> {
39
41
  }
40
42
 
41
43
  get currentTime() {
42
- return this._currentTime
44
+ return this._nodeInfo._currentTime
43
45
  }
44
46
 
45
47
  set currentTime(val: number) {
46
- this._currentTime = val
48
+ this._nodeInfo._currentTime = val
47
49
  this.controller.setCurrentTime(val)
48
50
  }
49
51
  }
@@ -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() {
@@ -54,7 +62,7 @@ export class TaroWebViewElement extends TaroElement<WebViewProps>{
54
62
  }
55
63
  catch (error) {
56
64
  const e: business_error.BusinessError = error as business_error.BusinessError
57
-
65
+
58
66
  console.error(`ErrorCode: ${e.code}, Message: ${e.message}`)
59
67
  }
60
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
@@ -68,12 +68,10 @@ class TaroEventTarget extends Events {
68
68
  }
69
69
  }
70
70
 
71
-
72
71
  if (event._stop) {
73
72
  this._stopPropagation(event)
74
73
  }
75
74
 
76
-
77
75
  return listeners != null
78
76
  }
79
77
 
@@ -95,5 +93,4 @@ class TaroEventTarget extends Events {
95
93
  }
96
94
  }
97
95
 
98
-
99
96
  export { TaroEventTarget }
@@ -59,35 +59,38 @@ export class TaroNode extends TaroDataSourceElement {
59
59
  return this.childNodes[index] as TaroElement
60
60
  }
61
61
 
62
- public findIndex (refChild: TaroNode): number {
63
- return this.childNodes.findIndex(node => node._nid === refChild._nid)
62
+ public findIndex (refChild?: TaroNode): number {
63
+ return this.childNodes.findIndex(node => node._nid === refChild?._nid)
64
64
  }
65
65
 
66
- // 更新对应的 ArkUI 组件
67
- public updateComponent () {
68
- if (!this._isCompileMode && (!this.parentNode || !this.parentNode.listeners?.length)) return
66
+ public updateTextNode () {
67
+ // @ts-ignore
68
+ if (this.childNodes.length <= 0 || this.tagName !== 'VIEW') return
69
69
 
70
- const idx = this.parentNode.findIndex(this)
70
+ // TextNode 不具备 props 更新能力,需要由父节点来进行触发
71
+ this.childNodes.forEach(item => {
72
+ if (item.nodeType !== NodeType.TEXT_NODE) return
71
73
 
72
- if (this._isCompileMode) {
73
- // 半编译模式下走 @State 的更新模式
74
- if (this._isDynamicNode) {
75
- this._updateTrigger++
76
- } else {
77
- this.parentNode.updateComponent()
78
- }
74
+ item._updateTrigger++
75
+ })
76
+ }
77
+
78
+ // 更新对应的 ArkUI 组件
79
+ public updateComponent () {
80
+ // 非半编译模式或者半编译模式下拥有自主更新权力的节点走 @State 的更新模式
81
+ if (this._isDynamicNode || !this._isCompileMode) {
82
+ this._updateTrigger++
79
83
  } else {
80
- // 非半编译模式下走 LazyForEach 的更新模式
81
- if (idx >= 0) {
82
- this._updateTrigger++
83
- this.parentNode.notifyDataChange(idx)
84
- } else {
85
- this.parentNode.notifyDataReload()
86
- }
84
+ this.parentNode?.updateComponent()
87
85
  }
88
86
  }
89
87
 
90
- public get firstChild (): TaroNode | null{
88
+ // 提供唯一标识,方便与小程序一致,能根据uid获取到对应的节点
89
+ public get uid (): string {
90
+ return this._nid
91
+ }
92
+
93
+ public get firstChild (): TaroNode | null {
91
94
  return this.childNodes[0] || null
92
95
  }
93
96
 
@@ -128,11 +131,12 @@ export class TaroNode extends TaroDataSourceElement {
128
131
  public set textContent (value: string) {
129
132
  if (this.nodeType === NodeType.TEXT_NODE) {
130
133
  this._textContent = value
131
- this.parentNode?.updateComponent()
132
134
  } else if (this.nodeType === NodeType.ELEMENT_NODE) {
133
135
  const node = new TaroTextNode(value)
134
136
  node._doc = this.ownerDocument
135
- this.childNodes = [node]
137
+ node.parentNode = this
138
+ this.childNodes.length = 0
139
+ this.childNodes.push(node)
136
140
  }
137
141
  }
138
142
 
@@ -150,7 +154,6 @@ export class TaroNode extends TaroDataSourceElement {
150
154
  public set nodeValue (value: string | null) {
151
155
  if (this.nodeType === NodeType.TEXT_NODE && value) {
152
156
  this.textContent = value
153
- this.parentNode?.updateComponent()
154
157
  }
155
158
  }
156
159
 
@@ -163,28 +166,37 @@ export class TaroNode extends TaroDataSourceElement {
163
166
  }
164
167
 
165
168
  // TODO cloneNode()、contains()
166
-
167
- public appendChild (child: TaroNode): TaroNode {
169
+ public connectParentNode (child: TaroNode) {
168
170
  child.parentNode?.removeChild(child)
169
171
  child.parentNode = this
172
+ }
170
173
 
174
+ public appendChild (child: TaroNode): TaroNode {
175
+ this.connectParentNode(child)
171
176
  this.childNodes.push(child)
172
177
  this.notifyDataAdd(this.childNodes.length - 1)
173
178
 
179
+ // @ts-ignore
180
+ child.toggleLayer?.(true)
181
+
174
182
  checkIsCompileModeAndInstallAfterDOMAction(child, this)
175
183
  return child
176
184
  }
177
185
 
178
- public insertBefore (newNode: TaroNode, referenceNode: TaroNode | null): TaroNode {
186
+ public insertBefore (newNode: TaroNode, referenceNode?: TaroNode): TaroNode {
179
187
  newNode.parentNode?.removeChild(newNode)
180
188
 
181
- if (referenceNode === null) {
189
+ if (!referenceNode) {
182
190
  this.appendChild(newNode)
183
191
  } else {
184
192
  const idxOfRef = this.findIndex(referenceNode)
185
193
  this.childNodes.splice(idxOfRef, 0, newNode)
194
+ this.connectParentNode(newNode)
186
195
  // TODO: 优化
187
196
  this.notifyDataReload()
197
+
198
+ // @ts-ignore
199
+ newNode.toggleLayer?.(true)
188
200
  }
189
201
 
190
202
  checkIsCompileModeAndInstallAfterDOMAction(newNode, this)
@@ -224,11 +236,17 @@ export class TaroNode extends TaroDataSourceElement {
224
236
  }
225
237
 
226
238
  public dispose () {
239
+ // 渲染,层级大于0的节点需要让其回到正常层级,然后删掉
240
+ // @ts-ignore
241
+ this.toggleLayer?.(false)
242
+
227
243
  this.parentNode = null
228
244
  this.childNodes = []
229
245
  }
246
+
230
247
  }
231
248
 
249
+ @Observed
232
250
  export class TaroTextNode extends TaroNode {
233
251
  constructor(value = '', nodeName = '#text', nodeType: NodeType = NodeType.TEXT_NODE) {
234
252
  super(nodeName, nodeType)