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

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/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isFunction, isString, isArray, isObject, isNull, isNumber, isUndefined, queryToJson, PLATFORM_TYPE, singleQuote, internalComponents, mergeReconciler, mergeInternalComponents } from '@tarojs/shared';
2
2
  import _display from '@ohos.display';
3
- import { Current, window, hooks, document as document$1, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime';
3
+ import { Current, window, hooks, document as document$1, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME, getCurrentInstance } from '@tarojs/runtime';
4
4
  import { eventCenter, Events, History } from '@tarojs/runtime/dist/runtime.esm';
5
5
  import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
6
6
  import deviceInfo from '@ohos.deviceInfo';
@@ -267,33 +267,45 @@ const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkyline
267
267
  const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets');
268
268
 
269
269
  let display;
270
+ let navigationIndicatorRect;
270
271
  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;
272
+ let statusBarHeight;
273
+ let windowRect;
274
+ Current.contextPromise.then((context) => {
275
+ const win = window.__ohos.getLastWindow(context);
276
+ win.then(mainWindow => {
277
+ const topRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_SYSTEM).topRect;
278
+ navigationIndicatorRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect;
279
+ statusBarHeight = topRect.top + topRect.height;
280
+ windowRect = mainWindow.getWindowProperties().windowRect;
281
+ try {
282
+ display = _display.getDefaultDisplaySync();
283
+ // @ts-ignore
284
+ display.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
285
+ var _a, _b, _c, _d, _e, _f;
286
+ if (err === null || err === void 0 ? void 0 : err.code) {
287
+ console.error('Failed to get cutout info', JSON.stringify(err));
288
+ return;
289
+ }
290
+ const top = Math.max(...boundingRects.map(rect => rect.top + rect.height), ((_a = waterfallDisplayAreaRects.top) === null || _a === void 0 ? void 0 : _a.top) + ((_b = waterfallDisplayAreaRects.top) === null || _b === void 0 ? void 0 : _b.height), statusBarHeight);
291
+ const bottom = display.height - Math.min((_c = waterfallDisplayAreaRects.bottom) === null || _c === void 0 ? void 0 : _c.top, navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top);
292
+ const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
293
+ const right = display.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
294
+ safeArea = {
295
+ top,
296
+ bottom,
297
+ left,
298
+ right,
299
+ height: bottom - top,
300
+ width: right - left,
301
+ };
302
+ });
303
+ }
304
+ catch (e) {
305
+ console.error('Failed to get display', e);
279
306
  }
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
307
  });
293
- }
294
- catch (e) {
295
- console.error('Failed to get display', e);
296
- }
308
+ });
297
309
  /* 同步版本 */
298
310
  const getSystemInfoSync = function () {
299
311
  var _a, _b;
@@ -322,12 +334,12 @@ const getSystemInfoSync = function () {
322
334
  res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
323
335
  res.screenHeight = display === null || display === void 0 ? void 0 : display.height; // 屏幕高度,单位px number
324
336
  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
337
+ res.statusBarHeight = statusBarHeight; // 状态栏的高度,单位px number
326
338
  res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
327
339
  // Note: 更新配置时才能记录
328
340
  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
341
+ res.windowHeight = windowRect === null || windowRect === void 0 ? void 0 : windowRect.height; // 可使用窗口高度,单位px number
342
+ res.windowWidth = windowRect === null || windowRect === void 0 ? void 0 : windowRect.width; // 可使用窗口宽度,单位px number
331
343
  res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
332
344
  return res;
333
345
  };
@@ -2006,7 +2018,6 @@ function getEnv() {
2006
2018
  }
2007
2019
  // TODO
2008
2020
  const getCurrentPages = () => [];
2009
- const getCurrentInstance = () => Current;
2010
2021
  const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
2011
2022
 
2012
2023
  // @ts-nocheck
@@ -4774,7 +4785,7 @@ const defaultBaseFontSize = 20;
4774
4785
  const defaultUnitPrecision = 5;
4775
4786
  const defaultTargetUnit = 'vp';
4776
4787
  function getApp$1() {
4777
- return Current.app;
4788
+ return Current.app || {};
4778
4789
  }
4779
4790
  function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
4780
4791
  const taro = Current.taro;