@tarojs/taro 3.4.1 → 3.4.2
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/package.json +5 -5
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/visionkit.d.ts +303 -0
- package/types/api/base/crypto.d.ts +90 -0
- package/types/api/base/debug.d.ts +152 -13
- package/types/api/base/env.d.ts +2 -1
- package/types/api/base/index.d.ts +10 -2
- package/types/api/base/performance.d.ts +195 -0
- package/types/api/base/system.d.ts +539 -101
- package/types/api/base/update.d.ts +59 -7
- package/types/api/base/weapp/app-event.d.ts +46 -23
- package/types/api/base/weapp/life-cycle.d.ts +141 -1
- package/types/api/canvas/index.d.ts +150 -136
- package/types/api/cloud/index.d.ts +2 -2
- package/types/api/device/accelerometer.d.ts +3 -3
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +2 -2
- package/types/api/device/{ble.d.ts → bluetooth-ble.d.ts} +228 -62
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +67 -2
- package/types/api/device/calendar.d.ts +88 -0
- package/types/api/device/contact.d.ts +74 -50
- package/types/api/device/gyroscope.d.ts +5 -5
- package/types/api/device/iBeacon.d.ts +33 -19
- package/types/api/{ui → device}/keyboard.d.ts +0 -0
- package/types/api/device/{performance.d.ts → memory.d.ts} +4 -4
- package/types/api/device/motion.d.ts +3 -3
- package/types/api/device/network.d.ts +53 -12
- package/types/api/device/nfc.d.ts +1089 -13
- package/types/api/device/scan.d.ts +1 -1
- package/types/api/device/screen.d.ts +40 -12
- package/types/api/device/wifi.d.ts +41 -6
- package/types/api/files/index.d.ts +371 -184
- package/types/api/location/index.d.ts +116 -55
- package/types/api/media/audio.d.ts +629 -38
- package/types/api/media/background-audio.d.ts +8 -8
- package/types/api/media/camera.d.ts +38 -19
- package/types/api/media/editor.d.ts +22 -2
- package/types/api/media/image.d.ts +61 -32
- package/types/api/media/live.d.ts +66 -6
- package/types/api/media/map.d.ts +469 -49
- package/types/api/media/media-recorder.d.ts +92 -0
- package/types/api/media/recorder.d.ts +20 -20
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +11 -7
- package/types/api/media/video.d.ts +45 -16
- package/types/api/media/voip.d.ts +290 -0
- package/types/api/{open-api/navigate.d.ts → navigate/index.d.ts} +63 -25
- package/types/api/network/download.d.ts +39 -16
- package/types/api/network/request.d.ts +125 -37
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +154 -83
- package/types/api/network/upload.d.ts +41 -25
- package/types/api/network/websocket.d.ts +16 -15
- package/types/api/open-api/authorize.d.ts +41 -2
- package/types/api/open-api/channels.d.ts +178 -0
- package/types/api/open-api/facial.d.ts +3 -0
- package/types/api/open-api/favorites.d.ts +100 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +2 -2
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +21 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +76 -14
- package/types/api/open-api/soter.d.ts +2 -2
- package/types/api/open-api/subscribe-message.d.ts +88 -3
- package/types/api/open-api/user-info.d.ts +55 -18
- package/types/api/open-api/werun.d.ts +33 -6
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/route/index.d.ts +13 -9
- package/types/api/share/index.d.ts +192 -9
- package/types/api/storage/index.d.ts +29 -83
- package/types/api/swan/index.d.ts +1 -1
- package/types/api/ui/animation.d.ts +84 -70
- package/types/api/ui/background.d.ts +4 -2
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +27 -31
- package/types/api/ui/navigation-bar.d.ts +1 -0
- package/types/api/ui/scroll.d.ts +73 -7
- package/types/api/ui/sticky.d.ts +4 -4
- package/types/api/ui/tab-bar.d.ts +7 -7
- package/types/api/ui/window.d.ts +22 -2
- package/types/api/worker/index.d.ts +9 -1
- package/types/api/wxml/index.d.ts +111 -107
- package/types/compile.d.ts +5 -0
- package/types/global.d.ts +142 -111
- package/types/taro.api.d.ts +79 -62
- package/types/api/open-api/payment.d.ts +0 -61
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import Taro from '../../index'
|
|
2
2
|
|
|
3
3
|
declare module '../../index' {
|
|
4
|
+
namespace saveFileToDisk {
|
|
5
|
+
interface Option {
|
|
6
|
+
/** 待保存文件路径 */
|
|
7
|
+
filePath: string
|
|
8
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
9
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
10
|
+
/** 接口调用失败的回调函数 */
|
|
11
|
+
fail?: (result: TaroGeneral.CallbackResult) => void
|
|
12
|
+
/** 接口调用成功的回调函数 */
|
|
13
|
+
success?: (result: TaroGeneral.CallbackResult) => void
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
namespace saveFile {
|
|
5
18
|
interface Option {
|
|
6
19
|
/** 临时存储文件路径 */
|
|
@@ -63,12 +76,12 @@ declare module '../../index' {
|
|
|
63
76
|
/** 接口调用失败的回调函数 */
|
|
64
77
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
65
78
|
/** 文件类型,指定文件类型打开文件 */
|
|
66
|
-
fileType?: keyof
|
|
79
|
+
fileType?: keyof FileType
|
|
67
80
|
/** 接口调用成功的回调函数 */
|
|
68
81
|
success?: (res: TaroGeneral.CallbackResult) => void
|
|
69
82
|
}
|
|
70
83
|
/** 文件类型 */
|
|
71
|
-
interface
|
|
84
|
+
interface FileType {
|
|
72
85
|
/** doc 格式 */
|
|
73
86
|
doc
|
|
74
87
|
/** docx 格式 */
|
|
@@ -166,22 +179,17 @@ declare module '../../index' {
|
|
|
166
179
|
}
|
|
167
180
|
}
|
|
168
181
|
|
|
169
|
-
/**
|
|
182
|
+
/** 文件管理器,可通过 [Taro.getFileSystemManager](./getFileSystemManager) 获取。
|
|
183
|
+
* @supported weapp
|
|
184
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.html
|
|
185
|
+
*/
|
|
170
186
|
interface FileSystemManager {
|
|
171
|
-
/** FileSystemManager.readdir 的同步版本
|
|
172
|
-
* @supported weapp
|
|
173
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdirSync.html
|
|
174
|
-
*/
|
|
175
|
-
readdirSync(
|
|
176
|
-
/** 要读取的目录路径 */
|
|
177
|
-
dirPath: string,
|
|
178
|
-
): string[]
|
|
179
187
|
/** 判断文件/目录是否存在
|
|
180
188
|
* @supported weapp
|
|
181
189
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.access.html
|
|
182
190
|
*/
|
|
183
191
|
access(option: FileSystemManager.AccessOption): void
|
|
184
|
-
/** FileSystemManager.access 的同步版本
|
|
192
|
+
/** [FileSystemManager.access](#access) 的同步版本
|
|
185
193
|
* @supported weapp
|
|
186
194
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.accessSync.html
|
|
187
195
|
*/
|
|
@@ -194,7 +202,7 @@ declare module '../../index' {
|
|
|
194
202
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFile.html
|
|
195
203
|
*/
|
|
196
204
|
appendFile(option: FileSystemManager.AppendFileOption): void
|
|
197
|
-
/** FileSystemManager.appendFile 的同步版本
|
|
205
|
+
/** [FileSystemManager.appendFile](#appendfile) 的同步版本
|
|
198
206
|
* @supported weapp
|
|
199
207
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFileSync.html
|
|
200
208
|
*/
|
|
@@ -204,14 +212,24 @@ declare module '../../index' {
|
|
|
204
212
|
/** 要追加的文本或二进制数据 */
|
|
205
213
|
data: string | ArrayBuffer,
|
|
206
214
|
/** 指定写入文件的字符编码 */
|
|
207
|
-
encoding?: keyof FileSystemManager.
|
|
215
|
+
encoding?: keyof FileSystemManager.Encoding,
|
|
208
216
|
): void
|
|
217
|
+
/** 关闭文件
|
|
218
|
+
* @supported weapp
|
|
219
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.close.html
|
|
220
|
+
*/
|
|
221
|
+
close(option: FileSystemManager.CloseOption): void
|
|
222
|
+
/** [FileSystemManager.close](#close) 的同步版本
|
|
223
|
+
* @supported weapp
|
|
224
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.closeSync.html
|
|
225
|
+
*/
|
|
226
|
+
closeSync(option: FileSystemManager.CloseSyncOption): void
|
|
209
227
|
/** 复制文件
|
|
210
228
|
* @supported weapp
|
|
211
229
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFile.html
|
|
212
230
|
*/
|
|
213
231
|
copyFile(option: FileSystemManager.CopyFileOption): void
|
|
214
|
-
/** FileSystemManager.copyFile 的同步版本
|
|
232
|
+
/** [FileSystemManager.copyFile](#copyfile) 的同步版本
|
|
215
233
|
* @supported weapp
|
|
216
234
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFileSync.html
|
|
217
235
|
*/
|
|
@@ -221,7 +239,27 @@ declare module '../../index' {
|
|
|
221
239
|
/** 目标文件路径 */
|
|
222
240
|
destPath: string,
|
|
223
241
|
): void
|
|
224
|
-
/**
|
|
242
|
+
/** 获取文件的状态信息
|
|
243
|
+
* @supported weapp
|
|
244
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.fstat.html
|
|
245
|
+
*/
|
|
246
|
+
fstat(option: FileSystemManager.FstatOption): void
|
|
247
|
+
/** [FileSystemManager.fstat](#fstat) 的同步版本
|
|
248
|
+
* @supported weapp
|
|
249
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.fstatSync.html
|
|
250
|
+
*/
|
|
251
|
+
fstatSync(option: FileSystemManager.FstatSyncOption): Stats
|
|
252
|
+
/** 对文件内容进行截断操作
|
|
253
|
+
* @supported weapp
|
|
254
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncate.html
|
|
255
|
+
*/
|
|
256
|
+
ftruncate(option: FileSystemManager.FtruncateOption): void
|
|
257
|
+
/** [FileSystemManager.ftruncate](#ftruncate) 的同步版本
|
|
258
|
+
* @supported weapp
|
|
259
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncateSync.html
|
|
260
|
+
*/
|
|
261
|
+
ftruncateSync(option: FileSystemManager.FtruncateSyncOption): void
|
|
262
|
+
/** 获取该小程序下的 `本地临时文件` 或 `本地缓存文件` 信息
|
|
225
263
|
* @supported weapp
|
|
226
264
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.getFileInfo.html
|
|
227
265
|
*/
|
|
@@ -236,7 +274,7 @@ declare module '../../index' {
|
|
|
236
274
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdir.html
|
|
237
275
|
*/
|
|
238
276
|
mkdir(option: FileSystemManager.MkdirOption): void
|
|
239
|
-
/** FileSystemManager.mkdir 的同步版本
|
|
277
|
+
/** [FileSystemManager.mkdir](#mkdir) 的同步版本
|
|
240
278
|
* @supported weapp
|
|
241
279
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdirSync.html
|
|
242
280
|
*/
|
|
@@ -246,16 +284,80 @@ declare module '../../index' {
|
|
|
246
284
|
/** 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 */
|
|
247
285
|
recursive?: boolean,
|
|
248
286
|
): void
|
|
249
|
-
|
|
287
|
+
/**打开文件,返回文件描述符
|
|
250
288
|
* @supported weapp
|
|
251
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.
|
|
289
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html
|
|
252
290
|
*/
|
|
253
|
-
|
|
291
|
+
open(option: FileSystemManager.OpenOption): void
|
|
292
|
+
/** [FileSystemManager.openSync](#opensync) 的同步版本
|
|
293
|
+
* @supported weapp
|
|
294
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncateSync.html
|
|
295
|
+
*/
|
|
296
|
+
openSync(option: FileSystemManager.OpenSyncOption): string /** 文件描述符 */
|
|
297
|
+
/** 读文件
|
|
298
|
+
* @supported weapp
|
|
299
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.read.html
|
|
300
|
+
*/
|
|
301
|
+
read(option: FileSystemManager.ReadOption): void
|
|
302
|
+
/** 读取指定压缩类型的本地文件内容
|
|
303
|
+
* @supported weapp
|
|
304
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readCompressedFile.html
|
|
305
|
+
*/
|
|
306
|
+
readCompressedFile(option: FileSystemManager.readCompressedFile.Option): Promise<FileSystemManager.readCompressedFile.Promised>
|
|
307
|
+
/** 同步读取指定压缩类型的本地文件内容
|
|
308
|
+
* @supported weapp
|
|
309
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readCompressedFileSync.html
|
|
310
|
+
*/
|
|
311
|
+
readCompressedFileSync(option: FileSystemManager.readCompressedFileSync.Option): ArrayBuffer /** 文件读取结果 */
|
|
254
312
|
/** 读取目录内文件列表
|
|
255
313
|
* @supported weapp
|
|
256
314
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdir.html
|
|
257
315
|
*/
|
|
258
316
|
readdir(option: FileSystemManager.ReaddirOption): void
|
|
317
|
+
/** [FileSystemManager.readdir](#readdir) 的同步版本
|
|
318
|
+
* @supported weapp
|
|
319
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdirSync.html
|
|
320
|
+
*/
|
|
321
|
+
readdirSync(
|
|
322
|
+
/** 要读取的目录路径 */
|
|
323
|
+
dirPath: string,
|
|
324
|
+
): string[]
|
|
325
|
+
/** 读取本地文件内容
|
|
326
|
+
* @supported weapp
|
|
327
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFile.html
|
|
328
|
+
*/
|
|
329
|
+
readFile(option: FileSystemManager.ReadFileOption): void
|
|
330
|
+
/** [FileSystemManager.readFile](#readfile) 的同步版本
|
|
331
|
+
* @supported weapp
|
|
332
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFileSync.html
|
|
333
|
+
*/
|
|
334
|
+
readFileSync(
|
|
335
|
+
/** 要读取的文件的路径 */
|
|
336
|
+
filePath: string,
|
|
337
|
+
/** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 */
|
|
338
|
+
encoding?: keyof FileSystemManager.Encoding,
|
|
339
|
+
/**从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte */
|
|
340
|
+
position?: number,
|
|
341
|
+
/**指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte */
|
|
342
|
+
length?: number,
|
|
343
|
+
): string | ArrayBuffer
|
|
344
|
+
/** [FileSystemManager.read](#read) 的同步版本
|
|
345
|
+
* @supported weapp
|
|
346
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readSync.html
|
|
347
|
+
*/
|
|
348
|
+
readSync(
|
|
349
|
+
option: FileSystemManager.ReadSyncOption
|
|
350
|
+
): {
|
|
351
|
+
/** 实际读取的字节数 */
|
|
352
|
+
bytesRead: number
|
|
353
|
+
/** 被写入的缓存区的对象,即接口入参的 arrayBuffer */
|
|
354
|
+
arrayBuffer: ArrayBuffer
|
|
355
|
+
}
|
|
356
|
+
/** 读取压缩包内的文件
|
|
357
|
+
* @supported weapp
|
|
358
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readZipEntry.html
|
|
359
|
+
*/
|
|
360
|
+
readZipEntry(option: FileSystemManager.readZipEntry.Option): Promise<FileSystemManager.readZipEntry.Promised>
|
|
259
361
|
/** 删除该小程序下已保存的本地缓存文件
|
|
260
362
|
* @supported weapp
|
|
261
363
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.removeSavedFile.html
|
|
@@ -266,7 +368,7 @@ declare module '../../index' {
|
|
|
266
368
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rename.html
|
|
267
369
|
*/
|
|
268
370
|
rename(option: FileSystemManager.RenameOption): void
|
|
269
|
-
/** FileSystemManager.rename 的同步版本
|
|
371
|
+
/** [FileSystemManager.rename](#rename) 的同步版本
|
|
270
372
|
* @supported weapp
|
|
271
373
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.renameSync.html
|
|
272
374
|
*/
|
|
@@ -281,7 +383,7 @@ declare module '../../index' {
|
|
|
281
383
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rmdir.html
|
|
282
384
|
*/
|
|
283
385
|
rmdir(option: FileSystemManager.RmdirOption): void
|
|
284
|
-
/** FileSystemManager.rmdir 的同步版本
|
|
386
|
+
/** [FileSystemManager.rmdir](#rmdir) 的同步版本
|
|
285
387
|
* @supported weapp
|
|
286
388
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rmdirSync.html
|
|
287
389
|
*/
|
|
@@ -296,17 +398,47 @@ declare module '../../index' {
|
|
|
296
398
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFile.html
|
|
297
399
|
*/
|
|
298
400
|
saveFile(option: FileSystemManager.SaveFileOption): void
|
|
401
|
+
/** [FileSystemManager.saveFile](#savefile) 的同步版本
|
|
402
|
+
* @supported weapp
|
|
403
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFileSync.html
|
|
404
|
+
*/
|
|
405
|
+
saveFileSync(
|
|
406
|
+
/** 临时存储文件路径 */
|
|
407
|
+
tempFilePath: string,
|
|
408
|
+
/** 要存储的文件路径 */
|
|
409
|
+
filePath?: string,
|
|
410
|
+
): string
|
|
299
411
|
/** 获取文件 Stats 对象
|
|
300
412
|
* @supported weapp
|
|
301
413
|
* https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.stat.html
|
|
302
414
|
*/
|
|
303
415
|
stat(option: FileSystemManager.StatOption): void
|
|
416
|
+
/** [FileSystemManager.stat](#stat) 的同步版本
|
|
417
|
+
* @supported weapp
|
|
418
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.statSync.html
|
|
419
|
+
*/
|
|
420
|
+
statSync(
|
|
421
|
+
/** 文件/目录路径 */
|
|
422
|
+
path: string,
|
|
423
|
+
/** 是否递归获取目录下的每个文件的 Stats 信息 */
|
|
424
|
+
recursive?: boolean,
|
|
425
|
+
): Stats | TaroGeneral.IAnyObject
|
|
426
|
+
/** 对文件内容进行截断操作
|
|
427
|
+
* @supported weapp
|
|
428
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncate.html
|
|
429
|
+
*/
|
|
430
|
+
truncate(option: FileSystemManager.TruncateOption): void
|
|
431
|
+
/** 对文件内容进行截断操作 ([truncate](#truncate) 的同步版本)
|
|
432
|
+
* @supported weapp
|
|
433
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncateSync.html
|
|
434
|
+
*/
|
|
435
|
+
truncateSync(option: FileSystemManager.TruncateSyncOption): void
|
|
304
436
|
/** 删除文件
|
|
305
437
|
* @supported weapp
|
|
306
438
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlink.html
|
|
307
439
|
*/
|
|
308
440
|
unlink(option: FileSystemManager.UnlinkOption): void
|
|
309
|
-
/** FileSystemManager.unlink 的同步版本
|
|
441
|
+
/** [FileSystemManager.unlink](#unlink) 的同步版本
|
|
310
442
|
* @supported weapp
|
|
311
443
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlinkSync.html
|
|
312
444
|
*/
|
|
@@ -319,12 +451,17 @@ declare module '../../index' {
|
|
|
319
451
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unzip.html
|
|
320
452
|
*/
|
|
321
453
|
unzip(option: FileSystemManager.UnzipOption): void
|
|
454
|
+
/** 写入文件
|
|
455
|
+
* @supported weapp
|
|
456
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.write.html
|
|
457
|
+
*/
|
|
458
|
+
write(option: FileSystemManager.WriteOption): void
|
|
322
459
|
/** 写文件
|
|
323
460
|
* @supported weapp
|
|
324
461
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFile.html
|
|
325
462
|
*/
|
|
326
463
|
writeFile(option: FileSystemManager.WriteFileOption): void
|
|
327
|
-
/** FileSystemManager.writeFile 的同步版本
|
|
464
|
+
/** [FileSystemManager.writeFile](#writefile) 的同步版本
|
|
328
465
|
* @supported weapp
|
|
329
466
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFileSync.html
|
|
330
467
|
*/
|
|
@@ -334,115 +471,9 @@ declare module '../../index' {
|
|
|
334
471
|
/** 要写入的文本或二进制数据 */
|
|
335
472
|
data: string | ArrayBuffer,
|
|
336
473
|
/** 指定写入文件的字符编码 */
|
|
337
|
-
encoding?: keyof FileSystemManager.
|
|
474
|
+
encoding?: keyof FileSystemManager.Encoding,
|
|
338
475
|
): void
|
|
339
|
-
/**
|
|
340
|
-
* @supported weapp
|
|
341
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.statSync.html
|
|
342
|
-
*/
|
|
343
|
-
statSync(
|
|
344
|
-
/** 文件/目录路径 */
|
|
345
|
-
path: string,
|
|
346
|
-
/** 是否递归获取目录下的每个文件的 Stats 信息 */
|
|
347
|
-
recursive?: boolean,
|
|
348
|
-
): Stats | TaroGeneral.IAnyObject
|
|
349
|
-
/** FileSystemManager.saveFile 的同步版本
|
|
350
|
-
* @supported weapp
|
|
351
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFileSync.html
|
|
352
|
-
*/
|
|
353
|
-
saveFileSync(
|
|
354
|
-
/** 临时存储文件路径 */
|
|
355
|
-
tempFilePath: string,
|
|
356
|
-
/** 要存储的文件路径 */
|
|
357
|
-
filePath?: string,
|
|
358
|
-
): string
|
|
359
|
-
/** FileSystemManager.readFile 的同步版本
|
|
360
|
-
* @supported weapp
|
|
361
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFileSync.html
|
|
362
|
-
*/
|
|
363
|
-
readFileSync(
|
|
364
|
-
/** 要读取的文件的路径 */
|
|
365
|
-
filePath: string,
|
|
366
|
-
/** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 */
|
|
367
|
-
encoding?: keyof FileSystemManager.encoding,
|
|
368
|
-
/**从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte */
|
|
369
|
-
position?: number,
|
|
370
|
-
/**指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte */
|
|
371
|
-
length?: number,
|
|
372
|
-
): string | ArrayBuffer
|
|
373
|
-
/** 获取文件的状态信息
|
|
374
|
-
* @supported weapp
|
|
375
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.fstat.html
|
|
376
|
-
*/
|
|
377
|
-
fstat(option: FileSystemManager.FstatOption): void
|
|
378
|
-
/** FileSystemManager.fstat 的同步版本
|
|
379
|
-
* @supported weapp
|
|
380
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.fstatSync.html
|
|
381
|
-
*/
|
|
382
|
-
fstatSync(option: FileSystemManager.FstatSyncOption): Stats
|
|
383
|
-
/**关闭文件
|
|
384
|
-
* @supported weapp
|
|
385
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.close.html
|
|
386
|
-
*/
|
|
387
|
-
close(option: FileSystemManager.CloseOption): void
|
|
388
|
-
/**FileSystemManager.close 的同步版本
|
|
389
|
-
* @supported weapp
|
|
390
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.closeSync.html
|
|
391
|
-
*/
|
|
392
|
-
closeSync(option: FileSystemManager.CloseSyncOption): void
|
|
393
|
-
/**对文件内容进行截断操作
|
|
394
|
-
* @supported weapp
|
|
395
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncate.html
|
|
396
|
-
*/
|
|
397
|
-
ftruncate(option: FileSystemManager.FtruncateOption): void
|
|
398
|
-
/**FileSystemManager.ftruncate 的同步版本
|
|
399
|
-
* @supported weapp
|
|
400
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncateSync.html
|
|
401
|
-
*/
|
|
402
|
-
ftruncateSync(option: FileSystemManager.FtruncateSyncOption): void
|
|
403
|
-
/**打开文件,返回文件描述符
|
|
404
|
-
* @supported weapp
|
|
405
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.open.html
|
|
406
|
-
*/
|
|
407
|
-
open(option: FileSystemManager.OpenOption): void
|
|
408
|
-
/**FileSystemManager.ftruncate 的同步版本
|
|
409
|
-
* @supported weapp
|
|
410
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.ftruncateSync.html
|
|
411
|
-
*/
|
|
412
|
-
openSync(option: FileSystemManager.OpenSyncOption): string /** 文件描述符 */
|
|
413
|
-
/** 读文件
|
|
414
|
-
* @supported weapp
|
|
415
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.read.html
|
|
416
|
-
*/
|
|
417
|
-
read(option: FileSystemManager.ReadOption): void
|
|
418
|
-
/** FileSystemManager.read 的同步版本
|
|
419
|
-
* @supported weapp
|
|
420
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readSync.html
|
|
421
|
-
*/
|
|
422
|
-
readSync(
|
|
423
|
-
option: FileSystemManager.ReadSyncOption
|
|
424
|
-
): {
|
|
425
|
-
/** 实际读取的字节数 */
|
|
426
|
-
bytesRead: number
|
|
427
|
-
/** 被写入的缓存区的对象,即接口入参的 arrayBuffer */
|
|
428
|
-
arrayBuffer: ArrayBuffer
|
|
429
|
-
}
|
|
430
|
-
/** 对文件内容进行截断操作
|
|
431
|
-
* @supported weapp
|
|
432
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncate.html
|
|
433
|
-
*/
|
|
434
|
-
truncate(option: FileSystemManager.TruncateOption): void
|
|
435
|
-
/** truncate 的同步版本
|
|
436
|
-
* @supported weapp
|
|
437
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncateSync.html
|
|
438
|
-
*/
|
|
439
|
-
truncateSync(option: FileSystemManager.TruncateSyncOption): void
|
|
440
|
-
/** 写入文件
|
|
441
|
-
* @supported weapp
|
|
442
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.write.html
|
|
443
|
-
*/
|
|
444
|
-
write(option: FileSystemManager.WriteOption): void
|
|
445
|
-
/** write 的同步版本
|
|
476
|
+
/** [write](#write) 的同步版本
|
|
446
477
|
* @supported weapp
|
|
447
478
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeSync.html
|
|
448
479
|
*/
|
|
@@ -456,7 +487,7 @@ declare module '../../index' {
|
|
|
456
487
|
|
|
457
488
|
namespace FileSystemManager {
|
|
458
489
|
/** 字符编码 */
|
|
459
|
-
interface
|
|
490
|
+
interface Encoding {
|
|
460
491
|
ascii
|
|
461
492
|
base64
|
|
462
493
|
binary
|
|
@@ -475,17 +506,17 @@ declare module '../../index' {
|
|
|
475
506
|
}
|
|
476
507
|
/** 文件系统标志 */
|
|
477
508
|
interface flag {
|
|
478
|
-
a /**打开文件用于追加。 如果文件不存在,则创建该文件
|
|
479
|
-
ax /**类似于 'a',但如果路径存在,则失败
|
|
480
|
-
'a+' /**打开文件用于读取和追加。 如果文件不存在,则创建该文件
|
|
481
|
-
'ax+' /**类似于 'a+',但如果路径存在,则失败
|
|
482
|
-
as /**打开文件用于追加(在同步模式中)。 如果文件不存在,则创建该文件
|
|
483
|
-
'as+' /**打开文件用于读取和追加(在同步模式中)。 如果文件不存在,则创建该文件
|
|
484
|
-
r /**打开文件用于读取。 如果文件不存在,则会发生异常
|
|
485
|
-
'r+' /**打开文件用于读取和写入。 如果文件不存在,则会发生异常
|
|
486
|
-
w /**打开文件用于写入。 如果文件不存在则创建文件,如果文件存在则截断文件
|
|
487
|
-
wx /**类似于 'w',但如果路径存在,则失败
|
|
488
|
-
'w+' /**打开文件用于读取和写入。 如果文件不存在则创建文件,如果文件存在则截断文件
|
|
509
|
+
a /**打开文件用于追加。 如果文件不存在,则创建该文件 */
|
|
510
|
+
ax /**类似于 'a',但如果路径存在,则失败 */
|
|
511
|
+
'a+' /**打开文件用于读取和追加。 如果文件不存在,则创建该文件 */
|
|
512
|
+
'ax+' /**类似于 'a+',但如果路径存在,则失败 */
|
|
513
|
+
as /**打开文件用于追加(在同步模式中)。 如果文件不存在,则创建该文件 */
|
|
514
|
+
'as+' /**打开文件用于读取和追加(在同步模式中)。 如果文件不存在,则创建该文件 */
|
|
515
|
+
r /**打开文件用于读取。 如果文件不存在,则会发生异常 */
|
|
516
|
+
'r+' /**打开文件用于读取和写入。 如果文件不存在,则会发生异常 */
|
|
517
|
+
w /**打开文件用于写入。 如果文件不存在则创建文件,如果文件存在则截断文件 */
|
|
518
|
+
wx /**类似于 'w',但如果路径存在,则失败 */
|
|
519
|
+
'w+' /**打开文件用于读取和写入。 如果文件不存在则创建文件,如果文件存在则截断文件 */
|
|
489
520
|
'wx+' /**类似于 'w+',但如果路径存在,则失败*/
|
|
490
521
|
}
|
|
491
522
|
interface AccessOption {
|
|
@@ -515,7 +546,7 @@ declare module '../../index' {
|
|
|
515
546
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
516
547
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
517
548
|
/** 指定写入文件的字符编码 */
|
|
518
|
-
encoding?: keyof FileSystemManager.
|
|
549
|
+
encoding?: keyof FileSystemManager.Encoding
|
|
519
550
|
/** 接口调用失败的回调函数 */
|
|
520
551
|
fail?: (result: AppendFileFailCallbackResult) => void
|
|
521
552
|
/** 接口调用成功的回调函数 */
|
|
@@ -639,7 +670,7 @@ declare module '../../index' {
|
|
|
639
670
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
640
671
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
641
672
|
/** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 */
|
|
642
|
-
encoding?: keyof FileSystemManager.
|
|
673
|
+
encoding?: keyof FileSystemManager.Encoding
|
|
643
674
|
/** 接口调用失败的回调函数 */
|
|
644
675
|
fail?: (result: ReadFileFailCallbackResult) => void
|
|
645
676
|
/** 接口调用成功的回调函数 */
|
|
@@ -687,6 +718,74 @@ declare module '../../index' {
|
|
|
687
718
|
errMsg: string
|
|
688
719
|
}
|
|
689
720
|
|
|
721
|
+
namespace readZipEntry {
|
|
722
|
+
type Promised = FailCallbackResult | SuccessCallbackResult
|
|
723
|
+
interface Option {
|
|
724
|
+
/** 要读取的压缩包的路径 (本地路径) */
|
|
725
|
+
filePath: string
|
|
726
|
+
/** 统一指定读取文件的字符编码,只在 entries 值为"all"时有效。如果 entries 值为"all"且不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 */
|
|
727
|
+
encoding?: keyof Encoding | string
|
|
728
|
+
/** 要读取的压缩包内的文件列表(当传入"all" 时表示读取压缩包内所有文件) */
|
|
729
|
+
entries: File[] | 'all'
|
|
730
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
731
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
732
|
+
/** 接口调用失败的回调函数 */
|
|
733
|
+
fail?: (result: FailCallbackResult) => void
|
|
734
|
+
/** 接口调用成功的回调函数 */
|
|
735
|
+
success?: (res: SuccessCallbackResult) => void
|
|
736
|
+
}
|
|
737
|
+
interface File {
|
|
738
|
+
/** 压缩包内文件路径 */
|
|
739
|
+
path: string
|
|
740
|
+
/** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 */
|
|
741
|
+
encoding?: keyof Encoding | string
|
|
742
|
+
/** 从文件指定位置开始读,如果不指定,则从文件头开始读。读取的范围应该是左闭右开区间 [position, position+length)。有效范围:[0, fileLength - 1]。单位:byte */
|
|
743
|
+
position?: number
|
|
744
|
+
/** 指定文件的长度,如果不指定,则读到文件末尾。有效范围:[1, fileLength]。单位:byte */
|
|
745
|
+
length?: number
|
|
746
|
+
}
|
|
747
|
+
/** 字符编码合法值 */
|
|
748
|
+
interface Encoding {
|
|
749
|
+
ascii
|
|
750
|
+
base64
|
|
751
|
+
binary
|
|
752
|
+
hex
|
|
753
|
+
/** @illustrate 以小端序读取 */
|
|
754
|
+
ucs2
|
|
755
|
+
/** @illustrate 以小端序读取 */
|
|
756
|
+
'ucs-2'
|
|
757
|
+
/** @illustrate 以小端序读取 */
|
|
758
|
+
utf16le
|
|
759
|
+
/** @illustrate 以小端序读取 */
|
|
760
|
+
'utf-16le'
|
|
761
|
+
'utf-8'
|
|
762
|
+
utf8
|
|
763
|
+
latin1
|
|
764
|
+
}
|
|
765
|
+
interface FailCallbackResult extends TaroGeneral.CallbackResult {
|
|
766
|
+
/** 错误信息
|
|
767
|
+
*
|
|
768
|
+
* 可选值:
|
|
769
|
+
* - 'fail no such file or directory, open ${filePath}': 指定的 filePath 所在目录不存在
|
|
770
|
+
* - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有读权限
|
|
771
|
+
* - 'fail sdcard not mounted': Android sdcard 挂载失败
|
|
772
|
+
* */
|
|
773
|
+
errMsg: string
|
|
774
|
+
}
|
|
775
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
776
|
+
/** 文件读取结果。res.entries 是一个对象,key是文件路径,value是一个对象 FileItem ,表示该文件的读取结果。每个 FileItem 包含 data (文件内容) 和 errMsg (错误信息) 属性。 */
|
|
777
|
+
entries: {
|
|
778
|
+
[path: string]: FileItem
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
interface FileItem extends TaroGeneral.CallbackResult {
|
|
782
|
+
/** 文件内容 */
|
|
783
|
+
data: string | ArrayBuffer
|
|
784
|
+
/** 错误信息 */
|
|
785
|
+
errMsg: string
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
690
789
|
interface RemoveSavedFileOption {
|
|
691
790
|
/** 需要删除的文件路径 */
|
|
692
791
|
filePath: string
|
|
@@ -799,7 +898,7 @@ declare module '../../index' {
|
|
|
799
898
|
errMsg: string
|
|
800
899
|
}
|
|
801
900
|
interface StatSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
802
|
-
/** [Stats](
|
|
901
|
+
/** [Stats](/docs/apis/files/Stats) | Object
|
|
803
902
|
*
|
|
804
903
|
* 当 recursive 为 false 时,res.stats 是一个 Stats 对象。当 recursive 为 true 且 path 是一个目录的路径时,res.stats 是一个 Object,key 以 path 为根路径的相对路径,value 是该路径对应的 Stats 对象。 */
|
|
805
904
|
stats: Stats | TaroGeneral.IAnyObject
|
|
@@ -857,7 +956,7 @@ declare module '../../index' {
|
|
|
857
956
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
858
957
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
859
958
|
/** 指定写入文件的字符编码 */
|
|
860
|
-
encoding?: keyof FileSystemManager.
|
|
959
|
+
encoding?: keyof FileSystemManager.Encoding
|
|
861
960
|
/** 接口调用失败的回调函数 */
|
|
862
961
|
fail?: (result: WriteFileFailCallbackResult) => void
|
|
863
962
|
/** 接口调用成功的回调函数 */
|
|
@@ -887,8 +986,8 @@ declare module '../../index' {
|
|
|
887
986
|
/** 错误信息
|
|
888
987
|
*
|
|
889
988
|
* 可选值:
|
|
890
|
-
* - 'bad file descriptor':
|
|
891
|
-
* - 'fail permission denied':
|
|
989
|
+
* - 'bad file descriptor': 无效的文件描述符;
|
|
990
|
+
* - 'fail permission denied': 指定的 fd 路径没有读权限; */
|
|
892
991
|
errMsg: string
|
|
893
992
|
}
|
|
894
993
|
interface FstatSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
@@ -915,7 +1014,7 @@ declare module '../../index' {
|
|
|
915
1014
|
/** 错误信息
|
|
916
1015
|
*
|
|
917
1016
|
* 可选值:
|
|
918
|
-
* - 'bad file descriptor':
|
|
1017
|
+
* - 'bad file descriptor': 无效的文件描述符 */
|
|
919
1018
|
errMsg: string
|
|
920
1019
|
}
|
|
921
1020
|
interface CloseSyncOption {
|
|
@@ -938,10 +1037,10 @@ declare module '../../index' {
|
|
|
938
1037
|
/** 错误信息
|
|
939
1038
|
*
|
|
940
1039
|
* 可选值:
|
|
941
|
-
* - 'bad file descriptor':
|
|
942
|
-
* - 'fail permission denied':
|
|
943
|
-
* - 'fail the maximum size of the file storage limit is exceeded':
|
|
944
|
-
* - 'fail sdcard not mounted
|
|
1040
|
+
* - 'bad file descriptor': 无效的文件描述符
|
|
1041
|
+
* - 'fail permission denied': 指定的 fd 没有写权限
|
|
1042
|
+
* - 'fail the maximum size of the file storage limit is exceeded': 存储空间不足
|
|
1043
|
+
* - 'fail sdcard not mounted android sdcard': 挂载失败 */
|
|
945
1044
|
errMsg: string
|
|
946
1045
|
}
|
|
947
1046
|
interface FtruncateSyncOption {
|
|
@@ -967,7 +1066,7 @@ declare module '../../index' {
|
|
|
967
1066
|
/** 错误信息
|
|
968
1067
|
*
|
|
969
1068
|
* 可选值:
|
|
970
|
-
* - 'fail no such file or directory "${filePath}"':
|
|
1069
|
+
* - 'fail no such file or directory "${filePath}"': 上级目录不存在 */
|
|
971
1070
|
errMsg: string
|
|
972
1071
|
}
|
|
973
1072
|
interface OpenSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
@@ -1004,12 +1103,12 @@ declare module '../../index' {
|
|
|
1004
1103
|
/** 错误信息
|
|
1005
1104
|
*
|
|
1006
1105
|
* 可选值:
|
|
1007
|
-
* - 'bad file descriptor':
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1106
|
+
* - 'bad file descriptor': 无效的文件描述符
|
|
1107
|
+
* - 'fail permission denied': 指定的 fd 路径没有读权限
|
|
1108
|
+
* - 'fail the value of "offset" is out of range': 传入的 offset 不合法
|
|
1109
|
+
* - 'fail the value of "length" is out of range': 传入的 length 不合法
|
|
1110
|
+
* - 'fail sdcard not mounted': android sdcard 挂载失败
|
|
1111
|
+
* - 'bad file descriptor': 无效的文件描述符
|
|
1013
1112
|
* */
|
|
1014
1113
|
errMsg: string
|
|
1015
1114
|
}
|
|
@@ -1021,6 +1120,53 @@ declare module '../../index' {
|
|
|
1021
1120
|
/** 调用结果 */
|
|
1022
1121
|
errMsg: string
|
|
1023
1122
|
}
|
|
1123
|
+
namespace readCompressedFile {
|
|
1124
|
+
type Promised = FailCallbackResult | SuccessCallbackResult
|
|
1125
|
+
interface Option {
|
|
1126
|
+
/** 要读取的文件的路径 (本地用户文件或代码包文件) */
|
|
1127
|
+
filePath: string
|
|
1128
|
+
/** 文件压缩类型,目前仅支持 'br'。 */
|
|
1129
|
+
compressionAlgorithm: keyof CompressionAlgorithm | string
|
|
1130
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
1131
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
1132
|
+
/** 接口调用失败的回调函数 */
|
|
1133
|
+
fail?: (result: FailCallbackResult) => void
|
|
1134
|
+
/** 接口调用成功的回调函数 */
|
|
1135
|
+
success?: (res: SuccessCallbackResult) => void
|
|
1136
|
+
}
|
|
1137
|
+
/** 文件压缩类型合法值 */
|
|
1138
|
+
interface CompressionAlgorithm {
|
|
1139
|
+
/** brotli压缩文件 */
|
|
1140
|
+
br
|
|
1141
|
+
}
|
|
1142
|
+
interface FailCallbackResult extends TaroGeneral.CallbackResult {
|
|
1143
|
+
/** 错误信息
|
|
1144
|
+
*
|
|
1145
|
+
* 可选值:
|
|
1146
|
+
* - 'fail decompress fail': 指定的 compressionAlgorithm 与文件实际压缩格式不符
|
|
1147
|
+
* - 'fail no such file or directory, open ${filePath}': 指定的 filePath 所在目录不存在
|
|
1148
|
+
* - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有读权限
|
|
1149
|
+
* */
|
|
1150
|
+
errMsg: string
|
|
1151
|
+
}
|
|
1152
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
1153
|
+
/** 文件内容 */
|
|
1154
|
+
data: ArrayBuffer
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
namespace readCompressedFileSync {
|
|
1158
|
+
interface Option {
|
|
1159
|
+
/** 要读取的文件的路径 (本地用户文件或代码包文件) */
|
|
1160
|
+
filePath: string
|
|
1161
|
+
/** 文件压缩类型,目前仅支持 'br'。 */
|
|
1162
|
+
compressionAlgorithm: keyof CompressionAlgorithm | string
|
|
1163
|
+
}
|
|
1164
|
+
/** 文件压缩类型合法值 */
|
|
1165
|
+
interface CompressionAlgorithm {
|
|
1166
|
+
/** brotli压缩文件 */
|
|
1167
|
+
br
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1024
1170
|
interface ReadSyncOption {
|
|
1025
1171
|
/** 文件描述符。fd 通过 FileSystemManager.open 或 FileSystemManager.openSync 接口获得 */
|
|
1026
1172
|
fd: string
|
|
@@ -1049,11 +1195,11 @@ declare module '../../index' {
|
|
|
1049
1195
|
/** 错误信息
|
|
1050
1196
|
*
|
|
1051
1197
|
* 可选值:
|
|
1052
|
-
* - 'fail no such file or directory, open ${filePath}':
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1198
|
+
* - 'fail no such file or directory, open ${filePath}': 指定的 filePath 所在目录不存在
|
|
1199
|
+
* - 'fail illegal operation on a directory, open "${filePath}"': 指定的 filePath 是一个已经存在的目录
|
|
1200
|
+
* - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有写权限
|
|
1201
|
+
* - 'fail the maximum size of the file storage limit is exceeded': 存储空间不足
|
|
1202
|
+
* - 'fail sdcard not mounted': android sdcard 挂载失败
|
|
1057
1203
|
* */
|
|
1058
1204
|
errMsg: string
|
|
1059
1205
|
}
|
|
@@ -1073,7 +1219,7 @@ declare module '../../index' {
|
|
|
1073
1219
|
/** 只在 data 类型是 ArrayBuffer 时有效,指定要写入的字节数,默认为 arrayBuffer 从0开始偏移 offset 个字节后剩余的字节数 */
|
|
1074
1220
|
length?: number
|
|
1075
1221
|
/** 只在 data 类型是 String 时有效,指定写入文件的字符编码,默认为 utf8 */
|
|
1076
|
-
encoding?: keyof FileSystemManager.
|
|
1222
|
+
encoding?: keyof FileSystemManager.Encoding
|
|
1077
1223
|
/** 指定文件开头的偏移量,即数据要被写入的位置。当 position 不传或者传入非 Number 类型的值时,数据会被写入当前指针所在位置。 */
|
|
1078
1224
|
position?: number
|
|
1079
1225
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
@@ -1087,9 +1233,9 @@ declare module '../../index' {
|
|
|
1087
1233
|
/** 错误信息
|
|
1088
1234
|
*
|
|
1089
1235
|
* 可选值:
|
|
1090
|
-
* 'bad file descriptor':
|
|
1091
|
-
* 'fail permission denied':
|
|
1092
|
-
* 'fail sdcard not mounted':
|
|
1236
|
+
* 'bad file descriptor': 无效的文件描述符
|
|
1237
|
+
* 'fail permission denied': 指定的 fd 路径没有写权限
|
|
1238
|
+
* 'fail sdcard not mounted': android sdcard 挂载失败
|
|
1093
1239
|
* */
|
|
1094
1240
|
errMsg: string
|
|
1095
1241
|
}
|
|
@@ -1109,22 +1255,36 @@ declare module '../../index' {
|
|
|
1109
1255
|
/** 只在 data 类型是 ArrayBuffer 时有效,指定要写入的字节数,默认为 arrayBuffer 从0开始偏移 offset 个字节后剩余的字节数 */
|
|
1110
1256
|
length?: number
|
|
1111
1257
|
/** 只在 data 类型是 String 时有效,指定写入文件的字符编码,默认为 utf8 */
|
|
1112
|
-
encoding?: keyof FileSystemManager.
|
|
1258
|
+
encoding?: keyof FileSystemManager.Encoding
|
|
1113
1259
|
/** 指定文件开头的偏移量,即数据要被写入的位置。当 position 不传或者传入非 Number 类型的值时,数据会被写入当前指针所在位置。 */
|
|
1114
1260
|
position?: number
|
|
1115
1261
|
}
|
|
1116
1262
|
}
|
|
1117
1263
|
|
|
1118
|
-
/**
|
|
1264
|
+
/** 文件读取结果。 通过 [FileSystemManager.readSync](./FileSystemManager#readsync) 接口返回
|
|
1265
|
+
* @supported weapp
|
|
1266
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/ReadResult.html
|
|
1267
|
+
*/
|
|
1268
|
+
interface ReadResult {
|
|
1269
|
+
/** 实际读取的字节数 */
|
|
1270
|
+
bytesRead: number
|
|
1271
|
+
/** 被写入的缓存区的对象,即接口入参的 arrayBuffer */
|
|
1272
|
+
arrayBuffer: ArrayBuffer
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
/** 描述文件状态的对象
|
|
1276
|
+
* @supported weapp
|
|
1277
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.html
|
|
1278
|
+
*/
|
|
1119
1279
|
interface Stats {
|
|
1120
|
-
/** 文件最近一次被存取或被执行的时间,UNIX 时间戳,对应 POSIX stat.st_atime */
|
|
1121
|
-
lastAccessedTime: number
|
|
1122
|
-
/** 文件最后一次被修改的时间,UNIX 时间戳,对应 POSIX stat.st_mtime */
|
|
1123
|
-
lastModifiedTime: number
|
|
1124
1280
|
/** 文件的类型和存取的权限,对应 POSIX stat.st_mode */
|
|
1125
1281
|
mode: string
|
|
1126
1282
|
/** 文件大小,单位:B,对应 POSIX stat.st_size */
|
|
1127
1283
|
size: number
|
|
1284
|
+
/** 文件最近一次被存取或被执行的时间,UNIX 时间戳,对应 POSIX stat.st_atime */
|
|
1285
|
+
lastAccessedTime: number
|
|
1286
|
+
/** 文件最后一次被修改的时间,UNIX 时间戳,对应 POSIX stat.st_mtime */
|
|
1287
|
+
lastModifiedTime: number
|
|
1128
1288
|
/** 判断当前文件是否一个目录
|
|
1129
1289
|
* @supported weapp
|
|
1130
1290
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.isDirectory.html
|
|
@@ -1137,11 +1297,38 @@ declare module '../../index' {
|
|
|
1137
1297
|
isFile(): boolean
|
|
1138
1298
|
}
|
|
1139
1299
|
|
|
1300
|
+
/** 文件写入结果。 通过 [FileSystemManager.writeSync](./FileSystemManager#writesync) 接口返回
|
|
1301
|
+
* @supported weapp
|
|
1302
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/WriteResult.html
|
|
1303
|
+
*/
|
|
1304
|
+
interface WriteResult {
|
|
1305
|
+
/** 实际被写入到文件中的字节数(注意,被写入的字节数不一定与被写入的字符串字符数相同) */
|
|
1306
|
+
bytesWritten: number
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1140
1309
|
interface TaroStatic {
|
|
1141
|
-
/**
|
|
1310
|
+
/** 保存文件系统的文件到用户磁盘,仅在 PC 端支持
|
|
1142
1311
|
* @supported weapp
|
|
1143
1312
|
* @example
|
|
1144
1313
|
* ```tsx
|
|
1314
|
+
* Taro.saveFileToDisk({
|
|
1315
|
+
* filePath: `${Taro.env.USER_DATA_PATH}/hello.txt`,
|
|
1316
|
+
* success(res) {
|
|
1317
|
+
* console.log(res)
|
|
1318
|
+
* },
|
|
1319
|
+
* fail(res) {
|
|
1320
|
+
* console.error(res)
|
|
1321
|
+
* }
|
|
1322
|
+
* })
|
|
1323
|
+
* ```
|
|
1324
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.saveFileToDisk.html
|
|
1325
|
+
*/
|
|
1326
|
+
saveFileToDisk(option: saveFileToDisk.Option): Promise<TaroGeneral.CallbackResult>
|
|
1327
|
+
|
|
1328
|
+
/** 保存文件到本地。**注意:saveFile 会把临时文件移动,因此调用成功后传入的 tempFilePath 将不可用**
|
|
1329
|
+
* @supported weapp, rn
|
|
1330
|
+
* @example
|
|
1331
|
+
* ```tsx
|
|
1145
1332
|
* Taro.chooseImage({
|
|
1146
1333
|
* success: function (res) {
|
|
1147
1334
|
* var tempFilePaths = res.tempFilePaths
|
|
@@ -1159,7 +1346,7 @@ declare module '../../index' {
|
|
|
1159
1346
|
saveFile(option: saveFile.Option): Promise<saveFile.SuccessCallbackResult | saveFile.FailCallbackResult>
|
|
1160
1347
|
|
|
1161
1348
|
/** 删除该小程序下已保存的本地缓存文件
|
|
1162
|
-
* @supported weapp
|
|
1349
|
+
* @supported weapp, rn
|
|
1163
1350
|
* @example
|
|
1164
1351
|
* ```tsx
|
|
1165
1352
|
* Taro.getSavedFileList({
|
|
@@ -1184,7 +1371,7 @@ declare module '../../index' {
|
|
|
1184
1371
|
* @example
|
|
1185
1372
|
```tsx
|
|
1186
1373
|
* Taro.downloadFile({
|
|
1187
|
-
* url: '
|
|
1374
|
+
* url: 'https://example.com/somefile.pdf',
|
|
1188
1375
|
* success: function (res) {
|
|
1189
1376
|
* var filePath = res.tempFilePath
|
|
1190
1377
|
* Taro.openDocument({
|
|
@@ -1201,7 +1388,7 @@ declare module '../../index' {
|
|
|
1201
1388
|
openDocument(option: openDocument.Option): Promise<TaroGeneral.CallbackResult>
|
|
1202
1389
|
|
|
1203
1390
|
/** 获取本地已保存的文件列表
|
|
1204
|
-
* @supported weapp
|
|
1391
|
+
* @supported weapp, rn
|
|
1205
1392
|
* @example
|
|
1206
1393
|
* ```tsx
|
|
1207
1394
|
* Taro.getSavedFileList({
|
|
@@ -1214,8 +1401,8 @@ declare module '../../index' {
|
|
|
1214
1401
|
*/
|
|
1215
1402
|
getSavedFileList(option?: getSavedFileList.Option): Promise<getSavedFileList.SuccessCallbackResult>
|
|
1216
1403
|
|
|
1217
|
-
/** 获取本地文件的文件信息。此接口只能用于获取已保存到本地的文件,若需要获取临时文件信息,请使用 [Taro.getFileInfo](
|
|
1218
|
-
* @supported weapp
|
|
1404
|
+
/** 获取本地文件的文件信息。此接口只能用于获取已保存到本地的文件,若需要获取临时文件信息,请使用 [Taro.getFileInfo](/docs/apis/files/getFileInfo) 接口。
|
|
1405
|
+
* @supported weapp, rn
|
|
1219
1406
|
* @example
|
|
1220
1407
|
* ```tsx
|
|
1221
1408
|
* Taro.getSavedFileInfo({
|
|
@@ -1232,7 +1419,7 @@ declare module '../../index' {
|
|
|
1232
1419
|
|
|
1233
1420
|
/**
|
|
1234
1421
|
* 获取该小程序下的 本地临时文件 或 本地缓存文件 信息
|
|
1235
|
-
* @supported weapp
|
|
1422
|
+
* @supported weapp, rn
|
|
1236
1423
|
* @example
|
|
1237
1424
|
* ```tsx
|
|
1238
1425
|
* Taro.getFileInfo({
|