@tarojs/taro 3.3.11 → 3.3.15

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.
Files changed (97) hide show
  1. package/package.json +5 -5
  2. package/types/api/ad/index.d.ts +34 -28
  3. package/types/api/alipay/index.d.ts +11 -7
  4. package/types/api/base/debug.d.ts +60 -54
  5. package/types/api/base/env.d.ts +12 -8
  6. package/types/api/base/index.d.ts +87 -83
  7. package/types/api/base/system.d.ts +59 -54
  8. package/types/api/base/update.d.ts +37 -33
  9. package/types/api/base/weapp/app-event.d.ts +147 -131
  10. package/types/api/base/weapp/life-cycle.d.ts +14 -10
  11. package/types/api/canvas/index.d.ts +115 -110
  12. package/types/api/cloud/index.d.ts +99 -94
  13. package/types/api/data-analysis/index.d.ts +68 -64
  14. package/types/api/device/accelerometer.d.ts +57 -50
  15. package/types/api/device/battery.d.ts +19 -15
  16. package/types/api/device/ble.d.ts +241 -228
  17. package/types/api/device/bluetooth.d.ts +207 -194
  18. package/types/api/device/clipboard.d.ts +48 -43
  19. package/types/api/device/compass.d.ts +55 -48
  20. package/types/api/device/contact.d.ts +13 -9
  21. package/types/api/device/gyroscope.d.ts +41 -35
  22. package/types/api/device/iBeacon.d.ts +79 -73
  23. package/types/api/device/motion.d.ts +42 -37
  24. package/types/api/device/network.d.ts +80 -42
  25. package/types/api/device/nfc.d.ts +105 -96
  26. package/types/api/device/performance.d.ts +32 -18
  27. package/types/api/device/phone.d.ts +20 -15
  28. package/types/api/device/scan.d.ts +31 -26
  29. package/types/api/device/screen.d.ts +74 -67
  30. package/types/api/device/vibrate.d.ts +31 -25
  31. package/types/api/device/wifi.d.ts +151 -140
  32. package/types/api/ext/index.d.ts +44 -39
  33. package/types/api/files/index.d.ts +219 -209
  34. package/types/api/framework/index.d.ts +25 -20
  35. package/types/api/location/index.d.ts +140 -136
  36. package/types/api/media/audio.d.ts +135 -127
  37. package/types/api/media/background-audio.d.ts +135 -126
  38. package/types/api/media/camera.d.ts +30 -26
  39. package/types/api/media/editor.d.ts +35 -33
  40. package/types/api/media/image.d.ts +161 -150
  41. package/types/api/media/live.d.ts +88 -82
  42. package/types/api/media/map.d.ts +47 -43
  43. package/types/api/media/recorder.d.ts +90 -84
  44. package/types/api/media/video-processing.d.ts +10 -6
  45. package/types/api/media/video.d.ts +63 -58
  46. package/types/api/network/download.d.ts +34 -30
  47. package/types/api/network/mdns.d.ts +104 -91
  48. package/types/api/network/request.d.ts +83 -79
  49. package/types/api/network/udp.d.ts +20 -16
  50. package/types/api/network/upload.d.ts +60 -56
  51. package/types/api/network/websocket.d.ts +201 -194
  52. package/types/api/open-api/account.d.ts +18 -14
  53. package/types/api/open-api/address.d.ts +27 -23
  54. package/types/api/open-api/authorize.d.ts +30 -26
  55. package/types/api/open-api/card.d.ts +55 -51
  56. package/types/api/open-api/customer-service.d.ts +21 -17
  57. package/types/api/open-api/facial.d.ts +28 -24
  58. package/types/api/open-api/invoice.d.ts +38 -34
  59. package/types/api/open-api/login.d.ts +56 -52
  60. package/types/api/open-api/navigate.d.ts +79 -75
  61. package/types/api/open-api/payment.d.ts +34 -30
  62. package/types/api/open-api/settings.d.ts +49 -45
  63. package/types/api/open-api/soter.d.ts +92 -86
  64. package/types/api/open-api/subscribe-message.d.ts +24 -20
  65. package/types/api/open-api/user-info.d.ts +60 -57
  66. package/types/api/open-api/werun.d.ts +50 -46
  67. package/types/api/route/index.d.ts +122 -118
  68. package/types/api/share/index.d.ts +68 -64
  69. package/types/api/storage/background-fetch.d.ts +40 -35
  70. package/types/api/storage/index.d.ts +267 -262
  71. package/types/api/swan/index.d.ts +47 -42
  72. package/types/api/ui/animation.d.ts +21 -17
  73. package/types/api/ui/background.d.ts +38 -34
  74. package/types/api/ui/custom-component.d.ts +22 -18
  75. package/types/api/ui/fonts.d.ts +26 -21
  76. package/types/api/ui/interaction.d.ts +167 -121
  77. package/types/api/ui/keyboard.d.ts +59 -55
  78. package/types/api/ui/menu.d.ts +10 -6
  79. package/types/api/ui/navigation-bar.d.ts +67 -63
  80. package/types/api/ui/pull-down-refresh.d.ts +33 -29
  81. package/types/api/ui/scroll.d.ts +30 -26
  82. package/types/api/ui/sticky.d.ts +22 -19
  83. package/types/api/ui/tab-bar.d.ts +101 -97
  84. package/types/api/ui/window.d.ts +24 -18
  85. package/types/api/worker/index.d.ts +28 -24
  86. package/types/api/wxml/index.d.ts +42 -38
  87. package/types/global.d.ts +390 -0
  88. package/types/index.d.ts +12 -98
  89. package/types/taro.api.d.ts +94 -0
  90. package/types/taro.component.d.ts +10 -57
  91. package/types/taro.config.d.ts +24 -6
  92. package/types/taro.extend.d.ts +33 -75
  93. package/types/taro.hooks.d.ts +68 -67
  94. package/types/taro.lifecycle.d.ts +47 -28
  95. package/types/api/ad/index.ts +0 -6
  96. package/types/api/alipay/index.ts +0 -7
  97. package/types/api/index.d.ts +0 -352
@@ -1,4 +1,6 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace getSystemInfoSync {
3
5
  /**
4
6
  * 注意:**H5** 端不支持 version、statusBarHeight、fontSizeSetting、SDKVersion
@@ -44,7 +46,7 @@ declare namespace Taro {
44
46
  /** 客户端平台 */
45
47
  platform: string
46
48
  /** 在竖屏正方向下的安全区域 */
47
- safeArea: General.SafeAreaResult
49
+ safeArea: TaroGeneral.SafeAreaResult
48
50
  /** 屏幕高度,单位px */
49
51
  screenHeight: number
50
52
  /** 屏幕宽度,单位px */
@@ -54,7 +56,7 @@ declare namespace Taro {
54
56
  /** 操作系统及版本 */
55
57
  system: string
56
58
  /** 系统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏) */
57
- theme?: 'light' | 'dark'
59
+ theme?: 'light' | 'dark'
58
60
  /** 微信版本号 */
59
61
  version: string
60
62
  /** Wi-Fi 的系统开关 */
@@ -68,28 +70,6 @@ declare namespace Taro {
68
70
  }
69
71
  }
70
72
 
71
- /**
72
- * 获取系统信息同步接口。
73
- * @supported weapp, h5, rn
74
- * @example
75
- * ```tsx
76
- * try {
77
- * const res = Taro.getSystemInfoSync()
78
- * console.log(res.model)
79
- * console.log(res.pixelRatio)
80
- * console.log(res.windowWidth)
81
- * console.log(res.windowHeight)
82
- * console.log(res.language)
83
- * console.log(res.version)
84
- * console.log(res.platform)
85
- * } catch (e) {
86
- * // Do something when catch error
87
- * }
88
- * ```
89
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfoSync.html
90
- */
91
- function getSystemInfoSync(): getSystemInfoSync.Result
92
-
93
73
  namespace getSystemInfo {
94
74
  interface Option {
95
75
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
@@ -103,7 +83,7 @@ declare namespace Taro {
103
83
  * 注意:**H5** 端不支持 version、statusBarHeight、fontSizeSetting、SDKVersion
104
84
  * 小程序可以在微信和企业微信中调用此接口,但是在企业微信中调用此接口时,会额外返回一个 environment 字段(微信中不返回),如此字段值为 wxwork,则表示当前小程序运行在企业微信环境中。
105
85
  */
106
- interface Result extends General.CallbackResult {
86
+ interface Result extends TaroGeneral.CallbackResult {
107
87
  /** 客户端基础库版本 */
108
88
  SDKVersion: string
109
89
  /** 允许微信使用相册的开关(仅 iOS 有效) */
@@ -141,7 +121,7 @@ declare namespace Taro {
141
121
  /** 客户端平台 */
142
122
  platform: string
143
123
  /** 在竖屏正方向下的安全区域 */
144
- safeArea: General.SafeAreaResult
124
+ safeArea: TaroGeneral.SafeAreaResult
145
125
  /** 屏幕高度,单位px */
146
126
  screenHeight: number
147
127
  /** 屏幕宽度,单位px */
@@ -162,33 +142,58 @@ declare namespace Taro {
162
142
  environment?: string
163
143
  /** 调用结果 */
164
144
  errMsg: string
145
+ }
165
146
  }
147
+
148
+ interface TaroStatic {
149
+ /**
150
+ * 获取系统信息同步接口。
151
+ * @supported weapp, h5, rn
152
+ * @example
153
+ * ```tsx
154
+ * try {
155
+ * const res = Taro.getSystemInfoSync()
156
+ * console.log(res.model)
157
+ * console.log(res.pixelRatio)
158
+ * console.log(res.windowWidth)
159
+ * console.log(res.windowHeight)
160
+ * console.log(res.language)
161
+ * console.log(res.version)
162
+ * console.log(res.platform)
163
+ * } catch (e) {
164
+ * // Do something when catch error
165
+ * }
166
+ * ```
167
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfoSync.html
168
+ */
169
+ getSystemInfoSync(): getSystemInfoSync.Result
170
+
171
+ /**
172
+ * 获取系统信息,支持 `Promise` 化使用。
173
+ * @supported weapp, h5, rn
174
+ * @example
175
+ * ```tsx
176
+ * Taro.getSystemInfo({
177
+ * success: res => console.log(res)
178
+ * })
179
+ * .then(res => console.log(res))
180
+ * ```
181
+ * @example
182
+ * ```tsx
183
+ * Taro.getSystemInfo({
184
+ * success: function (res) {
185
+ * console.log(res.model)
186
+ * console.log(res.pixelRatio)
187
+ * console.log(res.windowWidth)
188
+ * console.log(res.windowHeight)
189
+ * console.log(res.language)
190
+ * console.log(res.version)
191
+ * console.log(res.platform)
192
+ * }
193
+ * })
194
+ * ```
195
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfo.html
196
+ */
197
+ getSystemInfo(res?: getSystemInfo.Option): Promise<getSystemInfo.Result>
166
198
  }
167
- /**
168
- * 获取系统信息,支持 `Promise` 化使用。
169
- * @supported weapp, h5, rn
170
- * @example
171
- * ```tsx
172
- * Taro.getSystemInfo({
173
- * success: res => console.log(res)
174
- * })
175
- * .then(res => console.log(res))
176
- * ```
177
- * @example
178
- * ```tsx
179
- * Taro.getSystemInfo({
180
- * success: function (res) {
181
- * console.log(res.model)
182
- * console.log(res.pixelRatio)
183
- * console.log(res.windowWidth)
184
- * console.log(res.windowHeight)
185
- * console.log(res.language)
186
- * console.log(res.version)
187
- * console.log(res.platform)
188
- * }
189
- * })
190
- * ```
191
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfo.html
192
- */
193
- function getSystemInfo(res?: getSystemInfo.Option): Promise<getSystemInfo.Result>
194
199
  }
@@ -1,35 +1,6 @@
1
- declare namespace Taro {
2
- /**
3
- * 获取**全局唯一**的版本更新管理器,用于管理小程序更新。
4
- * 关于小程序的更新机制,可以查看[运行机制](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/operating-mechanism.html)文档。
5
- * @example
6
- * ```tsx
7
- * const updateManager = Taro.getUpdateManager()
8
- * updateManager.onCheckForUpdate(function (res) {
9
- * // 请求完新版本信息的回调
10
- * console.log(res.hasUpdate)
11
- * })
12
- * updateManager.onUpdateReady(function () {
13
- * Taro.showModal({
14
- * title: '更新提示',
15
- * content: '新版本已经准备好,是否重启应用?',
16
- * success: function (res) {
17
- * if (res.confirm) {
18
- * // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
19
- * updateManager.applyUpdate()
20
- * }
21
- * }
22
- * })
23
- * })
24
- * updateManager.onUpdateFailed(function () {
25
- * // 新的版本下载失败
26
- * })
27
- * ```
28
- * @supported weapp
29
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/wx.getUpdateManager.html
30
- */
31
- function getUpdateManager(): UpdateManager
1
+ import Taro from '../../index'
32
2
 
3
+ declare module '../../index' {
33
4
  namespace UpdateManager {
34
5
  /** 向微信后台请求检查更新结果事件的回调函数 */
35
6
  type OnCheckForUpdateCallback = (
@@ -61,14 +32,47 @@ declare namespace Taro {
61
32
  */
62
33
  onUpdateFailed(
63
34
  /** 小程序更新失败事件的回调函数 */
64
- callback: (res: General.CallbackResult) => void,
35
+ callback: (res: TaroGeneral.CallbackResult) => void,
65
36
  ): void
66
37
  /** 监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调
67
38
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.onUpdateReady.html
68
39
  */
69
40
  onUpdateReady(
70
41
  /** 小程序有版本更新事件的回调函数 */
71
- callback: (res: General.CallbackResult) => void,
42
+ callback: (res: TaroGeneral.CallbackResult) => void,
72
43
  ): void
73
44
  }
45
+
46
+ interface TaroStatic {
47
+ /**
48
+ * 获取**全局唯一**的版本更新管理器,用于管理小程序更新。
49
+ * 关于小程序的更新机制,可以查看[运行机制](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/operating-mechanism.html)文档。
50
+ * @example
51
+ * ```tsx
52
+ * const updateManager = Taro.getUpdateManager()
53
+ * updateManager.onCheckForUpdate(function (res) {
54
+ * // 请求完新版本信息的回调
55
+ * console.log(res.hasUpdate)
56
+ * })
57
+ * updateManager.onUpdateReady(function () {
58
+ * Taro.showModal({
59
+ * title: '更新提示',
60
+ * content: '新版本已经准备好,是否重启应用?',
61
+ * success: function (res) {
62
+ * if (res.confirm) {
63
+ * // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
64
+ * updateManager.applyUpdate()
65
+ * }
66
+ * }
67
+ * })
68
+ * })
69
+ * updateManager.onUpdateFailed(function () {
70
+ * // 新的版本下载失败
71
+ * })
72
+ * ```
73
+ * @supported weapp
74
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/wx.getUpdateManager.html
75
+ */
76
+ getUpdateManager(): UpdateManager
77
+ }
74
78
  }
@@ -1,4 +1,6 @@
1
- declare namespace Taro {
1
+ import Taro from '../../../index'
2
+
3
+ declare module '../../../index' {
2
4
  namespace onPageNotFound {
3
5
  interface Result {
4
6
  /** 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面) */
@@ -6,22 +8,11 @@ declare namespace Taro {
6
8
  /** 不存在页面的路径 */
7
9
  path: string
8
10
  /** 打开不存在页面的 query 参数 */
9
- query: General.IAnyObject
11
+ query: TaroGeneral.IAnyObject
10
12
  }
11
13
  /** 小程序要打开的页面不存在事件的回调函数 */
12
14
  type Callback = (res: Result) => void
13
15
  }
14
- /**
15
- * 监听小程序要打开的页面不存在事件。该事件与 [`App.onPageNotFound`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onpagenotfoundobject-object) 的回调时机一致。
16
- *
17
- * **注意**
18
- * - 开发者可以在回调中进行页面重定向,但必须在回调中**同步**处理,异步处理(例如 `setTimeout` 异步执行)无效。
19
- * - 若开发者没有调用 [Taro.onPageNotFound](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html) 绑定监听,也没有声明 `App.onPageNotFound`,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。
20
- * - 如果回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再第二次回调。
21
- * @supported weapp
22
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html
23
- */
24
- function onPageNotFound(callback: onPageNotFound.Callback): void
25
16
 
26
17
  namespace onError {
27
18
  /** 小程序错误事件的回调函数 */
@@ -30,62 +21,13 @@ declare namespace Taro {
30
21
  error: string,
31
22
  ) => void
32
23
  }
33
- /** 监听小程序错误事件。如脚本错误或 API 调用报错等。该事件与 [`App.onError`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onerrorstring-error) 的回调时机与参数一致。
34
- * @supported weapp
35
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html
36
- */
37
- function onError(callback: onError.Callback): void
38
-
39
- /**
40
- * 监听音频中断结束事件。在收到 onAudioInterruptionBegin 事件之后,小程序内所有音频会暂停,收到此事件之后才可再次播放成功
41
- * @supported weapp
42
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionEnd.html
43
- */
44
- function onAudioInterruptionEnd (
45
- /** 音频中断结束事件的回调函数 */
46
- callback: (res: General.CallbackResult) => void,
47
- ): void
48
-
49
- /**
50
- * 监听音频因为受到系统占用而被中断开始事件。以下场景会触发此事件:闹钟、电话、FaceTime 通话、微信语音聊天、微信视频聊天。此事件触发后,小程序内所有音频会暂停。
51
- * @supported weapp
52
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionBegin.html
53
- */
54
- function onAudioInterruptionBegin(
55
- /** 音频因为受到系统占用而被中断开始事件的回调函数 */
56
- callback: (res: General.CallbackResult) => void,
57
- ): void
58
-
59
- /** 监听小程序切前台事件。该事件与 [`App.onShow`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onshowobject-object) 的回调参数一致。
60
- *
61
- * **返回有效 referrerInfo 的场景**
62
- *
63
- * | 场景值 | 场景 | appId含义 |
64
- * | ------ | ------------------------------- | ---------- |
65
- * | 1020 | 公众号 profile 页相关小程序列表 | 来源公众号 |
66
- * | 1035 | 公众号自定义菜单 | 来源公众号 |
67
- * | 1036 | App 分享消息卡片 | 来源App |
68
- * | 1037 | 小程序打开小程序 | 来源小程序 |
69
- * | 1038 | 从另一个小程序返回 | 来源小程序 |
70
- * | 1043 | 公众号模板消息 | 来源公众号 |
71
- *
72
- * **注意**
73
- *
74
- * 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
75
- * @supported weapp
76
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppShow.html
77
- */
78
- function onAppShow(
79
- /** 小程序切前台事件的回调函数 */
80
- callback: (result: onAppShow.CallbackResult) => void,
81
- ): void
82
24
 
83
25
  namespace onAppShow {
84
26
  interface CallbackResult {
85
27
  /** 小程序切前台的路径 */
86
28
  path: string
87
29
  /** 小程序切前台的 query 参数 */
88
- query: General.IAnyObject
30
+ query: TaroGeneral.IAnyObject
89
31
  /** 来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 `{}`。(参见后文注意) */
90
32
  referrerInfo: ResultReferrerInfo
91
33
  /** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
@@ -98,65 +40,9 @@ declare namespace Taro {
98
40
  /** 来源小程序、公众号或 App 的 appId */
99
41
  appId: string
100
42
  /** 来源小程序传过来的数据,scene=1037或1038时支持 */
101
- extraData: General.IAnyObject
43
+ extraData: TaroGeneral.IAnyObject
102
44
  }
103
45
  }
104
- /** 监听小程序切后台事件。该事件与 [`App.onHide`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onhide) 的回调时机一致。
105
- * @supported weapp
106
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppHide.html
107
- */
108
- function onAppHide(
109
- /** 小程序切后台事件的回调函数 */
110
- callback: (res: General.CallbackResult) => void,
111
- ): void
112
- /** 取消监听小程序要打开的页面不存在事件
113
- * @supported weapp
114
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offPageNotFound.html
115
- */
116
- function offPageNotFound(
117
- /** 小程序要打开的页面不存在事件的回调函数 */
118
- callback: (res: General.CallbackResult) => void,
119
- ): void
120
- /** 取消监听音频播放错误事件
121
- * @supported weapp
122
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offError.html
123
- */
124
- function offError(
125
- /** 音频播放错误事件的回调函数 */
126
- callback: (res: General.CallbackResult) => void,
127
- ): void
128
- /** 取消监听音频中断结束事件
129
- * @supported weapp
130
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAudioInterruptionEnd.html
131
- */
132
- function offAudioInterruptionEnd(
133
- /** 音频中断结束事件的回调函数 */
134
- callback: (res: General.CallbackResult) => void,
135
- ): void
136
- /** 取消监听音频因为受到系统占用而被中断开始事件
137
- * @supported weapp
138
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAudioInterruptionBegin.html
139
- */
140
- function offAudioInterruptionBegin(
141
- /** 音频因为受到系统占用而被中断开始事件的回调函数 */
142
- callback: (res: General.CallbackResult) => void,
143
- ): void
144
- /** 取消监听小程序切前台事件
145
- * @supported weapp
146
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppShow.html
147
- */
148
- function offAppShow(
149
- /** 小程序切前台事件的回调函数 */
150
- callback: (res: General.CallbackResult) => void,
151
- ): void
152
- /** 取消监听小程序切后台事件
153
- * @supported weapp
154
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppHide.html
155
- */
156
- function offAppHide(
157
- /** 小程序切后台事件的回调函数 */
158
- callback: (res: General.CallbackResult) => void,
159
- ): void
160
46
 
161
47
  namespace themeChange {
162
48
  interface ITheme {
@@ -172,16 +58,146 @@ declare namespace Taro {
172
58
  /** 系统主题改变事件的回调函数 */
173
59
  type onThemeChangeCallback = (res: onThemeChangeResult) => void
174
60
  /** 系统主题改变事件的回调函数 */
175
- type offThemeChangeCallback = (res: General.CallbackResult) => void
61
+ type offThemeChangeCallback = (res: TaroGeneral.CallbackResult) => void
62
+ }
63
+
64
+ interface TaroStatic {
65
+ /**
66
+ * 监听小程序要打开的页面不存在事件。该事件与 [`App.onPageNotFound`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onpagenotfoundobject-object) 的回调时机一致。
67
+ *
68
+ * **注意**
69
+ * - 开发者可以在回调中进行页面重定向,但必须在回调中**同步**处理,异步处理(例如 `setTimeout` 异步执行)无效。
70
+ * - 若开发者没有调用 [Taro.onPageNotFound](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html) 绑定监听,也没有声明 `App.onPageNotFound`,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。
71
+ * - 如果回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再第二次回调。
72
+ * @supported weapp
73
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html
74
+ */
75
+ onPageNotFound(callback: onPageNotFound.Callback): void
76
+
77
+ /** 监听小程序错误事件。如脚本错误或 API 调用报错等。该事件与 [`App.onError`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onerrorstring-error) 的回调时机与参数一致。
78
+ * @supported weapp
79
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html
80
+ */
81
+ onError(callback: onError.Callback): void
82
+
83
+ /**
84
+ * 监听音频中断结束事件。在收到 onAudioInterruptionBegin 事件之后,小程序内所有音频会暂停,收到此事件之后才可再次播放成功
85
+ * @supported weapp
86
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionEnd.html
87
+ */
88
+ onAudioInterruptionEnd (
89
+ /** 音频中断结束事件的回调函数 */
90
+ callback: (res: TaroGeneral.CallbackResult) => void,
91
+ ): void
92
+
93
+ /**
94
+ * 监听音频因为受到系统占用而被中断开始事件。以下场景会触发此事件:闹钟、电话、FaceTime 通话、微信语音聊天、微信视频聊天。此事件触发后,小程序内所有音频会暂停。
95
+ * @supported weapp
96
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAudioInterruptionBegin.html
97
+ */
98
+ onAudioInterruptionBegin(
99
+ /** 音频因为受到系统占用而被中断开始事件的回调函数 */
100
+ callback: (res: TaroGeneral.CallbackResult) => void,
101
+ ): void
102
+
103
+ /** 监听小程序切前台事件。该事件与 [`App.onShow`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onshowobject-object) 的回调参数一致。
104
+ *
105
+ * **返回有效 referrerInfo 的场景**
106
+ *
107
+ * | 场景值 | 场景 | appId含义 |
108
+ * | ------ | ------------------------------- | ---------- |
109
+ * | 1020 | 公众号 profile 页相关小程序列表 | 来源公众号 |
110
+ * | 1035 | 公众号自定义菜单 | 来源公众号 |
111
+ * | 1036 | App 分享消息卡片 | 来源App |
112
+ * | 1037 | 小程序打开小程序 | 来源小程序 |
113
+ * | 1038 | 从另一个小程序返回 | 来源小程序 |
114
+ * | 1043 | 公众号模板消息 | 来源公众号 |
115
+ *
116
+ * **注意**
117
+ *
118
+ * 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
119
+ * @supported weapp
120
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppShow.html
121
+ */
122
+ onAppShow(
123
+ /** 小程序切前台事件的回调函数 */
124
+ callback: (result: onAppShow.CallbackResult) => void,
125
+ ): void
126
+
127
+ /** 监听小程序切后台事件。该事件与 [`App.onHide`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onhide) 的回调时机一致。
128
+ * @supported weapp
129
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppHide.html
130
+ */
131
+ onAppHide(
132
+ /** 小程序切后台事件的回调函数 */
133
+ callback: (res: TaroGeneral.CallbackResult) => void,
134
+ ): void
135
+
136
+ /** 取消监听小程序要打开的页面不存在事件
137
+ * @supported weapp
138
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offPageNotFound.html
139
+ */
140
+ offPageNotFound(
141
+ /** 小程序要打开的页面不存在事件的回调函数 */
142
+ callback: (res: TaroGeneral.CallbackResult) => void,
143
+ ): void
144
+
145
+ /** 取消监听音频播放错误事件
146
+ * @supported weapp
147
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offError.html
148
+ */
149
+
150
+ offError(
151
+ /** 音频播放错误事件的回调函数 */
152
+ callback: (res: TaroGeneral.CallbackResult) => void,
153
+ ): void
154
+
155
+ /** 取消监听音频中断结束事件
156
+ * @supported weapp
157
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAudioInterruptionEnd.html
158
+ */
159
+ offAudioInterruptionEnd(
160
+ /** 音频中断结束事件的回调函数 */
161
+ callback: (res: TaroGeneral.CallbackResult) => void,
162
+ ): void
163
+
164
+ /** 取消监听音频因为受到系统占用而被中断开始事件
165
+ * @supported weapp
166
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAudioInterruptionBegin.html
167
+ */
168
+ offAudioInterruptionBegin(
169
+ /** 音频因为受到系统占用而被中断开始事件的回调函数 */
170
+ callback: (res: TaroGeneral.CallbackResult) => void,
171
+ ): void
172
+
173
+ /** 取消监听小程序切前台事件
174
+ * @supported weapp
175
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppShow.html
176
+ */
177
+ offAppShow(
178
+ /** 小程序切前台事件的回调函数 */
179
+ callback: (res: TaroGeneral.CallbackResult) => void,
180
+ ): void
181
+
182
+ /** 取消监听小程序切后台事件
183
+ * @supported weapp
184
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppHide.html
185
+ */
186
+ offAppHide(
187
+ /** 小程序切后台事件的回调函数 */
188
+ callback: (res: TaroGeneral.CallbackResult) => void,
189
+ ): void
190
+
191
+ /** 监听系统主题改变事件。该事件与 [`App.onThemeChange`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onThemeChange-Object-object) 的回调时机一致。
192
+ * @supported weapp
193
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onThemeChange.html
194
+ */
195
+ onThemeChange(callback: themeChange.onThemeChangeCallback): void
196
+
197
+ /** 取消监听系统主题改变事件
198
+ * @supported weapp
199
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offThemeChange.html
200
+ */
201
+ offThemeChange(callback: themeChange.offThemeChangeCallback): void
176
202
  }
177
- /** 监听系统主题改变事件。该事件与 [`App.onThemeChange`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onThemeChange-Object-object) 的回调时机一致。
178
- * @supported weapp
179
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onThemeChange.html
180
- */
181
- function onThemeChange(callback: themeChange.onThemeChangeCallback): void
182
- /** 取消监听系统主题改变事件
183
- * @supported weapp
184
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offThemeChange.html
185
- */
186
- function offThemeChange(callback: themeChange.offThemeChangeCallback): void
187
203
  }
@@ -1,11 +1,15 @@
1
- declare namespace Taro {
2
- /**
3
- * 获取小程序启动时的参数。与 [`App.onLaunch`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onlaunchobject-object) 的回调参数一致。
4
- *
5
- * **注意**
6
- * 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
7
- * @supported weapp
8
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html
9
- */
10
- function getLaunchOptionsSync(): General.LaunchOptionsApp
1
+ import Taro from '../../../index'
2
+
3
+ declare module '../../../index' {
4
+ interface TaroStatic {
5
+ /**
6
+ * 获取小程序启动时的参数。与 [`App.onLaunch`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onlaunchobject-object) 的回调参数一致。
7
+ *
8
+ * **注意**
9
+ * 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。
10
+ * @supported weapp
11
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html
12
+ */
13
+ getLaunchOptionsSync(): TaroGeneral.LaunchOptionsApp
14
+ }
11
15
  }