@tarojs/plugin-platform-harmony-ets 4.0.0-beta.57 → 4.0.0-beta.58

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.
@@ -163,6 +163,10 @@ function depthTraversal(root: ReactElement) {
163
163
  function combineStyle(nestingStyle: NestingStyle, class_mapping: TMapping, alias: Record<string, string[]>) {
164
164
 
165
165
  const findElement = (selector_string, combinator_type, selector_mapping, remainder_selector, declaration) => {
166
+ // 防止修改原数组
167
+ if (selector_string instanceof Array) {
168
+ selector_string = selector_string.slice()
169
+ }
166
170
  let selector_list = [selector_string]
167
171
  const selector_nodes: TSelectorNode[] = []
168
172
  let shouldUseCombinations = false
@@ -182,31 +186,36 @@ function combineStyle(nestingStyle: NestingStyle, class_mapping: TMapping, alias
182
186
  for (let i = 0; i < selector_list.length; i++) {
183
187
  const selector = selector_list[i]
184
188
  if (selector instanceof Array) {
185
- let obj
189
+ let hitElements: any
186
190
  // 如果是数组,说明他是一个多类选择器:.a.b,我们需要搜索这两个类名都指向同一个node
187
191
  if (shouldUseCombinations) {
188
- obj = generateCombinations(selector, (combination) => {
192
+ hitElements = generateCombinations(selector, (combination) => {
189
193
  // combination 是组合后的选择器['parent', 'child']
190
194
  const _obj = findSendNode(combination, selector_mapping)
191
195
  if (_obj) return _obj
192
196
  })
193
197
  } else {
194
- obj = findSendNode(selector, selector_mapping)
198
+ hitElements = findSendNode(selector, selector_mapping)
195
199
  }
196
200
  // 找出最后搜寻出来的node
197
- if (obj) {
198
- if (typeof obj.node.type === 'function') {
199
- // 自定义组件,往下传递需要搜寻的内容向里面搜寻
200
- const nestingData = {
201
- selectors: [selector_string, combinator_type, ...remainder_selector.slice()],
202
- declaration: declaration
201
+ if (hitElements) {
202
+ let objs = [hitElements]
203
+ objs = flattenArray(objs)
204
+ objs.forEach(obj => {
205
+ if (typeof obj.node.type === 'function') {
206
+ // 自定义组件,往下传递需要搜寻的内容向里面搜寻
207
+ const nestingData = {
208
+ selectors: [selector_string, combinator_type, ...remainder_selector.slice()],
209
+ declaration: declaration
210
+ }
211
+ obj.node.props.__nesting = obj.node.props.__nesting ?
212
+ [...obj.node.props.__nesting, nestingData] : [nestingData]
203
213
  }
204
- obj.node.props.__nesting = obj.node.props.__nesting ?
205
- [...obj.node.props.__nesting, nestingData] : [nestingData]
206
- }
207
- selector_nodes.push({
208
- mapping: (obj.ref || obj)[combinator_type === ' > ' ? 'children' : 'descendants'],
209
- node: obj.node
214
+ selector_nodes.push({
215
+ // @ts-ignore
216
+ mapping: (obj.ref || obj)[combinator_type === ' > ' ? 'children' : 'descendants'],
217
+ node: obj.node
218
+ })
210
219
  })
211
220
  }
212
221
  } else {
@@ -286,17 +295,19 @@ function generateCombinations (arrays: (string[] | string)[], cbFn, currentCombi
286
295
  const currentArray = arrays[0]
287
296
  if (currentArray instanceof Array) {
288
297
  // 遍历当前数组的每个元素
298
+ const eles: TMappingNode[] = []
289
299
  for (let i = 0; i < currentArray.length; i++) {
290
300
  // 将当前元素添加到当前组合中
291
301
  currentCombination.push(currentArray[i])
292
302
  // 递归处理剩余的数组
293
303
  const shouldStop = generateCombinations(arrays.slice(1), cbFn, currentCombination)
294
304
  if (shouldStop) {
295
- return shouldStop
305
+ eles.push(shouldStop)
296
306
  }
297
307
  // 回溯,移除最后一个元素,尝试其他组合
298
308
  currentCombination.pop()
299
309
  }
310
+ return eles
300
311
  } else {
301
312
  // 如果不是数组,直接将当前元素添加到当前组合中
302
313
  currentCombination.push(currentArray)
@@ -391,3 +402,10 @@ export function __combine_nesting_style__(react_tree: ReactElement, styles: Nest
391
402
  }
392
403
  return react_tree
393
404
  }
405
+
406
+ // 拍平数组
407
+ function flattenArray(arr) {
408
+ return arr.reduce((acc, val) => {
409
+ return acc.concat(Array.isArray(val) ? flattenArray(val) : val)
410
+ }, [])
411
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/plugin-platform-harmony-ets",
3
- "version": "4.0.0-beta.57",
3
+ "version": "4.0.0-beta.58",
4
4
  "description": "OpenHarmony & 鸿蒙系统插件",
5
5
  "author": "O2Team",
6
6
  "homepage": "https://gitee.com/openharmony-sig/taro",
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "webpack-sources": "^3.2.3",
28
- "@tarojs/components": "4.0.0-beta.57",
29
- "@tarojs/helper": "4.0.0-beta.57",
30
- "@tarojs/runtime": "4.0.0-beta.57",
31
- "@tarojs/runner-utils": "4.0.0-beta.57",
32
- "@tarojs/service": "4.0.0-beta.57",
33
- "@tarojs/shared": "4.0.0-beta.57",
34
- "@tarojs/taro": "4.0.0-beta.57"
28
+ "@tarojs/components": "4.0.0-beta.58",
29
+ "@tarojs/helper": "4.0.0-beta.58",
30
+ "@tarojs/runtime": "4.0.0-beta.58",
31
+ "@tarojs/service": "4.0.0-beta.58",
32
+ "@tarojs/shared": "4.0.0-beta.58",
33
+ "@tarojs/taro": "4.0.0-beta.58",
34
+ "@tarojs/runner-utils": "4.0.0-beta.58"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -44,7 +44,7 @@
44
44
  "solid-js": "^1.8.16",
45
45
  "tslib": "^2.4.0",
46
46
  "typescript": "^4.8.2",
47
- "rollup-plugin-copy": "4.0.0-beta.57"
47
+ "rollup-plugin-copy": "4.0.0-beta.58"
48
48
  },
49
49
  "scripts": {
50
50
  "prebuild": "rimraf ./dist",