@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10
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/apis.ts +6 -2
- package/dist/apis/base/crypto.ts +4 -0
- package/dist/apis/base/debug.ts +5 -0
- package/dist/apis/base/index.ts +9 -1
- package/dist/apis/base/performance.ts +8 -0
- package/dist/apis/base/system.ts +74 -21
- package/dist/apis/base/update.ts +5 -0
- package/dist/apis/base/weapp/app-event.ts +75 -0
- package/dist/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/apis/canvas/index.ts +27 -0
- package/dist/apis/data-analysis/index.ts +6 -0
- package/dist/apis/device/accelerometer.ts +2 -1
- package/dist/apis/device/accessibility.ts +4 -0
- package/dist/apis/device/battery.ts +2 -2
- package/dist/apis/device/bluetooth-ble.ts +19 -0
- package/dist/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/apis/device/bluetooth.ts +16 -0
- package/dist/apis/device/calendar.ts +5 -0
- package/dist/apis/device/clipboard.ts +17 -9
- package/dist/apis/device/compass.ts +21 -0
- package/dist/apis/device/contact.ts +5 -0
- package/dist/apis/device/crypto.ts +4 -0
- package/dist/apis/device/gyroscope.ts +7 -0
- package/dist/apis/device/iBeacon.ts +10 -0
- package/dist/apis/device/index.ts +15 -0
- package/dist/apis/device/keyboard.ts +2 -1
- package/dist/apis/device/memory.ts +10 -3
- package/dist/apis/device/motion.ts +6 -0
- package/dist/apis/device/network.ts +26 -9
- package/dist/apis/device/nfc.ts +10 -0
- package/dist/apis/device/phone.ts +2 -1
- package/dist/apis/device/scan.ts +4 -0
- package/dist/apis/device/screen.ts +2 -1
- package/dist/apis/device/sms.ts +4 -0
- package/dist/apis/device/vibrate.ts +19 -11
- package/dist/apis/device/wifi.ts +15 -0
- package/dist/apis/ext/index.ts +5 -0
- package/dist/apis/files/index.ts +2 -1
- package/dist/apis/files/manager.ts +2 -1
- package/dist/apis/framework/index.ts +3 -8
- package/dist/apis/index.ts +27 -17
- package/dist/apis/location/index.ts +61 -68
- package/dist/apis/media/EditorContext.ts +32 -0
- package/dist/apis/media/audio/index.ts +18 -0
- package/dist/apis/media/background-audio/index.ts +16 -0
- package/dist/apis/media/camera.ts +16 -0
- package/dist/apis/media/common.ts +2 -1
- package/dist/apis/media/{image.ts → image/index.ts} +4 -3
- package/dist/apis/media/index.ts +10 -0
- package/dist/apis/media/live.ts +5 -0
- package/dist/apis/media/map.ts +4 -0
- package/dist/apis/media/media-recorder.ts +4 -0
- package/dist/apis/media/recorder.ts +6 -0
- package/dist/apis/media/video/VideoContext.ts +68 -0
- package/dist/apis/media/{video.ts → video/index.ts} +13 -2
- package/dist/apis/media/video-decoder.ts +4 -0
- package/dist/apis/media/video-processing.ts +4 -0
- package/dist/apis/media/voip.ts +19 -0
- package/dist/apis/network/index.ts +3 -0
- package/dist/apis/network/mdns.ts +13 -0
- package/dist/apis/network/request.ts +7 -6
- package/dist/apis/network/tcp.ts +4 -0
- package/dist/apis/network/udp.ts +4 -0
- package/dist/apis/network/webSocket.ts +2 -6
- package/dist/apis/open-api/account.ts +4 -0
- package/dist/apis/open-api/address.ts +4 -0
- package/dist/apis/open-api/authorize.ts +5 -0
- package/dist/apis/open-api/card.ts +5 -0
- package/dist/apis/open-api/channels-live.ts +11 -0
- package/dist/apis/open-api/customer-service.ts +4 -0
- package/dist/apis/open-api/device-voip.ts +5 -0
- package/dist/apis/open-api/facial.ts +7 -0
- package/dist/apis/open-api/favorites.ts +5 -0
- package/dist/apis/open-api/group.ts +4 -0
- package/dist/apis/open-api/index.ts +20 -6
- package/dist/apis/open-api/invoice.ts +5 -0
- package/dist/apis/open-api/license-plate.ts +4 -0
- package/dist/apis/open-api/login.ts +6 -0
- package/dist/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/apis/open-api/privacy.ts +7 -0
- package/dist/apis/open-api/red-package.ts +4 -0
- package/dist/apis/open-api/settings.ts +5 -0
- package/dist/apis/open-api/soter.ts +6 -0
- package/dist/apis/open-api/subscribe-message.ts +6 -0
- package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
- package/dist/apis/open-api/werun.ts +5 -0
- package/dist/apis/payment/index.ts +6 -0
- package/dist/apis/route/index.ts +19 -28
- package/dist/apis/share/index.ts +33 -0
- package/dist/apis/storage/background-fetch.ts +7 -0
- package/dist/apis/storage/cache-manager.ts +4 -0
- package/dist/apis/storage/index.ts +158 -88
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +4 -19
- package/dist/apis/ui/custom-component.ts +8 -0
- package/dist/apis/ui/fonts.ts +4 -0
- package/dist/apis/ui/index.ts +8 -10
- package/dist/apis/ui/interaction/index.ts +45 -59
- package/dist/apis/ui/menu.ts +4 -0
- package/dist/apis/ui/navigation-bar/index.ts +60 -21
- package/dist/apis/ui/pull-down-refresh.ts +10 -4
- package/dist/apis/{page → ui/scroll}/index.ts +32 -27
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +24 -25
- package/dist/apis/wxml/index.ts +7 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +29 -17
- package/dist/components-harmony-ets/button.ets +106 -80
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +82 -148
- package/dist/components-harmony-ets/form.ets +45 -132
- package/dist/components-harmony-ets/icon.ets +66 -69
- package/dist/components-harmony-ets/image.ets +26 -61
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +7 -70
- package/dist/components-harmony-ets/input.ets +60 -146
- package/dist/components-harmony-ets/label.ets +86 -92
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +124 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- 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 +172 -198
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +85 -155
- package/dist/components-harmony-ets/richText.ets +15 -87
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +81 -149
- package/dist/components-harmony-ets/slider.ets +47 -94
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +396 -0
- package/dist/components-harmony-ets/swiper.ets +51 -151
- package/dist/components-harmony-ets/switch.ets +35 -76
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +131 -76
- package/dist/components-harmony-ets/textArea.ets +64 -140
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
- package/dist/components-harmony-ets/utils/helper.ets +18 -65
- 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 +55 -51
- package/dist/components-harmony-ets/utils/styles.ets +177 -65
- package/dist/components-harmony-ets/video.ets +70 -116
- package/dist/components-harmony-ets/view.ets +58 -64
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +230 -60
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +96 -0
- package/dist/runtime-ets/dom/class-list.ts +4 -6
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +36 -51
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +439 -0
- package/dist/runtime-ets/dom/element/form.ts +403 -0
- package/dist/runtime-ets/dom/element/index.ts +120 -0
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +242 -0
- package/dist/runtime-ets/dom/element/normal.ts +103 -0
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
- package/dist/runtime-ets/dom/element/text.ts +10 -0
- package/dist/runtime-ets/dom/element/video.ts +50 -0
- package/dist/runtime-ets/dom/element/webView.ts +68 -0
- package/dist/runtime-ets/dom/event.ts +26 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -3
- package/dist/runtime-ets/dom/node.ts +114 -49
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
- package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
- package/dist/runtime-ets/index.ts +2 -3
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +87 -17
- package/dist/runtime-ets/utils/info.ts +21 -47
- package/dist/runtime-framework/react/app.ts +20 -28
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +1 -2
- package/dist/runtime-framework/react/native-page.ts +421 -0
- package/dist/runtime-framework/react/page.ts +5 -17
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -36
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- 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 +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +1633 -549
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +1633 -549
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +7 -1
- package/LICENSE +0 -160
- package/dist/components-harmony-ets/base.ets +0 -63
- package/dist/components-harmony-ets/element.ets +0 -223
- package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
- package/dist/runtime-ets/dom/element.ts +0 -457
- package/dist/runtime-ets/dom/text.ts +0 -19
- package/dist/runtime-ets/utils/bind.ts +0 -35
- package/types/api.d.ts +0 -4
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import promptAction from '@ohos.promptAction'
|
|
2
2
|
|
|
3
3
|
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
|
|
4
4
|
|
|
@@ -29,10 +29,11 @@ export function showToast (options) {
|
|
|
29
29
|
return callAsyncFail(reject, res, options)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
promptAction.showToast({
|
|
33
33
|
message: options.title,
|
|
34
34
|
duration: options.duration,
|
|
35
|
-
bottom: options.bottom
|
|
35
|
+
bottom: options.bottom,
|
|
36
|
+
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
36
37
|
})
|
|
37
38
|
callAsyncSuccess(resolve, resCallback('showToast'), options)
|
|
38
39
|
})
|
|
@@ -72,37 +73,20 @@ export function showModal (options) {
|
|
|
72
73
|
})
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
return new Promise(resolve => {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
76
77
|
const modalOptions = {
|
|
77
78
|
title,
|
|
78
79
|
message: content,
|
|
79
80
|
buttons: buttons,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
options
|
|
91
|
-
)
|
|
92
|
-
} else {
|
|
93
|
-
callAsyncSuccess(
|
|
94
|
-
resolve,
|
|
95
|
-
{
|
|
96
|
-
...resCallback('showModal'),
|
|
97
|
-
confirm: false,
|
|
98
|
-
cancel: true
|
|
99
|
-
},
|
|
100
|
-
options
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
// 鸿蒙没有失败方法,只有取消
|
|
105
|
-
cancel: (_) => {
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
promptAction.showDialog(modalOptions, (error, data) => {
|
|
84
|
+
if (error) {
|
|
85
|
+
const res = { errMsg: error }
|
|
86
|
+
callAsyncFail(reject, res, options)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (data.index === 0 && showCancel) {
|
|
106
90
|
callAsyncSuccess(
|
|
107
91
|
resolve,
|
|
108
92
|
{
|
|
@@ -112,10 +96,19 @@ export function showModal (options) {
|
|
|
112
96
|
},
|
|
113
97
|
options
|
|
114
98
|
)
|
|
99
|
+
} else {
|
|
100
|
+
callAsyncSuccess(
|
|
101
|
+
resolve,
|
|
102
|
+
{
|
|
103
|
+
...resCallback('showModal'),
|
|
104
|
+
confirm: true,
|
|
105
|
+
cancel: false,
|
|
106
|
+
content: null
|
|
107
|
+
},
|
|
108
|
+
options
|
|
109
|
+
)
|
|
115
110
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
prompt.showDialog(modalOptions)
|
|
111
|
+
})
|
|
119
112
|
})
|
|
120
113
|
}
|
|
121
114
|
|
|
@@ -152,44 +145,37 @@ export function showActionSheet (options) {
|
|
|
152
145
|
|
|
153
146
|
const actionSheetOptions = {
|
|
154
147
|
title,
|
|
155
|
-
buttons
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
...data,
|
|
161
|
-
...resCallback('showActionSheet')
|
|
162
|
-
},
|
|
163
|
-
options
|
|
164
|
-
)
|
|
165
|
-
},
|
|
166
|
-
// 取消方法,并非失败
|
|
167
|
-
fail: (data) => {
|
|
148
|
+
buttons
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
promptAction.showActionMenu(actionSheetOptions, (error, data) => {
|
|
152
|
+
if (error) {
|
|
168
153
|
callAsyncFail(
|
|
169
154
|
reject,
|
|
170
155
|
{
|
|
171
156
|
...data,
|
|
172
|
-
errMsg: data.errMsg
|
|
157
|
+
errMsg: data.errMsg?.replace('showActionMenu', 'showActionSheet')
|
|
173
158
|
},
|
|
174
159
|
options
|
|
175
160
|
)
|
|
176
161
|
}
|
|
177
|
-
}
|
|
178
162
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
duration: 10,
|
|
188
|
-
bottom: '9999px'
|
|
163
|
+
callAsyncSuccess(
|
|
164
|
+
resolve,
|
|
165
|
+
{
|
|
166
|
+
...data,
|
|
167
|
+
...resCallback('showActionSheet')
|
|
168
|
+
},
|
|
169
|
+
options
|
|
170
|
+
)
|
|
189
171
|
})
|
|
190
|
-
callAsyncSuccess(resolve, resCallback('hideToast'), options)
|
|
191
172
|
})
|
|
192
173
|
}
|
|
193
174
|
|
|
175
|
+
export const hideToast = /* @__PURE__ */ temporarilyNotSupport('hideToast')
|
|
176
|
+
|
|
194
177
|
export const showLoading = temporarilyNotSupport('showLoading')
|
|
195
178
|
export const hideLoading = temporarilyNotSupport('hideLoading')
|
|
179
|
+
|
|
180
|
+
export const enableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('enableAlertBeforeUnload')
|
|
181
|
+
export const disableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('disableAlertBeforeUnload')
|
|
@@ -1,33 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { MethodHandler } from '../../utils/handler'
|
|
4
4
|
|
|
5
|
-
import type Taro from '@tarojs/
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
6
|
|
|
7
7
|
export const setNavigationBarTitle: typeof Taro.setNavigationBarTitle = function (options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const page = taro.getCurrentInstance().page
|
|
11
|
-
const res = { errMsg: 'setNavigationBarTitle:ok' }
|
|
8
|
+
const { success, fail, complete } = options || {}
|
|
9
|
+
const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete })
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
eventCenter.trigger('__taroNavigationStyle', {
|
|
13
|
+
title: options.title,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
return handle.success({}, { resolve, reject })
|
|
15
17
|
})
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const setNavigationBarColor: typeof Taro.setNavigationBarColor = function (options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const { success, fail, complete } = options || {}
|
|
22
|
+
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete })
|
|
23
|
+
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
eventCenter.trigger('__taroNavigationStyle', {
|
|
26
|
+
animation: options.animation,
|
|
27
|
+
backgroundColor: options.backgroundColor,
|
|
28
|
+
frontColor: options.frontColor,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return handle.success({}, { resolve, reject })
|
|
28
32
|
})
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
export const showNavigationBarLoading =
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
export const showNavigationBarLoading: typeof Taro.setNavigationBarColor = function (options) {
|
|
36
|
+
const { success, fail, complete } = options || {}
|
|
37
|
+
const handle = new MethodHandler({ name: 'showNavigationBarLoading', success, fail, complete })
|
|
38
|
+
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
eventCenter.trigger('__taroNavigationStyle', {
|
|
41
|
+
loading: true,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return handle.success({}, { resolve, reject })
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const hideNavigationBarLoading: typeof Taro.hideNavigationBarLoading = function (options) {
|
|
49
|
+
const { success, fail, complete } = options || {}
|
|
50
|
+
const handle = new MethodHandler({ name: 'hideNavigationBarLoading', success, fail, complete })
|
|
51
|
+
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
eventCenter.trigger('__taroNavigationStyle', {
|
|
54
|
+
loading: false,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return handle.success({}, { resolve, reject })
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const hideHomeButton: typeof Taro.hideHomeButton = function (options) {
|
|
62
|
+
const { success, fail, complete } = options || {}
|
|
63
|
+
const handle = new MethodHandler({ name: 'hideHomeButton', success, fail, complete })
|
|
64
|
+
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
eventCenter.trigger('__taroNavigationStyle', {
|
|
67
|
+
home: false,
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return handle.success({}, { resolve, reject })
|
|
71
|
+
})
|
|
72
|
+
}
|
|
@@ -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
|
-
import type Taro from '@tarojs/
|
|
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
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* 鸿蒙SDK API Version 6
|
|
4
3
|
* 将页面滚动到目标位置
|
|
@@ -9,49 +8,51 @@
|
|
|
9
8
|
import { AREA_CHANGE_EVENT_NAME, Current, findChildNodeWithDFS, getPageScrollerOrNode, setNodeEventCallbackAndTriggerComponentUpdate } from '@tarojs/runtime'
|
|
10
9
|
import { pxTransformHelper } from '@tarojs/taro'
|
|
11
10
|
|
|
12
|
-
import {
|
|
11
|
+
import { MethodHandler } from '../../utils/handler'
|
|
13
12
|
|
|
14
|
-
import type Taro from '@tarojs/
|
|
15
|
-
|
|
16
|
-
// TODO
|
|
17
|
-
export const getCurrentPages = () => []
|
|
13
|
+
import type Taro from '@tarojs/taro/types'
|
|
18
14
|
|
|
15
|
+
/**
|
|
16
|
+
* 将页面滚动到目标位置
|
|
17
|
+
*/
|
|
19
18
|
export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
19
|
+
const { scrollTop, selector = '', duration = 300, offsetTop = 0, success, fail, complete } = options || {}
|
|
20
|
+
const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete })
|
|
20
21
|
// eslint-disable-next-line no-async-promise-executor
|
|
21
22
|
return new Promise(async (resolve, reject) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (scrollTop === undefined && !selector) {
|
|
24
|
+
return handle.fail({
|
|
25
|
+
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
26
|
+
}, { resolve, reject })
|
|
27
|
+
}
|
|
27
28
|
|
|
28
29
|
if (scrollTop && selector) {
|
|
29
30
|
console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector')
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
const taro = (Current as any).taro
|
|
34
|
+
const page = taro.getCurrentInstance().page
|
|
35
|
+
|
|
32
36
|
let scrollValue = -1
|
|
33
|
-
let scroller = page
|
|
34
|
-
const currentPageNode = getPageScrollerOrNode(page
|
|
37
|
+
let scroller = getPageScrollerOrNode(page?.scroller, page)
|
|
38
|
+
const currentPageNode = getPageScrollerOrNode(page?.node, page)
|
|
35
39
|
|
|
36
40
|
if (scrollTop || typeof scrollTop === 'number') {
|
|
37
41
|
scrollValue = scrollTop
|
|
38
42
|
} else if (selector) {
|
|
39
43
|
const node = findChildNodeWithDFS(currentPageNode, selector)
|
|
40
44
|
|
|
41
|
-
if (!node
|
|
42
|
-
|
|
43
|
-
const instance = node._instance
|
|
44
|
-
const id = node?._nid
|
|
45
|
+
if (!node) return
|
|
45
46
|
|
|
46
47
|
// 获取 areaInfo,需要先调用 setNodeEventCallbackAndTriggerComponentUpdate 更新一次组件并获取组件信息
|
|
47
48
|
await setNodeEventCallbackAndTriggerComponentUpdate(node, AREA_CHANGE_EVENT_NAME, null, true)
|
|
48
49
|
|
|
49
|
-
const { areaInfo } =
|
|
50
|
+
const { areaInfo } = node._nodeInfo || {}
|
|
50
51
|
|
|
51
52
|
let parent = node?.parentNode
|
|
52
53
|
while (!!parent && parent !== currentPageNode) {
|
|
53
|
-
if (parent?.
|
|
54
|
-
scroller = parent.
|
|
54
|
+
if (parent?.scroller) {
|
|
55
|
+
scroller = parent.scroller
|
|
55
56
|
break
|
|
56
57
|
}
|
|
57
58
|
parent = parent?.parentNode
|
|
@@ -65,12 +66,14 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
|
65
66
|
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true)
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if (!scroller || scrollValue === -1) {
|
|
70
|
+
return handle.fail({
|
|
71
|
+
errMsg: '请检查传入的 scrollTop 或 selector 是否合法'
|
|
72
|
+
}, { resolve, reject })
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
const { xOffset } = scroller.currentOffset()
|
|
76
|
+
|
|
74
77
|
try {
|
|
75
78
|
scroller.scrollTo({
|
|
76
79
|
xOffset,
|
|
@@ -83,10 +86,12 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
|
83
86
|
})
|
|
84
87
|
|
|
85
88
|
setTimeout(() => {
|
|
86
|
-
|
|
89
|
+
handle.success({}, { resolve, reject })
|
|
87
90
|
}, duration)
|
|
88
|
-
} catch (
|
|
89
|
-
|
|
91
|
+
} catch (err) {
|
|
92
|
+
return handle.fail({
|
|
93
|
+
errMsg: err.message
|
|
94
|
+
}, { resolve, reject })
|
|
90
95
|
}
|
|
91
96
|
})
|
|
92
97
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
// eslint-disable-
|
|
2
|
-
import {
|
|
3
|
-
// eslint-disable-next-line import/no-duplicates
|
|
4
|
-
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
1
|
+
import { Current } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
|
|
2
|
+
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
|
|
5
3
|
|
|
6
4
|
import { callAsyncFail, callAsyncSuccess } from '../utils'
|
|
7
5
|
|
|
8
|
-
import type Taro from '@tarojs/
|
|
6
|
+
import type Taro from '@tarojs/taro/types'
|
|
9
7
|
|
|
10
8
|
interface ShowTabBar {
|
|
11
9
|
type: 'show'
|
|
@@ -24,7 +22,7 @@ const toggleTabBar = function<T extends ToggleAPIs['type']> (type: T): Extract<T
|
|
|
24
22
|
return new Promise((resolve, reject) => {
|
|
25
23
|
const taro = (Current as any).taro
|
|
26
24
|
const page = taro.getCurrentInstance().page
|
|
27
|
-
const currentData = page
|
|
25
|
+
const currentData = page?._data?.taroTabBar || page?.tabBar
|
|
28
26
|
const res = { errMsg: `${type}TabBar:ok` }
|
|
29
27
|
const error = { errMsg: `${type}TabBar:fail not TabBar page` }
|
|
30
28
|
|
|
@@ -51,7 +49,7 @@ export const setTabBarStyle: typeof Taro.setTabBarStyle = function (options = {}
|
|
|
51
49
|
return new Promise((resolve, reject) => {
|
|
52
50
|
const taro = (Current as any).taro
|
|
53
51
|
const page = taro.getCurrentInstance().page
|
|
54
|
-
const currentData = page
|
|
52
|
+
const currentData = page?._data?.taroTabBar || page?.tabBar
|
|
55
53
|
const res = { errMsg: 'setTabBarStyle:ok' }
|
|
56
54
|
const error = { errMsg: 'setTabBarStyle:fail not TabBar page' }
|
|
57
55
|
|
|
@@ -76,7 +74,7 @@ export const setTabBarItem: typeof Taro.setTabBarItem = function (options) {
|
|
|
76
74
|
return new Promise((resolve, reject) => {
|
|
77
75
|
const taro = (Current as any).taro
|
|
78
76
|
const page = taro.getCurrentInstance().page
|
|
79
|
-
const currentData = page
|
|
77
|
+
const currentData = page?._data?.taroTabBar || page?.tabBar
|
|
80
78
|
const res = { errMsg: 'setTabBarItem:ok' }
|
|
81
79
|
const error = { errMsg: 'setTabBarItem:fail not TabBar page' }
|
|
82
80
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
import type Taro from '@tarojs/taro/types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
|
|
7
|
+
*/
|
|
8
|
+
export const setWindowSize = /* @__PURE__ */ temporarilyNotSupport('setWindowSize')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 监听窗口尺寸变化事件
|
|
12
|
+
*/
|
|
13
|
+
export const onWindowResize: typeof Taro.onWindowResize = /* @__PURE__ */ temporarilyNotSupport('onWindowResize')
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 取消监听窗口尺寸变化事件
|
|
17
|
+
*/
|
|
18
|
+
export const offWindowResize: typeof Taro.offWindowResize = /* @__PURE__ */ temporarilyNotSupport('offWindowResize')
|
|
19
|
+
|
|
20
|
+
export const checkIsPictureInPictureActive = /* @__PURE__ */ temporarilyNotSupport('checkIsPictureInPictureActive')
|
|
@@ -11,7 +11,7 @@ interface IMethodParam<T = Partial<ICallbackResult>> {
|
|
|
11
11
|
name: string
|
|
12
12
|
success?: TCallback<T & ICallbackResult>
|
|
13
13
|
fail?: TCallback
|
|
14
|
-
complete?: TCallback
|
|
14
|
+
complete?: TCallback<T | ICallbackResult>
|
|
15
15
|
}
|
|
16
16
|
interface IMockPromise {
|
|
17
17
|
resolve?: typeof Promise.resolve | TFunc
|
|
@@ -23,7 +23,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
|
|
|
23
23
|
|
|
24
24
|
protected __success?: TCallback<T>
|
|
25
25
|
protected __fail?: TCallback
|
|
26
|
-
protected __complete?: TCallback
|
|
26
|
+
protected __complete?: TCallback<T | ICallbackResult>
|
|
27
27
|
|
|
28
28
|
protected isHandlerError = false
|
|
29
29
|
|
|
@@ -41,7 +41,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
|
|
|
41
41
|
res.errMsg = `${this.methodName}:ok`
|
|
42
42
|
}
|
|
43
43
|
isFunction(this.__success) && this.__success(res as T)
|
|
44
|
-
isFunction(this.__complete) && this.__complete(res)
|
|
44
|
+
isFunction(this.__complete) && this.__complete(res as T)
|
|
45
45
|
|
|
46
46
|
const { resolve = Promise.resolve.bind(Promise) } = promise
|
|
47
47
|
return resolve(res as Required<T & U & ICallbackResult>)
|
|
@@ -54,7 +54,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
|
|
|
54
54
|
res.errMsg = `${this.methodName}:fail ${res.errMsg}`
|
|
55
55
|
}
|
|
56
56
|
isFunction(this.__fail) && this.__fail(res)
|
|
57
|
-
isFunction(this.__complete) && this.__complete(res)
|
|
57
|
+
isFunction(this.__complete) && this.__complete(res as ICallbackResult)
|
|
58
58
|
|
|
59
59
|
const {
|
|
60
60
|
resolve = Promise.resolve.bind(Promise),
|
package/dist/apis/utils/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function temporarilyNotSupport (name: string, recommended?: string) {
|
|
|
19
19
|
return (option = {}, ...args) => {
|
|
20
20
|
const { success, fail, complete } = option as any
|
|
21
21
|
const handle = new MethodHandler({ name, success, fail, complete })
|
|
22
|
-
let errMsg =
|
|
22
|
+
let errMsg = `暂时不支持 API ${name}`
|
|
23
23
|
if (recommended) {
|
|
24
24
|
errMsg += `, 请使用 ${recommended}`
|
|
25
25
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
// @ts-ignore
|
|
3
1
|
import { Current, disconnectEvent, findChildNodeWithDFS, getPageScrollerOrNode, setNodeEventCallbackAndTriggerComponentUpdate, TaroElement, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
4
2
|
|
|
5
3
|
import { temporarilyNotSupport } from '../utils'
|
|
6
4
|
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
|
+
|
|
7
7
|
export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
8
8
|
// 自定义组件实例
|
|
9
9
|
private _component: any
|
|
@@ -19,62 +19,59 @@ 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
|
-
|
|
33
|
-
|
|
34
|
-
n._instance?.nodeInfoMap?.[n._nid]?.thresholds = null
|
|
35
|
-
}
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
n._nodeInfo.thresholds = null
|
|
36
34
|
})
|
|
37
35
|
} else {
|
|
38
36
|
disconnectEvent(this._observerNodes, VISIBLE_CHANGE_EVENT_NAME)
|
|
39
37
|
// @ts-ignore
|
|
40
|
-
if (this._observerNodes.
|
|
38
|
+
if (this._observerNodes._nodeInfo) {
|
|
41
39
|
// @ts-ignore
|
|
42
|
-
this._observerNodes.
|
|
40
|
+
this._observerNodes._nodeInfo.thresholds = null
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {
|
|
47
|
+
if (!this._component) return
|
|
48
|
+
|
|
49
49
|
const { observeAll, thresholds } = this._options
|
|
50
50
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll)
|
|
51
51
|
this._observerNodes = node
|
|
52
52
|
|
|
53
|
-
|
|
54
53
|
if (node) {
|
|
55
54
|
if (node instanceof Array) {
|
|
56
55
|
node.forEach(n => {
|
|
57
56
|
// @ts-ignore
|
|
58
|
-
n.
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
n._instance?.nodeInfoMap?.[n._nid]?.thresholds = thresholds
|
|
57
|
+
n._nodeInfo.thresholds = thresholds
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})
|
|
59
|
+
setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
60
|
+
callback(this.handleResult(isVisible, currentRatio, n))
|
|
65
61
|
})
|
|
66
62
|
})
|
|
67
63
|
} else {
|
|
68
64
|
// @ts-ignore
|
|
69
|
-
node.
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
node._instance?.nodeInfoMap?.[node._nid]?.thresholds = thresholds
|
|
65
|
+
node._nodeInfo.thresholds = thresholds
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
67
|
+
setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
68
|
+
callback(this.handleResult(isVisible, currentRatio, node))
|
|
76
69
|
})
|
|
77
70
|
}
|
|
71
|
+
} else {
|
|
72
|
+
callback({
|
|
73
|
+
errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
|
|
74
|
+
})
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
|
|
@@ -89,8 +86,10 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
// @ts-ignore
|
|
92
|
-
private handleResult (isVisible: boolean, currentRatio: number): Taro.IntersectionObserver.ObserveCallbackResult {
|
|
89
|
+
private handleResult (isVisible: boolean, currentRatio: number, node: TaroElement): Taro.IntersectionObserver.ObserveCallbackResult {
|
|
93
90
|
const result = {
|
|
91
|
+
id: node.id,
|
|
92
|
+
dataset: node.dataset,
|
|
94
93
|
intersectionRatio: currentRatio,
|
|
95
94
|
// TODO 未做,等待能拿到element的info信息
|
|
96
95
|
boundingClientRect: {
|
package/dist/apis/wxml/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
3
2
|
import { IntersectionObserver } from './IntersectionObserver'
|
|
4
3
|
import { SelectorQuery } from './selectorQuery'
|
|
5
4
|
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
|
+
|
|
6
7
|
export const createSelectorQuery = () => {
|
|
7
8
|
return new SelectorQuery()
|
|
8
9
|
}
|
|
@@ -10,3 +11,7 @@ export const createSelectorQuery = () => {
|
|
|
10
11
|
export const createIntersectionObserver: typeof Taro.createIntersectionObserver = (component, options) => {
|
|
11
12
|
return new IntersectionObserver(component, options)
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
export const createMediaQueryObserver = /* @__PURE__ */ temporarilyNotSupport('createMediaQueryObserver')
|
|
16
|
+
|
|
17
|
+
export { IntersectionObserver }
|