improvement: 更新weapp类型定义

This commit is contained in:
rex 2019-02-02 16:18:12 +08:00 committed by GitHub
parent d28ca0271a
commit 705aa8c1df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 509 additions and 28 deletions

83
types/weapp.d.ts vendored
View File

@ -2,54 +2,81 @@ type BehaviorOptions = {
[key: string]: any & ThisType<any>
};
type WX = {
[key: string]: any
};
declare const wx: WX;
declare function Behavior(options: BehaviorOptions): void;
declare function Component(options: any): void;
declare function getCurrentPages(): Weapp.Page[];
declare function Behavior(options: BehaviorOptions): void
declare function Component(options: any): void
declare function getCurrentPages(): Weapp.Page[]
declare namespace Weapp {
interface Component {
[key: string]: any;
getRelationNodes(selector: string): any[];
setData(data: any, callback?: Function): void;
[key: string]: any
getRelationNodes(selector: string): any[]
setData(data: any, callback?: Function): void
}
interface FormField {
data: {
name: string;
value: any;
name: string
value: any
}
}
interface Target {
id: string;
tagName: string;
dataset: any;
id: string
tagName: string
dataset: {
[key: string]: any
}
}
interface Event {
type: string;
detail: any;
timeStamp: number;
target: Target;
currentTarget: Target;
/**
*
*/
type: string
/**
*
*/
timeStamp: number
/**
*
*/
target: Target
/**
*
*/
currentTarget: Target
/**
*
*/
detail: any
}
interface Touch {
identifier: number;
pageX: number;
pageY: number;
clientX: number;
clientY: number;
/**
*
*/
identifier: number
/**
* X轴Y轴
*/
pageX: number
/**
* X轴Y轴
*/
pageY: number
/**
* X轴Y轴
*/
clientX: number
/**
* X轴Y轴
*/
clientY: number
}
interface TouchEvent extends Event {
touches: Array<Touch>;
changedTouches: Array<Touch>;
touches: Array<Touch>
changedTouches: Array<Touch>
}
interface Page {

454
types/wx.d.ts vendored Normal file
View File

@ -0,0 +1,454 @@
interface SystemInfo {
/**
*
*/
brand: string
/**
*
*/
model: string
/**
*
*/
pixelRatio: number
/**
* px
*/
screenWidth: number
/**
* px
*/
screenHeight: number
/**
* 使px
*/
windowWidth: number
/**
* 使px
*/
windowHeight: number
/**
* px
*/
statusBarHeight: number
/**
*
*/
language: string
/**
*
*/
version: string
/**
*
*/
system: string
/**
*
*/
platform: string
/**
* px---
*/
fontSizeSetting: number
/**
*
*/
SDKVersion: string
/**
* Android小游戏-2 0-1>=150
*/
benchmarkLevel: number
}
type TimingFunction =
| 'linear'
| 'ease'
| 'ease-in'
| 'ease-in-out'
| 'ease-out'
| 'step-start'
| 'step-end';
interface AnimationOptions {
/**
* ms
*/
duration?: number
/**
*
*/
timingFunction?: TimingFunction
/**
* ms
*/
delay?: number
/**
* transform-origin
*/
transformOrigin?: string
}
interface Animation {
/**
* export
*/
export(): object
/**
*
*/
step(object: AnimationOptions): void
/**
* 0~1
*/
opacity(value: number): Animation
/**
*
*/
backgroundColor(color: string): Animation
/**
* Number 使 px
*/
width(length: number): Animation
/**
* Number 使 px
*/
height(length: number): Animation
/**
* Number 使 px
*/
top(length: number): Animation
/**
* Number 使 px
*/
left(length: number): Animation
/**
* Number 使 px
*/
bottom(length: number): Animation
/**
* Number 使 px
*/
right(length: number): Animation
/**
* deg的范围-180~180deg角度
*/
rotate(deg: number): Animation
/**
* deg的范围-180~180X轴旋转一个deg角度
*/
rotateX(deg: number): Animation
/**
* deg的范围-180~180Y轴旋转一个deg角度
*/
rotateY(deg: number): Animation
/**
* deg的范围-180~180Z轴旋转一个deg角度
*/
rotateZ(deg: number): Animation
/**
* transform-function rotate3d
*/
rotate3d(x: number, y: number, z: number, deg: number): Animation
/**
* X轴Y轴同时缩放sx倍数X轴缩放sx倍数Y轴缩放sy倍数
*/
scale(sx: number, sy?: number): Animation
/**
* X轴缩放sx倍数
*/
scaleX(sx: number): Animation
/**
* Y轴缩放sy倍数
*/
scaleY(sy: number): Animation
/**
* Z轴缩放sy倍数
*/
scaleZ(sz: number): Animation
/**
* X轴缩放sx倍数Y轴缩放sy倍数Z轴缩放sz倍数
*/
scale3d(sx: number, sy: number, sz: number): Animation
/**
* X轴偏移txpxX轴偏移txY轴偏移typx
*/
translate(tx: number, ty?: number): Animation
/**
* X轴偏移txpx
*/
translateX(tx: number): Animation
/**
* Y轴偏移txpx
*/
translateY(tx: number): Animation
/**
* Z轴偏移txpx
*/
translateZ(tx: number): Animation
/**
* X轴偏移txY轴偏移tyZ轴偏移tzpx
*/
translate3d(tx: number, ty: number, tz: number): Animation
/**
* -180~180Y轴坐标不变X轴坐标延顺时针倾斜ax度X轴倾斜ax度Y轴倾斜ay度
*/
skew(ax: number, ay?: number): Animation
/**
* -180~180Y轴坐标不变X轴坐标延顺时针倾斜ax度
*/
skewX(ax: number): Animation
/**
* -180~180X轴坐标不变Y轴坐标延顺时针倾斜ay度
*/
skewY(ay: number): Animation
/**
* transform-function matrix
*/
matrix(
a: number,
b: number,
c: number,
d: number,
tx: number,
ty: number
): Animation
/**
* transform-function matrix3d
*/
matrix3d(): Animation
}
interface FieldsOptions {
/**
* id
*/
id?: boolean
/**
* dataset
*/
dataset?: boolean
rect?: boolean
size?: boolean
scrollOffset?: boolean
properties?: string[]
computedStyle?: string[]
context?: boolean
}
interface BoundingClientRect {
id: string
dataset: object
left: number
right: number
top: number
bottom: number
width: number
height: number
}
interface IntersectionRect {
/**
*
*/
left: number
/**
*
*/
right: number
/**
*
*/
top: number
/**
*
*/
bottom: number
}
interface ScrollOffset {
/**
* ID
*/
id: string
/**
* dataset
*/
dataset: Object
/**
*
*/
scrollLeft: number
/**
*
*/
scrollTop: number
}
interface NodesRef {
/**
* fields中指定 nodesRef selectorQuery
*/
fields(object: FieldsOptions): object
/**
* DOM getBoundingClientRect NodesRef SelectorQuery
*/
boundingClientRect(callback: (res: BoundingClientRect) => void): SelectorQuery
/**
* scroll-view viewport NodesRef SelectorQuery
*/
scrollOffset(callback: (res: ScrollOffset) => void): SelectorQuery
/**
* Context VideoContextCanvasContextLivePlayerContext MapContext
*/
context(callback: (res: { content: any }) => void): SelectorQuery
}
interface SelectorQuery {
/**
* component
* @param component [description]
*/
in(component: Weapp.Component): SelectorQuery
/**
* selector NodesRef
*/
select(selector: string): NodesRef
/**
* selector
*/
selectAll(selector: string): NodesRef
/**
*
*/
selectViewport(): NodesRef
/**
* callback的第一个参数中返回
*/
exec(callback?: Function): NodesRef
}
interface ObserverOptions {
/**
*
*/
thresholds?: number[]
/**
*
*/
initialRatio?: number
/**
* true observe targetSelector
*/
observeAll?: boolean
}
interface Margins {
/**
*
*/
left: number
/**
*
*/
right: number
/**
*
*/
top: number
/**
*
*/
bottom: number
}
interface IntersectionObserver {
/**
*
*/
disconnect(): void
/**
* 使
*/
relativeTo(selector: string, object: Margins): IntersectionObserver
/**
*
*/
relativeToViewport(object: Margins): IntersectionObserver
/**
*
*/
observe(
selector: string,
callback: (
object: {
/**
*
*/
intersectionRatio: number
/**
*
*/
intersectionRect: IntersectionRect
/**
*
*/
boundingClientRect: IntersectionRect
/**
*
*/
relativeRect: IntersectionRect
/**
*
*/
time: number
}
) => void
): void
}
interface Wx {
/**
*
*/
getSystemInfo(object: {
success: (res: SystemInfo) => void
fail?: () => void
complete?: () => void
}): void
/**
*
*/
getSystemInfoSync(): SystemInfo
/**
* animation export animation
*/
createAnimation(object: AnimationOptions): Animation
/**
* SelectorQuery 使 this.createSelectorQuery()
*/
createSelectorQuery(): SelectorQuery
createIntersectionObserver(
component: Weapp.Component,
options: ObserverOptions
): IntersectionObserver
}
declare const wx: Wx;