forked from vuejs/vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weex.js
122 lines (103 loc) · 3.29 KB
/
weex.js
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
// global flag to be compiled away
declare var __WEEX__: boolean;
// global object in Weex
declare var WXEnvironment: WeexEnvironment;
declare type Weex = {
config: WeexConfigAPI;
document: WeexDocument;
requireModule: (name: string) => Object | void;
supports: (condition: string) => boolean | void;
isRegisteredModule: (name: string, method?: string) => boolean;
isRegisteredComponent: (name: string) => boolean;
};
declare type WeexConfigAPI = {
bundleUrl: string; // === weex.document.URL
bundleType: string;
env: WeexEnvironment; // === WXEnvironment
};
declare type WeexEnvironment = {
platform: string; // could be "Web", "iOS", "Android"
weexVersion: string; // the version of WeexSDK
osName: string; // could be "iOS", "Android" or others
osVersion: string;
appName: string; // mobile app name or browser name
appVersion: string;
// informations of current running device
deviceModel: string; // phone device model
deviceWidth: number;
deviceHeight: number;
scale: number;
// only available on the web
userAgent?: string;
dpr?: number;
rem?: number;
};
declare interface WeexDocument {
id: string;
URL: string;
taskCenter: WeexTaskCenter;
open: () => void;
close: () => void;
createElement: (tagName: string, props?: Object) => WeexElement;
createComment: (text: string) => Object;
fireEvent: (type: string) => void;
destroy: () => void;
};
declare interface WeexTaskCenter {
instanceId: string;
callbackManager: Object;
send: (type: string, params: Object, args: Array<any>, options?: Object) => void;
registerHook: (componentId: string, type: string, hook: string, fn: Function) => void;
updateData: (componentId: string, data: Object | void, callback?: Function) => void;
};
declare interface WeexElement {
nodeType: number;
nodeId: string;
type: string;
ref: string;
text?: string;
parentNode: WeexElement | void;
children: Array<WeexElement>;
previousSibling: WeexElement | void;
nextSibling: WeexElement | void;
appendChild: (node: WeexElement) => void;
removeChild: (node: WeexElement, preserved?: boolean) => void;
insertBefore: (node: WeexElement, before: WeexElement) => void;
insertAfter: (node: WeexElement, after: WeexElement) => void;
setAttr: (key: string, value: any, silent?: boolean) => void;
setAttrs: (attrs: Object, silent?: boolean) => void;
setStyle: (key: string, value: any, silent?: boolean) => void;
setStyles: (attrs: Object, silent?: boolean) => void;
addEvent: (type: string, handler: Function, args?: Array<any>) => void;
removeEvent: (type: string) => void;
fireEvent: (type: string) => void;
destroy: () => void;
};
declare type WeexInstanceOption = {
instanceId: string;
config: WeexConfigAPI;
document: WeexDocument;
Vue?: GlobalAPI;
app?: Component;
data?: Object;
};
declare type WeexRuntimeContext = {
weex: Weex;
service: Object;
BroadcastChannel?: Function;
};
declare type WeexInstanceContext = {
Vue: GlobalAPI;
// DEPRECATED
setTimeout?: Function;
clearTimeout?: Function;
setInterval?: Function;
clearInterval?: Function;
};
declare type WeexCompilerOptions = CompilerOptions & {
// whether to compile special template for <recycle-list>
recyclable?: boolean;
};
declare type WeexCompiledResult = CompiledResult & {
'@render'?: string;
};