miniapp-windmill-renderer
Version:
Windmill renderer-side proxy.
55 lines (45 loc) • 1.64 kB
TypeScript
/**
* @fileOverview: windmill-renderer types.
* declare module types for windmill-renderer.
*/
declare interface Weex {
config: { [key: string]: any }
requireModule: (name: string) => { [key: string]: any } | void
supports: (condition: string) => boolean | void
isRegisteredModule: (name: string, method?: string) => boolean
isRegisteredComponent: (name: string) => boolean
}
type PlainObject = {
[key: string]: any
}
type CallbackResult = {
status?: string
}
type EventData = {
type: string,
origin?: string,
data: PlainObject
}
type Params = {
[key: string]: any
}
type CallbackFunction = (result: CallbackResult) => void
type FailureCallback = (err: Error) => void
declare interface Windmill {
$on: (event: string, callback: (result: EventData) => void) => void
$once: (event: string, callback: (result: EventData) => void) => void
$off: (event: string, callback?: (result: EventData) => void) => void
$emit: (event: string, data: Params, target?: string) => void
$cycle: (lifecycle: string, hook: (result: PlainObject) => void) => void
$decycle: (lifecycle: string, hook?: (result: PlainObject) => void) => void
$call: (method: string, params: Params, successCallback?: CallbackFunction, failureCallback?: FailureCallback) => void
$callAsync: (method: string, params: Params) => Promise<any>
$navTo: (params: Params) => void
$getAvailableModules: () => { [name: string]: Array<string> }
}
declare interface InitRendererOption {
clientId: string,
[key: string]: any
}
declare function registerWeex (weex: Weex, option?: InitRendererOption): Windmill
export default registerWeex