@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,218 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ /** 一个 UDP Socket 实例,默认使用 IPv4 协议。
5
+ * @supported weapp
6
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.html
7
+ */
8
+ interface UDPSocket {
9
+ /** 绑定一个系统随机分配的可用端口,或绑定一个指定的端口号
10
+ * @supported weapp
11
+ * @example
12
+ * ```tsx
13
+ * const udp = Taro.createUDPSocket()
14
+ * udp.close()
15
+ * ```
16
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.bind.html
17
+ */
18
+ bind(
19
+ /** 指定要绑定的端口号,不传则返回系统随机分配的可用端口 */
20
+ port: number,
21
+ ): number
22
+ /** 设置 IP_TTL 套接字选项,用于设置一个 IP 数据包传输时允许的最大跳步数
23
+ * @supported weapp
24
+ * @example
25
+ * ```tsx
26
+ * const udp = Taro.createUDPSocket()
27
+ * udp.onListening(function () {
28
+ * udp.setTTL(64)
29
+ * })
30
+ * udp.bind()
31
+ * ```
32
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.setTTL.html
33
+ */
34
+ setTTL(
35
+ /** ttl 参数可以是 0 到 255 之间 */
36
+ ttl: number
37
+ ): void
38
+ /** 向指定的 IP 和 port 发送消息
39
+ * @supported weapp
40
+ * @example
41
+ * ```tsx
42
+ * const udp = Taro.createUDPSocket()
43
+ * udp.bind()
44
+ * udp.send({
45
+ * address: '192.168.193.2',
46
+ * port: 8848,
47
+ * message: 'hello, how are you'
48
+ * })
49
+ * ```
50
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.send.html
51
+ */
52
+ send(option: UDPSocket.send.Option): void
53
+ /** 预先连接到指定的 IP 和 port,需要配合 write 方法一起使用
54
+ * @supported weapp
55
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.connect.html
56
+ */
57
+ connect(option: UDPSocket.connect.Option): void
58
+ /** 用法与 send 方法相同,如果没有预先调用 connect 则与 send 无差异(注意即使调用了 connect 也需要在本接口填入地址和端口参数)
59
+ * @supported weapp
60
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.write.html
61
+ */
62
+ write(): void
63
+ /** 关闭 UDP Socket 实例,相当于销毁。 在关闭之后,UDP Socket 实例不能再发送消息,每次调用 `UDPSocket.send` 将会触发错误事件,并且 message 事件回调函数也不会再也执行。在 `UDPSocket` 实例被创建后将被 Native 强引用,保证其不被 GC。在 `UDPSocket.close` 后将解除对其的强引用,让 UDPSocket 实例遵从 GC。
64
+ * @supported weapp
65
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.close.html
66
+ */
67
+ close(): void
68
+ /** 监听关闭事件
69
+ * @supported weapp
70
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onClose.html
71
+ */
72
+ onClose(
73
+ /** 关闭事件的回调函数 */
74
+ callback: UDPSocket.onClose.Callback,
75
+ ): void
76
+ /** 取消监听关闭事件
77
+ * @supported weapp
78
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offClose.html
79
+ */
80
+ offClose(
81
+ /** 关闭事件的回调函数 */
82
+ callback: UDPSocket.onClose.Callback,
83
+ ): void
84
+ /** 监听错误事件
85
+ * @supported weapp
86
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onError.html
87
+ */
88
+ onError(
89
+ /** 错误事件的回调函数 */
90
+ callback: UDPSocket.onError.Callback,
91
+ ): void
92
+ /** 取消监听错误事件
93
+ * @supported weapp
94
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offError.html
95
+ */
96
+ offError(
97
+ /** 错误事件的回调函数 */
98
+ callback: UDPSocket.onError.Callback,
99
+ ): void
100
+ /** 监听开始监听数据包消息的事件
101
+ * @supported weapp
102
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onListening.html
103
+ */
104
+ onListening(
105
+ /** 监听开始监听数据包消息的事件 */
106
+ callback: UDPSocket.onListening.Callback,
107
+ ): void
108
+ /** 取消监听开始监听数据包消息的事件
109
+ * @supported weapp
110
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offListening.html
111
+ */
112
+ offListening(
113
+ /** 监听开始监听数据包消息的事件 */
114
+ callback: UDPSocket.onListening.Callback,
115
+ ): void
116
+ /** 监听收到消息的事件
117
+ * @supported weapp
118
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onMessage.html
119
+ */
120
+ onMessage(
121
+ /** 收到消息的事件的回调函数 */
122
+ callback: UDPSocket.onMessage.Callback,
123
+ ): void
124
+ /** 取消监听收到消息的事件
125
+ * @supported weapp
126
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offMessage.html
127
+ */
128
+ offMessage(
129
+ /** 收到消息的事件的回调函数 */
130
+ callback: UDPSocket.onMessage.Callback,
131
+ ): void
132
+ }
133
+
134
+ namespace UDPSocket {
135
+ namespace connect {
136
+ interface Option {
137
+ /** 要发消息的地址 */
138
+ address: string
139
+ /** 要发送消息的端口号 */
140
+ port: number
141
+ }
142
+ }
143
+ namespace onClose {
144
+ /** 当一个 socket 完全关闭就发出该事件的回调函数 */
145
+ type Callback = (...args: unknown[]) => void
146
+ }
147
+ namespace onError {
148
+ /** 错误事件的回调函数 */
149
+ type Callback = (result: CallbackResult) => void
150
+ interface CallbackResult extends TaroGeneral.CallbackResult {
151
+ /** 错误信息 */
152
+ errMsg: string
153
+ }
154
+ }
155
+ namespace onListening {
156
+ /** 监听开始监听数据包消息的事件 */
157
+ type Callback = (...args: unknown[]) => void
158
+ }
159
+ namespace onMessage {
160
+ /** 收到消息的事件的回调函数 */
161
+ type Callback = (result: CallbackResult) => void
162
+ interface CallbackResult extends TaroGeneral.CallbackResult {
163
+ /** 收到的消息 */
164
+ message: ArrayBuffer
165
+ /** 发送端地址信息 */
166
+ remoteInfo: RemoteInfo
167
+ /** 接收端地址信息 */
168
+ localInfo: LocalInfo
169
+ }
170
+ /** 发送端地址信息 */
171
+ interface RemoteInfo {
172
+ /** 发送消息的 socket 的地址 */
173
+ address: string
174
+ /** 使用的协议族,为 IPv4 或者 IPv6 */
175
+ family: string
176
+ /** 端口号 */
177
+ port: number
178
+ }
179
+ /** 接收端地址信息 */
180
+ interface LocalInfo {
181
+ /** 接收消息的 socket 的地址 */
182
+ address: string
183
+ /** 使用的协议族,为 IPv4 或者 IPv6 */
184
+ family: string
185
+ /** 端口号 */
186
+ port: number
187
+ /** message 的大小,单位:字节 */
188
+ size: number
189
+ }
190
+ }
191
+ namespace send {
192
+ interface Option {
193
+ /** 要发消息的地址。在基础库 <= 2.9.3 版本必须是和本机同网段的 IP 地址,或安全域名列表内的域名地址;之后版本可以是任意 IP 和域名 */
194
+ address: string
195
+ /** 要发送消息的端口号 */
196
+ port: number
197
+ /** 要发送的数据 */
198
+ message: string | ArrayBuffer
199
+ /** 发送数据的偏移量,仅当 message 为 ArrayBuffer 类型时有效
200
+ * @default 0
201
+ */
202
+ offset?: number
203
+ /** 发送数据的长度,仅当 message 为 ArrayBuffer 类型时有效
204
+ * @default message.byteLength
205
+ */
206
+ length?: number
207
+ }
208
+ }
209
+ }
210
+
211
+ interface TaroStatic {
212
+ /** 创建一个 UDP Socket 实例。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
213
+ * @supported weapp
214
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/wx.createUDPSocket.html
215
+ */
216
+ createUDPSocket(): UDPSocket
217
+ }
218
+ }
@@ -0,0 +1,201 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace uploadFile {
5
+ interface Option {
6
+ /** 开发者服务器地址 */
7
+ url: string
8
+ /** 要上传文件资源的路径 */
9
+ filePath: string
10
+ /** 文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容 */
11
+ name: string
12
+ /** HTTP 请求 Header,Header 中不能设置 Referer */
13
+ header?: TaroGeneral.IAnyObject
14
+ /** HTTP 请求中其他额外的 form data */
15
+ formData?: TaroGeneral.IAnyObject
16
+ /** 超时时间,单位为毫秒 */
17
+ timeout?: number
18
+ /** 上传的文件名
19
+ * @supported h5
20
+ */
21
+ fileName?: string
22
+ /** 是否应使用传出凭据 (cookie) 发送此请求
23
+ * @default true
24
+ * @supported h5
25
+ */
26
+ withCredentials?: boolean
27
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
28
+ complete?: (res: TaroGeneral.CallbackResult) => void
29
+ /** 接口调用失败的回调函数 */
30
+ fail?: (res: TaroGeneral.CallbackResult) => void
31
+ /** 接口调用成功的回调函数 */
32
+ success?: (
33
+ result: SuccessCallbackResult,
34
+ ) => void
35
+ }
36
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
37
+ /** 开发者服务器返回的数据 */
38
+ data: string
39
+ /** 开发者服务器返回的 HTTP 状态码 */
40
+ statusCode: number
41
+ /** 调用结果 */
42
+ errMsg: string
43
+ /**
44
+ * 开发者服务器返回的 HTTP Response Header
45
+ * @supported weapp
46
+ * @weapp 非官方文档标注属性
47
+ */
48
+ header?: TaroGeneral.IAnyObject
49
+ /**
50
+ * cookies
51
+ * @supported weapp
52
+ * @weapp 非官方文档标注属性
53
+ */
54
+ cookies?: string[]
55
+ }
56
+ }
57
+
58
+ namespace UploadTask {
59
+ /** HTTP Response Header 事件的回调函数 */
60
+ type OnHeadersReceivedCallback = (
61
+ result: OnHeadersReceivedCallbackResult,
62
+ ) => void
63
+ /** 上传进度变化事件的回调函数 */
64
+ type OnProgressUpdateCallback = (
65
+ result: OnProgressUpdateCallbackResult,
66
+ ) => void
67
+ interface OnHeadersReceivedCallbackResult {
68
+ /** 开发者服务器返回的 HTTP Response Header */
69
+ header: TaroGeneral.IAnyObject
70
+ }
71
+ interface OnProgressUpdateCallbackResult {
72
+ /** 上传进度百分比 */
73
+ progress: number
74
+ /** 预期需要上传的数据总长度,单位 Bytes */
75
+ totalBytesExpectedToSend: number
76
+ /** 已经上传的数据长度,单位 Bytes */
77
+ totalBytesSent: number
78
+ }
79
+
80
+ type UploadTaskPromise = Promise<uploadFile.SuccessCallbackResult> & UploadTask & {
81
+ headersReceive: UploadTask['onHeadersReceived']
82
+ progress: UploadTask['onProgressUpdate']
83
+ }
84
+ }
85
+
86
+ /** 一个可以监听上传进度变化事件,以及取消上传任务的对象
87
+ * @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid
88
+ * @example
89
+ * ```tsx
90
+ * const uploadTask = Taro.uploadFile({
91
+ * url: 'http://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
92
+ * filePath: tempFilePaths[0],
93
+ * name: 'file',
94
+ * formData:{
95
+ * 'user': 'test'
96
+ * },
97
+ * success (res){
98
+ * const data = res.data
99
+ * //do something
100
+ * }
101
+ * })
102
+ *
103
+ * uploadTask.onProgressUpdate((res) => {
104
+ * console.log('上传进度', res.progress)
105
+ * console.log('已经上传的数据长度', res.totalBytesSent)
106
+ * console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
107
+ * })
108
+ *
109
+ * uploadTask.abort() // 取消上传任务
110
+ * ```
111
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.html
112
+ */
113
+ interface UploadTask {
114
+ /** 中断上传任务
115
+ * @supported weapp, h5, tt, harmony_hybrid
116
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.abort.html
117
+ */
118
+ abort(): void
119
+ /** 监听上传进度变化事件
120
+ * @supported weapp, h5, tt, harmony_hybrid
121
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.onProgressUpdate.html
122
+ */
123
+ onProgressUpdate(
124
+ /** 上传进度变化事件的回调函数 */
125
+ callback: UploadTask.OnProgressUpdateCallback,
126
+ ): void
127
+ /** 取消监听上传进度变化事件
128
+ * @supported weapp, h5, tt, harmony_hybrid
129
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.offProgressUpdate.html
130
+ */
131
+ offProgressUpdate(
132
+ /** 上传进度变化事件的回调函数 */
133
+ callback: UploadTask.OnProgressUpdateCallback,
134
+ ): void
135
+ /** 监听 HTTP Response Header 事件。会比请求完成事件更早
136
+ * @supported weapp, h5, harmony_hybrid
137
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.onHeadersReceived.html
138
+ */
139
+ onHeadersReceived(
140
+ /** HTTP Response Header 事件的回调函数 */
141
+ callback: UploadTask.OnHeadersReceivedCallback,
142
+ ): void
143
+ /** 取消监听 HTTP Response Header 事件
144
+ * @supported weapp, h5, harmony_hybrid
145
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.offHeadersReceived.html
146
+ */
147
+ offHeadersReceived(
148
+ /** HTTP Response Header 事件的回调函数 */
149
+ callback: UploadTask.OnHeadersReceivedCallback,
150
+ ): void
151
+ }
152
+
153
+ interface TaroStatic {
154
+ /** 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 `content-type` 为 `multipart/form-data`。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
155
+ * @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid, harmony
156
+ * @example
157
+ * ```tsx
158
+ * Taro.chooseImage({
159
+ * success (res) {
160
+ * const tempFilePaths = res.tempFilePaths
161
+ * Taro.uploadFile({
162
+ * url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
163
+ * filePath: tempFilePaths[0],
164
+ * name: 'file',
165
+ * formData: {
166
+ * 'user': 'test'
167
+ * },
168
+ * success (res){
169
+ * const data = res.data
170
+ * //do something
171
+ * }
172
+ * })
173
+ * }
174
+ * })
175
+ * ```
176
+ * @example
177
+ * ```tsx
178
+ * const uploadTask = Taro.uploadFile({
179
+ * url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
180
+ * filePath: tempFilePaths[0],
181
+ * name: 'file',
182
+ * formData:{
183
+ * 'user': 'test'
184
+ * },
185
+ * success: function (res){
186
+ * var data = res.data
187
+ * //do something
188
+ * }
189
+ * })
190
+ * uploadTask.progress((res) => {
191
+ * console.log('上传进度', res.progress)
192
+ * console.log('已经上传的数据长度', res.totalBytesSent)
193
+ * console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
194
+ * })
195
+ * uploadTask.abort() // 取消上传任务
196
+ * ```
197
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/wx.uploadFile.html
198
+ */
199
+ uploadFile(option: uploadFile.Option): UploadTask.UploadTaskPromise
200
+ }
201
+ }