@tarojs/plugin-platform-harmony-ets 4.0.0-beta.10 → 4.0.0-beta.12

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.
Files changed (44) hide show
  1. package/dist/apis/base/system.ts +40 -22
  2. package/dist/components-harmony-ets/button.ets +34 -31
  3. package/dist/components-harmony-ets/checkbox.ets +5 -4
  4. package/dist/components-harmony-ets/form.ets +31 -28
  5. package/dist/components-harmony-ets/icon.ets +22 -18
  6. package/dist/components-harmony-ets/image.ets +15 -11
  7. package/dist/components-harmony-ets/innerHtml.ets +9 -5
  8. package/dist/components-harmony-ets/input.ets +1 -1
  9. package/dist/components-harmony-ets/label.ets +44 -40
  10. package/dist/components-harmony-ets/movableArea.ets +67 -0
  11. package/dist/components-harmony-ets/movableView.ets +66 -0
  12. package/dist/components-harmony-ets/picker.ets +7 -6
  13. package/dist/components-harmony-ets/progress.ets +45 -0
  14. package/dist/components-harmony-ets/radio.ets +5 -5
  15. package/dist/components-harmony-ets/richText.ets +14 -9
  16. package/dist/components-harmony-ets/scrollView.ets +40 -35
  17. package/dist/components-harmony-ets/slider.ets +1 -1
  18. package/dist/components-harmony-ets/swiper.ets +23 -19
  19. package/dist/components-harmony-ets/switch.ets +1 -1
  20. package/dist/components-harmony-ets/text.ets +28 -22
  21. package/dist/components-harmony-ets/textArea.ets +1 -1
  22. package/dist/components-harmony-ets/utils/styles.ets +2 -2
  23. package/dist/components-harmony-ets/video.ets +26 -21
  24. package/dist/components-harmony-ets/view.ets +34 -30
  25. package/dist/components-harmony-ets/webView.ets +37 -32
  26. package/dist/index.js +36 -16
  27. package/dist/index.js.map +1 -1
  28. package/dist/runtime-ets/dom/element/element.ts +0 -4
  29. package/dist/runtime-ets/dom/element/form.ts +11 -4
  30. package/dist/runtime-ets/dom/element/index.ts +9 -1
  31. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  32. package/dist/runtime-ets/dom/element/movableView.ts +12 -0
  33. package/dist/runtime-ets/dom/element/normal.ts +8 -2
  34. package/dist/runtime-ets/dom/element/progress.ts +13 -0
  35. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  36. package/dist/runtime-ets/dom/element/text.ts +1 -0
  37. package/dist/runtime-ets/dom/element/video.ts +1 -0
  38. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  39. package/dist/runtime-ets/dom/node.ts +18 -17
  40. package/dist/runtime-utils.js +43 -21
  41. package/dist/runtime-utils.js.map +1 -1
  42. package/dist/runtime.js +43 -21
  43. package/dist/runtime.js.map +1 -1
  44. package/package.json +8 -8
package/dist/runtime.js CHANGED
@@ -2,9 +2,9 @@ import { isFunction, isString, isArray, isObject, isNull, isNumber, isUndefined,
2
2
  import _display from '@ohos.display';
3
3
  import { Current, window, hooks, document as document$1, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime';
4
4
  import { eventCenter, Events, History } from '@tarojs/runtime/dist/runtime.esm';
5
+ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
5
6
  import deviceInfo from '@ohos.deviceInfo';
6
7
  import i18n from '@ohos.i18n';
7
- import deviceMethod from '@system.device';
8
8
  import errorManager from '@ohos.app.ability.errorManager';
9
9
  import sensor from '@ohos.sensor';
10
10
  import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo';
@@ -266,16 +266,37 @@ const preloadWebview = /* @__PURE__ */ temporarilyNotSupport('preloadWebview');
266
266
  const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkylineView');
267
267
  const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets');
268
268
 
269
- // 设备信息,从 API Version 6 开始支持
270
- const display = _display.getDefaultDisplaySync();
271
- let device;
272
- deviceMethod.getInfo({
273
- success: data => {
274
- device = data;
275
- }
276
- });
269
+ let display;
270
+ let safeArea = null;
271
+ try {
272
+ display = _display.getDefaultDisplaySync();
273
+ // @ts-ignore
274
+ display.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
275
+ var _a, _b, _c, _d, _e, _f, _g, _h;
276
+ if (err === null || err === void 0 ? void 0 : err.code) {
277
+ console.error('Failed to get cutout info', JSON.stringify(err));
278
+ return;
279
+ }
280
+ const top = Math.max(...boundingRects.map(rect => rect.top * 2 + rect.height), ((_a = waterfallDisplayAreaRects.top) === null || _a === void 0 ? void 0 : _a.top) + ((_b = waterfallDisplayAreaRects.top) === null || _b === void 0 ? void 0 : _b.height));
281
+ const bottom = (((_c = waterfallDisplayAreaRects.bottom) === null || _c === void 0 ? void 0 : _c.top) + ((_d = waterfallDisplayAreaRects.bottom) === null || _d === void 0 ? void 0 : _d.height)) || display.height;
282
+ const left = ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.left) + ((_f = waterfallDisplayAreaRects.left) === null || _f === void 0 ? void 0 : _f.width);
283
+ const right = (((_g = waterfallDisplayAreaRects.right) === null || _g === void 0 ? void 0 : _g.left) + ((_h = waterfallDisplayAreaRects.right) === null || _h === void 0 ? void 0 : _h.width)) || display.width;
284
+ safeArea = {
285
+ top,
286
+ bottom,
287
+ left,
288
+ right,
289
+ height: bottom - top,
290
+ width: right - left,
291
+ };
292
+ });
293
+ }
294
+ catch (e) {
295
+ console.error('Failed to get display', e);
296
+ }
277
297
  /* 同步版本 */
278
298
  const getSystemInfoSync = function () {
299
+ var _a, _b;
279
300
  const res = {};
280
301
  res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion; // 客户端基础库版本 string
281
302
  res.albumAuthorized = false; // 允许使用相册的开关(仅 iOS 有效) boolean
@@ -285,7 +306,7 @@ const getSystemInfoSync = function () {
285
306
  res.cameraAuthorized = null; // 允许使用摄像头的开关 boolean
286
307
  res.enableDebug = null; // 是否已打开调试 boolean
287
308
  res.fontSizeSetting = null; // 用户字体大小(单位px) number
288
- res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage(); // string
309
+ res.language = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.getSystemLanguage) === null || _a === void 0 ? void 0 : _a.call(i18n); // string
289
310
  res.locationAuthorized = null; // 定位的开关 boolean
290
311
  res.locationEnabled = null; // 地理位置的系统开关 boolean
291
312
  res.microphoneAuthorized = null; // 麦克风的开关 boolean
@@ -296,17 +317,18 @@ const getSystemInfoSync = function () {
296
317
  res.notificationSoundAuthorized = false; // 通知带有声音的开关(仅 iOS 有效)boolean
297
318
  res.phoneCalendarAuthorized = null; // 使用日历的开关 boolean
298
319
  res.wifiEnabled = false; // Wi-Fi 的系统开关 boolean
299
- res.pixelRatio = null; // 设备像素比,number
300
- res.platform = 'android'; // 客户端平台 string
301
- res.safeArea = null; // 在竖屏正方向下的安全区域 General.SafeAreaResult
302
- res.screenHeight = display && display.height; // 屏幕高度,单位px number
303
- res.screenWidth = display && display.width; // 屏幕宽度,单位px number
304
- res.statusBarHeight = null; // 状态栏的高度,单位px number
305
- res.system = deviceInfo && deviceInfo.osFullName; // 操作系统及版本 string
306
- res.theme = null; // 系统当前主题,取值为light或dark 'light' | 'dark'
307
- res.windowWidth = device && device.windowWidth; // 可使用窗口宽度,单位px number
308
- res.windowHeight = device && device.windowHeight; // 可使用窗口高度,单位px number
309
- res.version = deviceInfo && deviceInfo.displayVersion; // 版本号 string
320
+ res.pixelRatio = display && (Math.round(display.xDPI / display.width * 100) / 100); // 设备像素比,number
321
+ res.platform = 'harmony'; // 客户端平台 string
322
+ res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
323
+ res.screenHeight = display === null || display === void 0 ? void 0 : display.height; // 屏幕高度,单位px number
324
+ res.screenWidth = display === null || display === void 0 ? void 0 : display.width; // 屏幕宽度,单位px number
325
+ res.statusBarHeight = safeArea === null || safeArea === void 0 ? void 0 : safeArea.top; // 状态栏的高度,单位px number
326
+ res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
327
+ // Note: 更新配置时才能记录
328
+ res.theme = ((_b = AppStorage.get('__TARO_APP_CONFIG')) === null || _b === void 0 ? void 0 : _b.colorMode) === ConfigurationConstant.ColorMode.COLOR_MODE_DARK ? 'dark' : 'light'; // 系统当前主题,取值为light或dark 'light' | 'dark'
329
+ res.windowHeight = display === null || display === void 0 ? void 0 : display.height; // 可使用窗口高度,单位px number
330
+ res.windowWidth = display === null || display === void 0 ? void 0 : display.width; // 可使用窗口宽度,单位px number
331
+ res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
310
332
  return res;
311
333
  };
312
334
  /* 异步版本 */