-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathwx.d.ts
executable file
·3418 lines (3039 loc) · 79.6 KB
/
wx.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright (c) xzh <https://github.com/Adherentman>
* project: https://github.com/Adherentman/Typescript-wxApi.d.ts
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Common Types
interface string2AnyMap {
[key: string]: any;
}
interface string2stringMap {
[key: string]: string | null;
}
type ZeroParamVoidFunc = () => void;
interface ReturnCallBack {
(res: ZeroParamVoidFunc): void;
}
interface createLiveObj extends WxApiCallback {}
// App Types
interface AppReferrerInfo {
appId: string;
extraData: any;
}
interface AppLaunchShowFuncOpts {
path: string;
query: string2stringMap;
scene: number;
shareTicket: string;
referrerInfo: AppReferrerInfo;
}
type AppLaunchShowFunc = (options: AppLaunchShowFuncOpts) => void;
interface AppOpts {
onLaunch?: AppLaunchShowFunc;
onShow?: AppLaunchShowFunc;
onHide?: ZeroParamVoidFunc;
onError?: (msg: string) => void;
[key: string]: any;
}
interface IApp extends AppOpts {}
// Page Types
interface PageOpts<Data = {}> {
data?: Data;
onLoad?: (options: string2stringMap) => void;
onReady?: ZeroParamVoidFunc;
onShow?: ZeroParamVoidFunc;
onHide?: ZeroParamVoidFunc;
onUnload?: ZeroParamVoidFunc;
/**
* 在 Page 中定义 onPullDownRefresh 处理函数,监听该页面用户下拉刷新事件。
*/
onPullDownRefresh?: ZeroParamVoidFunc;
onReachBottom?: ZeroParamVoidFunc;
/**
* 在 Page 中定义 onShareAppMessage 事件处理函数,自定义该页面的转发内容。
*/
onShareAppMessage?: ZeroParamVoidFunc;
onPageScroll?: ZeroParamVoidFunc;
onTabItemTap?: (item: any) => void;
[key: string]: any;
}
interface IPage<Data = {}> extends PageOpts<Data> {
setData: (data: string2AnyMap) => void;
}
// Component Types
interface IComponent {}
interface WxApiCallback<Res = undefined> {
success?: (res: Res) => void;
fail?: (err: any) => void;
complete?: (obj: any) => void;
}
/**
* Network APIs
*/
// 发起请求
type NetworkRequestData = string | object | ArrayBuffer;
interface NetworkRequestRes {
data: NetworkRequestData;
statusCode: number;
header: string2stringMap;
}
interface NetworkRequestOpts extends WxApiCallback<NetworkRequestRes> {
url: string;
data?: NetworkRequestData;
header?: string2stringMap;
method?: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT';
dataType?: string;
responseType?: 'text' | 'arraybuffer';
}
interface requestTask {
/**
* 中断请求任务
*/
abort: ZeroParamVoidFunc;
}
// 上传
interface uploadFileRes {
data: string;
statusCode: number;
}
interface uploadFileOpts extends WxApiCallback<uploadFileRes> {
url: string;
filePath: string;
name: string;
header?: object;
formData?: object;
}
interface onProgressUpdateRes {
progress: number;
totalBytesSent: number;
totalBytesExpectedToWrite: number;
}
interface onProgressUpdateCallback {
(res: onProgressUpdateRes): void;
}
interface uploadTask {
/**
* 监听下载进度变化事件
*/
onProgressUpdate(res: onProgressUpdateCallback): void;
/**
* 中断上传任务
*/
abort: ZeroParamVoidFunc;
}
// 下载
interface downloadRes {
tempFilePath: string;
statusCode: number;
}
interface downloadFileOpts extends WxApiCallback<downloadRes> {
url: string;
header?: object;
filePath: string;
}
interface downloadTask {
/**
* 监听下载进度变化事件
*/
onProgressUpdate(res: onProgressUpdateCallback): void;
/**
* 中断下载任务
*/
abort: ZeroParamVoidFunc;
}
// Webscoket connectSocket
interface connectSocketOpts extends WxApiCallback {
url: string;
header?: object;
method?: string;
protocols?: string[];
}
// 监听WebSocket连接打开事件。
interface onSocketOpenRes {
header?: object;
}
interface onSocketOpenCallBack {
(res: onSocketOpenRes): void;
}
interface onSocketErrorCallBack {
(res: any): void;
}
// sendSocketMessage
interface sendSocketMessageOpts extends WxApiCallback<sendSocketMessageRes> {}
interface sendSocketMessageRes {
data: string | ArrayBuffer;
}
//onSocketMessage
interface onSocketMessageRes {
data: string | ArrayBuffer;
}
interface onSocketMessageCallback {
(res: onSocketMessageRes): void;
}
//closeSocket
interface closeSocketOpts extends WxApiCallback<closeSocketRes> {}
interface closeSocketRes {
code?: number;
reason?: string;
}
interface onSocketCloseCallBack {
(res: any): void;
}
interface offLocalServiceDiscoveryStopCallBack {
(res: any): void;
}
interface offLocalServiceFoundCallBack {
(res: any): void;
}
interface offLocalServiceLostCallBack {
(res: any): void;
}
interface offLocalServiceResolveFailCallBack {
(res: any): void;
}
interface onLocalServiceDiscoveryStopCallBack {
(res: any): void;
}
interface onLocalServiceFoundCallBackRes {
serviceType?: string;
serviceName?: string;
ip?: string;
port?: string;
}
interface onLocalServiceFoundCallBack {
(res: onLocalServiceFoundCallBackRes): void;
}
interface onLocalServiceLostCallBackRes {
serviceType?: string;
serviceName?: string;
}
interface onLocalServiceLostCallBack {
(res: onLocalServiceLostCallBackRes): void;
}
interface onLocalServiceResolveFailCallBackRes {
serviceType?: string;
serviceName?: string;
}
interface onLocalServiceResolveFailCallBack {
(res: onLocalServiceResolveFailCallBackRes): void;
}
interface startLocalServiceDiscoveryOpts extends WxApiCallback {
serviceType: string;
}
interface stopLocalServiceDiscoveryOpts extends WxApiCallback {}
interface NetworkAPIs {
/**
* 发起请求
*/
request: (options: NetworkRequestOpts) => requestTask;
/**
* 上传
*/
uploadFile: (options: uploadFileOpts) => uploadTask;
/**
* 下载
*/
downloadFile: (options: downloadFileOpts) => downloadTask;
/**
* 取消监听mDNS 服务停止搜索的事件
*/
offLocalServiceDiscoveryStop: (callback: offLocalServiceDiscoveryStopCallBack) => void;
/**
* 取消监听mDNS 服务发现的事件
*/
offLocalServiceFound: (callback: offLocalServiceFoundCallBack) => void;
/**
* 取消监听mDNS 服务离开的事件
*/
offLocalServiceLost: (callback: offLocalServiceLostCallBack) => void;
/**
* 取消监听mDNS 服务解析失败的事件
*/
offLocalServiceResolveFail: (callback: offLocalServiceResolveFailCallBack) => void;
/**
* 监听mDNS 服务停止搜索的事件
*/
onLocalServiceDiscoveryStop: (callback: onLocalServiceDiscoveryStopCallBack) => void;
/**
* 监听mDNS 服务发现的事件
*/
onLocalServiceFound: (callback: onLocalServiceFoundCallBack) => void;
/**
* 监听mDNS 服务离开的事件
*/
onLocalServiceLost: (callback: onLocalServiceLostCallBack) => void;
/**
* 监听mDNS 服务解析失败的事件
*/
onLocalServiceResolveFail: (callback: onLocalServiceResolveFailCallBack) => void;
/**
* 开始搜索局域网下的 mDNS 服务。搜索的结果会通过 wx.onLocalService* 事件返回。
*/
startLocalServiceDiscovery: (options: startLocalServiceDiscoveryOpts) => void;
/**
*
*/
stopLocalServiceDiscovery: (options: stopLocalServiceDiscoveryOpts) => void;
// WebSocket
connectSocket: (options: connectSocketOpts) => void;
onSocketOpen: (callback: onSocketOpenCallBack) => void;
onSocketError: (callback: onSocketErrorCallBack) => void;
sendSocketMessage: (options: sendSocketMessageOpts) => void;
onSocketMessage: (options: onSocketMessageCallback) => void;
closeSocket: (options: closeSocketOpts) => void;
onSocketClose: (callback: onSocketCloseCallBack) => void;
}
/**
* SocketTask APIs
*/
//send
interface sendOpts extends WxApiCallback<sendRes> {}
interface sendRes {
data?: string | ArrayBuffer;
}
interface onOpenRes {
header: object;
}
interface onOpenCallBack {
(res: onOpenRes): void;
}
//close
interface closeOpts extends WxApiCallback<closeRes> {}
interface closeRes {
code?: number;
reason?: string;
}
// onClose
interface onCloseCallBack {
(res: any): void;
}
//onError
interface onErrorOpts {
errMsg?: string;
}
interface onErrorCallBack {
(res: onErrorOpts): void;
}
//onMessage
interface onMessageOpts {
data?: string | ArrayBuffer;
}
interface onMessageCallBack {
(res: onMessageOpts): void;
}
interface SocketTaskAPIs {
send: (options?: sendOpts) => void;
close: (options?: closeOpts) => void;
onOpen: (res: onOpenCallBack) => void;
onClose: (res: onCloseCallBack) => void;
onError: (res: onErrorCallBack) => void;
onMessage: (res: onMessageCallBack) => void;
}
/**
* Media APIs
*/
// picture 图片
interface tempFilesStruct {
path: string;
size: number;
}
interface chooseImageRes {
tempFilePaths: string[];
tempFiles: tempFilesStruct;
}
interface chooseImageOpts extends WxApiCallback<chooseImageRes> {
count?: number;
sizeType?: string[];
sourceType?: string[];
}
interface previewImageOpts extends WxApiCallback {
current?: string;
urls: string[];
}
interface getImageInfoRes {
width: number;
height: number;
path: string;
/**
* 1.9.90
*/
orientation:
| 'up'
| 'down'
| 'left'
| 'right'
| 'up-mirrored'
| 'down-mirrored'
| 'left-mirrored'
| 'right-mirrored';
/**
* 1.9.90
*/
type: string;
}
interface getImageInfoOpts extends WxApiCallback<getImageInfoRes> {
src: string;
}
interface saveImageToPhotosAlbumRes {
errMsg: string;
}
interface saveImageToPhotosAlbumOpts extends WxApiCallback {
filePath: string;
}
// Record 录音
interface startRecordRes {
tempFilePath: string;
}
interface startRecordOpts extends WxApiCallback<startRecordRes> {}
interface RecordStartOpts {
duration?: number;
sampleRate?: number;
/**
* numberOfChannels有效值 1/2
*/
numberOfChannels?: number;
encodeBitRate?: number;
/**
* format有效值aac/mp3
*/
format?: string;
frameSize?: number;
audioSource?: string;
}
interface RecordOnStopRes {
tempFilePath: string;
}
interface RecordOnStopCallBack {
(res: RecordOnStopRes): void;
}
interface onFrameRecordedRes {
frameBuffer: ArrayBuffer;
isLastFrame: boolean;
}
interface onFrameRecordedCallBack {
(res: onFrameRecordedRes): void;
}
interface RecordOnErrorRes {
errMsg: string;
}
interface RecordOnErrorCallBack {
(res: RecordOnErrorRes): void;
}
interface getRecorderManagerOpts {
/**
* 开始录音
*/
start: (options: RecordStartOpts) => void;
/**
* 暂停录音
*/
pause: ZeroParamVoidFunc;
/**
* 继续录音
*/
resume: ZeroParamVoidFunc;
/**
* 停止录音
*/
stop: ZeroParamVoidFunc;
/**
* 监听录音开始事件
*/
onStart: ReturnCallBack;
/**
* 监听录音继续事件
*/
onResume: ReturnCallBack;
/**
* 监听录音暂停事件
*/
onPause: ReturnCallBack;
/**
* 监听录音结束事件
*/
onStop: (res: RecordOnStopCallBack) => void;
/**
* 监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。
*/
onFrameRecorded: (res: onFrameRecordedRes) => void;
/**
* 监听录音错误事件
*/
onError: (res: RecordOnErrorCallBack) => void;
/**
* 监听录音因为受到系统占用而被中断开始事件。
*/
onInterruptionBegin: ReturnCallBack;
/**
* 监听录音中断结束事件。
*/
onInterruptionEnd: ReturnCallBack;
}
// Voice 音频
interface playVoiceOpts extends WxApiCallback {
filePath: string;
duration?: number;
}
interface getBackgroundAudioPlayerStateRes {
duration: number;
currentPosition: number;
status: '2' | '1' | '0';
downloadPercent: number;
dataUrl: string;
}
interface getBackgroundAudioPlayerStateOpts
extends WxApiCallback<getBackgroundAudioPlayerStateRes> {}
interface playBackgroundAudioOpts extends WxApiCallback {
dataUrl: string;
title?: string;
coverImgUrl?: string;
}
interface seekBackgroundAudioOpts extends WxApiCallback {
position: number;
}
interface getBackgroundAudioManagerOpts {
duration: number;
currentTime: number;
paused: boolean;
src: string;
startTime: number;
buffered: number;
title: string;
epname: string;
singer: string;
coverImgUrl: string;
webUrl: string;
/**
* 支持版本1.9.94
*/
protocol: string;
/**
* 播放音乐
*/
play: ZeroParamVoidFunc;
/**
* 暂停音乐
*/
pause: ZeroParamVoidFunc;
/**
* 停止音乐
*/
stop: ZeroParamVoidFunc;
/**
* 跳转到指定位置
* currentTime 跳转的位置,单位 s。精确到小数点后 3 位,即支持 ms 级别精确度
*/
seek: (currentTime: number) => void;
/**
* 监听背景音频进入可播放状态事件。但不保证后面可以流畅播放
*/
onCanplay: (callback: ReturnCallBack) => void;
/**
* 监听背景音频自然播放结束事件
*/
onEnded: (callback: ReturnCallBack) => void;
/**
* 监听背景音频播放错误事件
*/
onError: (callback: ReturnCallBack) => void;
/**
* 监听用户在系统音乐播放面板点击下一曲事件(仅iOS)
*/
onNext: (callback: ReturnCallBack) => void;
/**
* 监听背景音频暂停事件
*/
onPause: (callback: ReturnCallBack) => void;
/**
* 监听背景音频播放事件
*/
onPlay: (callback: ReturnCallBack) => void;
/**
* 监听用户在系统音乐播放面板点击上一曲事件(仅iOS)
*/
onPrev: (callback: ReturnCallBack) => void;
/**
* 监听背景音频完成跳转操作事件
*/
onSeeked: (callback: ReturnCallBack) => void;
/**
* 监听背景音频开始跳转操作事件
*/
onSeeking: (callback: ReturnCallBack) => void;
/**
* 监听背景音频停止事件
*/
onStop: (callback: ReturnCallBack) => void;
/**
* 监听背景音频播放进度更新事件
*/
onTimeUpdate: (callback: ReturnCallBack) => void;
/**
* 监听音频加载中事件。当音频因为数据不足,需要停下来加载时会触发
*/
onWaiting: (callback: ReturnCallBack) => void;
}
interface createInnerAudioContextonErrorRes {
errCode: number;
}
interface createInnerAudioContextonErrorCallBack {
(callback: createInnerAudioContextonErrorRes);
}
interface createInnerAudioContextOpts {
src: string;
startTime: number;
autoplay: boolean;
loop: boolean;
obeyMuteSwitch: boolean;
duration: number;
currentTime: number;
paused: boolean;
buffered: number;
/**
* 支持版本1.9.90
*/
volume: number;
play: ZeroParamVoidFunc;
pause: ZeroParamVoidFunc;
stop: ZeroParamVoidFunc;
seek: (position: any) => void;
destroy: ZeroParamVoidFunc;
onCanplay: (callback: ReturnCallBack) => void;
onPlay: (callback: ReturnCallBack) => void;
onPause: (callback: ReturnCallBack) => void;
onStop: (callback: ReturnCallBack) => void;
onEnded: (callback: ReturnCallBack) => void;
onTimeUpdate: (callback: ReturnCallBack) => void;
onError: (callback: createInnerAudioContextonErrorCallBack) => void;
onWaiting: (callback: ReturnCallBack) => void;
onSeeking: (callback: ReturnCallBack) => void;
onSeeked: (callback: ReturnCallBack) => void;
/**
* 以下方法支持的版本为1.9.0
*/
offCanplay: (callback: ReturnCallBack) => void;
offPlay: (callback: ReturnCallBack) => void;
offPause: (callback: ReturnCallBack) => void;
offStop: (callback: ReturnCallBack) => void;
offEnded: (callback: ReturnCallBack) => void;
offTimeUpdate: (callback: ReturnCallBack) => void;
offError: (callback: ReturnCallBack) => void;
offWaiting: (callback: ReturnCallBack) => void;
offSeeking: (callback: ReturnCallBack) => void;
offSeeked: (callback: ReturnCallBack) => void;
}
interface getAvailableAudioSourcesRes {
audioSources: string[];
}
interface getAvailableAudioSourcesOpts extends WxApiCallback<getAvailableAudioSourcesRes> {}
// Video 视频
interface chooseVideoRes {
tempFilePath: string;
duration: number;
size: string;
height: number;
width: number;
}
interface chooseVideoOpts extends WxApiCallback<chooseImageRes> {
sourceType?: string[];
compressed?: boolean;
maxDuration?: number;
}
interface saveVideoToPhotosAlbumRes {
errMsg: string;
}
interface saveVideoToPhotosAlbumOpts extends WxApiCallback<saveImageToPhotosAlbumRes> {
filePath: string;
}
interface Videodanmu {
text: string;
color: string;
}
interface createVideoContextOpts {
play: ZeroParamVoidFunc;
pause: ZeroParamVoidFunc;
seek: (position: any) => void;
sendDanmu: (danmu: Videodanmu) => void;
playbackRate: (rate: any) => void;
requestFullScreen: ZeroParamVoidFunc;
exitFullScreen: ZeroParamVoidFunc;
/**
* 2.1.0仅在iOS全屏下有效
*/
showStatusBar: ZeroParamVoidFunc;
hideStatusBar: ZeroParamVoidFunc;
}
interface takePhotoObj extends WxApiCallback {
quality?: 'high' | 'normal' | 'low';
}
interface startRecordObj extends WxApiCallback {
timeoutCallback?: ZeroParamVoidFunc;
}
interface stopRecordObj extends WxApiCallback {}
interface createCameraContextOpts {
takePhoto: (options: takePhotoObj) => void;
startRecord: (options: startRecordObj) => void;
stopRecord: (options: stopRecordObj) => void;
}
interface requestFullScreenObj extends WxApiCallback {
direction: number;
}
interface exitFullScreen extends WxApiCallback {}
interface createLivePlayerContextOpts {
play: (options: createLiveObj) => void;
stop: (options: createLiveObj) => void;
mute: (options: createLiveObj) => void;
/**
* pause, resume只支持在版本1.9.90
*/
pause: (options: createLiveObj) => void;
resume: (options: createLiveObj) => void;
requestFullScreen: (options: requestFullScreenObj) => void;
exitFullScreen: (options: createLiveObj) => void;
}
interface createLivePusherContextOpts {
start: (options: createLiveObj) => void;
stop: (options: createLiveObj) => void;
pause: (options: createLiveObj) => void;
resume: (options: createLiveObj) => void;
switchCamera: (options: createLiveObj) => void;
snapshot: (options: createLiveObj) => void;
toggleTorch: (options: createLiveObj) => void;
}
interface LoadFontFaceDesc {
style?: string;
weight?: string;
variant?: string;
}
interface loadFontFaceRes {
status: any;
}
interface loadFontFaceOpts extends WxApiCallback<loadFontFaceRes> {
family: string;
source: string;
desc?: LoadFontFaceDesc;
}
interface compressImageOpts extends WxApiCallback {
src: string;
quality?: number;
}
interface chooseMessageFileRes {
path: string;
size: number;
name: string;
type: 'video' | 'image' | 'file';
time: number;
}
interface chooseMessageFileOpts extends WxApiCallback<chooseMessageFileRes> {
count: number;
type?: 'all' | 'video' | 'image' | 'file';
extension?: string[];
}
interface MediaAPIs {
/**
* 保存图片到系统相册。
*/
saveImageToPhotosAlbum: (options: saveImageToPhotosAlbumOpts) => void;
/**
* 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
*/
previewImage: (options: previewImageOpts) => void;
/**
* 获取图片信息。网络图片需先配置download域名才能生效。
*/
getImageInfo: (options: getImageInfoOpts) => void;
/**
* 支持版本 >= 2.4.0
* 压缩图片接口,可选压缩质量
*/
compressImage: (options: compressImageOpts) => void;
/**
* 从客户端会话选择文件。
*/
chooseMessageFile: (options: chooseMessageFileOpts) => void;
/**
* 从本地相册选择图片或使用相机拍照。
*/
chooseImage: (options: chooseImageOpts) => void;
startRecord: (options: startRecordOpts) => void;
stopRecord: ZeroParamVoidFunc;
getRecorderManager: () => getRecorderManagerOpts;
/**
* 注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 wx.createInnerAudioContext 接口
*/
playVoice: (options: playVoiceOpts) => void;
/**
* 注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 wx.createInnerAudioContext 接口
*/
pauseVoice: ZeroParamVoidFunc;
/**
* 注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 wx.createInnerAudioContext 接口
*/
stopVoice: ZeroParamVoidFunc;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
*/
getBackgroundAudioPlayerState: (options: getBackgroundAudioPlayerStateOpts) => void;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
*/
playBackgroundAudio: (options: playBackgroundAudioOpts) => void;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
*/
pauseBackgroundAudio: ZeroParamVoidFunc;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
*/
seekBackgroundAudio: (options: seekBackgroundAudioOpts) => void;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
//callback
*/
stopBackgroundAudio: ZeroParamVoidFunc;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
*/
onBackgroundAudioPlay: (callback: ReturnCallBack) => void;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
*/
onBackgroundAudioPause: (callback: ReturnCallBack) => void;
/**
* 注意:1.2.0 版本开始,本接口不再维护。建议使用能力更强的 wx.getBackgroundAudioManager 接口
*/
onBackgroundAudioStop: (callback: ReturnCallBack) => void;
getBackgroundAudioManager: () => getBackgroundAudioManagerOpts;
/**
* 注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 wx.createInnerAudioContext 接口
*/
createAudioContext: (audioId: string, that?: IComponent) => void;
createInnerAudioContext: () => createInnerAudioContextOpts;
/**
* 2.1.0开始支持
*/
getAvailableAudioSources: (options: getAvailableAudioSourcesOpts) => void;
chooseVideo: (options: chooseVideoOpts) => void;
saveVideoToPhotosAlbum: (options: saveVideoToPhotosAlbumOpts) => void;
createVideoContext: (audioId: string, that?: IComponent) => createVideoContextOpts;
createCameraContext: () => createCameraContextOpts;
createLivePlayerContext: (domid: string) => createLivePlayerContextOpts;
createLivePusherContext: () => createLivePusherContextOpts;
loadFontFace: (options: loadFontFaceOpts) => void;
}
// File APIs
// save
interface saveFileRes {
savedFilePath: string;
}
interface saveFileOpts extends WxApiCallback<saveFileRes> {
tempFilePath: string;
}
//getFileInfo
interface getFileInfoRes {
size: number;
digest: string;
errMsg: string;
}
interface getFileInfoOpts extends WxApiCallback<getFileInfoRes> {
filePath: string;
digestAlgorithm?: string;
}
// getSavedFileList
interface fileListOpts {
filePath: string;
createTime: number;
size: number;
}
interface getSavedFileListRes {
errMsg: string;
fileList: fileListOpts;
}
interface getSavedFileListOpts extends WxApiCallback<getSavedFileListRes> {}
// getSavedFileInfo
interface getSavedFileInfoRes {
errMsg: string;
size: number;
createTime: number;
}
interface getSavedFileInfoOpts extends WxApiCallback<getSavedFileInfoRes> {
filePath: string;
}
// removeSavedFile
interface removeSavedFileOpts extends WxApiCallback {
filePath: string;
}
// openDocument
interface openDocumentOpts extends WxApiCallback {
filePath: string;
fileType?: string;
}
/**
* 更新于2018年9月14日
*/
interface mkdirOpts extends WxApiCallback {
dirPath: string;
recursive: boolean;
}