forked from Polymer/polymer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.d.ts
200 lines (175 loc) · 4.83 KB
/
interfaces.d.ts
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/**
* This file contains the types that are required for compilation of the
* Polymer generated type declarations, but which could not themselves be
* automatically generated.
*/
// Types from "externs/polymer-externs.js"
export interface PolymerElementPropertiesMeta {
type?: Function;
value?: any;
readOnly?: boolean;
computed?: string;
reflectToAttribute?: boolean;
notify?: boolean;
observer?: string|((val: any, old: any) => void);
}
export type PolymerElementProperties = {
[key: string]: PolymerElementPropertiesMeta|Function;
};
// TODO Document these properties.
export interface PolymerInit {
is: string;
extends?: string;
properties?: PolymerElementProperties;
observers?: string[];
_template?: HTMLTemplateElement;
hostAttributes?: {[key: string]: any};
listeners?: {[key: string]: string};
behaviors?: BehaviorInit | BehaviorInit[];
// Lifecycle methods
registered?(): void;
created?(): void;
attached?(): void;
detached?(): void;
ready?(): void;
attributeChanged?(name: string, old?: string, value?: string): void;
// Allow any other user-defined properties
[others: string]: any;
}
export type BehaviorInit = Pick<
PolymerInit,
Exclude<keyof PolymerInit, "is" | "extends" | "_template">
>;
/**
* The object passed to ".*" wildcard obsevers. A record of a change made to an
* object.
* @template B The object matching the non-wildcard portion of the path.
* @template V Additional types that could be set at the path.
*/
export interface PolymerDeepPropertyChange<B, V> {
/** Path to the property that changed. */
path: string;
/** The object matching the non-wildcard portion of the path. */
base: B;
/** New value of the path that changed. */
value: B|V;
}
/**
* A record of changes made to an array.
* @template T The type of the array being observed.
*/
export interface PolymerSplice<T extends Array<{}|null|undefined>> {
/** Position where the splice started. */
index: number;
/** Array of removed items. */
removed: T;
/** Number of new items inserted at index. */
addedCount: number;
/** A reference to the array in question. */
object: T;
/** The string literal 'splice'. */
type: 'splice';
}
/**
* The object passed to ".splices" observers. A set of mutations made to the
* array.
* @template T The type of the array being observed.
*/
export interface PolymerSpliceChange<T extends Array<{}|null|undefined>> {
indexSplices: Array<PolymerSplice<T>>;
}
// Types from "externs/polymer-internal-shared-types.js"
export interface StampedTemplate extends DocumentFragment {
__noInsertionPoint: boolean;
nodeList: Node[];
$: {[key: string]: Node};
templateInfo?: TemplateInfo;
}
export interface NodeInfo {
id: string;
events: {name: string, value: string}[];
hasInsertionPoint: boolean;
templateInfo: TemplateInfo;
parentInfo: NodeInfo;
parentIndex: number;
infoIndex: number;
bindings: Binding[];
}
export interface TemplateInfo {
nodeInfoList: NodeInfo[];
nodeList: Node[];
stripWhitespace: boolean;
hasInsertionPoint?: boolean;
hostProps: Object;
propertyEffects: Object;
childNodes: Node[];
wasPreBound: boolean;
}
export interface LiteralBindingPart {
literal: string;
compoundIndex?: number;
}
export interface MethodArg {
literal: boolean;
name: string;
value: string|number;
rootProperty?: string;
structured?: boolean;
wildcard?: boolean;
}
export interface MethodSignature {
methodName: string;
static: boolean;
args: MethodArg[];
dynamicFn?: boolean;
}
export interface ExpressionBindingPart {
mode: string;
negate: boolean;
source: string;
dependencies: Array<MethodArg|string>;
customEvent: boolean;
signature: Object|null;
event: string;
}
export type BindingPart = LiteralBindingPart|ExpressionBindingPart;
export interface Binding {
kind: string;
target: string;
parts: BindingPart[];
literal?: string;
isCompound: boolean;
listenerEvent?: string;
listenerNegate?: boolean;
}
export interface AsyncInterface {
run: (fn: Function, delay?: number) => number;
cancel: (handle: number) => void;
}
// Types from "lib/utils/gestures.html"
export interface GestureRecognizer {
reset: () => void;
mousedown?: (e: MouseEvent) => void;
mousemove?: (e: MouseEvent) => void;
mouseup?: (e: MouseEvent) => void;
touchstart?: (e: TouchEvent) => void;
touchmove?: (e: TouchEvent) => void;
touchend?: (e: TouchEvent) => void;
click?: (e: MouseEvent) => void;
}
/**
* Not defined in the TypeScript DOM library.
* See https://developer.mozilla.org/en-US/docs/Web/API/IdleDeadline
*/
export interface IdleDeadline {
didTimeout: boolean;
timeRemaining(): number;
}
export interface PolymerElementConstructor {
new (): HTMLElement;
is?: string;
extends?: string;
properties?: PolymerElementProperties;
observers?: string[];
template?: string|HTMLTemplateElement|null;
}