@tarojs/plugin-platform-harmony-ets 4.0.0-beta.46 → 4.0.0-beta.48

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.
@@ -103,6 +103,16 @@ export interface TaroStyleType {
103
103
  type: TextDecorationType
104
104
  }
105
105
 
106
+ // animation
107
+ animationName?: {
108
+ percentage: number
109
+ event: TaroStyleType
110
+ }[]
111
+ animationDuration?: number
112
+ animationTimingFunction?: string
113
+ animationDelay?: number
114
+ animationIterationCount?: number
115
+
106
116
  // other
107
117
  opacity?: number | Resource
108
118
  zIndex?: number
@@ -1,5 +1,5 @@
1
1
  import _display from '@ohos.display'
2
- import { pxTransformHelper } from '@tarojs/taro'
2
+ import { getSystemInfoSync, pxTransformHelper } from '@tarojs/taro'
3
3
 
4
4
  import { NodeType } from '../dom/node'
5
5
  import convertWebStyle2HmStyle from '../dom/stylesheet/covertWeb2Hm'
@@ -60,16 +60,12 @@ export function parseClasses (classNames: string | string[] = []): string[] {
60
60
  }
61
61
 
62
62
  // 合并静态样式,从样式表里面找到对应的样式
63
- export function calcStaticStyle (styleSheet: Record<string, CSSProperties>, classNames: string | string[] = [], style: CSSProperties): CSSProperties {
63
+ export function calcStaticStyle (styleSheet: Record<string, CSSProperties>, classNames: string | string[] = []): CSSProperties {
64
64
  const obj: CSSProperties[] = []
65
65
  const classes = parseClasses(classNames)
66
66
  if (classes.length === 1) {
67
- if (style) {
68
- return Object.assign({}, styleSheet[classes[0]], style)
69
- } else {
70
- // 同一个引用
71
- return styleSheet[classes[0]]
72
- }
67
+ // 同一个引用
68
+ return styleSheet[classes[0]]
73
69
  } else {
74
70
  for (let i = 0; i < classes.length; i++) {
75
71
  const className = classes[i]
@@ -77,9 +73,6 @@ export function calcStaticStyle (styleSheet: Record<string, CSSProperties>, clas
77
73
  obj.push(styleSheet[className])
78
74
  }
79
75
  }
80
- if (style) {
81
- obj.push(style)
82
- }
83
76
  return Object.assign.apply(null, [{}].concat(obj))
84
77
  }
85
78
  }
@@ -92,6 +85,27 @@ export function calcDynamicStyle (style: CSSProperties): CSSProperties {
92
85
  return {}
93
86
  }
94
87
 
88
+ // css env()环境样式获取
89
+ export function __env__(safeAreaType: string, fallback?: string | number) {
90
+ const sysInfo = getSystemInfoSync()
91
+
92
+ switch (safeAreaType) {
93
+ case 'safe-area-inset-top': {
94
+ return sysInfo.safeArea?.top ? `${sysInfo.safeArea?.top}px` : fallback
95
+ }
96
+ case 'safe-area-inset-right': {
97
+ return sysInfo.safeArea?.right ? `${sysInfo.screenWidth - sysInfo.safeArea?.right}px` : fallback
98
+ }
99
+ case 'safe-area-inset-bottom': {
100
+ return sysInfo.safeArea?.bottom ? `${sysInfo.screenHeight - sysInfo.safeArea?.bottom}px` : fallback
101
+ }
102
+ case 'safe-area-inset-left': {
103
+ return sysInfo.safeArea?.left ? `${sysInfo.safeArea?.left}px` : fallback
104
+ }
105
+ }
106
+ return fallback
107
+ }
108
+
95
109
  export function getPageScrollerOrNode (scrollerOrNode: any, page: any) {
96
110
  if (!page) return scrollerOrNode
97
111
 
@@ -9,6 +9,7 @@ import errorManager from '@ohos.app.ability.errorManager';
9
9
  import sensor from '@ohos.sensor';
10
10
  import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo';
11
11
  import pasteboard from '@ohos.pasteboard';
12
+ import promptAction from '@ohos.promptAction';
12
13
  import inputMethodEngine from '@ohos.inputMethodEngine';
13
14
  import network from '@system.network';
14
15
  import call from '@ohos.telephony.call';
@@ -30,7 +31,6 @@ import router from '@ohos.router';
30
31
  import bundleManager from '@ohos.bundle.bundleManager';
31
32
  import distributedKVStore from '@ohos.data.distributedKVStore';
32
33
  import matrix4 from '@ohos.matrix4';
33
- import prompt from '@ohos.prompt';
34
34
  import { pxTransformHelper as pxTransformHelper$1 } from '@tarojs/taro';
35
35
 
36
36
  class MethodHandler {
@@ -656,6 +656,7 @@ const setClipboardData = function (options) {
656
656
  callAsyncFail(reject, res, options);
657
657
  }
658
658
  else {
659
+ promptAction.showToast({ message: '内容已复制' });
659
660
  return handle.success({
660
661
  data,
661
662
  }, { resolve, reject });
@@ -3389,7 +3390,7 @@ const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStora
3389
3390
  const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage');
3390
3391
  const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync');
3391
3392
  const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage');
3392
- const clearStorage = temporarilyNotSupport('removeStorageSync');
3393
+ const clearStorage = temporarilyNotSupport('clearStorage');
3393
3394
  const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage');
3394
3395
  const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage');
3395
3396
  const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage');
@@ -3639,7 +3640,7 @@ function showToast(options) {
3639
3640
  const res = { errMsg: error.message };
3640
3641
  return callAsyncFail(reject, res, options);
3641
3642
  }
3642
- prompt.showToast({
3643
+ promptAction.showToast({
3643
3644
  message: options.title,
3644
3645
  duration: options.duration,
3645
3646
  bottom: options.bottom
@@ -3672,25 +3673,24 @@ function showModal(options) {
3672
3673
  color: confirmColor
3673
3674
  });
3674
3675
  }
3675
- return new Promise(resolve => {
3676
+ return new Promise((resolve, reject) => {
3676
3677
  const modalOptions = {
3677
3678
  title,
3678
3679
  message: content,
3679
3680
  buttons: buttons,
3680
- success: (data) => {
3681
- if (data.index === 1 || !showCancel) {
3682
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
3683
- }
3684
- else {
3685
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
3686
- }
3687
- },
3688
- // 鸿蒙没有失败方法,只有取消
3689
- cancel: (_) => {
3681
+ };
3682
+ promptAction.showDialog(modalOptions, (error, data) => {
3683
+ if (error) {
3684
+ const res = { errMsg: error };
3685
+ callAsyncFail(reject, res, options);
3686
+ }
3687
+ if (data.index === 0 && showCancel) {
3690
3688
  callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
3691
3689
  }
3692
- };
3693
- prompt.showDialog(modalOptions);
3690
+ else {
3691
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
3692
+ }
3693
+ });
3694
3694
  });
3695
3695
  }
3696
3696
  const showActionSheetSchema = {
@@ -3721,21 +3721,19 @@ function showActionSheet(options) {
3721
3721
  });
3722
3722
  const actionSheetOptions = {
3723
3723
  title,
3724
- buttons,
3725
- success: (data) => {
3726
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
3727
- },
3728
- // 取消方法,并非失败
3729
- fail: (data) => {
3724
+ buttons
3725
+ };
3726
+ promptAction.showActionMenu(actionSheetOptions, (error, data) => {
3727
+ if (error) {
3730
3728
  callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: data.errMsg.replace('showActionMenu', 'showActionSheet') }), options);
3731
3729
  }
3732
- };
3733
- prompt.showActionMenu(actionSheetOptions);
3730
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
3731
+ });
3734
3732
  });
3735
3733
  }
3736
3734
  function hideToast(options) {
3737
3735
  return new Promise(resolve => {
3738
- prompt.showToast({
3736
+ promptAction.showToast({
3739
3737
  message: '关闭中',
3740
3738
  duration: 10,
3741
3739
  bottom: '9999px'
@@ -4885,7 +4883,6 @@ let displayWidth = display.width;
4885
4883
  let ratioCache = false;
4886
4884
  let designWidthFunc;
4887
4885
  let designWidth = defaultDesignWidth;
4888
- let deviceRatio = defaultDesignRatio;
4889
4886
  function getRatio(value) {
4890
4887
  var _a;
4891
4888
  // Note: 提前调用 display 可能无法获取正确值
@@ -4896,10 +4893,6 @@ function getRatio(value) {
4896
4893
  ? config.designWidth
4897
4894
  : () => config.designWidth;
4898
4895
  designWidth = designWidthFunc(value) || defaultDesignWidth;
4899
- deviceRatio = config.deviceRatio || defaultDesignRatio;
4900
- if (!(designWidth in deviceRatio)) {
4901
- throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
4902
- }
4903
4896
  }
4904
4897
  displayWidth = display.width;
4905
4898
  ratioCache = Math.min(display.width, display.height) / designWidth;