@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.
@@ -15,6 +15,7 @@ export const WEB_STYLE_MAP = {
15
15
  marginRight: ['_marginRight'],
16
16
  marginBottom: ['_marginBottom'],
17
17
  marginLeft: ['_marginLeft'],
18
+ position: ['_position'],
18
19
  top: ['_top'],
19
20
  left: ['_left'],
20
21
  flex: ['_flexGrow', '_flexShrink', '_flexBasis'],
@@ -74,7 +75,8 @@ export const WEB_STYLE_MAP = {
74
75
  textDecoration: ['_textDecoration'],
75
76
  textOverflow: ['_textOverflow'],
76
77
  WebkitLineClamp: ['_WebkitLineClamp'],
77
- transform: ['_transform']
78
+ transform: ['_transform'],
79
+ display: ['_display']
78
80
  }
79
81
 
80
82
  // 将web端的style转换为hm端的style
@@ -458,6 +460,27 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
458
460
  hmStyle._transform = parseTransform(value)
459
461
  break
460
462
  }
463
+ case 'position': {
464
+ hmStyle._position = value
465
+ break
466
+ }
467
+ case 'display': {
468
+ hmStyle._display = value
469
+ break
470
+ }
471
+ case 'zIndex': {
472
+ hmStyle._zIndex = Number(value)
473
+ break
474
+ }
475
+ case 'opacity': {
476
+ const val = Number(value)
477
+ hmStyle._opacity = Number.isNaN(val) ? 1 : val
478
+ break
479
+ }
480
+ case 'overflow': {
481
+ hmStyle._overflow = value === 'hidden'
482
+ break
483
+ }
461
484
  default: {
462
485
  hmStyle[key] = value
463
486
  break
@@ -472,9 +495,9 @@ function setBackgroundImage(hmStyle, value) {
472
495
  // 如果包含 url(),则说明是 background-image 属性
473
496
  const match = value.match(new RegExp('url\\([\'"]?(.*?)[\'"]?\\)'))
474
497
  if (match) {
475
- hmStyle._backgroundImage = [{
498
+ hmStyle._backgroundImage = {
476
499
  src: match[1]
477
- }]
500
+ }
478
501
  }
479
502
  }
480
503
  }
@@ -482,10 +505,10 @@ function setBackgroundImage(hmStyle, value) {
482
505
  function setBackgroundRepeat(hmStyle, value) {
483
506
  if (typeof value === 'string') {
484
507
  switch (value) {
485
- case 'repeat-x': hmStyle._backgroundRepeat = [ImageRepeat.X]; break
486
- case 'repeat-y': hmStyle._backgroundRepeat = [ImageRepeat.Y]; break
487
- case 'no-repeat': hmStyle._backgroundRepeat = [ImageRepeat.NoRepeat]; break
488
- default: hmStyle._backgroundRepeat = [ImageRepeat.XY]; break
508
+ case 'repeat-x': hmStyle._backgroundRepeat = ImageRepeat.X; break
509
+ case 'repeat-y': hmStyle._backgroundRepeat = ImageRepeat.Y; break
510
+ case 'no-repeat': hmStyle._backgroundRepeat = ImageRepeat.NoRepeat; break
511
+ default: hmStyle._backgroundRepeat = ImageRepeat.XY; break
489
512
  }
490
513
  }
491
514
  }
@@ -494,9 +517,9 @@ function setBackgroundSize(hmStyle, value) {
494
517
  if (typeof value === 'string') {
495
518
  const sizes = value.split(' ')
496
519
  if (sizes.length === 1) {
497
- hmStyle._backgroundSize = [{ width: getUnit(sizes[0]) }]
520
+ hmStyle._backgroundSize = { width: getUnit(sizes[0]) }
498
521
  } else if (sizes.length === 2) {
499
- hmStyle._backgroundSize = [{ width: getUnit(sizes[0]), height: getUnit(sizes[1]) }]
522
+ hmStyle._backgroundSize = { width: getUnit(sizes[0]), height: getUnit(sizes[1]) }
500
523
  }
501
524
  }
502
525
  }
@@ -508,28 +531,28 @@ function setBackgroundPosistion (hmStyle, value) {
508
531
  const vertical = positions[1].toLowerCase() || 'top'
509
532
 
510
533
  if (horizontal === 'left' && vertical === 'top') {
511
- hmStyle._backgroundPosition = [Alignment.TopStart]
534
+ hmStyle._backgroundPosition = Alignment.TopStart
512
535
  } else if (horizontal === 'center' && vertical === 'top') {
513
- hmStyle._backgroundPosition = [Alignment.Top]
536
+ hmStyle._backgroundPosition = Alignment.Top
514
537
  } else if (horizontal === 'right' && vertical === 'top') {
515
- hmStyle._backgroundPosition = [Alignment.TopEnd]
538
+ hmStyle._backgroundPosition = Alignment.TopEnd
516
539
  } else if (horizontal === 'left' && vertical === 'center') {
517
- hmStyle._backgroundPosition = [Alignment.Start]
540
+ hmStyle._backgroundPosition = Alignment.Start
518
541
  } else if (horizontal === 'center' && vertical === 'center') {
519
- hmStyle._backgroundPosition = [Alignment.Center]
542
+ hmStyle._backgroundPosition = Alignment.Center
520
543
  } else if (horizontal === 'right' && vertical === 'center') {
521
- hmStyle._backgroundPosition = [Alignment.End]
544
+ hmStyle._backgroundPosition = Alignment.End
522
545
  } else if (horizontal === 'left' && vertical === 'bottom') {
523
- hmStyle._backgroundPosition = [Alignment.BottomStart]
546
+ hmStyle._backgroundPosition = Alignment.BottomStart
524
547
  } else if (horizontal === 'center' && vertical === 'bottom') {
525
- hmStyle._backgroundPosition = [Alignment.Bottom]
548
+ hmStyle._backgroundPosition = Alignment.Bottom
526
549
  } else if (horizontal === 'right' && vertical === 'bottom') {
527
- hmStyle._backgroundPosition = [Alignment.BottomEnd]
550
+ hmStyle._backgroundPosition = Alignment.BottomEnd
528
551
  } else {
529
552
  if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
530
- hmStyle._backgroundPosition = [{ x: getUnit(horizontal) }]
553
+ hmStyle._backgroundPosition = { x: getUnit(horizontal) }
531
554
  if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
532
- hmStyle._backgroundPosition = [{ x: getUnit(horizontal), y: getUnit(vertical) }]
555
+ hmStyle._backgroundPosition = { x: getUnit(horizontal), y: getUnit(vertical) }
533
556
  }
534
557
  }
535
558
  }
@@ -15,7 +15,7 @@ export default class StyleSheet {
15
15
  return this.hmStyle.display
16
16
  }
17
17
 
18
- set display (value: string) {
18
+ set _display (value: string) {
19
19
  this.hmStyle.display = value
20
20
  }
21
21
 
@@ -23,7 +23,7 @@ export default class StyleSheet {
23
23
  return this.hmStyle.position
24
24
  }
25
25
 
26
- set position (value: string) {
26
+ set _position (value: string) {
27
27
  this.hmStyle.position = value
28
28
  }
29
29
 
@@ -245,17 +245,17 @@ export default class StyleSheet {
245
245
  }
246
246
 
247
247
  set _background (value: TaroAny) {
248
- const _backgroundImage: HarmonyType.Background.backgroundImage = value?.image?.[0]
248
+ const _backgroundImage: HarmonyType.Background.backgroundImage = value?.image
249
249
  if (_backgroundImage) {
250
250
  this.hmStyle.backgroundImage = _backgroundImage.src
251
251
  if (_backgroundImage.repeat) {
252
252
  this.hmStyle.backgroundRepeat = _backgroundImage.repeat
253
253
  }
254
254
  }
255
- this.hmStyle.backgroundImageSize = value?.size?.[0]
255
+ this.hmStyle.backgroundImageSize = value?.size
256
256
  this.hmStyle.backgroundColor = this.hmStyle.backgroundImage ? null : value?.color
257
257
 
258
- const _backgroundPosition: HarmonyType.Background.backgroundImagePosition = value?.position?.[0]
258
+ const _backgroundPosition: HarmonyType.Background.backgroundImagePosition = value?.position
259
259
  this.hmStyle.backgroundImagePosition = _backgroundPosition
260
260
  }
261
261
 
@@ -272,7 +272,7 @@ export default class StyleSheet {
272
272
  }
273
273
 
274
274
  set _backgroundImage (value) {
275
- this.hmStyle.backgroundImage = value?.[0]
275
+ this.hmStyle.backgroundImage = value
276
276
  }
277
277
 
278
278
  get backgroundRepeat () {
@@ -287,7 +287,7 @@ export default class StyleSheet {
287
287
  }
288
288
 
289
289
  set _backgroundRepeat (value: ImageRepeat[]) {
290
- this.hmStyle.backgroundRepeat = value?.[0]
290
+ this.hmStyle.backgroundRepeat = value
291
291
  }
292
292
 
293
293
  get backgroundSize () {
@@ -297,7 +297,7 @@ export default class StyleSheet {
297
297
  }
298
298
 
299
299
  set _backgroundSize (value: HarmonyType.Background.backgroundImageSize[]) {
300
- this.hmStyle.backgroundSize = value?.[0]
300
+ this.hmStyle.backgroundSize = value
301
301
  }
302
302
 
303
303
  get backgroundPosition () {
@@ -322,7 +322,7 @@ export default class StyleSheet {
322
322
  }
323
323
 
324
324
  set _backgroundPosition (value: HarmonyType.Background.backgroundImagePosition[]) {
325
- this.hmStyle.backgroundPosition = value?.[0]
325
+ this.hmStyle.backgroundPosition = value
326
326
  }
327
327
 
328
328
  get border () {
@@ -493,7 +493,7 @@ export default class StyleSheet {
493
493
  return Number(this.hmStyle.zIndex)
494
494
  }
495
495
 
496
- set zIndex (value: string) {
496
+ set _zIndex (value: string) {
497
497
  this.hmStyle.zIndex = Number(value)
498
498
  }
499
499
 
@@ -501,16 +501,15 @@ export default class StyleSheet {
501
501
  return this.hmStyle.opacity
502
502
  }
503
503
 
504
- set opacity (value: string) {
505
- const val = Number(value)
506
- this.hmStyle.opacity = Number.isNaN(val) ? 1 : val
504
+ set _opacity (value: number) {
505
+ this.hmStyle.opacity = value
507
506
  }
508
507
 
509
508
  get overflow () {
510
509
  return this.hmStyle.overflow ? 'hidden' : 'visible'
511
510
  }
512
511
 
513
- set overflow (value: string) {
512
+ set _overflow (value: string) {
514
513
  this.hmStyle.overflow = value === 'hidden'
515
514
  }
516
515
 
@@ -658,5 +657,13 @@ export default class StyleSheet {
658
657
  set _transformOrigin(value) {
659
658
  this.hmStyle.transformOrigin = value
660
659
  }
660
+
661
+ get content () {
662
+ return this.hmStyle._content
663
+ }
664
+
665
+ set _content (value) {
666
+ this.hmStyle.content = value
667
+ }
661
668
  }
662
669
 
@@ -100,6 +100,7 @@ export interface TaroStyleType {
100
100
  zIndex?: number
101
101
  overflow?: boolean
102
102
  focus?: boolean
103
+ content?: string
103
104
  }
104
105
 
105
106
  export interface TaroTextStyleType {
@@ -237,7 +237,11 @@ export function createReactApp (
237
237
  }
238
238
  } as unknown as AppInstance
239
239
 
240
- Current.app = app
240
+ if (Current.app) {
241
+ Current.app = Object.assign(app, Current.app)
242
+ } else {
243
+ Current.app = app
244
+ }
241
245
 
242
246
  return app
243
247
  }
@@ -80,7 +80,11 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
80
80
 
81
81
  componentDidMount () {
82
82
  if (isDefaultEntryDom) {
83
- Current.app = this
83
+ if (Current.app) {
84
+ Current.app = Object.assign(this, Current.app)
85
+ } else {
86
+ Current.app = this
87
+ }
84
88
  } else {
85
89
  nativeComponentApp = this
86
90
  }
@@ -184,6 +184,7 @@ export function createPageConfig (component: any, pageName?: string, pageConfig?
184
184
  safeExecute(this.$taroPath, ON_READY)
185
185
  // 通过事件触发子组件的生命周期
186
186
  requestAnimationFrame(() => eventCenter.trigger(getOnReadyEventKey(id)))
187
+ this.onReady.called = true
187
188
  })
188
189
  },
189
190
  [ONSHOW] (options = {}) {
@@ -1,6 +1,6 @@
1
1
  import { isFunction, isString, isArray, isObject, isNull, isNumber, isUndefined, queryToJson, PLATFORM_TYPE, singleQuote, internalComponents } 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;