@tarojs/plugin-platform-harmony-ets 4.0.0-beta.56 → 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.
- package/dist/apis/wxml/selectorQuery.ts +7 -3
- package/dist/components-harmony-ets/image.ets +7 -0
- package/dist/components-harmony-ets/style.ets +4 -4
- package/dist/runtime-ets/dom/cssNesting.ts +34 -16
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +3 -3
- package/dist/runtime-utils.js +5 -2
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +5 -2
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
|
@@ -112,7 +112,7 @@ function filter (fields, dom) {
|
|
|
112
112
|
return res
|
|
113
113
|
}
|
|
114
114
|
if (context) {
|
|
115
|
-
// TODO: 暂未实现获取
|
|
115
|
+
// TODO: 暂未实现获取 context
|
|
116
116
|
// const typeName = dom.type
|
|
117
117
|
// if (/^video/i.test(typeName)) {
|
|
118
118
|
// return { context: dom }
|
|
@@ -179,9 +179,13 @@ function filter (fields, dom) {
|
|
|
179
179
|
|
|
180
180
|
function querySelector (selector, selectAll) {
|
|
181
181
|
if (typeof selector === 'string') {
|
|
182
|
-
return
|
|
182
|
+
return selector.split(',').reduce((prev, current) => {
|
|
183
|
+
const item = current.trim()
|
|
184
|
+
|
|
185
|
+
return prev.concat(parseHandler(item, selectAll))
|
|
186
|
+
}, [])
|
|
183
187
|
}
|
|
184
|
-
return
|
|
188
|
+
return []
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
function queryBat (queue, cb) {
|
|
@@ -39,5 +39,12 @@ export default struct TaroImage {
|
|
|
39
39
|
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
40
40
|
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
41
41
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
42
|
+
// TODO: 临时改为申明式,后续等鸿蒙修复modify设置失败的bug后删除该申明
|
|
43
|
+
.borderRadius({
|
|
44
|
+
topLeft: this.node._st.hmStyle.borderTopLeftRadius,
|
|
45
|
+
topRight: this.node._st.hmStyle.borderTopRightRadius,
|
|
46
|
+
bottomLeft: this.node._st.hmStyle.borderBottomLeftRadius,
|
|
47
|
+
bottomRight: this.node._st.hmStyle.borderBottomRightRadius
|
|
48
|
+
})
|
|
42
49
|
}
|
|
43
50
|
}
|
|
@@ -170,15 +170,15 @@ export function setTransformAttributeIntoInstance(instance: CommonAttribute, sty
|
|
|
170
170
|
x: style.transform?.Scale?.x,
|
|
171
171
|
y: style.transform?.Scale?.y,
|
|
172
172
|
z: style.transform?.Scale?.z,
|
|
173
|
-
centerX: style.transformOrigin?.x
|
|
174
|
-
centerY: style.transformOrigin?.y
|
|
173
|
+
centerX: style.transformOrigin?.x,
|
|
174
|
+
centerY: style.transformOrigin?.y,
|
|
175
175
|
})
|
|
176
176
|
instance.rotate({
|
|
177
177
|
x: style.transform?.Rotate?.x,
|
|
178
178
|
y: style.transform?.Rotate?.y,
|
|
179
179
|
z: style.transform?.Rotate?.z,
|
|
180
|
-
centerX: style.transformOrigin?.x
|
|
181
|
-
centerY: style.transformOrigin?.y
|
|
180
|
+
centerX: style.transformOrigin?.x,
|
|
181
|
+
centerY: style.transformOrigin?.y,
|
|
182
182
|
angle: style.transform?.Rotate?.angle || 0,
|
|
183
183
|
})
|
|
184
184
|
}
|
|
@@ -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
|
|
189
|
+
let hitElements: any
|
|
186
190
|
// 如果是数组,说明他是一个多类选择器:.a.b,我们需要搜索这两个类名都指向同一个node
|
|
187
191
|
if (shouldUseCombinations) {
|
|
188
|
-
|
|
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
|
-
|
|
198
|
+
hitElements = findSendNode(selector, selector_mapping)
|
|
195
199
|
}
|
|
196
200
|
// 找出最后搜寻出来的node
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
@@ -23,10 +23,10 @@ class CSSStyleDeclaration {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
public set cssText (value: string) {
|
|
26
|
+
// 复制,防止被篡改到attr上的原始内容
|
|
27
|
+
this._st.hmStyle = Object.assign({}, this.el._attrs?.__hmStyle) || {}
|
|
26
28
|
if (value === '' || value === undefined || value === null) {
|
|
27
|
-
//
|
|
28
|
-
// this.el._st = {}
|
|
29
|
-
this._st.hmStyle = {}
|
|
29
|
+
// 清空style,只保留class的样式
|
|
30
30
|
return
|
|
31
31
|
}
|
|
32
32
|
|
package/dist/runtime-utils.js
CHANGED
|
@@ -4340,9 +4340,12 @@ function filter(fields, dom) {
|
|
|
4340
4340
|
}
|
|
4341
4341
|
function querySelector(selector, selectAll) {
|
|
4342
4342
|
if (typeof selector === 'string') {
|
|
4343
|
-
return
|
|
4343
|
+
return selector.split(',').reduce((prev, current) => {
|
|
4344
|
+
const item = current.trim();
|
|
4345
|
+
return prev.concat(parseHandler(item, selectAll));
|
|
4346
|
+
}, []);
|
|
4344
4347
|
}
|
|
4345
|
-
return
|
|
4348
|
+
return [];
|
|
4346
4349
|
}
|
|
4347
4350
|
function queryBat(queue, cb) {
|
|
4348
4351
|
const result = [];
|