Files
esengine/source/lib/wxgame.d.ts

3945 lines
127 KiB
TypeScript
Raw Normal View History

/**
* IOS及安卓不支持
* globalCompositeOperation不支持以下值source-in source-out destination-atop lighter copy
* isPointInPath
*/
declare class WxRenderingContext extends CanvasRenderingContext2D {
}
/**
* IOS及安卓不支持
* pixelStorei gl.UNPACK_COLORSPACE_CONVERSION_WEBGL
* compressedTexImage2D不支持
* compressedTexSubImage2D不支持
*
* getExtension
* getSupportedExtensions
*/
declare class WxWebGLRenderingContext extends WebGLRenderingContext {
/**
* Canvas对应的Texture绑定到WebGL上下文( iOS 6.6.6 Android/)
* gl.wxBindCanvasTexture(gl.TEXTURE_2D, canvas)
* @param texture WebGL的纹理类型枚举值
* @param canvas Texture的Canvas
*/
wxBindCanvasTexture(texture: number, canvas: Canvas): void;
}
declare class WxPerformance {
/**
*
*/
now(): number;
}
declare class Canvas {
/**
*
*/
width: number;
/**
*
*/
height: number;
/**
* Canvas
*/
toTempFilePath(p: wx.types.ToTempFileParams): void;
/**
* toTempFilePath
*/
toTempFilePathSync(p: wx.types.ToTempFileSyncParams): string;
/**
*
* @param contextType
* @param contextAttributes webgl contextType webgl
*/
getContext(contextType: "2d" | "webgl", contextAttributes?: wx.types.RenderingContextConfig): WxRenderingContext | WxWebGLRenderingContext;
/**
* data URI
*/
toDataURL(): string;
}
declare class Stats {
/**
* POSIX stat.st_mode
*/
mode: string;
/**
* B POSIX stat.st_size
*/
size: number;
/**
* UNIX POSIX stat.st_atime
*/
lastAccessedTime: number;
/**
* UNIX POSIX stat.st_mtime
*/
lastModifiedTime: number;
/**
*
*/
isDirectory(): boolean;
/**
*
*/
isFile(): boolean;
}
/**
* 5M的日志内容5M后
* 使 button open-type="feedback"
* 使 wx.createFeedbackButton
*
* AppPage wx
*/
declare class LogManager {
/**
* debug日志
* @param args
*/
debug(... args: any[]): void;
/**
* info日志
* @param args
*/
info(... args: any[]): void;
/**
* log日志
* @param args
*/
log(... args: any[]): void;
/**
* warn日志
* @param args
*/
warn(... args: any[]): void;
}
declare class FileSystemManager {
/**
* oldPath newPath
*/
rename(param: wx.types.RenameParams): void;
/**
* FileSystemManager.rename
* @param oldPath
* @param newPath
* @throws
* @throws
*/
renameSync(oldPath: string, newPath: string): void;
/**
*
*/
rmdir(param: wx.types.RmdirParams): void;
/**
* rmdir
* @param dirPath
* @param recursive true
* @throws , , dirPath
*/
rmdirSync(dirPath: string, recursive?: boolean): void;
/**
*
*/
readdir(param: wx.types.ReaddirParams): void;
/**
* readdir的同步版本
* @param dirPath
* @throws
* @throws dirPath
* @throws filePath
*/
readdirSync(dirPath: string): ReadonlyArray<string>;
/**
*
*/
mkdir(param: wx.types.MkdirParams): void;
/**
* mkdir
* @param dirPath
* @param recursive dirPath a/b/c/d recursive true a a b a/b/c d
* @throws
* @throws filePath
* @throws
*/
mkdirSync(dirPath: string, recursive?: boolean): void;
/**
*
*/
unlink(param: wx.types.UnlinkParams): void;
/**
* unlink
* @param filePath
* @throws path
* @throws
* @throws filePath
*/
unlinkSync(filePath: string): void;
/**
*
*/
unzip(param: wx.types.UnzipParams): void;
/**
*
*/
readFile(param: wx.types.ReadfileParams): void;
/**
* readFile
* @param filePath
* @throws filePath
* @throws filePath
*/
readFileSync(filePath: string): ArrayBuffer;
/**
* readFile
* @param filePath
* @param encoding
* @throws filePath
* @throws filePath
*/
readFileSync(filePath: string, encoding: wx.types.FileContentEncoding): string;
/**
* Stats
*/
stat(param: wx.types.StatParams): void;
/**
* stat
* @param path /
* @throws path
* @throws
*/
statSync(path: string): Stats;
/**
*
*/
writeFile(param: wx.types.WritefileParams): void;
/**
* writeFile
* @param filePath
* @param data
* @throws filePath
* @throws filePath
*/
writeFileSync(filePath: string, data: ArrayBuffer): void;
/**
* writeFile
* @param filePath
* @param data
* @param encoding
* @throws filePath
* @throws filePath
*/
writeFileSync(filePath: string, data: string, encoding: wx.types.FileContentEncoding): void;
/**
* /
*/
access(param: wx.types.AccessfileParams): void;
/**
* access的同步版本
* @param path /
* @throws /
*/
accessSync(path: string): void;
/**
*
*/
copyFile(param: wx.types.CopyfileParams): void;
/**
* copyFile
* @param srcPath
* @param destPath
* @throws
* @throws
*/
copyFileSync(srcPath: string, destPath: string): void;
/**
*
* @param res.fileList.filePath
* @param res.fileList.size
* @param res.fileList.createTime
*/
getSavedFileList(param: wx.types.CallbacksWithType<wx.types.SavedfileList>): void;
/**
*
*/
getFileInfo(param: wx.types.FileinfoParams): void;
/**
* 使unlink
*/
removeSavedFile(param: wx.types.RemovefileParams): void;
/**
* tempFilePath
*/
saveFile(param: wx.types.SavefileParams): void;
/**
* saveFile的同步版本
* @param tempFilePath
* @param filePath
* @throws tempFilePath
* @throws filePath
* @throws
*/
saveFileSync(tempFilePath: string, filePath?: string): string;
/**
*
*/
appendFile(param: wx.types.AppendfileParams): void;
/**
* appendFile的同步版本
* @param filePath
* @param data
* @param encoding
* @throws filePath
* @throws filePath
* @throws filePath
* @throws filePath
*/
appendFileSync(filePath: string, data: string | ArrayBuffer, encoding: wx.types.FileContentEncoding): void;
}
declare class DownloadTask {
/**
*
*/
abort(): void;
/**
*
* @param res.progress 0100
* @param res.totalBytesWritten Bytes
* @param res.totalBytesExpectedToWrite Bytes
*/
onProgressUpdate(callback: (res: { progress: number, totalBytesWritten: number, totalBytesExpectedToWrite: number }) => void): void;
}
declare class RequestTask {
/**
*
*/
abort(): void;
}
declare class SocketTask {
/**
* WebSocket发送数据
*/
send(param: wx.types.SocketSendParams): void;
/**
* WebSocket连接
*/
close(param: wx.types.SocketCloseParams): void;
/**
* WebSocket
*/
onOpen(callback: wx.types.SocketOpenCallback): void;
/**
* WebSocket
*/
onClose(callback: () => void): void;
/**
* WebSocket
*/
onError(callback: wx.types.SocketErrorCallback): void;
/**
* WebSocket
*/
onMessage(callback: wx.types.SocketMessageCallback): void;
}
/**
* UDP Socket 使 IPv4
*
* -1
* -2 socket接口错误
* -3
* 1 address不合法
* 2 port不合法
*/
declare class UDPSocket {
/**
*
* @param port 使
* @returns
*/
bind(port?: number): number;
/**
* IP port
*/
send(param: wx.types.UDPSendParams): void;
/**
* UDP Socket UDP Socket UDPSocket.send
* message UDPSocket Native GC UDPSocket.close
* UDPSocket GC
*/
close(): void;
/**
*
* @param callback
*/
onClose(callback: () => void): void;
/**
*
* @param callback
*/
offClose(callback: () => void): void;
/**
*
* @param callback
*/
onError(callback: (res: {
/**
*
*/
errMsg: string;
}) => void): void;
/**
*
* @param callback
*/
offError(callback: (res: {
/**
*
*/
errMsg: string;
}) => void): void;
/**
*
* @param callback
*/
onListening(callback: () => void): void;
/**
*
* @param callback
*/
offListening(callback: () => void): void;
/**
*
* @param callback
*/
onMessage(callback: (res: wx.types.UDPMessage) => void): void;
/**
*
* @param callback
*/
offMessage(callback: (res: wx.types.UDPMessage) => void): void;
}
declare class UploadTask {
/**
*
*/
abort(): void;
/**
*
* @param callback.res.progress
* @param callback.res.totalBytesSent Bytes
* @param callback.res.totalBytesExpectedToSend Bytes
*/
onProgressUpdate(callback: (res: { progress: number, totalBytesSent: number, totalBytesExpectedToSend: number }) => void): void;
}
declare class KVData {
key: string;
value: string;
}
declare class UserGameData {
/**
* url
*/
avatarUrl: string;
/**
*
*/
nickname: string;
/**
* openid
*/
openid: string;
/**
* KV
*/
KVDataList: ReadonlyArray<KVData>;
}
declare class CreatedButton {
type: wx.types.ButtonType;
text: string;
image: string;
style: wx.types.ButtonStyle;
show(): void;
hide(): void;
onTap(callback: (res?: any) => void): void; // res参数会被具体按钮的API定义覆盖为具体信息
offTap(callback: (res?: any) => void): void;
destroy(): void;
}
declare class UserInfoButton extends CreatedButton {
onTap(callback: (res: {
/**
* openid
*/
userInfo: wx.types.UserInfo,
/**
*
*/
rawData: string,
/**
* 使 sha1( rawData + sessionkey ) signature(https://mp.weixin.qq.com/debug/wxagame/dev/tutorial/open-ability/http-signature.html?t=201822)
*/
signature: string,
/**
* (https://mp.weixin.qq.com/debug/wxagame/dev/tutorial/open-ability/signature.html?t=201822)
*/
encryptedData: string,
/**
* (https://mp.weixin.qq.com/debug/wxagame/dev/tutorial/open-ability/signature.html?t=201822)
*/
iv: string,
errMsg: string
}) => void): void;
}
declare class OpenSettingButton extends CreatedButton {
onTap(callback: () => void): void;
offTap(callback: () => void): void;
}
declare class GameClubButton extends CreatedButton {
icon: wx.types.GameClubButtonIcon;
onTap(callback: (res: {
errMsg: string;
}) => void): void;
}
declare class FeedbackButton extends CreatedButton {
onTap(callback: (res: {
errMsg: string;
}) => void): void;
}
declare class OpenDataContext {
/**
* sharedCanvasgetContext只能使用2d模式
*/
canvas: Canvas;
/**
*
* @param message message key value primitive value numberstringbooleannullundefined
*/
postMessage(message: any): void;
}
declare class LoadSubpackageTask {
/**
*
* @param callback.res.progress
* @param callback.res.totalBytesWritten Bytes
* @param callback.res.totalBytesExpectedToWrite Bytes
*/
onProgressUpdate(callback: (res: { progress: number, totalBytesWritten: number, totalBytesExpectedToWrite: number }) => void): void;
}
declare class UpdateManager {
/**
*
*/
applyUpdate(): void;
/**
*
*/
onCheckForUpdate(callback: () => void): void;
/**
*
*/
onUpdateReady(callback: () => void): void;
/**
*
*/
onUpdateFailed(callback: () => void): void;
}
declare class WxWorker {
/**
* 线Worker线程发送的消息
* @param message JavaScript
*/
postMessage(message: any): void;
/**
* worker 线线 worker
*/
terminate(): void;
/**
* 线/Worker 线线
* @param callback.res.message 线/Worker 线线
*/
onMessage(callback: (res: { message: any }) => void): void;
}
/**
* InnerAudioContext wx.createInnerAudioContext
*/
declare class InnerAudioContext {
/**
*
*/
src: string;
/**
*
*/
autoplay: boolean;
/**
*
*/
loop: boolean;
/**
* false 使
*/
obeyMuteSwitch: boolean;
/**
* s src
*/
readonly duration: number;
/**
* s src 6
*/
readonly currentTime: number;
/**
* true false
*/
paused: boolean;
/**
*
*/
readonly buffered: number;
/**
* 0~1
*/
volume: number;
/**
*
*/
play(): void;
/**
*
*/
pause(): void;
/**
*
*/
stop(): void;
/**
* s
* @param position
*/
seek(position: number): void;
/**
*
*/
destroy(): void;
/**
*
*/
onCanplay(callback: () => void): void;
/**
*
*/
offCanplay(callback: () => void): void;
/**
*
*/
onPlay(callback: () => void): void;
/**
*
*/
offPlay(callback: () => void): void;
/**
*
*/
onPause(callback: () => void): void;
/**
*
*/
offPause(callback: () => void): void;
/**
*
*/
onStop(callback: () => void): void;
/**
*
*/
offStop(callback: () => void): void;
/**
*
*/
onEnded(callback: () => void): void;
/**
*
*/
offEnded(callback: () => void): void;
/**
*
*/
onTimeUpdate(callback: () => void): void;
/**
*
*/
offTimeUpdate(callback: () => void): void;
/**
*
*/
onError(callback: () => void): void;
/**
*
*/
offError(callback: () => void): void;
/**
*
*/
onWaiting(callback: () => void): void;
/**
*
*/
offWaiting(callback: () => void): void;
/**
*
*/
onSeeking(callback: () => void): void;
/**
*
*/
offSeeking(callback: () => void): void;
/**
*
*/
onSeeked(callback: () => void): void;
/**
*
*/
offSeeked(callback: () => void): void;
}
declare class RecorderManager {
/**
*
*/
start(param: {
/**
* ms 60000010 600001
*/
duration?: number,
/**
*
*/
sampleRate: 8000 | 11025 | 12000 | 16000 | 22050 | 24000 | 32000 | 44100 | 48000,
/**
*
*/
numberOfChannels: 1 | 2,
/**
*
*/
encodeBitRate: number,
/**
*
*/
format: "mp3" | "aac",
/**
* KB frameSize
*/
frameSize: number,
/**
* wx.getAvailableAudioSources() auto
*/
audioSource?: wx.types.AudioSourceType
}): void;
/**
*
*/
pause(): void;
/**
*
*/
resume(): void;
/**
*
*/
stop(): void;
/**
*
*/
onStart(callback: () => void): void;
/**
*
*/
onResume(callback: () => void): void;
/**
*
*/
onPause(callback: () => void): void;
/**
*
* @param callback.res.tempFilePath
*/
onStop(callback: (res: { tempFilePath: string }) => void): void;
/**
* frameSize
* @param callback.res.frameBuffer
* @param callback.res.isLastFrame
*/
onFrameRecorded(callback: (res: { frameBuffer: ArrayBuffer, isLastFrame: boolean }) => void): void;
/**
*
*/
onError(callback: (res: { errMsg: string }) => void): void;
}
declare class ImageFile {
/**
*
*/
path: string;
/**
* B
*/
size: number;
}
declare class Video {
/**
*
*/
x: number;
/**
*
*/
y: number;
/**
* 300
*/
width: number;
/**
* 150
*/
height: number;
/**
*
*/
src: string;
/**
*
*/
poster: string;
/**
* s 0
*/
initialTime: number;
/**
* 0.50.81.01.251.51.0
*/
playbackRate: number;
/**
* 0
*/
live?: number;
/**
*
* fill -
* contain -
* cover -
*/
objectFit: "contain" | "cover" | "fill";
/**
* true
*/
controls: boolean;
/**
* false
*/
autoplay: boolean;
/**
* false
*/
loop: boolean;
/**
* false
*/
muted: boolean;
/**
*
*/
onwaiting: () => void;
/**
*
*/
onplay: () => void;
/**
*
*/
onpause: () => void;
/**
*
*/
onended: () => void;
/**
*
*/
ontimeupdate: () => void;
/**
*
*/
onerror: () => void;
/**
*
*/
destroy(): void;
/**
*
*/
onWaiting(callback: () => void): void;
/**
*
*/
offWaiting(callback: () => void): void;
/**
*
*/
onPlay(callback: () => void): void;
/**
*
*/
offPlay(callback: () => void): void;
/**
*
*/
onPause(callback: () => void): void;
/**
*
*/
offPause(callback: () => void): void;
/**
*
*/
onEnded(callback: () => void): void;
/**
*
*/
offEnded(callback: () => void): void;
/**
*
* @param callback.res.position
* @param callback.res.duration
*/
onTimeUpdate(callback: (res: { position: number, duration: number }) => void): void;
/**
*
*/
offTimeUpdate(callback: (res: { position: number, duration: number }) => void): void;
/**
*
* @param callback.res.errMsg
* MEDIA_ERR_NETWORK -
* MEDIA_ERR_DECODE -
* MEDIA_ERR_SRC_NOT_SUPPORTED - video src
*/
onError(callback: (res: { errMsg: string }) => void): void;
/**
*
*/
offError(callback: (res: { errMsg: string }) => void): void;
/**
*
*/
play(): Promise<void>;
/**
*
*/
pause(): Promise<void>;
/**
*
*/
stop(): Promise<void>;
/**
*
* @param time s
*/
seek(time: number): Promise<void>;
/**
*
*/
requestFullScreen(): Promise<void>;
/**
* 退
*/
exitFullScreen(): Promise<void>;
}
2020-07-23 11:00:46 +08:00
/**
*
*/
declare class Camera {
/**
*
*/
x: number;
/**
*
*/
y: number;
/**
*
*/
width: number;
/**
*
*/
height: number;
/**
*
*/
devicePosition: "front" | "back";
/**
*
*/
flash: "auto" | "on" | "off";
/**
*
*/
size: "small" | "medium" | "large";
/**
*
* @param quality
*/
takePhoto(quality?: "high" | "normal" | "low"): Promise<{
/**
*
*/
tempImagePath: string,
/**
*
*/
width: string,
/**
*
*/
height: string
}>;
/**
*
*/
startRecord(): Promise<void>;
/**
*
* @param compressed
*/
stopRecord(compressed: boolean): Promise<{
/**
*
*/
tempThumbPath: string,
/**
*
*/
tempVideoPath: string
}>;
2020-07-23 11:00:46 +08:00
/**
* 使
* @param callback
*/
onAuthCancel(callback: () => void): void;
/**
* 退
* @param callback
*/
onStop(callback: () => void): void;
/**
*
*/
onCameraFrame(callback: (res: {
/**
*
*/
width: number,
/**
*
*/
height: number,
/**
* rgba
*/
data: ArrayBuffer
}) => void): void;
/**
*
*/
listenFrameChange(): void;
/**
*
*/
closeFrameChange(): void;
/**
*
*/
destroy(): void;
}
/**
* banner 广banner 广 Canvas Canvas banner 广 BannerAd.show() banner 广 BannerAd.onResize()
*/
declare class BannerAd {
/**
* 广 id
*/
adUnitId: string;
/**
* banner 广style banner 广 BannerAd.onResize()
*/
style: wx.types.AdStyle;
/**
* banner 广
*/
show(): Promise<void>;
/**
* banner 广
*/
hide(): void;
/**
* banner 广
*/
destroy(): void;
/**
* banner 广
*/
onResize(callback: (res: { width: number, height: number }) => void): void;
/**
* banner 广
*/
offResize(callback: (res: { width: number, height: number }) => void): void;
/**
* banner 广
*/
onLoad(callback: () => void): void;
/**
* banner 广
*/
offLoad(callback: () => void): void;
/**
* banner 广
*/
onError(callback: (res: { errMsg: string }) => void): void;
/**
* banner 广
*/
offError(callback: (res: { errMsg: string }) => void): void;
}
declare class InterstitialAd extends BannerAd {
/**
* 广
*/
load(): Promise<void>;
/**
* 广
*/
onClose(callback: (res: { isEnded: boolean }) => void): void;
/**
* 广
*/
offClose(callback: (res: { isEnded: boolean }) => void): void;
}
declare class RewardedVideoAd extends InterstitialAd {
}
// --定时器
declare function clearTimeout(timeoutID: number): void;
declare function clearInterval(intervalID: number): void;
declare function setTimeout(fn: () => void, delay: number, ...rest: any[]): number;
declare function setInterval(fn: () => void, delay: number, ...rest: any[]): number;
// --渲染
declare function cancelAnimationFrame(requestID: number): void;
declare function requestAnimationFrame(callback: () => void): number;
declare namespace wx {
namespace types {
interface Callbacks {
success?: () => void;
fail?: () => void;
complete?: () => void;
}
interface CallbacksWithType<T> {
success?: (res: T) => void;
fail?: () => void;
complete?: () => void;
}
interface CallbacksWithType2<T, F> {
success?: (res: T) => void;
fail?: (res: F) => void;
complete?: () => void;
}
interface RenderingContextConfig {
/**
* 齿
*/
antialias?: boolean;
/**
*
*/
preserveDrawingBuffer?: boolean;
/**
* 齿 2 iOS
*/
antialiasSamples?: number;
}
interface ToTempFileSyncParams {
/**
* canvas
*/
x?: number;
/**
* canvas
*/
y?: number;
/**
* canvas
*/
width?: number;
/**
* canvas
*/
height?: number;
/**
*
*/
destWidth?: number;
/**
*
*/
destHeight?: number;
/**
*
*/
fileType?: "jpg" | "png";
/**
* jpg图片的质量 fileType jpg 0.0- 1.0 0 1.0
*/
quality?: number;
}
interface ToTempFileParams extends ToTempFileSyncParams {
success?: (res: { tempFilePath: string }) => void;
fail?: () => void;
complete?: () => void;
}
interface RenameParams {
oldPath: string;
newPath: string;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface RmdirParams {
dirPath: string;
recursive?: boolean;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface ReaddirParams {
dirPath: string;
success?: (res: { files: ReadonlyArray<string> }) => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface MkdirParams {
dirPath: string;
recursive?: boolean;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
type FileContentEncoding = "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1";
interface ReadfileParams {
filePath: string;
encoding?: FileContentEncoding;
success?: (res: { data: string | ArrayBuffer }) => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface StatParams {
path: string;
success?: (res: { stat: Stats }) => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface WritefileParams {
filePath: string;
data: string | ArrayBuffer;
encoding?: FileContentEncoding;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface UnlinkParams {
filePath: string;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface UnzipParams {
zipFilePath: string;
targetPath: string;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface AccessfileParams {
path: string;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface SavedfileList {
fileList: {
filePath: string;
size: number;
createTime: number;
};
}
interface CopyfileParams {
srcPath: string;
destPath: string;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface FileinfoParams {
filePath: string;
success?: (res: { size: number, digest: string }) => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface RemovefileParams {
filePath: string;
success?: () => void;
fail?: () => void;
complete?: () => void;
}
interface SavefileParams {
tempFilePath: string;
filePath?: string;
success?: (res: { savedFilePath: string }) => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface AppendfileParams {
filePath: string;
data: string | ArrayBuffer;
encoding?: FileContentEncoding;
success?: () => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
interface LineHeightParams {
fontStyle?: "normal" | "italic";
fontWeight?: "normal" | "bold";
fontSize?: number;
fontFamily: string;
text: string;
success?: (res: { lineHeight: number }) => void;
fail?: () => void;
complete?: () => void;
}
interface Image {
src: string;
width: number;
height: number;
onload: () => void;
onerror: (e?: any) => void;
}
// --启动参数
interface LaunchOption {
/**
*
*/
scene: number;
/**
*
*/
query: any;
/**
*
*/
isSticky: boolean;
/**
*
*/
shareTicket: string;
}
// --系统信息
interface SystemInfo {
/**
*
*/
brand: string;
/**
*
*/
model: string;
/**
*
*/
pixelRatio: number;
/**
*
*/
screenWidth: number;
/**
*
*/
screenHeight: number;
/**
* 使
*/
windowWidth: number;
/**
* 使
*/
windowHeight: number;
/**
*
*/
language: string;
/**
*
*/
version: string;
/**
*
*/
system: string;
/**
*
*/
platform: string;
/**
* --- px
*/
fontSizeSetting: string;
/**
*
*/
SDKVersion: string;
/**
*
*/
benchmarkLevel: number;
/**
* 1 - 100
*/
battery: number;
/**
* wifi 0 - 4
*/
wifiSignal: number;
}
// --触摸对象
interface Touch {
/**
* Touch (),
*/
identifier: number;
/**
* X
*/
pageX: number;
/**
* Y
*/
pageY: number;
/**
* X
*/
clientX: number;
/**
* Y
*/
clientY: number;
}
interface TouchData {
/**
*
*/
type: string;
/**
*
*/
touches: ReadonlyArray<Touch>;
/**
*
*/
changedTouches: ReadonlyArray<Touch>;
/**
*
*/
timeStamp: number;
}
// --iBeaconTODO
/**
* iBeacon
*/
function stopBeaconDiscovery(param: any): void;
/**
* iBeacon
*/
function startBeaconDiscovery(param: any): void;
/**
* iBeacon
*/
function onBeaconUpdate(callback: any): void;
/**
* iBeacon
*/
function onBeaconServiceChange(callback: any): void;
/**
* iBeacon
*/
function offBeaconUpdate(callback: any): void;
/**
* iBeacon
*/
function offBeaconServiceChange(callback: any): void;
/**
* iBeacon
*/
function getBeacons(param: any): void;
/*
IBeaconInfo
string uuid
iBeacon 广 uuid
string major
iBeacon id
string minor
iBeacon id
number proximity
number accuracy
iBeacon
number rssi
*/
// --低功耗蓝牙TODO
function writeBLECharacteristicValue(): void;
function readBLECharacteristicValue(): void;
function onBLEConnectionStateChange(): void;
function onBLECharacteristicValueChange(): void;
function notifyBLECharacteristicValueChange(): void;
function getBLEDeviceServices(): void;
function getBLEDeviceCharacteristics(): void;
function createBLEConnection(): void;
function closeBLEConnection(): void;
// --蓝牙TODO
function stopBluetoothDevicesDiscovery(): void;
function startBluetoothDevicesDiscovery(): void;
function openBluetoothAdapter(): void;
function onBluetoothDeviceFound(): void;
function onBluetoothAdapterStateChange(): void;
function getConnectedBluetoothDevices(): void;
function getBluetoothDevices(): void;
function getBluetoothAdapterState(): void;
function closeBluetoothAdapter(): void;
// --电量
interface BatteryInfo {
/**
* 1 - 100
*/
level: string;
/**
*
*/
isCharging: boolean;
}
// --剪切板
interface ClipboardData {
data: string;
}
interface SetClipboardDataParams {
success?: () => void;
fail?: () => void;
complete?: () => void;
data: string;
}
interface SetKeepScreenOnParams {
success?: () => void;
fail?: () => void;
complete?: () => void;
keepScreenOn: boolean;
}
interface SetScreenBrightnessParams {
success?: () => void;
fail?: () => void;
complete?: () => void;
/**
* 0 ~ 10 1
*/
value: number;
}
interface DownfileParams {
url: string;
/**
* filePath之后success回调中将不会有res.tempFilePath路径值filePath指定的路径使wx.env.USER_DATA_PATH
*/
filePath?: string;
/**
* HTTP HeaderHeader Referer
*/
header?: { [key: string]: string };
/**
* res.tempFilePath filePath
* res.statusCode HTTP
*/
success?: (res: { tempFilePath?: string, statusCode: number }) => void;
fail?: (res: { errMsg: string }) => void;
complete?: () => void;
}
type NetworkType = "wifi" | "2g" | "3g" | "4g" | "any" | "none";
type RequestMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | "CONNECT";
interface RequestParams {
/**
*
*/
url: string;
/**
*
*/
data?: string | { [key: string]: any };
/**
* headerheader Referer
*/
header?: { [name: string]: string };
/**
* HTTP
*/
method?: RequestMethod;
/**
*
*/
dataType?: "json" | "arraybuffer";
/**
* res.data usually can be string or ArrayBuffer
*/
success?: (res: { data: any, statusCode: number, header?: { [key: string]: string } }) => void;
fail?: () => void;
complete?: () => void;
}
interface SocketSendParams {
data: string | ArrayBuffer;
success?: () => void;
fail?: () => void;
complete?: () => void;
}
interface SocketConnectParams {
url: string;
protocols?: string[];
header?: { [key: string]: string };
method?: RequestMethod;
success?: () => void;
fail?: () => void;
complete?: () => void;
}
interface SocketCloseParams {
/**
* 1000
*/
code?: number;
/**
* 123UTF-8
*/
reason?: string;
success?: () => void;
fail?: () => void;
complete?: () => void;
}
type SocketOpenCallback = (res: { header?: { [key: string]: string } }) => void;
type SocketMessageCallback = (res: { data: string | ArrayBuffer }) => void;
type SocketErrorCallback = (res: { errMsg: string }) => void;
interface UDPSendParams {
/**
* IP
*/
address: string;
/**
*
*/
port: number;
/**
*
*/
message: string | ArrayBuffer;
/**
* message ArrayBuffer 0
*/
offset?: number;
/**
* message ArrayBuffer message.byteLength
*/
length?: number;
}
interface UDPMessage {
/**
*
*/
message: ArrayBuffer;
/**
*
*/
remoteInfo: {
/**
* socket
*/
address: string;
/**
* 使 IPv4 IPv6
*/
family: string;
/**
*
*/
port: number;
/**
* message
*/
size: number;
};
}
/**
* wx.getUserInfo的旧版本API参数使
*/
interface OldUserInfoParam {
/**
* withCredentials true wx.login encryptedData, iv withCredentials false encryptedData, iv
*/
withCredentials?: boolean;
/**
*
*/
lang?: "en" | "zh_CN" | "zh_TW";
success?: (res: {
/**
* openid
*/
userInfo: UserInfo,
/**
*
*/
rawData: string,
/**
* 使 sha1( rawData + sessionkey ) signature(https://mp.weixin.qq.com/debug/wxagame/dev/tutorial/open-ability/http-signature.html?t=201822)
*/
signature: string,
/**
* (https://mp.weixin.qq.com/debug/wxagame/dev/tutorial/open-ability/signature.html?t=201822)
*/
encryptedData: string,
/**
* (https://mp.weixin.qq.com/debug/wxagame/dev/tutorial/open-ability/signature.html?t=201822)
*/
iv: string,
errMsg: string
}) => void;
fail?: () => void;
complete?: () => void;
}
/**
* wx.getUserInfo的参数
*/
interface NewUserInfoParam {
/**
* openId 'selfOpenId'
*/
openIdList?: string[];
/**
*
*/
lang?: "en" | "zh_CN" | "zh_TW";
success?: (res: { data: ReadonlyArray<UserInfo> }) => void;
fail?: () => void;
complete?: () => void;
}
interface UserInfo {
language: string;
nickName: string;
avatarUrl: string;
/**
* 012
*/
gender: 0 | 1 | 2;
country: string;
province: string;
city: string;
}
type ButtonType = "text" | "image";
interface ButtonStyle {
left?: number;
top?: number;
width?: number;
height?: number;
/**
* #ff0000
*/
backgroundColor?: string;
/**
* #ff0000
*/
borderColor?: string;
borderWidth?: number;
borderRadius?: number;
textAlign?: "left" | "center" | "right";
fontSize?: number;
lineHeight?: number;
}
type GameClubButtonIcon = "green" | "white" | "dark" | "light";
// --设置
interface AuthSetting {
/**
* wx.getUserInfo
*/
"scope.userInfo"?: boolean;
/**
* wx.getLocation wx.chooseLocation
*/
"scope.userLocation"?: boolean;
/**
* wx.chooseAddress
*/
"scope.address"?: boolean;
/**
* wx.chooseInvoiceTitle
*/
"scope.invoiceTitle"?: boolean;
/**
* wx.getWeRunData
*/
"scope.werun"?: boolean;
/**
* wx.startRecord
*/
"scope.record"?: boolean;
/**
* wx.saveImageToPhotosAlbum, wx.saveVideoToPhotosAlbum
*/
"scope.writePhotosAlbum"?: boolean;
/**
* wx.camera
*/
"scope.camera"?: boolean;
}
interface SetStorageParams {
key: string;
data: any;
success?: () => void;
fail?: () => void;
complete?: () => void;
}
interface RemoveStorageParams {
key: string;
success?: () => void;
fail?: () => void;
complete?: () => void;
}
interface GetStorageParams {
key: string;
success?: (res: { data: any }) => void;
fail?: () => void;
complete?: () => void;
}
interface StorageInfo {
/**
* storage key
*/
keys: ReadonlyArray<string>;
/**
* , KB
*/
currentSize: number;
/**
* KB
*/
limitSize: number;
}
interface ShareOption {
/**
* 使
*/
title?: string;
/**
* 5:4
*/
imageUrl?: string;
/**
* key1=val1&key2=val2 wx.getLaunchOptionsSync() wx.onShow query
*/
query?: string;
}
interface AccelerometerParams {
interval: "game" | "ui" | "normal";
success?: () => void;
fail?: () => void;
complete?: () => void;
}
type AudioSourceType = "auto" | "buildInMic" | "headsetMic" | "mic" | "camcorder";
interface AdStyle {
/**
* 广
*/
left: number;
/**
* banner 广
*/
top: number;
/**
* banner 广 300 wx.getSystemInfoSync()
*/
width: number;
/**
* banner 广
*/
height: number;
/**
* banner 广
*/
realWidth: number;
/**
* banner 广
*/
realHeight: number;
}
}
/**
*
*/
function createCanvas(): Canvas;
/**
* sharedCanvas
*/
function getSharedCanvas(): Canvas;
/**
*
*/
function createImage(): types.Image;
/**
*
* @param p
*/
function getTextLineHeight(p: types.LineHeightParams): number;
/**
*
* @param path wxfile:// 协议的本地文件路径。
*/
function loadFont(path: string): string;
/**
* 60 requestAnimationFrame
* @param fps 1 - 60
*/
function setPreferredFramesPerSecond(fps: number): void;
// --生命周期
function exitMiniProgram(cb?: types.Callbacks): void;
function getLaunchOptionsSync(): types.LaunchOption;
function onHide(cb: () => void): void;
function offHide(cb: () => void): void;
function onShow(cb: (res: { scene: string, query: any, shareTicket: string }) => void): void;
function offShow(cb: (res: { scene: string, query: any, shareTicket: string }) => void): void;
// --系统信息
function getSystemInfo(cb: types.CallbacksWithType<types.SystemInfo>): void;
function getSystemInfoSync(): types.SystemInfo;
/**
* onAudioInterruptionBegin
*/
function onAudioInterruptionEnd(cb: () => void): void;
/**
* onAudioInterruptionBegin
*/
function offAudioInterruptionEnd(cb: () => void): void;
/**
* FaceTime
*/
function onAudioInterruptionBegin(cb: () => void): void;
/**
* FaceTime
*/
function offAudioInterruptionBegin(cb: () => void): void;
/**
*
*/
function onError(cb: (res: { message: string, stack: string }) => void): void;
function offError(cb: (res: { message: string, stack: string }) => void): void;
// --触摸事件
/**
*
*/
function onTouchStart(cb: (res: types.TouchData) => void): void;
function offTouchStart(cb: (res: types.TouchData) => void): void;
/**
*
*/
function onTouchMove(cb: (res: types.TouchData) => void): void;
function offTouchMove(cb: (res: types.TouchData) => void): void;
/**
*
*/
function onTouchEnd(cb: (res: types.TouchData) => void): void;
function offTouchEnd(cb: (res: types.TouchData) => void): void;
/**
*
*/
function onTouchCancel(cb: (res: types.TouchData) => void): void;
function offTouchCancel(cb: (res: types.TouchData) => void): void;
// --加速计
/**
* 5/使 wx.stopAccelerometer
*/
function onAccelerometerChange(cb: (res: { x: number, y: number, z: number }) => void): void;
/**
*
*/
function startAccelerometer(cb: types.AccelerometerParams): void;
/**
*
*/
function stopAccelerometer(cb?: types.Callbacks): void;
// --电量
/**
* API wx.getBatteryInfoSync iOS
*/
function getBatteryInfo(cb: types.CallbacksWithType<types.BatteryInfo>): void;
/**
* IOS上这个同步API无法使用
*/
function getBatteryInfoSync(): types.BatteryInfo;
// --剪贴板
/**
*
*/
function getClipboardData(cb: types.CallbacksWithType<types.ClipboardData>): void;
/**
*
*/
function setClipboardData(p: types.SetClipboardDataParams): void;
// --罗盘
/**
* 5 /使 wx.stopCompass
* @param cb.res.direction
*/
function onCompassChange(cb: (res: { direction: number }) => void): void;
/**
*
*/
function startCompass(cb?: types.Callbacks): void;
/**
*
*/
function stopCompass(cb?: types.Callbacks): void;
// --网络
/**
*
*/
function getNetworkType(cb: types.CallbacksWithType<{ isConnected: boolean, networkType: types.NetworkType }>): void;
/**
*
*/
function onNetworkStatusChange(cb: (res: {
/**
*
*/
isConnected: boolean,
/**
* none - , any - Android
*/
networkType: types.NetworkType
}) => void): void;
// --屏幕
/**
*
*/
function getScreenBrightness(cb: types.CallbacksWithType<{ value: number }>): void;
/**
*
*/
function setKeepScreenOn(p: types.SetKeepScreenOnParams): void;
/**
*
*/
function setScreenBrightness(p: types.SetScreenBrightnessParams): void;
// --转屏
/**
*
*/
function onDeviceOrientationChange(callback: (res: { value: string }) => void): void;
/**
*
*/
function offDeviceOrientationChange(callback: (res: { value: string }) => void): void;
// --设备方向
/**
*
*/
function stopDeviceMotionListening(cb?: types.Callbacks): void;
/**
*
*/
function startDeviceMotionListening(param: {
/**
* normal
* game - 20ms/
* ui - UI 60ms/
* normal - 200ms/
*/
interval: "game" | "ui" | "normal"
} & types.Callbacks): void;
/**
* wx.startDeviceMotionListening() interval 使 wx.stopDeviceMotionListening()
*/
function onDeviceMotionChange(callback: (res: {
/**
* X/Y X/Y Z alpha [0, 2*PI)
*/
alpha: number,
/**
* Y/Z Y/Z X beta [-1*PI, PI)
*/
beta: number,
/**
* X/Z X/Z Y gamma [-1*PI/2, PI/2)
*/
gamma: number
}) => void): void;
/**
*
* @param callback
*/
function offDeviceMotionChange(callback?: any): void;
// --陀螺仪
/**
*
*/
function stopGyroscope(cb?: types.Callbacks): void;
/**
*
*/
function startGyroscope(param: {
/**
* normal
* game - 20ms/
* ui - UI 60ms/
* normal - 200ms/
*/
interval: "game" | "ui" | "normal"
} & types.Callbacks): void;
/**
* wx.startGyroscope() interval 使 wx.stopGyroscope()
* @param callback
*/
function onGyroscopeChange(callback: (res: {
/**
* x
*/
x: number,
/**
* y
*/
y: number,
/**
* z
*/
z: number
}) => void): void;
/**
*
* @param callback
*/
function offGyroscopeChange(callback: any): void;
// --振动
/**
* 使15 ms
*/
function vibrateShort(cb?: types.Callbacks): void;
/**
* 使400 ms)
*/
function vibrateLong(cb?: types.Callbacks): void;
// --文件系统
function getFileSystemManager(): FileSystemManager;
// --推荐弹窗
/**
* wx.getSystemInfoSync() SDKVersion >= 2.7.5 使 API
*/
function createGamePortal(param: {
/**
* id
*/
adUnitId: string
}): any /* GamePortal */; // TODO: GamePortal
/**
* icon组件 wx.getSystemInfoSync() SDKVersion >= 2.8.2 使 API
*/
function createGameIcon(param: {
/**
* id
*/
adUnitId: string,
/**
* icon的数量icon数量会小于等于count
*/
count: number,
/**
* icon设置位置和样式等信息style的每一项称为styleItem
*/
style: ReadonlyArray<{
/**
*
*/
appNameHidden: boolean,
/**
*
*/
color: string,
/**
* icon的宽高值
*/
size: number,
/**
* icon的border尺寸
*/
borderWidth: number,
/**
* icon的border颜色色值
*/
borderColor: string,
/**
* icon的X轴坐标
*/
left: number,
/**
* icon的Y轴坐标
*/
top: number
}>
}): any /* GameIcon */; // TODO: GameIcon
/**
* banner组件 wx.getSystemInfoSync() SDKVersion >= 2.7.5 使 API
*/
function createGameBanner(param: {
/**
* id
*/
adUnitId: string,
/**
* banner组件样式
*/
style: {
/**
* banner组件左上角横坐标
*/
left: number,
/**
* banner组件左上角纵坐标
*/
top: number
}
}): any /* GameBanner */; // TODO: GameBanner
// --游戏对局回放
/**
*
*/
function getGameRecorder(): any /* GameRecorder */; // TODO: GameRecorder
/**
*
*/
function createGameRecorderShareButton(): any /* GameRecorderShareButton */; // TODO: GameRecorderShareButton
// --第三方平台
/**
*
* Tips: 本接口暂时无法通过 wx.canIUse wx.getExtConfig
* if (wx.getExtConfig) {
* wx.getExtConfig({
* success (res) {
* console.log(res.extConfig)
* }
* })
* }
*/
function getExtConfig(callbacks: types.CallbacksWithType<{
/**
*
*/
extConfig: any
}>): void;
/**
* wx.getExtConfig
*/
function getExtConfigSync(): any;
/**
*
*/
const env: {
/**
*
*/
USER_DATA_PATH: string
};
// --位置
/**
*
*/
function getLocation(param: {
/**
* wgs84 gps gcj02 wx.openLocation
*/
type?: "wgs84" | "gcj02",
/**
* true >= 1.6.0
*/
altitude?: boolean,
success?: (res: {
/**
* -90~90
*/
latitude: number,
/**
* -180~180西
*/
longitude: number,
/**
* m/s
*/
speed: number,
/**
*
*/
accuracy: number,
/**
* m
*/
altitude: number,
/**
* mAndroid 0
*/
verticalAccuracy: number,
/**
* m
*/
horizontalAccuracy: number
}) => void,
fail?: () => void,
complete?: () => void
}): void;
// --网络
/**
*
*/
function downloadFile(param: types.DownfileParams): DownloadTask;
// --发起请求
function request(param: types.RequestParams): RequestTask;
// --websocket
/**
* WebSocket 5 WebSocket
*/
function connectSocket(param: types.SocketConnectParams): SocketTask;
/**
* WebSocket
*/
function closeSocket(param: types.SocketCloseParams): void;
/**
* WebSocket
*/
function onSocketOpen(callback: types.SocketOpenCallback): void;
/**
* WebSocket
*/
function onSocketClose(callback: () => void): void;
/**
* WebSocket
*/
function onSocketMessage(callback: types.SocketMessageCallback): void;
/**
* WebSocket
*/
function onSocketError(callback: types.SocketErrorCallback): void;
/**
* WebSocket wx.connectSocket wx.onSocketOpen
*/
function sendSocketMessage(param: types.SocketSendParams): void;
// --UDP通信
/**
* UDP Socket
*/
function createUDPSocket(): UDPSocket;
// --上传
function uploadFile(param: {
/**
*
*/
url: string,
/**
*
*/
filePath: string,
/**
* key key
*/
name: string,
/**
* HTTP HeaderHeader Referer
*/
header?: { [key: string]: string },
/**
* HTTP form data
*/
formData?: { [key: string]: any },
success?: (res: { data: string, statusCode: number }) => void,
fail?: () => void,
complete?: () => void
}): UploadTask;
// --开放数据
/**
* 使
*/
function getFriendCloudStorage(param: {
/**
* key
*/
keyList: string[],
success?: (res: { data: ReadonlyArray<UserGameData> }) => void,
fail?: () => void,
complete?: () => void
}): void;
/**
* key 使
*/
function getUserCloudStorage(param: {
/**
* key
*/
keyList: string[],
success?: (res: { KVDataList: ReadonlyArray<KVData> }) => void,
fail?: () => void,
complete?: () => void
}): void;
/**
*
* API会被逐渐作废使wx.createUserInfoButton或在隔离数据区取得用户信息
* 使withCredentials true wx.login scope.userInfo
*/
function getUserInfo(param: types.NewUserInfoParam | types.OldUserInfoParam): void;
/**
* 使
*/
function getGroupCloudStorage(param: {
/**
* shareTicket
*/
shareTicket: string,
/**
* key
*/
keyList: string[],
success?: (res: { data: ReadonlyArray<UserGameData> }) => void,
fail?: () => void,
complete?: () => void
}): void;
/**
* key
*/
function removeUserCloudStorage(param: {
/**
* key
*/
keyList: string[],
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
/**
* KV
*
* > openid所标识的微信用户在每个游戏上托管的数据不能超过128个key-value对
* > key-value列表当中每一项的key+value长度都不能超过1K(1024)
* > key-value列表当中每一个key长度都不能超过128字节
*/
function setUserCloudStorage(param: {
/**
* KV
*/
KVDataList: ReadonlyArray<KVData>,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
/**
* 使
* @param callback wx.modifyFriendInteractiveStorage key
*/
function onInteractiveStorageModified(callback: (key: string) => void): void;
/**
* 使
* wx.modifyFriendInteractiveStorage({
* key: '1',
* opNum: 1,
* operation: 'add',
* toUser: '', // 好友的 openId
* title: '送你 10 个金币,赶快打开游戏看看吧', // 2.9.0 支持
* imageUrl: 'image/xxx' // 2.9.0 支持
* });
*
*
* JSServer "checkInteractiveData" checkInteractiveData {ret: true}
*
* 使
* 2.9.0 game.json modifyFriendInteractiveStorageTemplates
* modifyFriendInteractiveStorageTemplates是一个模板数组 key, action, object ratio
* {
* "modifyFriendInteractiveStorageTemplates": [
* {
* "key": "1", // 这个 key 与接口中同名参数相对应,不同的 key 对应不同的模板
* "action": "赠送", // 互动行为
* "object": "金币", // 互动物品
* "ratio": 10 // 物品比率opNum * ratio 代表物品个数
* }
* ]
* }
* "确认 ${action} ${nickname} ${object}" "确认 ${action} ${nickname} ${object} x ${opNum * ratio}"
*
* 使
* 2.7.7 2.9.0 game.json modifyFriendInteractiveStorageConfirmWording nickname ${nickname}
* {
* "modifyFriendInteractiveStorageConfirmWording": "确认送给${nickname}一个体力?"
* }
* 2.9.0 modifyFriendInteractiveStorageTemplates modifyFriendInteractiveStorageConfirmWording 使
*/
function modifyFriendInteractiveStorage(param: {
/**
* key '1' - '50'
*/
key: string,
/**
* 1
*/
opNum: number,
/**
*
*/
operation: "add",
/**
* openId
*/
toUser?: string
/**
*
*/
title?: string
/**
* wx.shareMessageToFriend
*/
imageUrl?: string,
/**
* ID wx.shareMessageToFriend
*/
imageUrlId?: string,
/**
* toUser
* false
*/
quiet?: boolean,
success?: () => void;
fail?: (res: {
/**
*
*/
errMsg: string,
/**
*
* -17006
* -17007 toUser openId
* -17008 key
* -17009 operation
* -17010
* -17011 JSServer
*/
errCode: number
}) => void;
complete?: () => void;
}): void;
/**
* key
*/
function getUserInteractiveStorage(param: {
/**
* key
*/
keyList: string[]
} & types.CallbacksWithType2<{
/**
* KVDataList KVData
*/
encryptedData: string,
/**
* ID
*/
cloudID: string
}, {
/**
*
*/
errMsg: string,
/**
*
* -17008 key
*/
errCode: number
}>): void;
/**
* 5 使
*/
function getPotentialFriendList(callback: types.CallbacksWithType<{
/**
*
*/
list: ReadonlyArray<{
/**
* url
*/
avatarUrl: string,
/**
*
*/
nickname: string,
/**
* openid
*/
openid: string
}>
}>): void;
// --登录
/**
* wx.login 使使 wx.checkSession wx.login
*/
function checkSession(cb: types.Callbacks): void;
/**
* codeopenid session_key
*/
function login(cb: types.CallbacksWithType<{
/**
* code2accessToken使 code openid session_key
*/
code: string
}>): void;
// --防沉迷
/**
*
*/
function checkIsUserAdvisedToRest(param: {
/**
*
*/
todayPlayedTime: number,
success?: (res: {
/**
*
*/
result: boolean
}) => void,
fail?: () => void,
complete?: () => void
}): void;
// --小程序跳转
/**
*
* @param param
*/
function navigateToMiniProgram(param: {
/**
* appId
*/
appId: string,
/**
* path ? query App.onLaunchApp.onShow
* Page.onLoad wx.onShow wx.getLaunchOptionsSync query
* query "?foo=bar"
*/
path?: string,
/**
* App.onLaunchApp.onShow wx.onShowwx.getLaunchOptionsSync
*/
extraData?: any,
/**
* release
* develop
* trial
* release
*/
envVersion?: "develop" | "trial" | "release"
} & types.Callbacks): void;
// --用户信息
function createUserInfoButton(param: {
/**
*
*/
type: types.ButtonType,
/**
* type text
*/
text?: string,
/**
* type image
*/
image?: string,
/**
*
*/
style?: types.ButtonStyle,
/**
* withCredentials true wx.login encryptedData, iv withCredentials false encryptedData, iv
*/
withCredentials?: boolean,
lang?: "en" | "zh_CN" | "zh_TW"
}): UserInfoButton;
// --设置
/**
*
*/
function createOpenSettingButton(param: {
/**
*
*/
type: types.ButtonType,
/**
* type text
*/
text?: string,
/**
* type image
*/
image?: string,
/**
*
*/
style?: types.ButtonStyle
}): OpenSettingButton;
/**
*
*/
function getSetting(p: types.CallbacksWithType<{ authSetting: types.AuthSetting }>): void;
/**
*
* @deprecated
*/
function openSetting(p: types.CallbacksWithType<{ authSetting: types.AuthSetting }>): void;
// --微信运动
/**
* wx.login scope.werun
*/
function getWeRunData(p: types.CallbacksWithType<{
/**
*
*/
encryptedData: string,
/**
*
*/
iv: string
}>): void;
// --卡券
/**
* 使https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&key=1490190158&version=1&lang=zh_CN&platform=2
*/
function openCard(param: {
/**
*
*/
cardList: ReadonlyArray<{
/**
* ID
*/
cardId: string,
/**
* wx.addCard code code https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Coupons-Mini_Program_Start_Up.html
*/
code: string
}>
} & types.CallbacksWithType<any>): void; // TODO: success回调里的res的结构官方文档没写
/**
* 使 https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&key=1490190158&version=1&lang=zh_CN&platform=2
*/
function addCard(param: {
/**
*
*/
cardList: ReadonlyArray<{
/**
* ID
*/
cardId: string,
/**
* CardExt JSON
*/
cardExt: string
}>
} & types.CallbacksWithType<{
/**
*
*/
cardList: ReadonlyArray<{
/**
* codecode加密后的字符串code
*/
code: string,
/**
* ID
*/
cardId: string,
/**
* JSON
*/
cardExt: string,
/**
*
*/
isSuccess: boolean
}>
}>): void;
// --授权
/**
* 使
*/
function authorize(param: {
/**
* scope
*/
scope: string,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --游戏圈
/**
* 使
*/
function createGameClubButton(param: {
type: types.ButtonType,
text?: string,
image?: string,
style?: types.ButtonStyle,
/**
* object.type image
*/
icon?: types.GameClubButtonIcon
}): GameClubButton;
// --意见反馈
/**
*
*/
function createFeedbackButton(param: {
type: types.ButtonType,
text?: string,
image?: string,
style?: types.ButtonStyle
}): FeedbackButton;
// --客服消息
/**
* touch
*/
function openCustomerServiceConversation(param: {
/**
*
*/
sessionFrom?: string,
/**
* true
*/
showMessageCard?: boolean,
/**
*
*/
sendMessageTitle?: string,
/**
*
*/
sendMessagePath?: string,
/**
*
*/
sendMessageImg?: string,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --开放数据域
/**
*
*/
function getOpenDataContext(): OpenDataContext;
/**
*
*/
function onMessage(callback: (data: any) => void): void;
// --转发
/**
*
*/
function getShareInfo(param: {
shareTicket: string,
success?: (res: {
/**
*
*/
errMsg: string,
/**
*
*/
encryptedData: string,
/**
*
*/
iv: string
}) => void,
fail?: () => void,
complete?: () => void
}): void;
/**
*
*/
function hideShareMenu(cb?: types.Callbacks): void;
/**
*
*/
function onShareAppMessage(cb: () => types.ShareOption): void;
/**
*
*/
function offShareAppMessage(cb: () => types.ShareOption): void;
/**
*
*/
function showShareMenu(param?: {
/**
* 使 shareTicket
*/
withShareTicket: boolean,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
/**
*
*/
function shareAppMessage(param: types.ShareOption): void;
/**
* wx.shareMessageToFriend query
* @param param
* @returns
*/
function setMessageToFriendQuery(param: {
/**
* 0 - 50
*/
shareMessageToFriendScene: number;
}): boolean;
/**
* 使
* query wx.setMessageToFriendQuery
* @param param
*/
function shareMessageToFriend(param: {
/**
* openId
*/
openId: string,
/**
* 使
*/
title?: string,
/**
* 5:4
*/
imageUrl?: string
/**
* ID 使https://developers.weixin.qq.com/minigame/dev/guide/open-ability/sh
* are/share.html#%E4%BD%BF%E7%94%A8%E5%AE%A1%E6%A0%B8%E9%80%9A%E8%BF%87%E7%9A%84%E8%BD%AC%E5%8F%91%E5%9B%BE%E7%89%87
*/
imageUrlId?: string
}): void;
/**
*
*/
function updateShareMenu(param: {
/**
* 使 shareTicket
*/
withShareTicket: boolean,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --性能
/**
*
*/
function getPerformance(): WxPerformance;
/**
* JavaScriptCore Garbage CollectionGC JavaScriptCore GC
*/
function triggerGC(): void;
/**
*
* @param callback.res.level Android :
* 10 TRIM_MEMORY_RUNNING_LOW
* 15 TRIM_MEMORY_RUNNING_CRITICAL
*/
function onMemoryWarning(callback: (res: { level: number }) => void): void;
/**
*
* @param sceneId ID
*/
function markScene(sceneId: number): void;
// --调试
function setEnableDebug(p: {
enableDebug: boolean,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
/**
*
* @param param
*/
function getLogManager(param?: {
/**
* 010 AppPage wx 1
* 0
*/
level?: 0 | 1
}): LogManager;
// --数据上报
/**
*
* 使---ID128
* @param name ID
* @param value
*/
function reportMonitor(name: string, value: number): void;
// --订阅消息
/**
* touchend
*/
function requestSubscribeMessage(param: {
/**
* id的集合iOS客户端7.0.6Android客户端7.0.7iOS客户端7.0.5Android客户端7.0.6
* id在[(mp.weixin.qq.com)--]
*/
tmplIds: ReadonlyArray<string>;
} & types.CallbacksWithType2<{
/**
* errMsg值为'requestSubscribeMessage:ok'
*/
errMsg: string;
/**
* [TEMPLATE_ID]id'accept''reject''ban''accept'id对应的模板消息'reject'id对应的模板消息'ban'
* { errMsg: "requestSubscribeMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE这条消息
*/
[TEMPLATE_ID: string]: 'accept' | 'reject' | 'ban' | string;
}, {
/**
*
*/
errMsg: string;
/**
*
*/
errCode: number;
}>): void;
// --数据缓存
/**
*
*/
function clearStorage(param: types.Callbacks): void;
/**
* clearStorage的同步版本
*/
function clearStorageSync(): void;
/**
* key
*/
function getStorage(param: types.GetStorageParams): void;
/**
* getStorage
*/
function getStorageSync(key: string): any;
/**
* storage的相关信息
*/
function getStorageInfo(param: types.CallbacksWithType<types.StorageInfo>): void;
/**
* getStorageInfo
*/
function getStorageInfoSync(): types.StorageInfo;
/**
* key
*/
function removeStorage(param: types.RemoveStorageParams): void;
/**
* removeStorage
* @param key key
*/
function removeStorageSync(key: string): void;
/**
* key key
*/
function setStorage(param: types.SetStorageParams): void;
/**
* setStorage
* @param key key
* @param data
*/
function setStorageSync(key: string, data: any): void;
// --分包加载
/**
*
*/
function loadSubpackage(param: {
/**
* name root
*/
name: string,
success?: () => void,
fail?: () => void,
complete?: () => void
}): LoadSubpackageTask;
// --菜单
/**
*
*/
function getMenuButtonBoundingClientRect(): {
/**
*
*/
width: number,
/**
*
*/
height: number,
/**
*
*/
top: number,
/**
*
*/
right: number,
/**
*
*/
bottom: number,
/**
*
*/
left: number
};
function setMenuStyle(param: {
/**
*
*/
style: "light" | "dark",
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --交互
/**
*
*/
function showToast(param: {
/**
*
*/
title?: string,
/**
*
*/
icon?: "success" | "loading",
/**
* image icon
*/
image?: string,
/**
*
*/
duration?: number,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
/**
*
*/
function hideToast(cb?: types.Callbacks): void;
/**
*
*/
function showModal(param: {
/**
*
*/
title?: string,
/**
*
*/
content?: string,
/**
* true
*/
showCancel?: boolean,
/**
* 4
*/
cancelText?: string,
/**
* 16 #000000
*/
cancelColor?: string,
/**
* 4
*/
confirmText?: string,
/**
* 16 #3cc51f
*/
confirmColor?: string,
success?: (res: { confirm?: boolean, cancel?: boolean }) => void,
fail?: () => void,
complete?: () => void
}): void;
/**
* loading , wx.hideLoading
*/
function showLoading(prms?: {
/**
*
*/
title?: string,
/**
*
*/
mask?: boolean,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
/**
* loading
*/
function hideLoading(cb?: types.Callbacks): void;
/**
*
*/
function showActionSheet(params: {
/**
* 6
*/
itemList: string[],
/**
* #000000
*/
itemColor?: string,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --键盘
function hideKeyboard(): void;
/**
*
* @param callback.res.value
*/
function onKeyboardInput(callback: (res: { value: string }) => void): void;
/**
*
*/
function offKeyboardInput(callback: (res: { value: string }) => void): void;
/**
* Confirm
* @param callback.res.value
*/
function onKeyboardConfirm(callback: (res: { value: string }) => void): void;
/**
* Confirm
*/
function offKeyboardConfirm(callback: (res: { value: string }) => void): void;
/**
*
* @param callback.res.value
*/
function onKeyboardComplete(callback: (res: { value: string }) => void): void;
/**
*
*/
function offKeyboardComplete(callback: (res: { value: string }) => void): void;
/**
*
*/
function showKeyboard(param: {
/**
*
*/
defaultValue: string,
/**
*
*/
maxLength?: number,
/**
*
*/
multiple?: boolean,
/**
*
*/
confirmHold?: boolean,
/**
* confirm
*/
confirmType?: "done" | "next" | "search" | "go" | "send"
}): void;
/**
*
*/
function updateKeyboard(param: {
/**
*
*/
value: string,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --状态栏
/**
* showStatusBarStyle
*/
function setStatusBarStyle(param: {
style: "white" | "black",
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --窗口
/**
*
*/
function onWindowResize(cb: (res: { windowWidth: number, windowHeight: number }) => void): void;
/**
*
*/
function offWindowResize(cb: (res: { windowWidth: number, windowHeight: number }) => void): void;
// --更新
function getUpdateManager(): UpdateManager;
// --Worker
/**
* Worker 线 Worker Worker Worker.terminate
*/
function createWorker(): WxWorker;
// --音频
/**
* InnerAudioContext
*/
function createInnerAudioContext(): InnerAudioContext;
/**
*
*/
function getAvailableAudioSources(param: types.CallbacksWithType<{
/**
*
*/
audioSources: ReadonlyArray<types.AudioSourceType>
}>): void;
// --录音
function getRecorderManager(): RecorderManager;
// --图片
/**
* 使
*/
function chooseImage(param: {
count: number,
/**
*
*/
sizeType: ['original'] | ['compressed'] | ['original', 'compressed'],
/**
*
*/
sourceType: ['album'] | ['camera'] | ['album', 'camera'],
success?: (res: { tempFilePaths: ReadonlyArray<string>, tempFiles: ReadonlyArray<ImageFile> }) => void,
fail?: () => void,
complete?: () => void
}): void;
/**
*
*/
function previewImage(param: {
/**
*
*/
urls: string[],
/**
* urls的第一张
*/
current?: string,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
/**
* scope.writePhotosAlbum
*/
function saveImageToPhotosAlbum(param: {
/**
*
*/
filePath: string,
success?: () => void,
fail?: () => void,
complete?: () => void
}): void;
// --视频
function createVideo(param: {
/**
*
*/
x?: number,
/**
*
*/
y?: number,
/**
* 300
*/
width?: number,
/**
* 150
*/
height?: number,
/**
*
*/
src: string,
/**
*
*/
poster?: string,
/**
* s 0
*/
initialTime?: number,
/**
* 0.50.81.01.251.51.0
*/
playbackRate?: number,
/**
* 0
*/
live?: number,
/**
*
* fill -
* contain -
* cover -
*/
objectFit?: "contain" | "cover" | "fill",
/**
* true
*/
controls?: boolean,
/**
* false
*/
autoplay?: boolean,
/**
* false
*/
loop?: boolean,
/**
* false
*/
muted?: boolean
}): Video;
// --相机
/**
*
* @param param
*/
function createCamera(param?: types.Callbacks & {
/**
* 0
*/
x?: number;
/**
* 0
*/
y?: number;
/**
* 300
*/
width?: number;
/**
* 150
*/
height?: number;
/**
* front, backback
*/
devicePosition?: "front" | "back";
/**
* auto, on, offauto
*/
flash?: "auto" | "on" | "off";
/**
* small, medium, largesmall
*/
size?: "small" | "medium" | "large";
}): Camera;
// -- VoIP
/**
*
* @param param
*/
function updateVoIPChatMuteConfig(param: types.Callbacks & {
/**
*
*/
muteConfig: {
/**
* false
*/
muteMicrophone?: boolean,
/**
* false
*/
muteEarphone?: boolean
}
}): void;
/**
* /
* @param callback
*/
function onVoIPChatSpeakersChanged(callback: (res: {
/**
* openId
*/
openIdList: ReadonlyArray<string>,
/**
*
*/
errCode: number,
/**
*
*/
errMsg: string
}) => void): void;
/**
*
* @param callback
*/
function offVoIPChatSpeakersChanged(callback: any): void;
/**
* 线/退
* @param callback 线
*/
function onVoIPChatMembersChanged(callback: (res: {
/**
* openId
*/
openIdList: ReadonlyArray<string>,
/**
*
*/
errCode: number,
/**
*
*/
errMsg: string
}) => void): void;
/**
* 线
* @param callback
*/
function offVoIPChatMembersChanged(callback: any): void;
/**
*
* @param callback
*/
function onVoIPChatInterrupted(callback: (res: {
/**
*
*/
errCode: number,
/**
*
*/
errMsg: string
}) => void): void;
/**
*
* @param callback
*/
function offVoIPChatInterrupted(callback: any): void;
/**
* () https://developers.weixin.qq.com/minigame/dev/guide/open-ability/voip-chat.html
*
* -1
* -2 使
* -3 退退退
* -1000
* @param param
*/
function joinVoIPChat(param: types.CallbacksWithType<{
/**
* openId
*/
openIdList: ReadonlyArray<string>,
/**
*
*/
errCode: number,
/**
*
*/
errMsg: string
}> & {
/**
*
*/
signature: string,
/**
*
*/
nonceStr: string,
/**
*
*/
timeStamp: number,
/**
* / ID groupId
*/
groupId: string,
/**
*
*/
muteConfig?: {
/**
* false
*/
muteMicrophone?: boolean,
/**
* false
*/
muteEarphone?: boolean
}
}): void;
/**
* 退
*/
function exitVoIPChat(callbacks?: types.Callbacks): void;
// --广告
/**
* banner 广 wx.getSystemInfoSync() SDKVersion >= 2.0.4 使 API API
*/
function createBannerAd(param: {
/**
* 广 id
*/
adUnitId: string,
/**
* banner 广
*/
style: types.AdStyle
}): BannerAd;
/**
* 广 wx.getSystemInfoSync() SDKVersion >= 2.0.4 使 API API
*/
function createRewardedVideoAd(param: {
/**
* 广 id
*/
adUnitId: string
}): RewardedVideoAd;
/**
* 广 wx.getSystemInfoSync() SDKVersion 使 API广广使
*/
function createInterstitialAd(param: {
/**
* 广 id
*/
adUnitId: string
}): InterstitialAd;
// --虚拟支付
/**
*
*/
function requestMidasPayment(param: {
/**
*
* game -
*/
mode: "game",
/**
* 0
* 0 -
* 1 -
*/
env?: 0 | 1,
/**
* id
*/
offerId: string,
/**
*
*/
currencyType: "CNY",
/**
* platform id有关
*/
platform?: "android",
/**
* mode=game buyQuantity
* mode为gamebuyQuantity不可任意填写 buyQuantity * = 0.1 10
*
*
* 1
* 3
* 6
* 8
* 12
* 18
* 25
* 30
* 40
* 45
* 50
* 60
* 68
* 73
* 78
* 88
* 98
* 108
* 118
* 128
* 148
* 168
* 188
* 198
* 328
* 648
*/
buyQuantity?: number,
/**
* ID
*/
zoneId?: string,
success?: () => void,
/**
* @param res.errCode
* -1
* -2
* -15001
* -15002
* -15003
* -15004
* -15006 appId
* -15006
* -15007
* 1
* 2 , ,
* 3 Android 使 Google Play Google Play
* 4
* 5
* 6
* 1000
* 1003 Portal
*/
fail?: (res: { errMsg: string, errCode: number }) => void,
complete?: () => void
}): void;
}