@spcsn/taro 0.1.0
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/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
namespace updateWeChatApp {
|
|
5
|
+
interface Option {
|
|
6
|
+
/** 接口调用成功的回调函数 */
|
|
7
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
8
|
+
/** 接口调用失败的回调函数 */
|
|
9
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
10
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
11
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
namespace UpdateManager {
|
|
16
|
+
/** 向微信后台请求检查更新结果事件的回调函数 */
|
|
17
|
+
type OnCheckForUpdateCallback = (
|
|
18
|
+
result: OnCheckForUpdateResult,
|
|
19
|
+
) => void
|
|
20
|
+
interface OnCheckForUpdateResult {
|
|
21
|
+
/** 是否有新版本 */
|
|
22
|
+
hasUpdate: boolean
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** UpdateManager 对象,用来管理更新,可通过 Taro.getUpdateManager 接口获取实例。
|
|
27
|
+
*
|
|
28
|
+
* **Tips**
|
|
29
|
+
* - 微信开发者工具上可以通过「编译模式」下的「下次编译模拟更新」开关来调试
|
|
30
|
+
* - 小程序开发版/体验版没有「版本」概念,所以无法在开发版/体验版上测试更版本更新情况
|
|
31
|
+
* @supported weapp, tt
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const updateManager = Taro.getUpdateManager()
|
|
35
|
+
*
|
|
36
|
+
* updateManager.onCheckForUpdate(function (res) {
|
|
37
|
+
* // 请求完新版本信息的回调
|
|
38
|
+
* console.log(res.hasUpdate)
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* updateManager.onUpdateReady(function () {
|
|
42
|
+
* wx.showModal({
|
|
43
|
+
* title: '更新提示',
|
|
44
|
+
* content: '新版本已经准备好,是否重启应用?',
|
|
45
|
+
* success: function (res) {
|
|
46
|
+
* if (res.confirm) {
|
|
47
|
+
* // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
48
|
+
* updateManager.applyUpdate()
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* })
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* updateManager.onUpdateFailed(function () {
|
|
55
|
+
* // 新版本下载失败
|
|
56
|
+
* })
|
|
57
|
+
* ```
|
|
58
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.html
|
|
59
|
+
*/
|
|
60
|
+
interface UpdateManager {
|
|
61
|
+
/** 强制小程序重启并使用新版本。在小程序新版本下载完成后(即收到 `onUpdateReady` 回调)调用。
|
|
62
|
+
* @supported weapp, tt
|
|
63
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.applyUpdate.html
|
|
64
|
+
*/
|
|
65
|
+
applyUpdate(): void
|
|
66
|
+
/** 监听向微信后台请求检查更新结果事件。微信在小程序冷启动时自动检查更新,不需由开发者主动触发。
|
|
67
|
+
* @supported weapp, tt
|
|
68
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.onCheckForUpdate.html
|
|
69
|
+
*/
|
|
70
|
+
onCheckForUpdate(
|
|
71
|
+
/** 向微信后台请求检查更新结果事件的回调函数 */
|
|
72
|
+
callback: UpdateManager.OnCheckForUpdateCallback,
|
|
73
|
+
): void
|
|
74
|
+
/** 监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调
|
|
75
|
+
* @supported weapp, tt
|
|
76
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.onUpdateReady.html
|
|
77
|
+
*/
|
|
78
|
+
onUpdateReady(
|
|
79
|
+
/** 小程序有版本更新事件的回调函数 */
|
|
80
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
81
|
+
): void
|
|
82
|
+
/** 监听小程序更新失败事件。小程序有新版本,客户端主动触发下载(无需开发者触发),下载失败(可能是网络原因等)后回调
|
|
83
|
+
* @supported weapp, tt
|
|
84
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.onUpdateFailed.html
|
|
85
|
+
*/
|
|
86
|
+
onUpdateFailed(
|
|
87
|
+
/** 小程序更新失败事件的回调函数 */
|
|
88
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
89
|
+
): void
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface TaroStatic {
|
|
93
|
+
/** 更新客户端版本。当判断用户小程序所在客户端版本过低时,可使用该接口跳转到更新微信页面。
|
|
94
|
+
* @supported weapp
|
|
95
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/wx.updateWeChatApp.html
|
|
96
|
+
*/
|
|
97
|
+
updateWeChatApp(option: updateWeChatApp.Option): Promise<TaroGeneral.CallbackResult>
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 获取**全局唯一**的版本更新管理器,用于管理小程序更新。
|
|
101
|
+
* 关于小程序的更新机制,可以查看[运行机制](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/operating-mechanism.html)文档。
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* const updateManager = Taro.getUpdateManager()
|
|
105
|
+
* updateManager.onCheckForUpdate(function (res) {
|
|
106
|
+
* // 请求完新版本信息的回调
|
|
107
|
+
* console.log(res.hasUpdate)
|
|
108
|
+
* })
|
|
109
|
+
* updateManager.onUpdateReady(function () {
|
|
110
|
+
* Taro.showModal({
|
|
111
|
+
* title: '更新提示',
|
|
112
|
+
* content: '新版本已经准备好,是否重启应用?',
|
|
113
|
+
* success: function (res) {
|
|
114
|
+
* if (res.confirm) {
|
|
115
|
+
* // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
116
|
+
* updateManager.applyUpdate()
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
* })
|
|
120
|
+
* })
|
|
121
|
+
* updateManager.onUpdateFailed(function () {
|
|
122
|
+
* // 新的版本下载失败
|
|
123
|
+
* })
|
|
124
|
+
* ```
|
|
125
|
+
* @supported weapp, tt
|
|
126
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/wx.getUpdateManager.html
|
|
127
|
+
*/
|
|
128
|
+
getUpdateManager(): UpdateManager
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import Taro from '../../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../../index' {
|
|
4
|
+
namespace onPageNotFound {
|
|
5
|
+
interface Result {
|
|
6
|
+
/** 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面) */
|
|
7
|
+
isEntryPage: boolean
|
|
8
|
+
/** 不存在页面的路径 */
|
|
9
|
+
path: string
|
|
10
|
+
/** 打开不存在页面的 query 参数 */
|
|
11
|
+
query: TaroGeneral.IAnyObject
|
|
12
|
+
}
|
|
13
|
+
/** 小程序要打开的页面不存在事件的回调函数 */
|
|
14
|
+
type Callback = (res: Result) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
namespace onError {
|
|
18
|
+
/** 小程序错误事件的回调函数 */
|
|
19
|
+
type Callback = (
|
|
20
|
+
/** 错误信息,包含堆栈 */
|
|
21
|
+
error: string | ErrorEvent | Error,
|
|
22
|
+
) => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
namespace onAppShow {
|
|
26
|
+
interface CallbackResult {
|
|
27
|
+
/** 小程序切前台的路径 */
|
|
28
|
+
path: string
|
|
29
|
+
/** 小程序切前台的 query 参数 */
|
|
30
|
+
query: TaroGeneral.IAnyObject
|
|
31
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
32
|
+
shareTicket: string
|
|
33
|
+
/** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
34
|
+
scene: number
|
|
35
|
+
/** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */
|
|
36
|
+
referrerInfo: ResultReferrerInfo
|
|
37
|
+
/** 打开的文件信息数组,只有从聊天素材场景打开(scene为1173)才会携带该参数 */
|
|
38
|
+
forwardMaterials?: ForwardMaterial[]
|
|
39
|
+
/** 从微信群聊/单聊打开小程序时,chatType 表示具体微信群聊/单聊类型 */
|
|
40
|
+
chatType?: keyof ChatType
|
|
41
|
+
/** API 类别 */
|
|
42
|
+
apiCategory?: keyof ApiCategory
|
|
43
|
+
}
|
|
44
|
+
/** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */
|
|
45
|
+
interface ResultReferrerInfo {
|
|
46
|
+
/** 来源小程序、公众号或 App 的 appId */
|
|
47
|
+
appId?: string
|
|
48
|
+
/** 来源小程序传过来的数据,scene=1037或1038时支持 */
|
|
49
|
+
extraData?: TaroGeneral.IAnyObject
|
|
50
|
+
}
|
|
51
|
+
/** ChatType 类型合法值 */
|
|
52
|
+
interface ForwardMaterial {
|
|
53
|
+
/** 文件的mimetype类型 */
|
|
54
|
+
type: string
|
|
55
|
+
/** 文件名 */
|
|
56
|
+
name: string
|
|
57
|
+
/** 文件路径(如果是webview则是url) */
|
|
58
|
+
path: string
|
|
59
|
+
/** 文件大小 */
|
|
60
|
+
size: number
|
|
61
|
+
}
|
|
62
|
+
/** ChatType 类型合法值 */
|
|
63
|
+
interface ChatType {
|
|
64
|
+
/** 微信联系人单聊 */
|
|
65
|
+
1
|
|
66
|
+
/** 企业微信联系人单聊 */
|
|
67
|
+
2
|
|
68
|
+
/** 普通微信群聊 */
|
|
69
|
+
3
|
|
70
|
+
/** 企业微信互通群聊 */
|
|
71
|
+
4
|
|
72
|
+
}
|
|
73
|
+
/** API 类别合法值 */
|
|
74
|
+
interface ApiCategory {
|
|
75
|
+
/** 默认类别 */
|
|
76
|
+
default
|
|
77
|
+
/** 原生功能化,视频号直播商品、商品橱窗等场景打开的小程序 */
|
|
78
|
+
nativeFunctionalized
|
|
79
|
+
/** 仅浏览,朋友圈快照页等场景打开的小程序 */
|
|
80
|
+
browseOnly
|
|
81
|
+
/** 内嵌,通过打开半屏小程序能力打开的小程序 */
|
|
82
|
+
embedded
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
namespace onUnhandledRejection {
|
|
87
|
+
type Callback<T = any> = (res: Result<T>) => void
|
|
88
|
+
type Result<T = any> = {
|
|
89
|
+
/** 拒绝原因,一般是一个 Error 对象 */
|
|
90
|
+
reason: string | Error
|
|
91
|
+
/** 被拒绝的 Promise 对象 */
|
|
92
|
+
promise: Promise<T>
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
namespace onThemeChange {
|
|
97
|
+
/** 系统主题改变事件的回调函数 */
|
|
98
|
+
type Callback = (res: Result) => void
|
|
99
|
+
interface Result {
|
|
100
|
+
/** 系统当前的主题,取值为`light`或`dark` */
|
|
101
|
+
theme: keyof ITheme
|
|
102
|
+
}
|
|
103
|
+
interface ITheme {
|
|
104
|
+
/** 浅色主题 */
|
|
105
|
+
light
|
|
106
|
+
/** 深色主题 */
|
|
107
|
+
dark
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface TaroStatic {
|
|
112
|
+
/** 监听未处理的 Promise 拒绝事件。该事件与 [`App.onUnhandledRejection`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onUnhandledRejection-Object-object) 的回调时机与参数一致。
|
|
113
|
+
*
|
|
114
|
+
* **注意**
|
|
115
|
+
* - 所有的 unhandledRejection 都可以被这一监听捕获,但只有 Error 类型的才会在小程序后台触发报警。
|
|
116
|
+
* @supported weapp, tt, h5, harmony, harmony_hybrid
|
|
117
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html
|
|
118
|
+
*/
|
|
119
|
+
onUnhandledRejection<T = any>(callback: onUnhandledRejection.Callback<T>): void
|
|
120
|
+
|
|
121
|
+
/** 监听系统主题改变事件。该事件与 [`App.onThemeChange`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onThemeChange-Object-object) 的回调时机一致。
|
|
122
|
+
* @supported weapp, h5
|
|
123
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onThemeChange.html
|
|
124
|
+
*/
|
|
125
|
+
onThemeChange(callback: onThemeChange.Callback): void
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 监听小程序要打开的页面不存在事件。该事件与 [`App.onPageNotFound`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onpagenotfoundobject-object) 的回调时机一致。
|
|
129
|
+
*
|
|
130
|
+
* **注意**
|
|
131
|
+
* - 开发者可以在回调中进行页面重定向,但必须在回调中**同步**处理,异步处理(例如 `setTimeout` 异步执行)无效。
|
|
132
|
+
* - 若开发者没有调用 [Taro.onPageNotFound](/docs/apis/base/weapp/app-event/onPageNotFound) 绑定监听,也没有声明 `App.onPageNotFound`,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。
|
|
133
|
+
* - 如果回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再第二次回调。
|
|
134
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
135
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html
|
|
136
|
+
*/
|
|
137
|
+
onPageNotFound(callback: onPageNotFound.Callback): void
|
|
138
|
+
|
|
139
|
+
/** 监听小程序错误事件。如脚本错误或 API 调用报错等。该事件与 [`App.onError`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onerrorstring-error) 的回调时机与参数一致。
|
|
140
|
+
* @supported weapp, tt, h5, harmony, harmony_hybrid
|
|
141
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html
|
|
142
|
+
*/
|
|
143
|
+
onError(callback: onError.Callback): void
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 监听音频中断结束事件。在收到 onAudioInterruptionBegin 事件之后,小程序内所有音频会暂停,收到此事件之后才可再次播放成功
|
|
147
|
+
* @supported weapp
|
|
148
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionEnd.html
|
|
149
|
+
*/
|
|
150
|
+
onAudioInterruptionEnd (
|
|
151
|
+
/** 音频中断结束事件的回调函数 */
|
|
152
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
153
|
+
): void
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 监听音频因为受到系统占用而被中断开始事件。以下场景会触发此事件:闹钟、电话、FaceTime 通话、微信语音聊天、微信视频聊天。此事件触发后,小程序内所有音频会暂停。
|
|
157
|
+
* @supported weapp
|
|
158
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionBegin.html
|
|
159
|
+
*/
|
|
160
|
+
onAudioInterruptionBegin(
|
|
161
|
+
/** 音频因为受到系统占用而被中断开始事件的回调函数 */
|
|
162
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
163
|
+
): void
|
|
164
|
+
|
|
165
|
+
/** 监听小程序切前台事件。该事件与 [`App.onShow`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onshowobject-object) 的回调参数一致。
|
|
166
|
+
*
|
|
167
|
+
* **返回有效 referrerInfo 的场景**
|
|
168
|
+
*
|
|
169
|
+
* | 场景值 | 场景 | appId含义 |
|
|
170
|
+
* | ------ | ------------------------------- | ---------- |
|
|
171
|
+
* | 1020 | 公众号 profile 页相关小程序列表 | 来源公众号 |
|
|
172
|
+
* | 1035 | 公众号自定义菜单 | 来源公众号 |
|
|
173
|
+
* | 1036 | App 分享消息卡片 | 来源App |
|
|
174
|
+
* | 1037 | 小程序打开小程序 | 来源小程序 |
|
|
175
|
+
* | 1038 | 从另一个小程序返回 | 来源小程序 |
|
|
176
|
+
* | 1043 | 公众号模板消息 | 来源公众号 |
|
|
177
|
+
*
|
|
178
|
+
* **注意**
|
|
179
|
+
*
|
|
180
|
+
* 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
|
|
181
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
182
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppShow.html
|
|
183
|
+
*/
|
|
184
|
+
onAppShow(
|
|
185
|
+
/** 小程序切前台事件的回调函数 */
|
|
186
|
+
callback: (res: onAppShow.CallbackResult) => void,
|
|
187
|
+
): void
|
|
188
|
+
|
|
189
|
+
/** 监听小程序切后台事件。该事件与 [`App.onHide`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onhide) 的回调时机一致。
|
|
190
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
191
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppHide.html
|
|
192
|
+
*/
|
|
193
|
+
onAppHide(
|
|
194
|
+
/** 小程序切后台事件的回调函数 */
|
|
195
|
+
callback: (res: onAppShow.CallbackResult) => void,
|
|
196
|
+
): void
|
|
197
|
+
|
|
198
|
+
/** 取消监听未处理的 Promise 拒绝事件
|
|
199
|
+
* @supported weapp, tt, h5, harmony, harmony_hybrid
|
|
200
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html
|
|
201
|
+
*/
|
|
202
|
+
offUnhandledRejection<T = any>(callback: onUnhandledRejection.Callback<T>): void
|
|
203
|
+
|
|
204
|
+
/** 取消监听系统主题改变事件
|
|
205
|
+
* @supported weapp, h5
|
|
206
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offThemeChange.html
|
|
207
|
+
*/
|
|
208
|
+
offThemeChange(callback: onThemeChange.Callback): void
|
|
209
|
+
|
|
210
|
+
/** 取消监听小程序要打开的页面不存在事件
|
|
211
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
212
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offPageNotFound.html
|
|
213
|
+
*/
|
|
214
|
+
offPageNotFound(
|
|
215
|
+
/** 小程序要打开的页面不存在事件的回调函数 */
|
|
216
|
+
callback: onPageNotFound.Callback,
|
|
217
|
+
): void
|
|
218
|
+
|
|
219
|
+
/** 取消监听音频播放错误事件
|
|
220
|
+
* @supported weapp, tt, h5, harmony, harmony_hybrid
|
|
221
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offError.html
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
offError(
|
|
225
|
+
/** 音频播放错误事件的回调函数 */
|
|
226
|
+
callback: onError.Callback,
|
|
227
|
+
): void
|
|
228
|
+
|
|
229
|
+
/** 取消监听音频中断结束事件
|
|
230
|
+
* @supported weapp
|
|
231
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAudioInterruptionEnd.html
|
|
232
|
+
*/
|
|
233
|
+
offAudioInterruptionEnd(
|
|
234
|
+
/** 音频中断结束事件的回调函数 */
|
|
235
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
236
|
+
): void
|
|
237
|
+
|
|
238
|
+
/** 取消监听音频因为受到系统占用而被中断开始事件
|
|
239
|
+
* @supported weapp
|
|
240
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAudioInterruptionBegin.html
|
|
241
|
+
*/
|
|
242
|
+
offAudioInterruptionBegin(
|
|
243
|
+
/** 音频因为受到系统占用而被中断开始事件的回调函数 */
|
|
244
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
245
|
+
): void
|
|
246
|
+
|
|
247
|
+
/** 取消监听小程序切前台事件
|
|
248
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
249
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppShow.html
|
|
250
|
+
*/
|
|
251
|
+
offAppShow(
|
|
252
|
+
/** 小程序切前台事件的回调函数 */
|
|
253
|
+
callback: (res: onAppShow.CallbackResult) => void,
|
|
254
|
+
): void
|
|
255
|
+
|
|
256
|
+
/** 取消监听小程序切后台事件
|
|
257
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
258
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppHide.html
|
|
259
|
+
*/
|
|
260
|
+
offAppHide(
|
|
261
|
+
/** 小程序切后台事件的回调函数 */
|
|
262
|
+
callback: (res: onAppShow.CallbackResult) => void,
|
|
263
|
+
): void
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import Taro from '../../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../../index' {
|
|
4
|
+
namespace getLaunchOptionsSync {
|
|
5
|
+
/** 启动参数 */
|
|
6
|
+
interface LaunchOptions {
|
|
7
|
+
/** 启动小程序的路径 */
|
|
8
|
+
path: string
|
|
9
|
+
/** 启动小程序的 query 参数 */
|
|
10
|
+
query: TaroGeneral.IAnyObject
|
|
11
|
+
/** 启动小程序的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
12
|
+
scene: number
|
|
13
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
14
|
+
shareTicket: string
|
|
15
|
+
/** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */
|
|
16
|
+
referrerInfo: LaunchOptions.ReferrerInfo
|
|
17
|
+
/** 打开的文件信息数组,只有从聊天素材场景打开(scene为1173)才会携带该参数 */
|
|
18
|
+
forwardMaterials?: LaunchOptions.ForwardMaterial[]
|
|
19
|
+
/** 从微信群聊/单聊打开小程序时,chatType 表示具体微信群聊/单聊类型 */
|
|
20
|
+
chatType?: keyof LaunchOptions.ChatType
|
|
21
|
+
/** API 类别 */
|
|
22
|
+
apiCategory?: keyof LaunchOptions.ApiCategory
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
namespace LaunchOptions {
|
|
26
|
+
/** 来源信息 */
|
|
27
|
+
interface ReferrerInfo {
|
|
28
|
+
/** 来源小程序、公众号或 App 的 appId */
|
|
29
|
+
appId?: string
|
|
30
|
+
/** 来源小程序传过来的数据,scene=1037或1038时支持 */
|
|
31
|
+
extraData?: TaroGeneral.IAnyObject
|
|
32
|
+
}
|
|
33
|
+
/** ChatType 类型合法值 */
|
|
34
|
+
interface ForwardMaterial {
|
|
35
|
+
/** 文件的mimetype类型 */
|
|
36
|
+
type: string
|
|
37
|
+
/** 文件名 */
|
|
38
|
+
name: string
|
|
39
|
+
/** 文件路径(如果是webview则是url) */
|
|
40
|
+
path: string
|
|
41
|
+
/** 文件大小 */
|
|
42
|
+
size: number
|
|
43
|
+
}
|
|
44
|
+
/** ChatType 类型合法值 */
|
|
45
|
+
interface ChatType {
|
|
46
|
+
/** 微信联系人单聊 */
|
|
47
|
+
1
|
|
48
|
+
/** 企业微信联系人单聊 */
|
|
49
|
+
2
|
|
50
|
+
/** 普通微信群聊 */
|
|
51
|
+
3
|
|
52
|
+
/** 企业微信互通群聊 */
|
|
53
|
+
4
|
|
54
|
+
}
|
|
55
|
+
/** API 类别合法值 */
|
|
56
|
+
interface ApiCategory {
|
|
57
|
+
/** 默认类别 */
|
|
58
|
+
default
|
|
59
|
+
/** 原生功能化,视频号直播商品、商品橱窗等场景打开的小程序 */
|
|
60
|
+
nativeFunctionalized
|
|
61
|
+
/** 仅浏览,朋友圈快照页等场景打开的小程序 */
|
|
62
|
+
browseOnly
|
|
63
|
+
/** 内嵌,通过打开半屏小程序能力打开的小程序 */
|
|
64
|
+
embedded
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
namespace getEnterOptionsSync {
|
|
70
|
+
/** 启动参数 */
|
|
71
|
+
interface EnterOptions {
|
|
72
|
+
/** 启动小程序的路径 */
|
|
73
|
+
path: string
|
|
74
|
+
/** 启动小程序的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
75
|
+
scene: number
|
|
76
|
+
/** 启动小程序的 query 参数 */
|
|
77
|
+
query: TaroGeneral.IAnyObject
|
|
78
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
79
|
+
shareTicket: string
|
|
80
|
+
/** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */
|
|
81
|
+
referrerInfo: EnterOptions.ReferrerInfo
|
|
82
|
+
/** 打开的文件信息数组,只有从聊天素材场景打开(scene为1173)才会携带该参数 */
|
|
83
|
+
forwardMaterials?: EnterOptions.ForwardMaterial[]
|
|
84
|
+
/** 从微信群聊/单聊打开小程序时,chatType 表示具体微信群聊/单聊类型 */
|
|
85
|
+
chatType?: keyof EnterOptions.ChatType
|
|
86
|
+
/** API 类别 */
|
|
87
|
+
apiCategory?: keyof EnterOptions.ApiCategory
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
namespace EnterOptions {
|
|
91
|
+
/** 来源信息 */
|
|
92
|
+
interface ReferrerInfo {
|
|
93
|
+
/** 来源小程序、公众号或 App 的 appId */
|
|
94
|
+
appId?: string
|
|
95
|
+
/** 来源小程序传过来的数据,scene=1037或1038时支持 */
|
|
96
|
+
extraData?: TaroGeneral.IAnyObject
|
|
97
|
+
}
|
|
98
|
+
/** ChatType 类型合法值 */
|
|
99
|
+
interface ForwardMaterial {
|
|
100
|
+
/** 文件的mimetype类型 */
|
|
101
|
+
type: string
|
|
102
|
+
/** 文件名 */
|
|
103
|
+
name: string
|
|
104
|
+
/** 文件路径(如果是webview则是url) */
|
|
105
|
+
path: string
|
|
106
|
+
/** 文件大小 */
|
|
107
|
+
size: number
|
|
108
|
+
}
|
|
109
|
+
/** ChatType 类型合法值 */
|
|
110
|
+
interface ChatType {
|
|
111
|
+
/** 微信联系人单聊 */
|
|
112
|
+
1
|
|
113
|
+
/** 企业微信联系人单聊 */
|
|
114
|
+
2
|
|
115
|
+
/** 普通微信群聊 */
|
|
116
|
+
3
|
|
117
|
+
/** 企业微信互通群聊 */
|
|
118
|
+
4
|
|
119
|
+
}
|
|
120
|
+
/** API 类别合法值 */
|
|
121
|
+
interface ApiCategory {
|
|
122
|
+
/** 默认类别 */
|
|
123
|
+
default
|
|
124
|
+
/** 原生功能化,视频号直播商品、商品橱窗等场景打开的小程序 */
|
|
125
|
+
nativeFunctionalized
|
|
126
|
+
/** 仅浏览,朋友圈快照页等场景打开的小程序 */
|
|
127
|
+
browseOnly
|
|
128
|
+
/** 内嵌,通过打开半屏小程序能力打开的小程序 */
|
|
129
|
+
embedded
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface TaroStatic {
|
|
135
|
+
/**
|
|
136
|
+
* 获取小程序启动时的参数。与 [`App.onLaunch`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onlaunchobject-object) 的回调参数一致。
|
|
137
|
+
*
|
|
138
|
+
* **注意**
|
|
139
|
+
* 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
|
|
140
|
+
* @supported weapp, tt, harmony_hybrid
|
|
141
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html
|
|
142
|
+
*/
|
|
143
|
+
getLaunchOptionsSync(): getLaunchOptionsSync.LaunchOptions
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 获取本次小程序启动时的参数。如果当前是冷启动,则返回值与 [`App.onLaunch`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onLaunch-Object-object) 的回调参数一致;如果当前是热启动,则返回值与 [`App.onShow`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onShow-Object-object) 一致。
|
|
147
|
+
*
|
|
148
|
+
* **注意**
|
|
149
|
+
* 部分版本在无 `referrerInfo` 的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
|
|
150
|
+
* @supported weapp
|
|
151
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getEnterOptionsSync.html
|
|
152
|
+
*/
|
|
153
|
+
getEnterOptionsSync(): getEnterOptionsSync.EnterOptions
|
|
154
|
+
}
|
|
155
|
+
}
|