@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.
Files changed (140) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +147 -0
  3. package/dist/index.js.map +1 -0
  4. package/index.js +9 -0
  5. package/package.json +86 -0
  6. package/types/api/ad/index.d.ts +197 -0
  7. package/types/api/ai/face.d.ts +133 -0
  8. package/types/api/ai/inference.d.ts +129 -0
  9. package/types/api/ai/visionkit.d.ts +874 -0
  10. package/types/api/alipay/index.d.ts +69 -0
  11. package/types/api/base/crypto.d.ts +104 -0
  12. package/types/api/base/debug.d.ts +329 -0
  13. package/types/api/base/env.d.ts +19 -0
  14. package/types/api/base/index.d.ts +102 -0
  15. package/types/api/base/performance.d.ts +258 -0
  16. package/types/api/base/system.d.ts +742 -0
  17. package/types/api/base/update.d.ts +130 -0
  18. package/types/api/base/weapp/app-event.d.ts +265 -0
  19. package/types/api/base/weapp/life-cycle.d.ts +155 -0
  20. package/types/api/canvas/index.d.ts +2162 -0
  21. package/types/api/cloud/index.d.ts +2622 -0
  22. package/types/api/data-analysis/index.d.ts +122 -0
  23. package/types/api/device/accelerometer.d.ts +102 -0
  24. package/types/api/device/accessibility.d.ts +26 -0
  25. package/types/api/device/battery.d.ts +46 -0
  26. package/types/api/device/bluetooth-ble.d.ts +601 -0
  27. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  28. package/types/api/device/bluetooth.d.ts +463 -0
  29. package/types/api/device/calendar.d.ts +98 -0
  30. package/types/api/device/clipboard.d.ts +81 -0
  31. package/types/api/device/compass.d.ts +105 -0
  32. package/types/api/device/contact.d.ts +110 -0
  33. package/types/api/device/gyroscope.d.ts +85 -0
  34. package/types/api/device/iBeacon.d.ts +168 -0
  35. package/types/api/device/keyboard.d.ts +97 -0
  36. package/types/api/device/memory.d.ts +52 -0
  37. package/types/api/device/motion.d.ts +88 -0
  38. package/types/api/device/network.d.ts +172 -0
  39. package/types/api/device/nfc.d.ts +1238 -0
  40. package/types/api/device/phone.d.ts +30 -0
  41. package/types/api/device/scan.d.ts +111 -0
  42. package/types/api/device/screen.d.ts +217 -0
  43. package/types/api/device/sms.d.ts +26 -0
  44. package/types/api/device/vibrate.d.ts +51 -0
  45. package/types/api/device/wifi.d.ts +301 -0
  46. package/types/api/ext/index.d.ts +64 -0
  47. package/types/api/files/index.d.ts +1472 -0
  48. package/types/api/framework/index.d.ts +51 -0
  49. package/types/api/location/index.d.ts +517 -0
  50. package/types/api/media/audio.d.ts +1013 -0
  51. package/types/api/media/background-audio.d.ts +291 -0
  52. package/types/api/media/camera.d.ts +207 -0
  53. package/types/api/media/editor.d.ts +239 -0
  54. package/types/api/media/image.d.ts +469 -0
  55. package/types/api/media/live.d.ts +461 -0
  56. package/types/api/media/map.d.ts +638 -0
  57. package/types/api/media/media-recorder.d.ts +117 -0
  58. package/types/api/media/recorder.d.ts +317 -0
  59. package/types/api/media/video-decoder.d.ts +117 -0
  60. package/types/api/media/video-processing.d.ts +84 -0
  61. package/types/api/media/video.d.ts +527 -0
  62. package/types/api/media/voip.d.ts +393 -0
  63. package/types/api/navigate/index.d.ts +327 -0
  64. package/types/api/network/download.d.ts +173 -0
  65. package/types/api/network/mdns.d.ts +191 -0
  66. package/types/api/network/request.d.ts +480 -0
  67. package/types/api/network/tcp.d.ts +181 -0
  68. package/types/api/network/udp.d.ts +218 -0
  69. package/types/api/network/upload.d.ts +201 -0
  70. package/types/api/network/websocket.d.ts +383 -0
  71. package/types/api/open-api/account.d.ts +51 -0
  72. package/types/api/open-api/address.d.ts +68 -0
  73. package/types/api/open-api/authorize.d.ts +80 -0
  74. package/types/api/open-api/card.d.ts +110 -0
  75. package/types/api/open-api/channels.d.ts +225 -0
  76. package/types/api/open-api/customer-service.d.ts +45 -0
  77. package/types/api/open-api/device-voip.d.ts +103 -0
  78. package/types/api/open-api/facial.d.ts +98 -0
  79. package/types/api/open-api/favorites.d.ts +101 -0
  80. package/types/api/open-api/group.d.ts +59 -0
  81. package/types/api/open-api/invoice.d.ts +87 -0
  82. package/types/api/open-api/license-plate.d.ts +27 -0
  83. package/types/api/open-api/login.d.ts +115 -0
  84. package/types/api/open-api/my-miniprogram.d.ts +28 -0
  85. package/types/api/open-api/privacy.d.ts +107 -0
  86. package/types/api/open-api/redpackage.d.ts +24 -0
  87. package/types/api/open-api/settings.d.ts +174 -0
  88. package/types/api/open-api/soter.d.ts +184 -0
  89. package/types/api/open-api/sticker.d.ts +83 -0
  90. package/types/api/open-api/subscribe-message.d.ts +305 -0
  91. package/types/api/open-api/user-info.d.ts +182 -0
  92. package/types/api/open-api/werun.d.ts +101 -0
  93. package/types/api/payment/index.d.ts +119 -0
  94. package/types/api/qq/index.d.ts +354 -0
  95. package/types/api/route/index.d.ts +324 -0
  96. package/types/api/share/index.d.ts +354 -0
  97. package/types/api/skyline/index.d.ts +345 -0
  98. package/types/api/storage/background-fetch.d.ts +131 -0
  99. package/types/api/storage/cache-manager.d.ts +249 -0
  100. package/types/api/storage/index.d.ts +405 -0
  101. package/types/api/swan/bookshelf.d.ts +307 -0
  102. package/types/api/swan/download-package.d.ts +80 -0
  103. package/types/api/swan/index.d.ts +251 -0
  104. package/types/api/swan/pay.d.ts +139 -0
  105. package/types/api/taro.extend.d.ts +233 -0
  106. package/types/api/taro.hooks.d.ts +148 -0
  107. package/types/api/ui/animation.d.ts +427 -0
  108. package/types/api/ui/background.d.ts +69 -0
  109. package/types/api/ui/custom-component.d.ts +23 -0
  110. package/types/api/ui/fonts.d.ts +77 -0
  111. package/types/api/ui/interaction.d.ts +281 -0
  112. package/types/api/ui/menu.d.ts +29 -0
  113. package/types/api/ui/navigation-bar.d.ts +130 -0
  114. package/types/api/ui/pull-down-refresh.d.ts +50 -0
  115. package/types/api/ui/scroll.d.ts +114 -0
  116. package/types/api/ui/sticky.d.ts +32 -0
  117. package/types/api/ui/tab-bar.d.ts +196 -0
  118. package/types/api/ui/window.d.ts +71 -0
  119. package/types/api/worker/index.d.ts +83 -0
  120. package/types/api/wxml/index.d.ts +540 -0
  121. package/types/compile/compiler.d.ts +32 -0
  122. package/types/compile/config/h5.d.ts +134 -0
  123. package/types/compile/config/harmony.d.ts +118 -0
  124. package/types/compile/config/index.d.ts +8 -0
  125. package/types/compile/config/manifest.d.ts +155 -0
  126. package/types/compile/config/mini.d.ts +118 -0
  127. package/types/compile/config/plugin.d.ts +34 -0
  128. package/types/compile/config/project.d.ts +338 -0
  129. package/types/compile/config/rn.d.ts +85 -0
  130. package/types/compile/config/util.d.ts +179 -0
  131. package/types/compile/hooks.d.ts +13 -0
  132. package/types/compile/index.d.ts +11 -0
  133. package/types/compile/viteCompilerContext.d.ts +167 -0
  134. package/types/global.d.ts +428 -0
  135. package/types/index.d.ts +190 -0
  136. package/types/taro.api.d.ts +130 -0
  137. package/types/taro.component.d.ts +168 -0
  138. package/types/taro.config.d.ts +712 -0
  139. package/types/taro.lifecycle.d.ts +220 -0
  140. package/types/taro.runtime.d.ts +9 -0
@@ -0,0 +1,327 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace openEmbeddedMiniProgram {
5
+ interface Option {
6
+ /** 要打开的小程序 appId */
7
+ appId?: string
8
+ /** 打开的页面路径,如果为空则打开首页。path 中 ? 后面的部分会成为 query,在小程序的 `App.onLaunch`、`App.onShow` 和 `Page.onLoad` 的回调函数或小游戏的 [Taro.onShow](#) 回调函数、[Taro.getLaunchOptionsSync](/docs/apis/base/weapp/life-cycle/getLaunchOptionsSync) 中可以获取到 query 数据。对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。 */
9
+ path?: string
10
+ /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。如果跳转的是小游戏,可以在 [Taro.onShow](#)、[Taro.getLaunchOptionsSync](/docs/apis/base/weapp/life-cycle/getLaunchOptionsSync) 中可以获取到这份数据数据。 */
11
+ extraData?: TaroGeneral.IAnyObject
12
+ /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 */
13
+ envVersion?: keyof EnvVersion
14
+ /** 小程序链接,当传递该参数后,可以不传 appId 和 path。链接可以通过【小程序菜单】->【复制链接】获取。 */
15
+ shortLink?: string
16
+ /** 校验方式 。默认为binding */
17
+ verify?: keyof Verify
18
+ /** 不 reLaunch 目标小程序,直接打开目标跳转的小程序退后台时的页面,需满足以下条件:1. 目标跳转的小程序生命周期未被销毁;2. 且目标当次启动的path、query、apiCategory与上次启动相同。默认值为 false 。 */
19
+ noRelaunchIfPathUnchanged?: boolean
20
+ /** 打开的小程序是否支持全屏 */
21
+ allowFullScreen?: boolean
22
+ /** 接口调用成功的回调函数 */
23
+ success?: (res: TaroGeneral.CallbackResult) => void
24
+ /** 接口调用失败的回调函数 */
25
+ fail?: (res: TaroGeneral.CallbackResult) => void
26
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
27
+ complete?: (res: TaroGeneral.CallbackResult) => void
28
+ }
29
+
30
+ interface Verify {
31
+ /** 校验小程序管理后台的绑定关系 */
32
+ binding
33
+ /** 校验目标打开链接是否为小程序联盟商品。 */
34
+ unionProduct
35
+ }
36
+
37
+ interface EnvVersion {
38
+ /** 开发版 */
39
+ develop
40
+ /** 体验版 */
41
+ trial
42
+ /** 正式版 */
43
+ release
44
+ }
45
+ }
46
+
47
+ namespace navigateToMiniProgram {
48
+ interface Option {
49
+ /** 要打开的小程序 appId */
50
+ appId?: string
51
+ /** 打开的页面路径,如果为空则打开首页。path 中 ? 后面的部分会成为 query,在小程序的 `App.onLaunch`、`App.onShow` 和 `Page.onLoad` 的回调函数或小游戏的 [Taro.onShow](#) 回调函数、[Taro.getLaunchOptionsSync](/docs/apis/base/weapp/life-cycle/getLaunchOptionsSync) 中可以获取到 query 数据。对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。 */
52
+ path?: string
53
+ /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。如果跳转的是小游戏,可以在 [Taro.onShow](#)、[Taro.getLaunchOptionsSync](/docs/apis/base/weapp/life-cycle/getLaunchOptionsSync) 中可以获取到这份数据数据。 */
54
+ extraData?: TaroGeneral.IAnyObject
55
+ /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 */
56
+ envVersion?: keyof EnvVersion
57
+ /** 小程序链接,当传递该参数后,可以不传 appId 和 path。链接可以通过【小程序菜单】->【复制链接】获取。 */
58
+ shortLink?: string
59
+ /** 接口调用成功的回调函数 */
60
+ success?: (res: TaroGeneral.CallbackResult) => void
61
+ /** 接口调用失败的回调函数 */
62
+ fail?: (res: TaroGeneral.CallbackResult) => void
63
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
64
+ complete?: (res: TaroGeneral.CallbackResult) => void
65
+ }
66
+
67
+ interface EnvVersion {
68
+ /** 开发版 */
69
+ develop
70
+ /** 体验版 */
71
+ trial
72
+ /** 正式版 */
73
+ release
74
+ }
75
+ }
76
+
77
+ namespace navigateBackMiniProgram {
78
+ interface Option {
79
+ /** 需要返回给上一个小程序的数据,上一个小程序可在 `App.onShow` 中获取到这份数据。 [详情](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html)。 */
80
+ extraData?: TaroGeneral.IAnyObject
81
+ /** 接口调用成功的回调函数 */
82
+ success?: (res: TaroGeneral.CallbackResult) => void
83
+ /** 接口调用失败的回调函数 */
84
+ fail?: (res: TaroGeneral.CallbackResult) => void
85
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
86
+ complete?: (res: TaroGeneral.CallbackResult) => void
87
+ }
88
+ }
89
+
90
+ namespace exitMiniProgram {
91
+ interface Option {
92
+ /** 接口调用成功的回调函数 */
93
+ success?: (res: TaroGeneral.CallbackResult) => void
94
+ /** 接口调用失败的回调函数 */
95
+ fail?: (res: TaroGeneral.CallbackResult) => void
96
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
97
+ complete?: (res: TaroGeneral.CallbackResult) => void
98
+ }
99
+ }
100
+
101
+ namespace openBusinessView {
102
+ /**
103
+ * wxpayScoreEnable 业务参数
104
+ * @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_9.shtml
105
+ */
106
+ interface ScoreEnableExtraData {
107
+ /**
108
+ * 用于跳转到微信侧小程序授权数据,跳转到微信侧小程序传入,有效期为1小时;apply_permissions_token可以从[《商户预授权API》](https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_2.shtml)接口的返回参数中获取。
109
+ * 示例值:1230000109
110
+ * @type {string[1,2048]}
111
+ */
112
+ apply_permissions_token: string
113
+ }
114
+ /**
115
+ * wxpayScoreUse 业务参数
116
+ * @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_13.shtml
117
+ */
118
+ interface ScoreUsedExtraData {
119
+ /**
120
+ * 商户号:微信支付分配的商户号。
121
+ * 示例值:1230000109
122
+ * @type {string[1,32]}
123
+ */
124
+ mch_id: string
125
+ /**
126
+ * 可在【创建订单】接口的返回字段package中获取。
127
+ * 示例值:XXXXXXXX
128
+ * @type {string[1,128]}
129
+ */
130
+ package: string
131
+ /**
132
+ * 时间戳:生成签名时间戳,单位秒。
133
+ * 示例值:1530097563
134
+ * @type {string[1,32]}
135
+ */
136
+ timestamp: string
137
+ /**
138
+ * 随机字符串:生成签名随机串。由数字、大小写字母组成,长度不超过32位。
139
+ * 示例值:zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2
140
+ * @type {string[1,32]}
141
+ */
142
+ nonce_str: string
143
+ /**
144
+ * 签名方式:签名类型,仅支持HMAC-SHA256。
145
+ * 示例值:HMAC-SHA256
146
+ * @type {string[1,32]}
147
+ */
148
+ sign_type: string
149
+ /**
150
+ * 签名:使用字段mch_id、service_id、out_order_no、timestamp、nonce_str、sign_type按照签名生成算法计算得出的签名值。
151
+ * 示例值:029B52F67573D7E3BE74904BF9AEA
152
+ * @type {string[1,64]}
153
+ */
154
+ sign: string
155
+ }
156
+ /**
157
+ * wxpayScoreDetail 业务参数
158
+ * @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_25.shtml
159
+ */
160
+ interface ScoreDetailExtraData {
161
+ /**
162
+ * 商户号:微信支付分配的商户号。
163
+ * 示例值:1230000109
164
+ * @type {string[1,32]}
165
+ */
166
+ mch_id: string
167
+ /**
168
+ * 服务ID
169
+ * 示例值:88888888000011
170
+ * @type {string[1,32]}
171
+ */
172
+ service_id: string
173
+ /**
174
+ * 商户服务订单号:商户系统内部服务订单号(不是交易单号)。
175
+ * 示例值:234323JKHDFE1243252
176
+ * @type {string[1,32]}
177
+ */
178
+ out_order_no: string
179
+ /**
180
+ * 时间戳:生成签名时间戳,单位秒。
181
+ * 示例值:1530097563
182
+ * @type {string[1,32]}
183
+ */
184
+ timestamp: string
185
+ /**
186
+ * 随机字符串:生成签名随机串。由数字、大小写字母组成,长度不超过32位。
187
+ * 示例值:zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2
188
+ * @type {string[1,32]}
189
+ */
190
+ nonce_str: string
191
+ /**
192
+ * 签名方式:签名类型,仅支持HMAC-SHA256。
193
+ * 示例值:HMAC-SHA256
194
+ * @type {string[1,32]}
195
+ */
196
+ sign_type: string
197
+ /**
198
+ * 签名:使用字段mch_id、service_id、out_order_no、timestamp、nonce_str、sign_type按照签名生成算法计算得出的签名值。
199
+ * 示例值:029B52F67573D7E3BE74904BF9AEA
200
+ * @type {string[1,64]}
201
+ */
202
+ sign: string
203
+ }
204
+
205
+ interface Option {
206
+ /**
207
+ * 跳转类型:固定配置:wxpayScoreDetail
208
+ * 示例值:wxpayScoreDetail
209
+ * @type {string[1,16]}
210
+ * @memberof Option
211
+ */
212
+ businessType: 'wxpayScoreEnable' | 'wxpayScoreUse' | 'wxpayScoreDetail' | string
213
+ /** 业务参数:需要传递给支付分的业务数据 */
214
+ extraData: ScoreEnableExtraData | ScoreUsedExtraData | ScoreDetailExtraData
215
+ /** 接口调用成功的回调函数 */
216
+ success?: (res: TaroGeneral.CallbackResult) => void
217
+ /** 接口调用失败的回调函数 */
218
+ fail?: (res: TaroGeneral.CallbackResult) => void
219
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
220
+ complete?: (res: TaroGeneral.CallbackResult) => void
221
+ }
222
+ }
223
+
224
+ interface TaroStatic {
225
+ /** 打开半屏小程序。接入指引请参考 [半屏小程序能力](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/openEmbeddedMiniProgram.html)。
226
+ * @supported weapp
227
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/navigate/wx.openEmbeddedMiniProgram.html
228
+ */
229
+ openEmbeddedMiniProgram(option?: openEmbeddedMiniProgram.Option): Promise<TaroGeneral.CallbackResult>
230
+
231
+ /** 打开另一个小程序
232
+ *
233
+ * **使用限制**
234
+ * ##### 需要用户触发跳转
235
+ * 从 2.3.0 版本开始,若用户未点击小程序页面任意位置,则开发者将无法调用此接口自动跳转至其他小程序。
236
+ * ##### 需要用户确认跳转
237
+ * 从 2.3.0 版本开始,在跳转至其他小程序前,将统一增加弹窗,询问是否跳转,用户确认后才可以跳转其他小程序。如果用户点击取消,则回调 `fail cancel`。
238
+ * ##### 每个小程序可跳转的其他小程序数量限制为不超过 10 个
239
+ * 从 2.4.0 版本以及指定日期(具体待定)开始,开发者提交新版小程序代码时,如使用了跳转其他小程序功能,则需要在代码配置中声明将要跳转的小程序名单,限定不超过 10 个,否则将无法通过审核。该名单可在发布新版时更新,不支持动态修改。配置方法详见 [小程序全局配置](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html)。调用此接口时,所跳转的 appId 必须在配置列表中,否则回调 `fail appId "${appId}" is not in navigateToMiniProgramAppIdList`。
240
+ *
241
+ * **关于调试**
242
+ * - 在开发者工具上调用此 API 并不会真实的跳转到另外的小程序,但是开发者工具会校验本次调用跳转是否成功。[详情](https://developers.weixin.qq.com/miniprogram/dev/devtools/different.html#跳转小程序调试支持)
243
+ * - 开发者工具上支持被跳转的小程序处理接收参数的调试。[详情](https://developers.weixin.qq.com/miniprogram/dev/devtools/different.html#跳转小程序调试支持)
244
+ * @supported weapp, tt, harmony_hybrid
245
+ * @example
246
+ * ```tsx
247
+ * Taro.navigateToMiniProgram({
248
+ * appId: '',
249
+ * path: 'page/index/index?id=123',
250
+ * extraData: {
251
+ * foo: 'bar'
252
+ * },
253
+ * envVersion: 'develop',
254
+ * success: function(res) {
255
+ * // 打开成功
256
+ * }
257
+ * })
258
+ * ```
259
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/miniprogram-navigate/wx.navigateToMiniProgram.html
260
+ */
261
+ navigateToMiniProgram(option: navigateToMiniProgram.Option): Promise<TaroGeneral.CallbackResult>
262
+
263
+ /** 返回到上一个小程序。只有在当前小程序是被其他小程序打开时可以调用成功
264
+ *
265
+ * 注意:**微信客户端 iOS 6.5.9,Android 6.5.10 及以上版本支持**
266
+ * @supported weapp, tt
267
+ * @example
268
+ * ```tsx
269
+ * Taro.navigateBackMiniProgram({
270
+ * extraData: {
271
+ * foo: 'bar'
272
+ * },
273
+ * success: function (res) {
274
+ * // 返回成功
275
+ * }
276
+ * })
277
+ * ```
278
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/miniprogram-navigate/wx.navigateBackMiniProgram.html
279
+ */
280
+ navigateBackMiniProgram(option: navigateBackMiniProgram.Option): Promise<TaroGeneral.CallbackResult>
281
+
282
+ /** 退出当前小程序。必须有点击行为才能调用成功。
283
+ * @supported weapp
284
+ * @example
285
+ * ```tsx
286
+ * Taro.exitMiniProgram()
287
+ * ···
288
+ *
289
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/navigate/wx.exitMiniProgram.html
290
+ */
291
+ exitMiniProgram(option?: exitMiniProgram.Option): Promise<TaroGeneral.CallbackResult>
292
+
293
+ /** 商户通过调用订单详情接口打开微信支付分小程序,引导用户查看订单详情(小程序端)
294
+ * @supported weapp
295
+ * @example
296
+ * ```tsx
297
+ * if (Taro.openBusinessView) {
298
+ * Taro.openBusinessView({
299
+ * businessType: 'wxpayScoreDetail',
300
+ * extraData: {
301
+ * mch_id: '1230000109',
302
+ * service_id: '88888888000011',
303
+ * out_order_no: '1234323JKHDFE1243252',
304
+ * timestamp: '1530097563',
305
+ * nonce_str: 'zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2',
306
+ * sign_type: 'HMAC-SHA256',
307
+ * sign: '029B52F67573D7E3BE74904BF9AEA'
308
+ * },
309
+ * success() {
310
+ * //dosomething
311
+ * },
312
+ * fail() {
313
+ * //dosomething
314
+ * },
315
+ * complete() {
316
+ * //dosomething
317
+ * }
318
+ * });
319
+ * } else {
320
+ * //引导用户升级微信版本
321
+ * }
322
+ * ```
323
+ * @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_25.shtml
324
+ */
325
+ openBusinessView(option: openBusinessView.Option): Promise<TaroGeneral.CallbackResult>
326
+ }
327
+ }
@@ -0,0 +1,173 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace downloadFile {
5
+ interface Option {
6
+ /** 下载资源的 url */
7
+ url: string
8
+ /** 指定文件下载后存储的路径 */
9
+ filePath?: string
10
+ /** HTTP 请求的 Header,Header 中不能设置 Referer */
11
+ header?: TaroGeneral.IAnyObject
12
+ /** 超时时间,单位为毫秒 */
13
+ timeout?: number
14
+ /** 是否应使用传出凭据 (cookie) 发送此请求
15
+ * @default true
16
+ * @supported h5
17
+ */
18
+ withCredentials?: boolean
19
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
20
+ complete?: (res: TaroGeneral.CallbackResult) => void
21
+ /** 接口调用失败的回调函数 */
22
+ fail?: (res: TaroGeneral.CallbackResult) => void
23
+ /** 接口调用成功的回调函数 */
24
+ success?: (result: FileSuccessCallbackResult) => void
25
+ }
26
+
27
+ interface FileSuccessCallbackResult extends TaroGeneral.CallbackResult {
28
+ /** 用户文件路径。传入 filePath 时会返回,跟传入的 filePath 一致 */
29
+ filePath: string
30
+ /** 开发者服务器返回的 HTTP 状态码 */
31
+ statusCode: number
32
+ /** 临时文件路径。没传入 filePath 指定文件存储路径时会返回,下载后的文件会存储到一个临时文件 */
33
+ tempFilePath: string
34
+ /** 调用结果 */
35
+ errMsg: string
36
+ /**
37
+ * 开发者服务器返回的 HTTP Response Header
38
+ * @supported weapp
39
+ * @weapp 非官方文档标注属性
40
+ */
41
+ header?: TaroGeneral.IAnyObject
42
+ /**
43
+ * 数据长度,单位 Byte
44
+ * @supported weapp
45
+ * @weapp 非官方文档标注属性
46
+ */
47
+ dataLength?: number
48
+ /**
49
+ * cookies
50
+ * @supported weapp
51
+ * @weapp 非官方文档标注属性
52
+ */
53
+ cookies?: string[]
54
+ /** 网络请求过程中一些调试信息 */
55
+ profile?: TaroGeneral.IAnyObject
56
+ }
57
+ }
58
+
59
+ namespace DownloadTask {
60
+ /** HTTP Response Header 事件的回调函数 */
61
+ type OnHeadersReceivedCallback = (
62
+ result: OnHeadersReceivedCallbackResult,
63
+ ) => void
64
+ /** 下载进度变化事件的回调函数 */
65
+ type OnProgressUpdateCallback = (
66
+ result: OnProgressUpdateCallbackResult,
67
+ ) => void
68
+ interface OnHeadersReceivedCallbackResult {
69
+ /** 开发者服务器返回的 HTTP Response Header */
70
+ header: TaroGeneral.IAnyObject
71
+ }
72
+ interface OnProgressUpdateCallbackResult {
73
+ /** 下载进度百分比 */
74
+ progress: number
75
+ /** 预期需要下载的数据总长度,单位 Bytes */
76
+ totalBytesExpectedToWrite: number
77
+ /** 已经下载的数据长度,单位 Bytes */
78
+ totalBytesWritten: number
79
+ }
80
+
81
+ type DownloadTaskPromise = Promise<downloadFile.FileSuccessCallbackResult> & DownloadTask & {
82
+ headersReceive: DownloadTask['onHeadersReceived']
83
+ progress: DownloadTask['onProgressUpdate']
84
+ }
85
+ }
86
+
87
+ /** 一个可以监听下载进度变化事件,以及取消下载任务的对象
88
+ * @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid
89
+ * @example
90
+ * ```tsx
91
+ * const downloadTask = Taro.downloadFile({
92
+ * url: 'http://example.com/audio/123', //仅为示例,并非真实的资源
93
+ * success (res) {
94
+ * Taro.playVoice({
95
+ * filePath: res.tempFilePath
96
+ * })
97
+ * }
98
+ * })
99
+ *
100
+ * downloadTask.onProgressUpdate((res) => {
101
+ * console.log('下载进度', res.progress)
102
+ * console.log('已经下载的数据长度', res.totalBytesWritten)
103
+ * console.log('预期需要下载的数据总长度', res.totalBytesExpectedToWrite)
104
+ * })
105
+ *
106
+ * downloadTask.abort() // 取消下载任务
107
+ * ```
108
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.html
109
+ */
110
+ interface DownloadTask {
111
+ /** 中断下载任务
112
+ * @supported weapp, h5, tt, harmony_hybrid
113
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.abort.html
114
+ */
115
+ abort(): void
116
+ /** 监听下载进度变化事件
117
+ * @supported weapp, h5, tt, harmony_hybrid
118
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.onProgressUpdate.html
119
+ */
120
+ onProgressUpdate(
121
+ /** 下载进度变化事件的回调函数 */
122
+ callback: DownloadTask.OnProgressUpdateCallback,
123
+ ): void
124
+ /** 取消监听下载进度变化事件
125
+ * @supported weapp, h5, tt, harmony_hybrid
126
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.offProgressUpdate.html
127
+ */
128
+ offProgressUpdate(
129
+ /** 下载进度变化事件的回调函数 */
130
+ callback: DownloadTask.OnProgressUpdateCallback,
131
+ ): void
132
+ /** 监听 HTTP Response Header 事件。会比请求完成事件更早
133
+ * @supported weapp, h5
134
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.onHeadersReceived.html
135
+ */
136
+ onHeadersReceived(
137
+ /** HTTP Response Header 事件的回调函数 */
138
+ callback: DownloadTask.OnHeadersReceivedCallback,
139
+ ): void
140
+ /** 取消监听 HTTP Response Header 事件
141
+ * @supported weapp, h5
142
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.offHeadersReceived.html
143
+ */
144
+ offHeadersReceived(
145
+ /** HTTP Response Header 事件的回调函数 */
146
+ callback: DownloadTask.OnHeadersReceivedCallback,
147
+ ): void
148
+ }
149
+
150
+ interface TaroStatic {
151
+ /** 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径,单次下载允许的最大文件为 50MB。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
152
+ *
153
+ * 注意:请在服务端响应的 header 中指定合理的 `Content-Type` 字段,以保证客户端正确处理文件类型。
154
+ * @supported weapp, h5, alipay, swan, rn, tt, harmony_hybrid, harmony
155
+ * @example
156
+ * ```tsx
157
+ * Taro.downloadFile({
158
+ * url: 'https://example.com/audio/123', //仅为示例,并非真实的资源
159
+ * success: function (res) {
160
+ * // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
161
+ * if (res.statusCode === 200) {
162
+ * Taro.playVoice({
163
+ * filePath: res.tempFilePath
164
+ * })
165
+ * }
166
+ * }
167
+ * })
168
+ * ```
169
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/wx.downloadFile.html
170
+ */
171
+ downloadFile(option: downloadFile.Option): DownloadTask.DownloadTaskPromise
172
+ }
173
+ }
@@ -0,0 +1,191 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace stopLocalServiceDiscovery {
5
+ interface Option {
6
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
+ complete?: (res: TaroGeneral.CallbackResult) => void
8
+ /** 接口调用失败的回调函数 */
9
+ fail?: (result: FailCallbackResult) => void
10
+ /** 接口调用成功的回调函数 */
11
+ success?: (res: TaroGeneral.CallbackResult) => void
12
+ }
13
+ interface FailCallbackResult extends TaroGeneral.CallbackResult {
14
+ /** 错误信息
15
+ *
16
+ * 可选值:
17
+ * - 'task not found': 在当前没有处在搜索服务中的情况下调用 stopLocalServiceDiscovery; */
18
+ errMsg: string
19
+ }
20
+ }
21
+ namespace startLocalServiceDiscovery {
22
+ interface Option {
23
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
24
+ complete?: (res: TaroGeneral.CallbackResult) => void
25
+ /** 接口调用失败的回调函数 */
26
+ fail?: (result: FailCallbackResult) => void
27
+ /** 接口调用成功的回调函数 */
28
+ success?: (res: TaroGeneral.CallbackResult) => void
29
+ }
30
+ interface FailCallbackResult extends TaroGeneral.CallbackResult {
31
+ /** 错误信息
32
+ *
33
+ * 可选值:
34
+ * - 'invalid param': serviceType 为空;
35
+ * - 'scan task already exist': 在当前 startLocalServiceDiscovery 发起的搜索未停止的情况下,再次调用 startLocalServiceDiscovery; */
36
+ errMsg: string
37
+ }
38
+ }
39
+
40
+ namespace onLocalServiceResolveFail {
41
+ /** mDNS 服务解析失败的事件的回调函数 */
42
+ type Callback = (result: CallbackResult) => void
43
+ interface CallbackResult {
44
+ /** 服务的名称 */
45
+ serviceName: string
46
+ /** 服务的类型 */
47
+ serviceType: string
48
+ }
49
+ }
50
+
51
+ namespace onLocalServiceLost {
52
+ /** mDNS 服务离开的事件的回调函数 */
53
+ type Callback = (result: CallbackResult) => void
54
+ interface CallbackResult {
55
+ /** 服务的名称 */
56
+ serviceName: string
57
+ /** 服务的类型 */
58
+ serviceType: string
59
+ }
60
+ }
61
+
62
+ namespace onLocalServiceFound {
63
+ /** mDNS 服务发现的事件的回调函数 */
64
+ type Callback = (result: CallbackResult) => void
65
+ interface CallbackResult {
66
+ /** 服务的 ip 地址 */
67
+ ip: string
68
+ /** 服务的端口 */
69
+ port: number
70
+ /** 服务的名称 */
71
+ serviceName: string
72
+ /** 服务的类型 */
73
+ serviceType: string
74
+ }
75
+ }
76
+
77
+ namespace onLocalServiceDiscoveryStop {
78
+ /** mDNS 服务停止搜索的事件的回调函数 */
79
+ type Callback = (res: TaroGeneral.CallbackResult) => void
80
+ }
81
+
82
+ namespace offLocalServiceResolveFail {
83
+ /** mDNS 服务解析失败的事件的回调函数 */
84
+ type Callback = (res: TaroGeneral.CallbackResult) => void
85
+ }
86
+
87
+ namespace offLocalServiceLost {
88
+ /** mDNS 服务离开的事件的回调函数 */
89
+ type Callback = (res: TaroGeneral.CallbackResult) => void
90
+ }
91
+
92
+ namespace offLocalServiceFound {
93
+ /** mDNS 服务发现的事件的回调函数 */
94
+ type Callback = (res: TaroGeneral.CallbackResult) => void
95
+ }
96
+
97
+ namespace offLocalServiceDiscoveryStop {
98
+ /** mDNS 服务停止搜索的事件的回调函数 */
99
+ type Callback = (res: TaroGeneral.CallbackResult) => void
100
+ }
101
+
102
+ interface TaroStatic {
103
+ /** 停止搜索 mDNS 服务
104
+ * @supported weapp
105
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.stopLocalServiceDiscovery.html
106
+ */
107
+ stopLocalServiceDiscovery(option?: stopLocalServiceDiscovery.Option): void
108
+
109
+ /** 开始搜索局域网下的 mDNS 服务。搜索的结果会通过 wx.onLocalService* 事件返回。
110
+ *
111
+ * **注意**
112
+ * 1. wx.startLocalServiceDiscovery 是一个消耗性能的行为,开始 30 秒后会自动 stop 并执行 wx.onLocalServiceDiscoveryStop 注册的回调函数。
113
+ * 2. 在调用 wx.startLocalServiceDiscovery 后,在这次搜索行为停止后才能发起下次 wx.startLocalServiceDiscovery。停止本次搜索行为的操作包括调用 wx.stopLocalServiceDiscovery 和 30 秒后系统自动 stop 本次搜索。
114
+ * @supported weapp
115
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.startLocalServiceDiscovery.html
116
+ */
117
+ startLocalServiceDiscovery(option: startLocalServiceDiscovery.Option): void
118
+
119
+ /** 监听 mDNS 服务解析失败的事件
120
+ * @supported weapp
121
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.onLocalServiceResolveFail.html
122
+ */
123
+ onLocalServiceResolveFail(
124
+ /** mDNS 服务解析失败的事件的回调函数 */
125
+ callback: onLocalServiceResolveFail.Callback
126
+ ): void
127
+
128
+ /** 监听 mDNS 服务离开的事件
129
+ * @supported weapp
130
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.onLocalServiceLost.html
131
+ */
132
+ onLocalServiceLost(
133
+ /** mDNS 服务离开的事件的回调函数 */
134
+ callback: onLocalServiceLost.Callback
135
+ ): void
136
+
137
+ /** 监听 mDNS 服务发现的事件
138
+ * @supported weapp
139
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.onLocalServiceFound.html
140
+ */
141
+ onLocalServiceFound(
142
+ /** mDNS 服务发现的事件的回调函数 */
143
+ callback: onLocalServiceFound.Callback
144
+ ): void
145
+
146
+ /** 监听 mDNS 服务停止搜索的事件
147
+ * @supported weapp
148
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.onLocalServiceDiscoveryStop.html
149
+ */
150
+ onLocalServiceDiscoveryStop(
151
+ /** mDNS 服务停止搜索的事件的回调函数 */
152
+ callback: onLocalServiceDiscoveryStop.Callback
153
+ ): void
154
+
155
+ /** 取消监听 mDNS 服务解析失败的事件
156
+ * @supported weapp
157
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.offLocalServiceResolveFail.html
158
+ */
159
+ offLocalServiceResolveFail(
160
+ /** mDNS 服务解析失败的事件的回调函数 */
161
+ callback: offLocalServiceResolveFail.Callback
162
+ ): void
163
+
164
+ /** 取消监听 mDNS 服务离开的事件
165
+ * @supported weapp
166
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.offLocalServiceLost.html
167
+ */
168
+ offLocalServiceLost(
169
+ /** mDNS 服务离开的事件的回调函数 */
170
+ callback: offLocalServiceLost.Callback
171
+ ): void
172
+
173
+ /** 取消监听 mDNS 服务发现的事件
174
+ * @supported weapp
175
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.offLocalServiceFound.html
176
+ */
177
+ offLocalServiceFound(
178
+ /** mDNS 服务发现的事件的回调函数 */
179
+ callback: offLocalServiceFound.Callback
180
+ ): void
181
+
182
+ /** 取消监听 mDNS 服务停止搜索的事件
183
+ * @supported weapp
184
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/mdns/wx.offLocalServiceDiscoveryStop.html
185
+ */
186
+ offLocalServiceDiscoveryStop(
187
+ /** mDNS 服务停止搜索的事件的回调函数 */
188
+ callback: offLocalServiceDiscoveryStop.Callback
189
+ ): void
190
+ }
191
+ }