@tarojs/plugin-platform-harmony-ets 4.0.0-beta.11 → 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.
- package/dist/apis/base/system.ts +40 -22
- package/dist/components-harmony-ets/checkbox.ets +2 -2
- package/dist/components-harmony-ets/form.ets +1 -1
- package/dist/components-harmony-ets/label.ets +1 -1
- package/dist/components-harmony-ets/movableArea.ets +1 -1
- package/dist/components-harmony-ets/movableView.ets +1 -1
- package/dist/components-harmony-ets/picker.ets +5 -5
- package/dist/components-harmony-ets/radio.ets +3 -3
- package/dist/components-harmony-ets/scrollView.ets +6 -5
- package/dist/components-harmony-ets/utils/styles.ets +2 -2
- package/dist/components-harmony-ets/view.ets +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/element/element.ts +0 -3
- package/dist/runtime-utils.js +43 -21
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +43 -21
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -8
package/dist/apis/base/system.ts
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
|
+
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'
|
|
1
2
|
// 设备信息,从 API Version 6 开始支持
|
|
2
3
|
import deviceInfo from '@ohos.deviceInfo'
|
|
3
4
|
// 显示设备属性,从 API Version 7 开始支持
|
|
4
5
|
import _display from '@ohos.display'
|
|
5
6
|
// 从 API Version 7 开始支持
|
|
6
7
|
import i18n from '@ohos.i18n'
|
|
7
|
-
// 设备信息 从API Version 6开始,该接口不再维护,推荐使用新接口'@ohos.deviceInfo'进行设备信息查询
|
|
8
|
-
import deviceMethod from '@system.device'
|
|
9
8
|
|
|
10
9
|
import { callAsyncFail, callAsyncSuccess } from '../utils'
|
|
11
10
|
|
|
12
11
|
import type Taro from '@tarojs/taro/types'
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
let display
|
|
14
|
+
let safeArea: TaroGeneral.SafeAreaResult | null = null
|
|
15
|
+
try {
|
|
16
|
+
display = _display.getDefaultDisplaySync()
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
display.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} }: _display.CutoutInfo = {}) => {
|
|
19
|
+
if (err?.code) {
|
|
20
|
+
console.error('Failed to get cutout info', JSON.stringify(err))
|
|
21
|
+
return
|
|
22
|
+
}
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const top = Math.max(...boundingRects.map(rect => rect.top * 2 + rect.height), waterfallDisplayAreaRects.top?.top + waterfallDisplayAreaRects.top?.height)
|
|
25
|
+
const bottom = (waterfallDisplayAreaRects.bottom?.top + waterfallDisplayAreaRects.bottom?.height) || display.height
|
|
26
|
+
const left = waterfallDisplayAreaRects.left?.left + waterfallDisplayAreaRects.left?.width
|
|
27
|
+
const right = (waterfallDisplayAreaRects.right?.left + waterfallDisplayAreaRects.right?.width) || display.width
|
|
28
|
+
safeArea = {
|
|
29
|
+
top,
|
|
30
|
+
bottom,
|
|
31
|
+
left,
|
|
32
|
+
right,
|
|
33
|
+
height: bottom - top,
|
|
34
|
+
width: right - left,
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error('Failed to get display', e)
|
|
39
|
+
}
|
|
23
40
|
|
|
24
41
|
/* 同步版本 */
|
|
25
42
|
export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
|
|
@@ -32,7 +49,7 @@ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
|
|
|
32
49
|
res.cameraAuthorized = null // 允许使用摄像头的开关 boolean
|
|
33
50
|
res.enableDebug = null // 是否已打开调试 boolean
|
|
34
51
|
res.fontSizeSetting = null // 用户字体大小(单位px) number
|
|
35
|
-
res.language = i18n
|
|
52
|
+
res.language = i18n?.getSystemLanguage?.() // string
|
|
36
53
|
res.locationAuthorized = null // 定位的开关 boolean
|
|
37
54
|
res.locationEnabled = null // 地理位置的系统开关 boolean
|
|
38
55
|
res.microphoneAuthorized = null // 麦克风的开关 boolean
|
|
@@ -43,17 +60,18 @@ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
|
|
|
43
60
|
res.notificationSoundAuthorized = false // 通知带有声音的开关(仅 iOS 有效)boolean
|
|
44
61
|
res.phoneCalendarAuthorized = null // 使用日历的开关 boolean
|
|
45
62
|
res.wifiEnabled = false // Wi-Fi 的系统开关 boolean
|
|
46
|
-
res.pixelRatio =
|
|
47
|
-
res.platform = '
|
|
48
|
-
res.safeArea =
|
|
49
|
-
res.screenHeight = display
|
|
50
|
-
res.screenWidth = display
|
|
51
|
-
res.statusBarHeight =
|
|
52
|
-
res.system = deviceInfo
|
|
53
|
-
|
|
54
|
-
res.
|
|
55
|
-
res.windowHeight =
|
|
56
|
-
res.
|
|
63
|
+
res.pixelRatio = display && (Math.round(display.xDPI / display.width * 100) / 100) // 设备像素比,number
|
|
64
|
+
res.platform = 'harmony' // 客户端平台 string
|
|
65
|
+
res.safeArea = safeArea // 在竖屏正方向下的安全区域 General.SafeAreaResult
|
|
66
|
+
res.screenHeight = display?.height // 屏幕高度,单位px number
|
|
67
|
+
res.screenWidth = display?.width // 屏幕宽度,单位px number
|
|
68
|
+
res.statusBarHeight = safeArea?.top // 状态栏的高度,单位px number
|
|
69
|
+
res.system = deviceInfo?.osFullName // 操作系统及版本 string
|
|
70
|
+
// Note: 更新配置时才能记录
|
|
71
|
+
res.theme = AppStorage.get('__TARO_APP_CONFIG')?.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK ? 'dark' : 'light' // 系统当前主题,取值为light或dark 'light' | 'dark'
|
|
72
|
+
res.windowHeight = display?.height // 可使用窗口高度,单位px number
|
|
73
|
+
res.windowWidth = display?.width // 可使用窗口宽度,单位px number
|
|
74
|
+
res.version = deviceInfo?.displayVersion // 版本号 string
|
|
57
75
|
|
|
58
76
|
return res
|
|
59
77
|
}
|
|
@@ -2,7 +2,7 @@ import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_E
|
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
6
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
7
|
|
|
8
8
|
import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
|
|
@@ -60,7 +60,7 @@ export struct TaroCheckbox {
|
|
|
60
60
|
this.node.updateComponent()
|
|
61
61
|
} else {
|
|
62
62
|
this.node.updateCheckedValue(value)
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
if (value) {
|
|
65
65
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
66
66
|
eventHandler(event, 'change', this.node)
|
|
@@ -3,7 +3,7 @@ import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBL
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
@@ -3,7 +3,7 @@ import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
|
|
@@ -2,7 +2,7 @@ import type { TaroMovableAreaElement, TaroStyleType } from '@tarojs/runtime'
|
|
|
2
2
|
import commonStyleModify from './style'
|
|
3
3
|
import { createLazyChildren } from './render'
|
|
4
4
|
|
|
5
|
-
import { FlexManager } from './utils/
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
6
|
import { getNormalAttributes } from './utils/helper'
|
|
7
7
|
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ import type { TaroMovableViewElement, TaroStyleType } from '@tarojs/runtime'
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
5
|
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { getNormalAttributes, } from './utils/helper'
|
|
8
8
|
@Extend(Row)
|
|
9
9
|
function rowAttrs(style: TaroStyleType) {
|
|
@@ -3,7 +3,7 @@ import { createLazyChildren } from './render'
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { getSingleSelector, getMultiSelector } from './utils'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
@@ -238,8 +238,8 @@ export default struct TaroPicker {
|
|
|
238
238
|
break
|
|
239
239
|
case 'time': {
|
|
240
240
|
const hour = new Date().getHours()
|
|
241
|
-
const minute = new Date().getMinutes()
|
|
242
|
-
|
|
241
|
+
const minute = new Date().getMinutes()
|
|
242
|
+
|
|
243
243
|
defaultResetValue = `${('00'+hour).slice(-2)}:${('00'+minute).slice(-2)}`
|
|
244
244
|
break
|
|
245
245
|
}
|
|
@@ -248,7 +248,7 @@ export default struct TaroPicker {
|
|
|
248
248
|
const day = data[1]
|
|
249
249
|
const month = data[0]
|
|
250
250
|
const year = data[2]
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
defaultResetValue = `${year}-${month}-${day}`
|
|
253
253
|
break
|
|
254
254
|
}
|
|
@@ -256,7 +256,7 @@ export default struct TaroPicker {
|
|
|
256
256
|
defaultResetValue = ''
|
|
257
257
|
break
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
|
|
260
260
|
this.node._isInit = true
|
|
261
261
|
this.node._reset = this.node.value || defaultResetValue
|
|
262
262
|
}
|
|
@@ -3,7 +3,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
|
|
@@ -36,7 +36,7 @@ function themeStyles(isDisabled: boolean) {
|
|
|
36
36
|
@Component
|
|
37
37
|
export struct TaroRadio {
|
|
38
38
|
@ObjectLink node: TaroRadioElement
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
aboutToAppear () {
|
|
41
41
|
if (this.node && !this.node._isInit) {
|
|
42
42
|
this.node._isInit = true
|
|
@@ -61,7 +61,7 @@ export struct TaroRadio {
|
|
|
61
61
|
this.node.updateComponent()
|
|
62
62
|
} else {
|
|
63
63
|
this.node.updateCheckedValue(value)
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
if (value) {
|
|
66
66
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
67
67
|
eventHandler(event, 'change', this.node)
|
|
@@ -2,7 +2,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL
|
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
7
7
|
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
8
8
|
|
|
@@ -49,8 +49,8 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
49
49
|
deltaY: vp2px(yOffset),
|
|
50
50
|
scrollLeft: vp2px(currentXOffset),
|
|
51
51
|
scrollTop: vp2px(currentYOffset),
|
|
52
|
-
scrollWidth: vp2px(Number(node._scroll?.width)),
|
|
53
|
-
scrollHeight: vp2px(Number(node._scroll?.height)),
|
|
52
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
53
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
54
54
|
}
|
|
55
55
|
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
56
56
|
|
|
@@ -91,7 +91,7 @@ export default struct TaroScrollView {
|
|
|
91
91
|
.rowAttrs(getNormalAttributes(this.node))
|
|
92
92
|
.width(null)
|
|
93
93
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
94
|
-
this.node._scroll = areaResult
|
|
94
|
+
this.node._nodeInfo._scroll = areaResult
|
|
95
95
|
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
96
96
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
97
97
|
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
@@ -105,7 +105,7 @@ export default struct TaroScrollView {
|
|
|
105
105
|
.height(null)
|
|
106
106
|
.alignItems(HorizontalAlign.Start)
|
|
107
107
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
108
|
-
this.node._scroll = areaResult
|
|
108
|
+
this.node._nodeInfo._scroll = areaResult
|
|
109
109
|
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
110
110
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
111
111
|
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
@@ -127,5 +127,6 @@ export default struct TaroScrollView {
|
|
|
127
127
|
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
128
128
|
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
129
129
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
130
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
130
131
|
}
|
|
131
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isUndefined } from '@tarojs/shared'
|
|
2
2
|
import { ObjectAssign } from '@tarojs/runtime'
|
|
3
3
|
|
|
4
|
-
import { FlexManager } from './
|
|
4
|
+
import { FlexManager } from './flexManager'
|
|
5
5
|
import { TEXT_DEFAULT_STYLE } from './constant/style'
|
|
6
6
|
|
|
7
7
|
import type { StandardProps, TextProps } from '@tarojs/components/types'
|
|
@@ -25,7 +25,7 @@ export function getFontAttributes (node: TaroElement): TaroTextStyleType {
|
|
|
25
25
|
// 模拟 div 自动撑满父元素的情况
|
|
26
26
|
function isMaxWidthView (node: TaroElement) {
|
|
27
27
|
const parentNode: TaroElement = node.parentNode as TaroElement
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
return node.tagName === 'VIEW' && parentNode && parentNode.tagName === 'VIEW' &&
|
|
30
30
|
!(FlexManager.isFlexNode(parentNode) && FlexManager.flexOptions(parentNode).direction !== FlexDirection.Column)
|
|
31
31
|
}
|
|
@@ -3,7 +3,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroViewElement, TaroStyleType, TaroAny } from '@tarojs/runtime'
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ export {
|
|
|
158
158
|
const PLATFORM_NAME = 'harmony';
|
|
159
159
|
const PACKAGE_NAME = '@tarojs/plugin-platform-harmony-ets';
|
|
160
160
|
const PLUGIN_NAME = 'TaroHarmony';
|
|
161
|
-
const HARMONY_SCOPES = [/^@system\./, /^@ohos\./, /^@hmscore\//];
|
|
161
|
+
const HARMONY_SCOPES = [/^@system\./, /^@ohos\./, /^@hmscore\//, /^@jd-oh\//];
|
|
162
162
|
|
|
163
163
|
function parseRelativePath(from, to) {
|
|
164
164
|
const relativePath = path.relative(from, to).replace(/\\/g, '/');
|