@tarojs/plugin-platform-harmony-ets 4.0.0-beta.31 → 4.0.0-beta.33
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/index.ts +4 -5
- package/dist/components-harmony-ets/button.ets +2 -2
- package/dist/components-harmony-ets/index.ets +20 -0
- package/dist/components-harmony-ets/style.ets +56 -49
- package/dist/components-harmony-ets/text.ets +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +0 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +141 -23
- package/dist/runtime-ets/dom/stylesheet/type.ts +7 -3
- package/dist/runtime-ets/dom/stylesheet/util.ts +3 -3
- package/dist/runtime-utils.js +48 -7
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +48 -7
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
package/dist/runtime.js
CHANGED
|
@@ -32,7 +32,7 @@ import dataPreferences from '@ohos.data.preferences';
|
|
|
32
32
|
import hilog from '@ohos.hilog';
|
|
33
33
|
import matrix4 from '@ohos.matrix4';
|
|
34
34
|
import prompt from '@ohos.prompt';
|
|
35
|
-
import { pxTransformHelper } from '@tarojs/taro';
|
|
35
|
+
import { pxTransformHelper as pxTransformHelper$1 } from '@tarojs/taro';
|
|
36
36
|
|
|
37
37
|
class MethodHandler {
|
|
38
38
|
constructor({ name, success, fail, complete }) {
|
|
@@ -3880,7 +3880,7 @@ const pageScrollTo = (options) => {
|
|
|
3880
3880
|
scroller = getPageScrollerOrNode(scroller, page);
|
|
3881
3881
|
const { yOffset } = scroller.currentOffset();
|
|
3882
3882
|
if (areaInfo) {
|
|
3883
|
-
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true);
|
|
3883
|
+
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper$1(offsetTop, 'px', true);
|
|
3884
3884
|
}
|
|
3885
3885
|
}
|
|
3886
3886
|
const { xOffset } = scroller.currentOffset();
|
|
@@ -4870,19 +4870,60 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
|
|
|
4870
4870
|
}
|
|
4871
4871
|
}
|
|
4872
4872
|
const display = _display.getDefaultDisplaySync();
|
|
4873
|
-
display.width;
|
|
4873
|
+
let displayWidth = display.width;
|
|
4874
|
+
let ratioCache = false;
|
|
4875
|
+
let designWidthFunc;
|
|
4876
|
+
let designWidth = defaultDesignWidth;
|
|
4877
|
+
let deviceRatio = defaultDesignRatio;
|
|
4878
|
+
function getRatio(value) {
|
|
4879
|
+
var _a;
|
|
4880
|
+
// Note: 提前调用 display 可能无法获取正确值
|
|
4881
|
+
if (ratioCache === false || displayWidth !== display.width) {
|
|
4882
|
+
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4883
|
+
if (!isFunction(designWidthFunc)) {
|
|
4884
|
+
designWidthFunc = isFunction(config.designWidth)
|
|
4885
|
+
? config.designWidth
|
|
4886
|
+
: () => config.designWidth;
|
|
4887
|
+
designWidth = designWidthFunc(value) || defaultDesignWidth;
|
|
4888
|
+
deviceRatio = config.deviceRatio || defaultDesignRatio;
|
|
4889
|
+
if (!(designWidth in deviceRatio)) {
|
|
4890
|
+
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
displayWidth = display.width;
|
|
4894
|
+
ratioCache = Math.min(display.width, display.height) / designWidth / deviceRatio[designWidth];
|
|
4895
|
+
}
|
|
4896
|
+
return ratioCache;
|
|
4897
|
+
}
|
|
4898
|
+
// Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
|
|
4899
|
+
function pxTransformHelper(size, unit, isNumber = false) {
|
|
4900
|
+
var _a;
|
|
4901
|
+
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4902
|
+
const targetUnit = unit || config.targetUnit || defaultTargetUnit;
|
|
4903
|
+
if (targetUnit === 'PX') {
|
|
4904
|
+
return px2vp(size * display.scaledDensity) + 'vp';
|
|
4905
|
+
}
|
|
4906
|
+
const ratio = getRatio(size);
|
|
4907
|
+
let val = size * ratio;
|
|
4908
|
+
switch (targetUnit) {
|
|
4909
|
+
case 'vp':
|
|
4910
|
+
// Note: 在应用创建前调用无效
|
|
4911
|
+
val = px2vp(val);
|
|
4912
|
+
break;
|
|
4913
|
+
}
|
|
4914
|
+
return isNumber ? val : val + targetUnit;
|
|
4915
|
+
}
|
|
4874
4916
|
function pxTransform(size) {
|
|
4875
4917
|
var _a;
|
|
4876
4918
|
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4877
4919
|
const targetUnit = config.targetUnit || defaultTargetUnit;
|
|
4878
|
-
|
|
4920
|
+
const val = size;
|
|
4879
4921
|
switch (targetUnit) {
|
|
4880
4922
|
case 'vp':
|
|
4881
|
-
|
|
4882
|
-
break;
|
|
4923
|
+
return pxTransformHelper(size, 'px');
|
|
4883
4924
|
// NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
|
|
4884
4925
|
}
|
|
4885
|
-
return val +
|
|
4926
|
+
return val + targetUnit;
|
|
4886
4927
|
}
|
|
4887
4928
|
function canIUseWebp() {
|
|
4888
4929
|
return true;
|