@tarojs/plugin-platform-harmony-ets 4.0.0-beta.61 → 4.0.0-beta.63

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.
@@ -95,7 +95,7 @@ function depthTraversal(root: ReactElement) {
95
95
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
96
96
  processLeaf(tree.props.children[i], descendant_map)
97
97
  }
98
- } else if (typeof tree.props.children !== 'string'){
98
+ } else if (typeof tree.props.children !== 'string') {
99
99
  // 收集叶子节点所拥有的类名
100
100
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
101
101
  processLeaf(tree.props.children, descendant_map)
@@ -161,7 +161,6 @@ function depthTraversal(root: ReactElement) {
161
161
 
162
162
  // 将嵌套样式与节点合并
163
163
  function combineStyle(nestingStyle: NestingStyle, class_mapping: TMapping, alias: Record<string, string[]>) {
164
-
165
164
  const findElement = (selector_string, combinator_type, selector_mapping, remainder_selector, declaration) => {
166
165
  // 防止修改原数组
167
166
  if (selector_string instanceof Array) {
@@ -208,8 +207,8 @@ function combineStyle(nestingStyle: NestingStyle, class_mapping: TMapping, alias
208
207
  selectors: [selector_string, combinator_type, ...remainder_selector.slice()],
209
208
  declaration: declaration
210
209
  }
211
- obj.node.props.__nesting = obj.node.props.__nesting ?
212
- [...obj.node.props.__nesting, nestingData] : [nestingData]
210
+ obj.node.props.__nesting = obj.node.props.__nesting
211
+ ? [...obj.node.props.__nesting, nestingData] : [nestingData]
213
212
  }
214
213
  selector_nodes.push({
215
214
  // @ts-ignore
@@ -228,8 +227,8 @@ function combineStyle(nestingStyle: NestingStyle, class_mapping: TMapping, alias
228
227
  selectors: [selector_string, combinator_type, ...remainder_selector.slice()],
229
228
  declaration: declaration
230
229
  }
231
- object.node.props.__nesting = object.node.props.__nesting ?
232
- [...object.node.props.__nesting, nestingData] : [nestingData]
230
+ object.node.props.__nesting = object.node.props.__nesting
231
+ ? [...object.node.props.__nesting, nestingData] : [nestingData]
233
232
  }
234
233
  selector_nodes.push({
235
234
  mapping: (object.ref || object)[combinator_type === ' > ' ? 'children' : 'descendants'],
@@ -342,7 +341,7 @@ function findSendNode (selectorArr: string[], selector_mapping: TMapping) {
342
341
  function insertParentStyle(data: {key: string, value: CSSProperties}, class_mapping: TMapping, alias: Record<string, string[]>) {
343
342
  const { key, value } = data
344
343
  key.split(' ').forEach(key => {
345
- let classnames = [key]
344
+ let classnames = [key]
346
345
  if (alias[key]) {
347
346
  classnames = classnames.concat(alias[key])
348
347
  }
@@ -362,7 +361,6 @@ function insertParentStyle(data: {key: string, value: CSSProperties}, class_mapp
362
361
  }
363
362
  })
364
363
  })
365
-
366
364
  }
367
365
 
368
366
  // 合并嵌套样式
@@ -374,7 +372,7 @@ export function __combine_nesting_style__(react_tree: ReactElement, styles: Nest
374
372
  const parentProps: {
375
373
  __styleSheet?: {key: string, value: CSSProperties}
376
374
  __nesting?: NestingStyle
377
- } = // @ts-ignore
375
+ } = // @ts-ignore
378
376
  react_tree._owner?.pendingProps // Hack:取出父组件的props,考虑版本问题,取的内部属性,可能会有问题
379
377
 
380
378
  if (newStyle || (parentProps && (parentProps.__styleSheet || parentProps.__nesting))) {
@@ -42,7 +42,7 @@ class CSSStyleDeclaration {
42
42
  const [propName, ...valList] = rule.split(':')
43
43
  const val = valList.join(':')
44
44
 
45
- if (typeof val === undefined) {
45
+ if (typeof val === 'undefined') {
46
46
  continue
47
47
  }
48
48
  this.setProperty(propName.trim(), val.trim())
@@ -70,9 +70,9 @@ class TaroDocument extends TaroNode {
70
70
  const taro = (Current as any).taro
71
71
  const page = taro.getCurrentInstance().page
72
72
  const element = getPageScrollerOrNode(page.node, page)
73
-
73
+
74
74
  if (element == null) return null
75
-
75
+
76
76
  return findChildNodeWithDFS(element, selectors)
77
77
  }
78
78
 
@@ -80,9 +80,9 @@ class TaroDocument extends TaroNode {
80
80
  const taro = (Current as any).taro
81
81
  const page = taro.getCurrentInstance().page
82
82
  const element = getPageScrollerOrNode(page.node, page)
83
-
83
+
84
84
  if (element == null) return []
85
-
85
+
86
86
  return findChildNodeWithDFS(element, selectors, true) || []
87
87
  }
88
88
  // @Todo
@@ -342,7 +342,7 @@ export class TaroElement<
342
342
  this.setLayer(0)
343
343
  } else {
344
344
  Object.keys(currentLayerParents).forEach(fixedId => {
345
- const parentIds =currentLayerParents[fixedId]
345
+ const parentIds = currentLayerParents[fixedId]
346
346
  if (parentIds[this._nid]) {
347
347
  // 需要移除fixedId
348
348
  delete currentLayerParents[fixedId]
@@ -5,7 +5,6 @@ import type { MovableAreaProps } from '@tarojs/components/types'
5
5
 
6
6
  @Observed
7
7
  export class TaroMovableAreaElement extends TaroElement<MovableAreaProps> {
8
-
9
8
  constructor() {
10
9
  super('MovableArea')
11
10
  }
@@ -5,7 +5,6 @@ import type { ProgressProps } from '@tarojs/components/types'
5
5
 
6
6
  @Observed
7
7
  export class TaroProgressElement extends TaroElement<ProgressProps> {
8
-
9
8
  constructor() {
10
9
  super('Progress')
11
10
  }
@@ -4,7 +4,6 @@ import type { VideoProps } from '@tarojs/components/types'
4
4
 
5
5
  @Observed
6
6
  export class TaroVideoElement extends TaroElement<VideoProps> {
7
-
8
7
  controller: VideoController = new VideoController()
9
8
 
10
9
  constructor() {
@@ -59,8 +59,7 @@ export class TaroWebViewElement extends TaroElement<WebViewProps> {
59
59
  return null
60
60
  }
61
61
  }
62
- }
63
- catch (error) {
62
+ } catch (error) {
64
63
  const e: business_error.BusinessError = error as business_error.BusinessError
65
64
 
66
65
  console.error(`ErrorCode: ${e.code}, Message: ${e.message}`)
@@ -110,7 +110,7 @@ const BUBBLE_EVENTS = new Set([
110
110
  'longTap',
111
111
  'change',
112
112
  'submit',
113
- 'submit-btn',
113
+ 'submit-btn',
114
114
  'reset-btn'
115
115
  ])
116
116
 
@@ -143,7 +143,7 @@ export function eventHandler (event, type: string, node: TaroElement) {
143
143
 
144
144
  // hooks.call('dispatchTaroEventFinish', e, node)
145
145
  }
146
-
146
+
147
147
  dispatch()
148
148
  if (isBatchUpdates) {
149
149
  // collectBatchFunction(type, dispatch)
@@ -243,7 +243,6 @@ export class TaroNode extends TaroDataSourceElement {
243
243
  this.parentNode = null
244
244
  this.childNodes = []
245
245
  }
246
-
247
246
  }
248
247
 
249
248
  @Observed
@@ -7,7 +7,6 @@ import type { HarmonyStyle, HarmonyType, TaroStyleType, TaroTextStyleType } from
7
7
  export { HarmonyStyle, HarmonyType, TaroStyleType, TaroTextStyleType }
8
8
 
9
9
  export default class StyleSheet {
10
-
11
10
  public hmStyle: HarmonyStyle = {}
12
11
 
13
12
  get display () {
@@ -157,7 +156,7 @@ export default class StyleSheet {
157
156
  case ImageRepeat.Y: return 'repeat-y'; break
158
157
  case ImageRepeat.XY: return 'repeat'; break
159
158
  case ImageRepeat.NoRepeat: return 'no-repeat'; break
160
- }
159
+ }
161
160
  }
162
161
  }
163
162
 
@@ -196,7 +195,7 @@ export default class StyleSheet {
196
195
  return this.hmStyle.borderWidth
197
196
  }
198
197
 
199
- get borderLeftWidth () {
198
+ get borderLeftWidth () {
200
199
  return this.hmStyle.borderLeftWidth
201
200
  }
202
201
 
@@ -378,5 +377,4 @@ export default class StyleSheet {
378
377
  get content () {
379
378
  return this.hmStyle._content
380
379
  }
381
-
382
380
  }
@@ -40,7 +40,7 @@ export function convertNumber2PX (value: number) {
40
40
 
41
41
  export function convertNumber2VP (value: number, unit = 'px'): string | number {
42
42
  if (unit === 'vw' || unit === 'vh') {
43
- return (value / 100 * (unit === 'vw' ? display.width: display.height)) + 'px'
43
+ return (value / 100 * (unit === 'vw' ? display.width : display.height)) + 'px'
44
44
  }
45
45
  if (unit === 'PX') {
46
46
  // 特殊单位:相当于PX、pX、Px
@@ -80,7 +80,7 @@ export function calcStaticStyle (styleSheet: Record<string, CSSProperties>, clas
80
80
  const result = Object.assign.apply(null, [{}].concat(obj))
81
81
 
82
82
  cache[classNames] = result
83
-
83
+
84
84
  return result
85
85
  }
86
86
  }
@@ -97,7 +97,7 @@ export function calcDynamicStyle (style: CSSProperties): CSSProperties {
97
97
  // css env()环境样式获取
98
98
  export function __env__(safeAreaType: string, fallback?: string | number) {
99
99
  const sysInfo = getSystemInfoSync()
100
-
100
+
101
101
  switch (safeAreaType) {
102
102
  case 'safe-area-inset-top': {
103
103
  return sysInfo.safeArea?.top ? `${sysInfo.safeArea?.top}px` : fallback
@@ -91,7 +91,7 @@ export function triggerAttributesCallback (node, attributeName) {
91
91
 
92
92
  const value = node._attrs[attributeName]
93
93
  const cb = node._nodeInfo.attributeCallback[attributeName]
94
-
94
+
95
95
  isFunction(cb) && cb(value)
96
96
  }
97
97
 
@@ -24,7 +24,6 @@ const createTaroHook = (lifecycle: keyof PageLifeCycle | keyof AppInstance) => {
24
24
  if (fnRef.current !== fn) fnRef.current = fn
25
25
 
26
26
  React.useLayoutEffect(() => {
27
-
28
27
  let inst = instRef.current = getPageInstance(id)
29
28
  let first = false
30
29
  if (!inst) {
@@ -18,19 +18,19 @@ function isEqual (obj1, obj2) {
18
18
 
19
19
  export function updateProps (dom: TaroElement, oldProps: Props, newProps: Props) {
20
20
  const updatePayload = getUpdatePayload(dom, oldProps, newProps)
21
- if (updatePayload){
21
+ if (updatePayload) {
22
22
  updatePropsByPayload(dom, oldProps, updatePayload)
23
23
  }
24
24
  }
25
25
 
26
- export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updatePayload: any[]){
27
- for (let i = 0; i < updatePayload.length; i += 2){ // key, value 成对出现
28
- const key = updatePayload[i]; const newProp = updatePayload[i+1]; const oldProp = oldProps[key]
26
+ export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updatePayload: any[]) {
27
+ for (let i = 0; i < updatePayload.length; i += 2) { // key, value 成对出现
28
+ const key = updatePayload[i]; const newProp = updatePayload[i + 1]; const oldProp = oldProps[key]
29
29
  setProperty(dom, key, newProp, oldProp)
30
30
  }
31
31
  }
32
32
 
33
- export function getUpdatePayload (dom: TaroElement, oldProps: Props, newProps: Props){
33
+ export function getUpdatePayload (dom: TaroElement, oldProps: Props, newProps: Props) {
34
34
  let i: string
35
35
  let updatePayload: any[] | null = null
36
36
 
@@ -185,7 +185,7 @@ export function setProperty (dom: TaroElement, name: string, value: unknown, old
185
185
  }
186
186
 
187
187
  // 设置鸿蒙伪类属性(特殊设置)
188
- function setPseudo(dom: TaroElement, name: '::after' | '::before', value: StyleValue | null){
188
+ function setPseudo(dom: TaroElement, name: '::after' | '::before', value: StyleValue | null) {
189
189
  if (name === '::after') {
190
190
  // @ts-ignore
191
191
  dom.set_pseudo_after(value)