@tarojs/plugin-platform-harmony-ets 4.0.0-beta.12 → 4.0.0-beta.121
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 +60 -25
- package/dist/apis/base/weapp/life-cycle.ts +1 -1
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +2 -6
- package/dist/apis/index.ts +25 -17
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/route/index.ts +1 -2
- package/dist/apis/storage/index.ts +135 -131
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +3 -2
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +2 -2
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +6 -6
- package/dist/apis/ui/tab-bar.ts +4 -5
- package/dist/apis/utils/index.ts +20 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +36 -9
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +69 -60
- package/dist/components-harmony-ets/form.ets +33 -15
- package/dist/components-harmony-ets/icon.ets +16 -8
- package/dist/components-harmony-ets/image.ets +22 -6
- package/dist/components-harmony-ets/index.ets +39 -0
- package/dist/components-harmony-ets/innerHtml.ets +6 -5
- package/dist/components-harmony-ets/input.ets +63 -37
- package/dist/components-harmony-ets/label.ets +43 -21
- package/dist/components-harmony-ets/listView.ets +32 -0
- package/dist/components-harmony-ets/movableArea.ets +110 -51
- package/dist/components-harmony-ets/movableView.ets +74 -47
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +36 -33
- package/dist/components-harmony-ets/progress.ets +31 -24
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +75 -66
- package/dist/components-harmony-ets/richText.ets +4 -25
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +46 -42
- package/dist/components-harmony-ets/slider.ets +19 -15
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +386 -129
- package/dist/components-harmony-ets/swiper.ets +42 -5
- package/dist/components-harmony-ets/switch.ets +36 -32
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +102 -46
- package/dist/components-harmony-ets/textArea.ets +49 -34
- package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
- package/dist/components-harmony-ets/utils/flexManager.ets +49 -19
- package/dist/components-harmony-ets/utils/helper.ets +20 -8
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +169 -91
- package/dist/components-harmony-ets/video.ets +28 -20
- package/dist/components-harmony-ets/view.ets +45 -39
- package/dist/components-harmony-ets/webView.ets +6 -5
- package/dist/index.d.ts +152 -0
- package/dist/index.js +73 -44
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/URL.ts +2 -0
- package/dist/runtime-ets/bom/document.ts +5 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -3
- package/dist/runtime-ets/bom/history.ts +1 -0
- package/dist/runtime-ets/bom/location.ts +1 -0
- package/dist/runtime-ets/bom/navigator.ts +1 -21
- package/dist/runtime-ets/bom/raf.ts +1 -37
- package/dist/runtime-ets/bom/window.ts +10 -4
- package/dist/runtime-ets/constant.ts +17 -10
- package/dist/runtime-ets/current.ts +5 -2
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +419 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- package/dist/runtime-ets/dom/document.ts +9 -12
- package/dist/runtime-ets/dom/element/canvas.ts +137 -0
- package/dist/runtime-ets/dom/element/element.ts +379 -55
- package/dist/runtime-ets/dom/element/form.ts +26 -22
- package/dist/runtime-ets/dom/element/index.ts +22 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +0 -1
- package/dist/runtime-ets/dom/element/movableView.ts +238 -2
- package/dist/runtime-ets/dom/element/normal.ts +27 -6
- package/dist/runtime-ets/dom/element/progress.ts +0 -2
- package/dist/runtime-ets/dom/element/text.ts +0 -8
- package/dist/runtime-ets/dom/element/video.ts +4 -4
- package/dist/runtime-ets/dom/element/webView.ts +4 -5
- package/dist/runtime-ets/dom/event-source.ts +1 -0
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -4
- package/dist/runtime-ets/dom/node.ts +53 -22
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/emitter/emitter.ts +1 -0
- package/dist/runtime-ets/env.ts +1 -0
- package/dist/runtime-ets/index.ts +23 -7
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/interface/index.ts +6 -0
- package/dist/runtime-ets/utils/index.ts +78 -19
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-ets/utils/router.ts +9 -0
- package/dist/runtime-framework/react/app.ts +15 -11
- package/dist/runtime-framework/react/hooks.ts +1 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +217 -81
- package/dist/runtime-framework/react/page.ts +4 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +29 -46
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +73 -29
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +3 -5
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +574 -285
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +574 -285
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +5 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +1 -1
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { Current } from '@tarojs/runtime'
|
|
2
3
|
|
|
3
4
|
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
|
|
4
5
|
|
|
@@ -29,10 +30,16 @@ export function showToast (options) {
|
|
|
29
30
|
return callAsyncFail(reject, res, options)
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
const uiContext = Current?.page?.getUIContext?.()
|
|
35
|
+
|
|
36
|
+
if (!uiContext) return
|
|
37
|
+
|
|
38
|
+
uiContext.getPromptAction().showToast({
|
|
33
39
|
message: options.title,
|
|
34
40
|
duration: options.duration,
|
|
35
|
-
bottom: options.bottom
|
|
41
|
+
bottom: options.bottom,
|
|
42
|
+
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
36
43
|
})
|
|
37
44
|
callAsyncSuccess(resolve, resCallback('showToast'), options)
|
|
38
45
|
})
|
|
@@ -72,37 +79,25 @@ export function showModal (options) {
|
|
|
72
79
|
})
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
return new Promise(resolve => {
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
76
83
|
const modalOptions = {
|
|
77
84
|
title,
|
|
78
85
|
message: content,
|
|
79
86
|
buttons: buttons,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
resolve,
|
|
95
|
-
{
|
|
96
|
-
...resCallback('showModal'),
|
|
97
|
-
confirm: false,
|
|
98
|
-
cancel: true
|
|
99
|
-
},
|
|
100
|
-
options
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
// 鸿蒙没有失败方法,只有取消
|
|
105
|
-
cancel: (_) => {
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
const uiContext = Current?.page?.getUIContext?.()
|
|
91
|
+
|
|
92
|
+
if (!uiContext) return
|
|
93
|
+
|
|
94
|
+
uiContext.getPromptAction().showDialog(modalOptions, (error, data) => {
|
|
95
|
+
if (error) {
|
|
96
|
+
const res = { errMsg: error }
|
|
97
|
+
callAsyncFail(reject, res, options)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (data.index === 0 && showCancel) {
|
|
106
101
|
callAsyncSuccess(
|
|
107
102
|
resolve,
|
|
108
103
|
{
|
|
@@ -112,10 +107,19 @@ export function showModal (options) {
|
|
|
112
107
|
},
|
|
113
108
|
options
|
|
114
109
|
)
|
|
110
|
+
} else {
|
|
111
|
+
callAsyncSuccess(
|
|
112
|
+
resolve,
|
|
113
|
+
{
|
|
114
|
+
...resCallback('showModal'),
|
|
115
|
+
confirm: true,
|
|
116
|
+
cancel: false,
|
|
117
|
+
content: null
|
|
118
|
+
},
|
|
119
|
+
options
|
|
120
|
+
)
|
|
115
121
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
prompt.showDialog(modalOptions)
|
|
122
|
+
})
|
|
119
123
|
})
|
|
120
124
|
}
|
|
121
125
|
|
|
@@ -152,45 +156,40 @@ export function showActionSheet (options) {
|
|
|
152
156
|
|
|
153
157
|
const actionSheetOptions = {
|
|
154
158
|
title,
|
|
155
|
-
buttons
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
// 取消方法,并非失败
|
|
167
|
-
fail: (data) => {
|
|
159
|
+
buttons
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
const uiContext = Current?.page?.getUIContext?.()
|
|
164
|
+
|
|
165
|
+
if (!uiContext) return
|
|
166
|
+
|
|
167
|
+
uiContext.getPromptAction().showActionMenu(actionSheetOptions, (error, data) => {
|
|
168
|
+
if (error) {
|
|
168
169
|
callAsyncFail(
|
|
169
170
|
reject,
|
|
170
171
|
{
|
|
171
172
|
...data,
|
|
172
|
-
errMsg: data.errMsg
|
|
173
|
+
errMsg: data.errMsg?.replace('showActionMenu', 'showActionSheet')
|
|
173
174
|
},
|
|
174
175
|
options
|
|
175
176
|
)
|
|
176
177
|
}
|
|
177
|
-
}
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
duration: 10,
|
|
188
|
-
bottom: '9999px'
|
|
179
|
+
callAsyncSuccess(
|
|
180
|
+
resolve,
|
|
181
|
+
{
|
|
182
|
+
...data,
|
|
183
|
+
...resCallback('showActionSheet')
|
|
184
|
+
},
|
|
185
|
+
options
|
|
186
|
+
)
|
|
189
187
|
})
|
|
190
|
-
callAsyncSuccess(resolve, resCallback('hideToast'), options)
|
|
191
188
|
})
|
|
192
189
|
}
|
|
193
190
|
|
|
191
|
+
export const hideToast = /* @__PURE__ */ temporarilyNotSupport('hideToast')
|
|
192
|
+
|
|
194
193
|
export const showLoading = temporarilyNotSupport('showLoading')
|
|
195
194
|
export const hideLoading = temporarilyNotSupport('hideLoading')
|
|
196
195
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { eventCenter } from '@tarojs/runtime
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import { MethodHandler } from '../../utils/handler'
|
|
4
4
|
|
|
@@ -19,7 +19,7 @@ export const setNavigationBarTitle: typeof Taro.setNavigationBarTitle = function
|
|
|
19
19
|
|
|
20
20
|
export const setNavigationBarColor: typeof Taro.setNavigationBarColor = function (options) {
|
|
21
21
|
const { success, fail, complete } = options || {}
|
|
22
|
-
const handle = new MethodHandler({ name: '
|
|
22
|
+
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete })
|
|
23
23
|
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
25
|
eventCenter.trigger('__taroNavigationStyle', {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Current } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import { callAsyncSuccess } from '../utils'
|
|
3
|
+
import { callAsyncFail, callAsyncSuccess } from '../utils'
|
|
4
4
|
|
|
5
5
|
import type Taro from '@tarojs/taro/types'
|
|
6
6
|
|
|
7
7
|
export const startPullDownRefresh: typeof Taro.startPullDownRefresh = function (options) {
|
|
8
|
-
return new Promise(resolve => {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
9
|
const taro = (Current as any).taro
|
|
10
10
|
const page = taro.getCurrentInstance().page
|
|
11
11
|
|
|
12
|
+
if (!page) {
|
|
13
|
+
return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options)
|
|
14
|
+
}
|
|
12
15
|
if (page.isRefreshing instanceof Array) {
|
|
13
16
|
const index = page.tabBarCurrentIndex || 0
|
|
14
17
|
page.isRefreshing[index] = true
|
|
@@ -23,10 +26,13 @@ export const startPullDownRefresh: typeof Taro.startPullDownRefresh = function (
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export const stopPullDownRefresh: typeof Taro.stopPullDownRefresh = function (options) {
|
|
26
|
-
return new Promise(resolve => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
27
30
|
const taro = (Current as any).taro
|
|
28
31
|
const page = taro.getCurrentInstance().page
|
|
29
32
|
|
|
33
|
+
if (!page) {
|
|
34
|
+
return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options)
|
|
35
|
+
}
|
|
30
36
|
if (page.isRefreshing instanceof Array) {
|
|
31
37
|
const index = page.tabBarCurrentIndex || 0
|
|
32
38
|
page.isRefreshing[index] = false
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* 文档地址 https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-framework-syntax-js-0000000000611432
|
|
7
7
|
*/
|
|
8
8
|
import { AREA_CHANGE_EVENT_NAME, Current, findChildNodeWithDFS, getPageScrollerOrNode, setNodeEventCallbackAndTriggerComponentUpdate } from '@tarojs/runtime'
|
|
9
|
-
import { pxTransformHelper } from '@tarojs/taro'
|
|
10
9
|
|
|
10
|
+
import { pxTransformHelper } from '../../index'
|
|
11
11
|
import { MethodHandler } from '../../utils/handler'
|
|
12
12
|
|
|
13
13
|
import type Taro from '@tarojs/taro/types'
|
|
@@ -34,8 +34,8 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
|
34
34
|
const page = taro.getCurrentInstance().page
|
|
35
35
|
|
|
36
36
|
let scrollValue = -1
|
|
37
|
-
let scroller = page
|
|
38
|
-
const currentPageNode = getPageScrollerOrNode(page
|
|
37
|
+
let scroller = getPageScrollerOrNode(page?.scroller, page)
|
|
38
|
+
const currentPageNode = getPageScrollerOrNode(page?.node, page)
|
|
39
39
|
|
|
40
40
|
if (scrollTop || typeof scrollTop === 'number') {
|
|
41
41
|
scrollValue = scrollTop
|
|
@@ -66,14 +66,14 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
|
66
66
|
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true)
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (scrollValue === -1) {
|
|
69
|
+
if (!scroller || scrollValue === -1) {
|
|
72
70
|
return handle.fail({
|
|
73
71
|
errMsg: '请检查传入的 scrollTop 或 selector 是否合法'
|
|
74
72
|
}, { resolve, reject })
|
|
75
73
|
}
|
|
76
74
|
|
|
75
|
+
const { xOffset } = scroller.currentOffset()
|
|
76
|
+
|
|
77
77
|
try {
|
|
78
78
|
scroller.scrollTo({
|
|
79
79
|
xOffset,
|
package/dist/apis/ui/tab-bar.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Current } from '@tarojs/runtime'
|
|
2
|
-
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
|
|
1
|
+
import { Current, eventCenter } from '@tarojs/runtime'
|
|
3
2
|
|
|
4
3
|
import { callAsyncFail, callAsyncSuccess } from '../utils'
|
|
5
4
|
|
|
@@ -22,7 +21,7 @@ const toggleTabBar = function<T extends ToggleAPIs['type']> (type: T): Extract<T
|
|
|
22
21
|
return new Promise((resolve, reject) => {
|
|
23
22
|
const taro = (Current as any).taro
|
|
24
23
|
const page = taro.getCurrentInstance().page
|
|
25
|
-
const currentData = page
|
|
24
|
+
const currentData = page?._data?.taroTabBar || page?.tabBar
|
|
26
25
|
const res = { errMsg: `${type}TabBar:ok` }
|
|
27
26
|
const error = { errMsg: `${type}TabBar:fail not TabBar page` }
|
|
28
27
|
|
|
@@ -49,7 +48,7 @@ export const setTabBarStyle: typeof Taro.setTabBarStyle = function (options = {}
|
|
|
49
48
|
return new Promise((resolve, reject) => {
|
|
50
49
|
const taro = (Current as any).taro
|
|
51
50
|
const page = taro.getCurrentInstance().page
|
|
52
|
-
const currentData = page
|
|
51
|
+
const currentData = page?._data?.taroTabBar || page?.tabBar
|
|
53
52
|
const res = { errMsg: 'setTabBarStyle:ok' }
|
|
54
53
|
const error = { errMsg: 'setTabBarStyle:fail not TabBar page' }
|
|
55
54
|
|
|
@@ -74,7 +73,7 @@ export const setTabBarItem: typeof Taro.setTabBarItem = function (options) {
|
|
|
74
73
|
return new Promise((resolve, reject) => {
|
|
75
74
|
const taro = (Current as any).taro
|
|
76
75
|
const page = taro.getCurrentInstance().page
|
|
77
|
-
const currentData = page
|
|
76
|
+
const currentData = page?._data?.taroTabBar || page?.tabBar
|
|
78
77
|
const res = { errMsg: 'setTabBarItem:ok' }
|
|
79
78
|
const error = { errMsg: 'setTabBarItem:fail not TabBar page' }
|
|
80
79
|
|
package/dist/apis/utils/index.ts
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
|
|
2
|
+
import { Current, eventCenter } from '@tarojs/runtime'
|
|
2
3
|
|
|
3
4
|
import { ICallbackResult, MethodHandler } from './handler'
|
|
4
5
|
|
|
5
6
|
import type { FunctionType, IAsyncParams } from './types'
|
|
6
7
|
|
|
7
8
|
export * from './validate'
|
|
9
|
+
export { MethodHandler }
|
|
8
10
|
export { noop } from '@tarojs/shared'
|
|
9
11
|
|
|
12
|
+
export function requestPermissions (permissions: string[]) {
|
|
13
|
+
return new Promise<void>((resolve, reject) => {
|
|
14
|
+
const context = getContext(Current?.page)
|
|
15
|
+
const atManager = abilityAccessCtrl.createAtManager()
|
|
16
|
+
|
|
17
|
+
atManager.requestPermissionsFromUser(context, permissions, (err, _) => {
|
|
18
|
+
if (err) {
|
|
19
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
20
|
+
reject(`[Taro] 请求用户授权 ${permissions.join('、')} 失败:${JSON.stringify(err)}`)
|
|
21
|
+
} else {
|
|
22
|
+
resolve()
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
export function object2String (obj) {
|
|
11
29
|
let str = ''
|
|
12
30
|
for (const item in obj) {
|
|
@@ -19,7 +37,7 @@ export function temporarilyNotSupport (name: string, recommended?: string) {
|
|
|
19
37
|
return (option = {}, ...args) => {
|
|
20
38
|
const { success, fail, complete } = option as any
|
|
21
39
|
const handle = new MethodHandler({ name, success, fail, complete })
|
|
22
|
-
let errMsg =
|
|
40
|
+
let errMsg = `暂时不支持 API ${name}`
|
|
23
41
|
if (recommended) {
|
|
24
42
|
errMsg += `, 请使用 ${recommended}`
|
|
25
43
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const READ_IMAGEVIDEO_PERMISSIONS = 'ohos.permission.READ_IMAGEVIDEO'
|
|
2
|
+
export const READ_MEDIA_PERMISSIONS = 'ohos.permission.READ_MEDIA'
|
|
3
|
+
export const WRITE_MEDIA_PERMISSIONS = 'ohos.permission.WRITE_MEDIA'
|
|
4
|
+
export const MEDIA_LOCATION_PERMISSIONS = 'ohos.permission.MEDIA_LOCATION'
|
|
5
|
+
|
|
6
|
+
export const IMAGE_PERMISSION = [READ_IMAGEVIDEO_PERMISSIONS, READ_MEDIA_PERMISSIONS, WRITE_MEDIA_PERMISSIONS, MEDIA_LOCATION_PERMISSIONS]
|
|
@@ -19,31 +19,33 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
19
19
|
constructor(component: any, options: Taro.createIntersectionObserver.Option = {}) {
|
|
20
20
|
const taro = (Current as any).taro
|
|
21
21
|
const page = taro.getCurrentInstance().page
|
|
22
|
-
|
|
23
|
-
this._component = component ||
|
|
22
|
+
|
|
23
|
+
this._component = component || getPageScrollerOrNode(page?.node, page)
|
|
24
24
|
Object.assign(this._options, options)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
public disconnect (): void {
|
|
28
|
-
if (this._observerNodes) {
|
|
28
|
+
if (this._observerNodes && this._component) {
|
|
29
29
|
if (this._observerNodes instanceof Array) {
|
|
30
30
|
this._observerNodes.forEach((n: TaroElement & any) => {
|
|
31
31
|
disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME)
|
|
32
32
|
// @ts-ignore
|
|
33
|
-
n._nodeInfo
|
|
33
|
+
n._nodeInfo.thresholds = null
|
|
34
34
|
})
|
|
35
35
|
} else {
|
|
36
36
|
disconnectEvent(this._observerNodes, VISIBLE_CHANGE_EVENT_NAME)
|
|
37
37
|
// @ts-ignore
|
|
38
38
|
if (this._observerNodes._nodeInfo) {
|
|
39
39
|
// @ts-ignore
|
|
40
|
-
this._observerNodes._nodeInfo
|
|
40
|
+
this._observerNodes._nodeInfo.thresholds = null
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {
|
|
47
|
+
if (!this._component) return
|
|
48
|
+
|
|
47
49
|
const { observeAll, thresholds } = this._options
|
|
48
50
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll)
|
|
49
51
|
this._observerNodes = node
|
|
@@ -52,20 +54,24 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
52
54
|
if (node instanceof Array) {
|
|
53
55
|
node.forEach(n => {
|
|
54
56
|
// @ts-ignore
|
|
55
|
-
n._nodeInfo
|
|
57
|
+
n._nodeInfo.thresholds = thresholds
|
|
56
58
|
|
|
57
59
|
setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
58
|
-
callback(this.handleResult(isVisible, currentRatio))
|
|
60
|
+
callback(this.handleResult(isVisible, currentRatio, n))
|
|
59
61
|
})
|
|
60
62
|
})
|
|
61
63
|
} else {
|
|
62
64
|
// @ts-ignore
|
|
63
|
-
node._nodeInfo
|
|
65
|
+
node._nodeInfo.thresholds = thresholds
|
|
64
66
|
|
|
65
67
|
setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
66
|
-
callback(this.handleResult(isVisible, currentRatio))
|
|
68
|
+
callback(this.handleResult(isVisible, currentRatio, node))
|
|
67
69
|
})
|
|
68
70
|
}
|
|
71
|
+
} else {
|
|
72
|
+
callback({
|
|
73
|
+
errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
|
|
74
|
+
})
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
|
|
@@ -80,8 +86,10 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
// @ts-ignore
|
|
83
|
-
private handleResult (isVisible: boolean, currentRatio: number): Taro.IntersectionObserver.ObserveCallbackResult {
|
|
89
|
+
private handleResult (isVisible: boolean, currentRatio: number, node: TaroElement): Taro.IntersectionObserver.ObserveCallbackResult {
|
|
84
90
|
const result = {
|
|
91
|
+
id: node.id,
|
|
92
|
+
dataset: node.dataset,
|
|
85
93
|
intersectionRatio: currentRatio,
|
|
86
94
|
// TODO 未做,等待能拿到element的info信息
|
|
87
95
|
boundingClientRect: {
|
|
@@ -112,7 +112,7 @@ function filter (fields, dom) {
|
|
|
112
112
|
return res
|
|
113
113
|
}
|
|
114
114
|
if (context) {
|
|
115
|
-
// TODO: 暂未实现获取
|
|
115
|
+
// TODO: 暂未实现获取 context
|
|
116
116
|
// const typeName = dom.type
|
|
117
117
|
// if (/^video/i.test(typeName)) {
|
|
118
118
|
// return { context: dom }
|
|
@@ -179,37 +179,50 @@ function filter (fields, dom) {
|
|
|
179
179
|
|
|
180
180
|
function querySelector (selector, selectAll) {
|
|
181
181
|
if (typeof selector === 'string') {
|
|
182
|
-
return
|
|
182
|
+
return selector.split(',').reduce((prev, current) => {
|
|
183
|
+
const item = current.trim()
|
|
184
|
+
|
|
185
|
+
return prev.concat(parseHandler(item, selectAll))
|
|
186
|
+
}, [])
|
|
183
187
|
}
|
|
184
|
-
return
|
|
188
|
+
return []
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
function queryBat (queue, cb) {
|
|
188
192
|
const result: any = []
|
|
189
193
|
const taro = (Current as any).taro
|
|
190
194
|
const page = taro.getCurrentInstance().page
|
|
191
|
-
const element = getPageScrollerOrNode(page
|
|
195
|
+
const element = getPageScrollerOrNode(page?.node, page)
|
|
192
196
|
|
|
193
|
-
if (element
|
|
197
|
+
if (!element) return null
|
|
194
198
|
|
|
195
199
|
arr = []
|
|
196
200
|
traversalDFSDom(element)
|
|
197
|
-
queue.forEach(item => {
|
|
201
|
+
queue.forEach((item) => {
|
|
198
202
|
const { selector, single, fields } = item
|
|
199
|
-
const nodeList = querySelector(selector, !single)
|
|
200
203
|
|
|
201
|
-
|
|
204
|
+
if (single) {
|
|
205
|
+
const dom = querySelector(selector, !single)[0]
|
|
202
206
|
// eslint-disable-next-line no-async-promise-executor
|
|
203
|
-
|
|
207
|
+
result.push(new Promise(async resolve => {
|
|
204
208
|
await setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true)
|
|
205
|
-
|
|
206
209
|
resolve(filter(fields, dom))
|
|
207
|
-
})
|
|
208
|
-
}
|
|
210
|
+
}))
|
|
211
|
+
} else {
|
|
212
|
+
const nodeList = querySelector(selector, !single)
|
|
213
|
+
result.push(nodeList.map(dom => {
|
|
214
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
215
|
+
return new Promise(async resolve => {
|
|
216
|
+
await setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true)
|
|
217
|
+
|
|
218
|
+
resolve(filter(fields, dom))
|
|
219
|
+
})
|
|
220
|
+
}))
|
|
221
|
+
}
|
|
209
222
|
})
|
|
210
223
|
|
|
211
224
|
Promise.all(result.map(item => {
|
|
212
|
-
return Promise.all(item)
|
|
225
|
+
return item instanceof Array ? Promise.all(item) : item
|
|
213
226
|
})).then(data => {
|
|
214
227
|
cb(data)
|
|
215
228
|
})
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
|
-
import { createLazyChildren } from './render'
|
|
3
2
|
import commonStyleModify from './style'
|
|
4
3
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
5
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
5
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
6
|
|
|
8
|
-
import type { TaroAny,
|
|
7
|
+
import type { TaroAny, TaroButtonElement, TaroEvent, TaroStyleType } from '@tarojs/runtime'
|
|
8
|
+
|
|
9
|
+
interface ButtonAttrs {
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Extend(Button)
|
|
14
|
+
function attrs(attr: ButtonAttrs) {
|
|
15
|
+
.enabled(!attr.disabled)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getAttributes(node: TaroButtonElement): ButtonAttrs {
|
|
19
|
+
return {
|
|
20
|
+
disabled: node._attrs.disabled || false,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
9
23
|
|
|
10
24
|
@Extend(Button)
|
|
11
25
|
function themeStyles(style: TaroStyleType) {
|
|
@@ -66,13 +80,13 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
|
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
function getButtonWidth (node: TaroButtonElement) {
|
|
83
|
+
function getButtonWidth (node: TaroButtonElement): string | number {
|
|
70
84
|
const isMini = node._attrs.size === 'mini'
|
|
71
85
|
|
|
72
86
|
return isMini ? convertNumber2VP(120) : '100%'
|
|
73
87
|
}
|
|
74
88
|
|
|
75
|
-
function getButtonHeight (node: TaroButtonElement) {
|
|
89
|
+
function getButtonHeight (node: TaroButtonElement): string | number {
|
|
76
90
|
const isMini = node._attrs.size === 'mini'
|
|
77
91
|
|
|
78
92
|
return isMini ? convertNumber2VP(60) : convertNumber2VP(92)
|
|
@@ -96,20 +110,33 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
|
|
|
96
110
|
|
|
97
111
|
@Component
|
|
98
112
|
export default struct TaroButton {
|
|
113
|
+
@Builder customBuilder() {}
|
|
114
|
+
@BuilderParam createLazyChildren: (node: TaroButtonElement, layer?: number) => void = this.customBuilder
|
|
99
115
|
@ObjectLink node: TaroButtonElement
|
|
116
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
117
|
+
|
|
118
|
+
aboutToAppear(): void {
|
|
119
|
+
if (this.node) {
|
|
120
|
+
this.node._instance = this
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
100
124
|
build() {
|
|
101
125
|
Button({ stateEffect: !this.node._attrs.disabled }) {
|
|
102
|
-
|
|
103
|
-
|
|
126
|
+
if (this.node._attrs.loading) {
|
|
127
|
+
Row() {
|
|
104
128
|
LoadingProgress()
|
|
105
129
|
.width(20).height(20)
|
|
106
130
|
.color(getThemeAttributes(this.node).color)
|
|
131
|
+
this.createLazyChildren(this.node, 0)
|
|
107
132
|
}
|
|
108
|
-
|
|
133
|
+
} else {
|
|
134
|
+
this.createLazyChildren(this.node, 0)
|
|
109
135
|
}
|
|
110
136
|
}
|
|
111
137
|
.themeStyles(getThemeAttributes(this.node))
|
|
112
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
138
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
139
|
+
.attrs(getAttributes(this.node))
|
|
113
140
|
.constraintSize({
|
|
114
141
|
minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
|
|
115
142
|
minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
|
|
@@ -125,7 +152,7 @@ export default struct TaroButton {
|
|
|
125
152
|
}
|
|
126
153
|
eventHandler(e, 'click', this.node)
|
|
127
154
|
})
|
|
128
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
155
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
129
156
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
130
157
|
this.node._nodeInfo.areaInfo = res[1]
|
|
131
158
|
}))
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { TaroAny, TaroCanvasElement } from '@tarojs/runtime'
|
|
2
|
+
import { cancelAnimationFrame, requestAnimationFrame } from '@tarojs/runtime'
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
|
|
5
|
+
@Component
|
|
6
|
+
export default struct TaroCanvas {
|
|
7
|
+
@ObjectLink node: TaroCanvasElement
|
|
8
|
+
rafId: number = 0
|
|
9
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
10
|
+
|
|
11
|
+
aboutToAppear(): void {
|
|
12
|
+
if (this.node) {
|
|
13
|
+
this.node._instance = this
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
aboutToDisappear() {
|
|
18
|
+
if(this.rafId) {
|
|
19
|
+
cancelAnimationFrame(this.rafId)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
Canvas(this.node._context)
|
|
25
|
+
.attributeModifier(commonStyleModify.setNode(this.node as TaroAny, {
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
backgroundColor: '#ffff00'
|
|
29
|
+
}).setAnimationStyle(this.overwriteStyle))
|
|
30
|
+
.onReady(() => {
|
|
31
|
+
const context = this.node._context
|
|
32
|
+
|
|
33
|
+
const draw = () => {
|
|
34
|
+
if (this.node._drawList.length) {
|
|
35
|
+
while (this.node._drawList.length) {
|
|
36
|
+
const item = this.node._drawList.shift()
|
|
37
|
+
if (item) {
|
|
38
|
+
if (typeof context[item.key] === 'function') {
|
|
39
|
+
context[item.key](...[].concat(item.value))
|
|
40
|
+
} else {
|
|
41
|
+
context[item.key] = item.value
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
this.rafId = requestAnimationFrame(draw)
|
|
47
|
+
}
|
|
48
|
+
draw()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|