From a4ae94c2dec9de1c490df7ed4aa0cfedd1d40012 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 6 Sep 2018 16:55:16 -0500 Subject: [PATCH 01/48] Correctly type style prop --- types/react-native-material-ui/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/react-native-material-ui/index.d.ts b/types/react-native-material-ui/index.d.ts index 91ae62a3fb..7b4d56fd0c 100644 --- a/types/react-native-material-ui/index.d.ts +++ b/types/react-native-material-ui/index.d.ts @@ -5,7 +5,10 @@ // TypeScript Version: 2.8 import { Component } from 'react'; -import { ViewStyle, TextStyle, Image } from 'react-native'; +import { StyleProp, ViewStyle as ViewStyleRaw, TextStyle as TextStyleRaw, Image } from 'react-native'; + +type ViewStyle = StyleProp; +type TextStyle = StyleProp; export interface ActionButtonProps { actions?: string[] | JSX.Element[] | Array<{ From a7f8850a0156677d5a5aace88451bd75e68eb845 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 6 Sep 2018 16:59:07 -0500 Subject: [PATCH 02/48] Version bump --- types/react-native-material-ui/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-ui/index.d.ts b/types/react-native-material-ui/index.d.ts index 7b4d56fd0c..c3dac63321 100644 --- a/types/react-native-material-ui/index.d.ts +++ b/types/react-native-material-ui/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-native-material-ui 1.30 +// Type definitions for react-native-material-ui 1.31 // Project: https://github.com/xotahal/react-native-material-ui // Definitions by: Kyle Roach // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From f72507f3c55873f8d93a1627ab7edef3b075c891 Mon Sep 17 00:00:00 2001 From: iyegoroff Date: Sat, 8 Sep 2018 18:02:19 +0300 Subject: [PATCH 03/48] fixed Animated.EventConfig --- types/react-native/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index f66e46cb1e..ad8abe57fd 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -8465,8 +8465,8 @@ export namespace Animated { export function parallel(animations: Array, config?: ParallelConfig): CompositeAnimation; type Mapping = { [key: string]: Mapping } | AnimatedValue; - interface EventConfig { - listener?: ValueListenerCallback; + interface EventConfig { + listener?: (event?: NativeSyntheticEvent) => void; useNativeDriver?: boolean; } @@ -8486,7 +8486,7 @@ export namespace Animated { * ]), *``` */ - export function event(argMapping: Array, config?: EventConfig): (...args: any[]) => void; + export function event(argMapping: Array, config?: EventConfig): (...args: any[]) => void; /** * Make any React component Animatable. Used to create `Animated.View`, etc. From 4e5b1485d63fc672db755db7df5a6b6fca12a493 Mon Sep 17 00:00:00 2001 From: iyegoroff Date: Sat, 8 Sep 2018 18:24:12 +0300 Subject: [PATCH 04/48] added Animated.event test --- types/react-native/test/animated.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index c27af04bb9..dab64d9d78 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -1,6 +1,6 @@ -import * as React from "react-native"; +import * as React from "react"; -import { Animated, View } from "react-native"; +import { Animated, View, NativeSyntheticEvent, NativeScrollEvent } from "react-native"; function TestAnimatedAPI() { // Value @@ -62,6 +62,17 @@ function TestAnimatedAPI() { Animated.sequence([spring1, springXY]); Animated.stagger(100, [spring1, springXY]); + + const listener = (e?: NativeSyntheticEvent) => { + if (e) { + console.warn(e.nativeEvent.contentOffset.y); + } + }; + + Animated.event( + [{ nativeEvent: { contentOffset: { y: v1 } } }], + { useNativeDriver: true, listener }, + ); return ( From 7f0cd433de22a10d890c2e02a6a8cf23f7397617 Mon Sep 17 00:00:00 2001 From: iyegoroff Date: Sat, 8 Sep 2018 18:30:18 +0300 Subject: [PATCH 05/48] Update animated.tsx --- types/react-native/test/animated.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index dab64d9d78..40f8c37ee7 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -62,7 +62,7 @@ function TestAnimatedAPI() { Animated.sequence([spring1, springXY]); Animated.stagger(100, [spring1, springXY]); - + const listener = (e?: NativeSyntheticEvent) => { if (e) { console.warn(e.nativeEvent.contentOffset.y); From 42a696eb7417e31892e73300d47786a5874dab1d Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Sep 2018 15:55:12 -0500 Subject: [PATCH 06/48] Export helper types ViewStyle and TextStyle --- types/react-native-material-ui/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native-material-ui/index.d.ts b/types/react-native-material-ui/index.d.ts index c3dac63321..b215820f2b 100644 --- a/types/react-native-material-ui/index.d.ts +++ b/types/react-native-material-ui/index.d.ts @@ -7,8 +7,8 @@ import { Component } from 'react'; import { StyleProp, ViewStyle as ViewStyleRaw, TextStyle as TextStyleRaw, Image } from 'react-native'; -type ViewStyle = StyleProp; -type TextStyle = StyleProp; +export type ViewStyle = StyleProp; +export type TextStyle = StyleProp; export interface ActionButtonProps { actions?: string[] | JSX.Element[] | Array<{ From 0125d65fd50252f27cd85e49b0cfa4dd2819faf0 Mon Sep 17 00:00:00 2001 From: Junyoung Clare Jang Date: Mon, 10 Sep 2018 17:31:21 -0400 Subject: [PATCH 07/48] Fix unselectable (#28763) --- types/react/index.d.ts | 2 +- types/react/test/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 789061779d..d6b4f441d1 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1036,7 +1036,7 @@ declare namespace React { itemRef?: string; results?: number; security?: string; - unselectable?: boolean; + unselectable?: 'on' | 'off'; } // All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/ diff --git a/types/react/test/index.ts b/types/react/test/index.ts index a78a480199..6b9400918f 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -400,6 +400,7 @@ const htmlAttr: React.HTMLProps = { dangerouslySetInnerHTML: { __html: "STRONG" }, + unselectable: 'on', 'aria-atomic': false, 'aria-checked': 'true', 'aria-colcount': 7, From c86f6b0ccff3e7e06415fe96c3f7f2bd14bc184d Mon Sep 17 00:00:00 2001 From: Michael Strobel Date: Mon, 10 Sep 2018 23:33:07 +0200 Subject: [PATCH 08/48] [webpack-bundle-analyzer] Add excludeAssets option (#28756) This was added in webpack-bundle-analyzer 2.12.0 --- types/webpack-bundle-analyzer/index.d.ts | 15 ++++++++++++++- .../webpack-bundle-analyzer-tests.ts | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/types/webpack-bundle-analyzer/index.d.ts b/types/webpack-bundle-analyzer/index.d.ts index 6b2db94b65..f1e3f2a3c6 100644 --- a/types/webpack-bundle-analyzer/index.d.ts +++ b/types/webpack-bundle-analyzer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack-bundle-analyzer 2.9 +// Type definitions for webpack-bundle-analyzer 2.13 // Project: https://github.com/th0r/webpack-bundle-analyzer // Definitions by: Michael Strobel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,6 +7,9 @@ import * as webpack from 'webpack'; export namespace BundleAnalyzerPlugin { + type ExcludeAssetsPatternFn = (assetName: string) => boolean; + type ExcludeAssetsPattern = string | RegExp | ExcludeAssetsPatternFn; + interface Options { /** * Can be "server", "static" or "disabled". @@ -68,6 +71,16 @@ export namespace BundleAnalyzerPlugin { */ statsOptions?: null | webpack.Stats.ToJsonOptionsObject; + /** + * Default: `null`. + * Patterns that will be used to match against asset names to exclude them from the report. + * If pattern is a string it will be converted to RegExp via `new RegExp(str)`. + * If pattern is a function it should have the following signature `(assetName: string) => boolean` + * and should return true to exclude matching asset. + * If multiple patterns are provided asset should match at least one of them to be excluded. + */ + excludeAssets?: null | ExcludeAssetsPattern | ExcludeAssetsPattern[]; + /** * Log level. Can be "info", "warn", "error" or "silent". * Defaults to "info" diff --git a/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts b/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts index 0b5fcabcc7..7aa2b0aee7 100644 --- a/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts +++ b/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts @@ -19,6 +19,11 @@ const config: webpack.Configuration = { statsOptions: { source: false }, + excludeAssets: [ + 'foo', + /foo/, + assetName => assetName.indexOf('foo') !== -1 + ], logLevel: 'info' }) ] From 0a583cbe13c4cfe76bc143d862cfd4ba16bcfbf5 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Tue, 11 Sep 2018 05:35:04 +0800 Subject: [PATCH 09/48] fix weixin-app, add this type to intersection observer (#28754) --- types/weixin-app/index.d.ts | 8181 +++++++++++++------------- types/weixin-app/tsconfig.json | 41 +- types/weixin-app/tslint.json | 12 +- types/weixin-app/weixin-app-tests.ts | 58 +- 4 files changed, 4142 insertions(+), 4150 deletions(-) diff --git a/types/weixin-app/index.d.ts b/types/weixin-app/index.d.ts index 32969d3b83..2b0a905afe 100644 --- a/types/weixin-app/index.d.ts +++ b/types/weixin-app/index.d.ts @@ -7,4100 +7,4087 @@ // TypeScript Version: 2.8 declare namespace wx { - // #region 基本参数 - interface DataResponse { - /** 回调函数返回的内容 */ - data: object | string | ArrayBuffer; - /** 开发者服务器返回的 HTTP 状态码 */ - statusCode: number; - /** 开发者服务器返回的 HTTP Response Header */ - header: object; - } - interface ErrMsgResponse { - /** 成功:ok,错误:详细信息 */ - errMsg: "ok" | string; - } - interface TempFileResponse { - /** 文件的临时路径 */ - tempFilePath: string; - } - interface BaseOptions { - /** 接口调用成功的回调函数 */ - success?(res: R): void; - /** 接口调用失败的回调函数 */ - fail?(res: E): void; - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?(res: any): void; - } - interface ErrCodeResponse { - errCode: number; - } - // #endregion - // #region 网络API列表 - // 发起请求 - interface RequestHeader { - [key: string]: string; - } - interface RequestOptions extends BaseOptions { - /** 开发者服务器接口地址 */ - url: string; - /** 请求的参数 */ - data?: string | object | ArrayBuffer; - /** 设置请求的 header , header 中不能设置 Referer */ - header?: RequestHeader; - /** 默认为 GET,有效值:OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT */ - method?: - | "GET" - | "OPTIONS" - | "GET" - | "HEAD" - | "POST" - | "PUT" - | "DELETE" - | "TRACE" - | "CONNECT"; - /** 如果设为json,会尝试对返回的数据做一次 JSON.parse */ - dataType?: string; - /** - * 设置响应的数据类型。合法值:text、arraybuffer - * @version 1.7.0 - */ - responseType?: string; - /** 收到开发者服务成功返回的回调函数,res = {data: '开发者服务器返回的内容'} */ - success?(res: DataResponse): void; - } - /** - * wx.request发起的是https请求。一个微信小程序,同时只能有5个网络请求连接。 - */ - function request(options: RequestOptions): RequestTask; - - /** - * 返回一个 requestTask 对象,通过 requestTask,可中断请求任务。 - */ - interface RequestTask { - abort(): void; - } - - interface UploadTask { - /** - * 监听上传进度变化 - * @version 1.4.0 - */ - onProgressUpdate( - callback?: ( - res: { - /** 上传进度百分比 */ - progress: number; - /** 已经上传的数据长度,单位 Bytes */ - totalBytesSent: number; - /** 预期需要上传的数据总长度,单位 Bytes */ - totalBytesExpectedToSend: number; - } - ) => void - ): void; - /** - * 中断下载任务 - * @version 1.4.0 - */ - abort(): void; - } - // 上传下载 - interface UploadFileOptions extends BaseOptions { - /** 开发者服务器 url */ - url: string; - /** 要上传文件资源的路径 */ - filePath: string; - /** 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容 */ - name: string; - /** HTTP 请求 Header , header 中不能设置 Referer */ - header?: RequestHeader; - /** HTTP 请求中其他额外的 form data */ - formData?: any; - } - interface UploadFileResponse { - data: string; // 开发者服务器返回的数据 - statusCode: number; // 开发者服务器返回的 HTTP 状态码 - } - /** - * 将本地资源上传到开发者服务器。 - * 如页面通过 wx.chooseImage 等接口获取到一个本地资源的临时文件路径后, - * 可通过此接口将本地资源上传到指定服务器。 - * 客户端发起一个 HTTPS POST 请求, - * 其中 Content-Type 为 multipart/form-data 。 - */ - function uploadFile(options: UploadFileOptions): UploadTask; - interface DownloadTask { - /** - * 监听下载进度变化 - * @version 1.4.0 - */ - onProgressUpdate( - callback?: ( - res: { - /** 下载进度百分比 */ - progress: number; - /** 已经下载的数据长度,单位 Bytes */ - totalBytesWritten: number; - /** 预期需要下载的数据总长度,单位 Bytes */ - totalBytesExpectedToWrite: number; - } - ) => void - ): void; - /** - * 中断下载任务 - * @version 1.4.0 - */ - abort(): void; - } - interface DownloadFileOptions extends BaseOptions { - /** 下载资源的 url */ - url: string; - /** 下载资源的类型,用于客户端识别处理,有效值:image/audio/video */ - type?: string; - /** HTTP 请求 Header */ - header?: RequestHeader; - /** 下载成功后以 tempFilePath 的形式传给页面,res = {tempFilePath: '文件的临时路径'} */ - success?(res: TempFileResponse): void; - } - /** - * 下载文件资源到本地。客户端直接发起一个 HTTP GET 请求, - * 把下载到的资源根据 type 进行处理,并返回文件的本地临时路径。 - */ - function downloadFile(options: DownloadFileOptions): DownloadTask; - // WebSocket - interface ConnectSocketOptions extends BaseOptions { - /** 开发者服务器接口地址,必须是 HTTPS 协议,且域名必须是后台配置的合法域名 */ - url: string; - /** 请求的数据 */ - data?: any; - /** HTTP Header , header 中不能设置 Referer */ - header?: RequestHeader; - /** 默认是GET,有效值为: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT */ - method?: string; - /** - * 子协议数组 - * @version 1.4.0 - */ - protocols?: string[]; - } - /** - * 创建一个 WebSocket 连接; - * 一个微信小程序同时只能有一个 WebSocket 连接, - * 如果当前已存在一个 WebSocket 连接, - * 会自动关闭该连接,并重新创建一个 WebSocket 连接。 - */ - function connectSocket(options: ConnectSocketOptions): void; - /** 监听WebSocket连接打开事件。 */ - function onSocketOpen(callback: () => void): void; - /** 监听WebSocket错误。 */ - function onSocketError(callback: (error: any) => void): void; - interface SendSocketMessageOptions extends BaseOptions { - /** 需要发送的内容 */ - data: string | ArrayBuffer; - } - /** - * 通过 WebSocket 连接发送数据,需要先 wx.connectSocket, - * 并在 wx.onSocketOpen 回调之后才能发送。 - */ - function sendSocketMessage(options: SendSocketMessageOptions): void; - /** - * 监听WebSocket接受到服务器的消息事件。 - */ - function onSocketMessage(callback: (res: DataResponse) => void): void; - /** - * 关闭WebSocket连接。 - */ - interface CloseSocketOptions extends BaseOptions { - code?: number; // 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。如果这个参数没有被指定,默认的取值是1000 (表示正常连接关闭) 1.4.0 - reason?: string; // 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于123字节的UTF-8 文本(不是字符) - } - - /** - * 关闭WebSocket连接。 - */ - function closeSocket(options: CloseSocketOptions): void; - /** 监听WebSocket关闭。 */ - function onSocketClose(callback: () => void): void; - // #endregion - // #region 媒体API列表 - // 媒体-----图片 - type ImageSizeType = "original" | "compressed"; - type ImageSourceType = "album" | "camera"; - type VideoSourceType = "album" | "camera"; - type CameraDevice = "front" | "back"; - interface TempFile { - /** 本地文件路径 */ - path: string; - /** 本地文件大小,单位:B */ - size: number; - } - interface TempFilesData { - /** 文件的临时路径 */ - tempFilePaths: string; - /** - * 图片的本地文件列表,每一项是一个 File 对象 - * @version 1.2.0 - */ - tempFiles: TempFile[]; - } - interface ChooseImageOptions extends BaseOptions { - /** 最多可以选择的图片张数,默认9 */ - count?: number; - /** original 原图,compressed 压缩图,默认二者都有 */ - sizeType?: ImageSizeType[]; - /** album 从相册选图,camera 使用相机,默认二者都有 */ - sourceType?: ImageSourceType[]; - /** 成功则返回图片的本地文件路径列表 tempFilePaths */ - success(res: TempFilesData): void; - } - /** - * 从本地相册选择图片或使用相机拍照。 - */ - function chooseImage(options: ChooseImageOptions): void; - interface PreviewImageOptions extends BaseOptions { - /** 当前显示图片的链接,不填则默认为 urls 的第一张 */ - current?: string; - /** 需要预览的图片链接列表 */ - urls: string[]; - } - /** - * 预览图片。 - */ - function previewImage(options: PreviewImageOptions): void; - interface GetImageInfoOptions extends BaseOptions { - /** - * 图片的路径,可以是相对路径,临时文件路径,存储文件路径,网络图片路径 - */ - src: string; - } - /** - * 获取图片信息 - */ - function getImageInfo(options: GetImageInfoOptions): void; - interface SaveImageToPhotosAlbumOptions extends BaseOptions { - /** - * 图片的路径,可以是相对路径,临时文件路径,存储文件路径,网络图片路径 - */ - filePath: string; - success(res: { errMsg: string }): void; - } - /** - * 保存图片到系统相册。 - * 需要用户授权 scope.writePhotosAlbum - * @version 1.2.0 - */ - function saveImageToPhotosAlbum( - options: SaveImageToPhotosAlbumOptions - ): void; - // 媒体-----录音 - interface StartRecordAudioOptions extends BaseOptions { - /** 录音成功后调用,返回录音文件的临时文件路径,res = {tempFilePath: '录音文件的临时路径'} */ - success?(res: TempFileResponse): void; - } - /** - * 开始录音。当主动调用wx.stopRecord, - * 或者录音超过1分钟时自动结束录音,返回录音文件的临时文件路径。 - * 注:文件的临时路径,在小程序本次启动期间可以正常使用, - * 如需持久保存,需在主动调用wx.saveFile,在小程序下次启动时才能访问得到。 - * @deprecated 1.6.0 - */ - function startRecord(options: StartRecordAudioOptions): void; - - interface StopRecordAudioOptions extends BaseOptions { - success?(res: TempFileResponse): void; - } - /** - * 主动调用停止录音。 - */ - function stopRecord(options?: StopRecordAudioOptions): void; - type EncodeBitRate = - | 8000 - | 11025 - | 12000 - | 16000 - | 22050 - | 24000 - | 32000 - | 44100 - | 48000; - interface RecorderManagerStartOptions { - /** - * 指定录音的时长,单位 ms - * 如果传入了合法的 duration - * 在到达指定的 duration 后会自动停止录音,最大值 600000(10 分钟),默认值 60000(1 分钟) - */ - duration?: number; - /** - * 采样率,有效值 8000/16000/44100 - */ - sampleRate?: number; - /** - * 否 录音通道数,有效值 1/2 - */ - numberOfChannels?: number; - /** - * 编码码率 - * 采样率和码率有一定要求,具体有效值如下: - * 采样率 编码码率 - * + 8000 16000 ~ 48000 - * + 11025 16000 ~ 48000 - * + 12000 24000 ~ 64000 - * + 16000 24000 ~ 96000 - * + 22050 32000 ~ 128000 - * + 24000 32000 ~ 128000 - * + 32000 48000 ~ 192000 - * + 44100 64000 ~ 320000 - * + 48000 64000 ~ 320000 - */ - encodeBitRate: number; - /** 音频格式,有效值 aac/mp3 */ - format: string; - /** - * 指定帧大小,单位 KB - * 传入 frameSize 后,每录制指定帧大小的内容后 - * 会回调录制的文件内容,不指定则不会回调。暂仅支持 mp3 格式。 - */ - frameSize: number; - } - interface OnRecorderManagerStopOptions { - tempFilePath: string; - } - interface OnFrameRecordedOptions { - /** 录音分片结果数据 */ - frameBuffer: ArrayBuffer; - /** 当前帧是否正常录音结束前的最后一帧 */ - isLastFrame: boolean; - } - interface RecorderManager { - /** 开始录音 */ - start(options?: RecorderManagerStartOptions): void; - /** 暂停录音 */ - pause(): void; - /** 继续录音 */ - resume(): void; - /** 停止录音 */ - stop(): void; - /** 录音开始事件 */ - onStart(callback?: () => void): void; - /** 录音暂停事件 */ - onPause(callback?: () => void): void; - /** 录音恢复事件 */ - onResume(callback?: () => void): void; - /** 录音停止事件,会回调文件地址 */ - onStop( - callback?: (options: OnRecorderManagerStopOptions) => void - ): void; - /** 已录制完指定帧大小的文件,会回调录音分片结果数据。如果设置了 frameSize ,则会回调此事件 */ - onFrameRecorded( - callback?: (options: OnFrameRecordedOptions) => void - ): void; - /** 录音错误事件, 会回调错误信息 */ - onError(callback?: (err: ErrMsgResponse) => void): void; - } - /** - * 获取全局唯一的录音管理器 recorderManager - * @version 1.6.0 - */ - function getRecorderManager(): RecorderManager; - // 媒体-----音频播放控制 - interface PlayVoiceOptions extends BaseOptions { - /** 需要播放的语音文件的文件路径 */ - filePath: string; - } - /** - * 开始播放语音,同时只允许一个语音文件正在播放, - * 如果前一个语音文件还没播放完,将中断前一个语音播放。 - * @deprecated 1.6.0 - */ - function playVoice(options: PlayVoiceOptions): void; - /** - * 暂停正在播放的语音。 - * 再次调用wx.playVoice播放同一个文件时,会从暂停处开始播放。 - * 如果想从头开始播放,需要先调用 wx.stopVoice。 - * @deprecated 1.6.0 - */ - function pauseVoice(): void; - /** - * 结束播放语音。 - * @deprecated 1.6.0 - */ - function stopVoice(): void; - // 媒体-----音乐播放控制 - interface BackgroundAudioPlayerState { - /** 选定音频的长度(单位:s),只有在当前有音乐播放时返回 */ - duration: number; - /** 选定音频的播放位置(单位:s),只有在当前有音乐播放时返回 */ - currentPosition: number; - /** 播放状态(2:没有音乐在播放,1:播放中,0:暂停中) */ - status: number; - /** 音频的下载进度(整数,80 代表 80%),只有在当前有音乐播放时返回 */ - downloadPercent: number; - /** 歌曲数据链接,只有在当前有音乐播放时返回 */ - dataUrl: string; - } - interface GetBackgroundAudioPlayerStateOptions extends BaseOptions { - /** 接口调用成功的回调函数 */ - success?(state: BackgroundAudioPlayerState): void; - /** 接口调用失败的回调函数 */ - fail?(): void; - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?(): void; - } - /** - * 获取音乐播放状态。 - * @deprecated 1.2.0 - */ - function getBackgroundAudioPlayerState( - options: GetBackgroundAudioPlayerStateOptions - ): void; - interface PlayBackgroundAudioOptions extends BaseOptions { - /** 音乐链接 */ - dataUrl: string; - /** 音乐标题 */ - title?: string; - /** 封面URL */ - coverImgUrl?: string; - } - /** - * 播放音乐,同时只能有一首音乐正在播放。 - * @deprecated 1.2.0 - */ - function playBackgroundAudio(options: PlayBackgroundAudioOptions): void; - /** - * 暂停播放音乐。 - * @deprecated 1.2.0 - */ - function pauseBackgroundAudio(options?: PlayBackgroundAudioOptions): void; - interface SeekBackgroundAudioOptions extends BaseOptions { - /** 音乐位置,单位:秒 */ - position: number; - } - /** - * 控制音乐播放进度。 - * @deprecated 1.2.0 - */ - function seekBackgroundAudio(options: SeekBackgroundAudioOptions): void; - /** - * 停止播放音乐。 - * @deprecated 1.2.0 - */ - function stopBackgroundAudio(options?: PlayBackgroundAudioOptions): void; - /** - * 监听音乐播放。 - * @deprecated 1.2.0 - */ - function onBackgroundAudioPlay(callback: () => void): void; - /** - * 监听音乐暂停。 - * @deprecated 1.2.0 - */ - function onBackgroundAudioPause(callback: () => void): void; - /** - * 监听音乐停止。 - * @deprecated 1.2.0 - */ - function onBackgroundAudioStop(callback: () => void): void; - interface BackgroundAudioManager { - /** 当前音频的长度(单位:s),只有在当前有合法的 src 时返回 */ - readonly duration: number; - /** 当前音频的播放位置(单位:s),只有在当前有合法的 src 时返回 */ - readonly currentTime: number; - /** 当前是是否暂停或停止状态,true 表示暂停或停止,false 表示正在播放 */ - readonly paused: boolean; - /** 音频的数据源,默认为空字符串,当设置了新的 src 时,会自动开始播放 ,目前支持的格式有 m4a, aac, mp3, wav */ - src: string; - /** 音频开始播放的位置(单位:s) */ - startTime: number; - /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲。 是 */ - buffered: number; - /** 音频标题,用于做原生音频播放器音频标题。原生音频播放器中的分享功能,分享出去的卡片标题,也将使用该值。 */ - title: string; - /** 专辑名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值 */ - epname: string; - /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值 */ - singer: string; - /** 封面图url,用于做原生音频播放器背景图。原生音频播放器中的分享功能,分享出去的卡片配图及背景也将使用该图。 */ - coverImgUrl: string; - /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值 */ - webUrl: string; - /** 播放 */ - play(): void; - /** 暂停 */ - pause(): void; - /** 停止 */ - stop(): void; - /** 跳转到指定位置,单位 s */ - seek(position: number): void; - /** 背景音频进入可以播放状态,但不保证后面可以流畅播放 */ - onCanplay(callback: (res: ErrCodeResponse) => void): void; - /** 背景音频播放事件 */ - onPlay(callback: (res: ErrCodeResponse) => void): void; - /** 背景音频暂停事件 */ - onPause(callback: (res: ErrCodeResponse) => void): void; - /** 背景音频停止事件 */ - onStop(callback: (res: ErrCodeResponse) => void): void; - /** 背景音频自然播放结束事件 */ - onEnded(callback: (res: ErrCodeResponse) => void): void; - /** 背景音频播放进度更新事件 */ - onTimeUpdate(callback: (res: ErrCodeResponse) => void): void; - /** 用户在系统音乐播放面板点击上一曲事件(iOS only) */ - onPrev(callback: (res: ErrCodeResponse) => void): void; - /** 用户在系统音乐播放面板点击下一曲事件(iOS only) */ - onNext(callback: (res: ErrCodeResponse) => void): void; - /** 背景音频播放错误事件 */ - onError(callback: (res: ErrCodeResponse) => void): void; - /** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发 */ - onWaiting(callback: (res: ErrCodeResponse) => void): void; - } - /** - * 获取全局唯一的背景音频管理器 backgroundAudioManager。 - * @version 1.2.0 - */ - function getBackgroundAudioManager(): BackgroundAudioManager; - // 媒体-----音频组件控制 - /** - * audioContext 通过 audioId 跟一个