2016-05-14 17:08:54 +08:00
|
|
|
declare type CompilerOptions = {
|
2016-06-08 06:33:34 +08:00
|
|
|
warn?: Function, // allow customizing warning in different environments, e.g. node
|
|
|
|
isIE?: boolean, // for detecting IE SVG innerHTML bug
|
|
|
|
expectHTML?: boolean, // only false for non-web builds
|
|
|
|
modules?: Array<ModuleOptions>, // platform specific modules, e.g. style, class
|
|
|
|
staticKeys?: string, // a list of AST properties to be considered static, for optimization
|
|
|
|
directives?: { [key: string]: Function }, // platform specific directives
|
|
|
|
isUnaryTag?: (tag: string) => ?boolean, // check if a tag is unary for the platform
|
|
|
|
isReservedTag?: (tag: string) => ?boolean, // check if a tag is a native for the platform
|
|
|
|
mustUseProp?: (attr: string) => ?boolean, // check if an attribute should be bound as a property
|
|
|
|
getTagNamespace?: (tag: string) => ?string, // check the namespace for a tag
|
|
|
|
transforms?: Array<Function>, // a list of transforms on parsed AST before codegen
|
2016-06-15 22:30:32 +08:00
|
|
|
preserveWhitespace?: boolean,
|
2016-06-08 06:33:34 +08:00
|
|
|
|
|
|
|
// runtime user-configurable
|
|
|
|
delimiters?: [string, string] // template delimiters
|
2016-05-14 17:08:54 +08:00
|
|
|
}
|
|
|
|
|
2016-06-08 09:36:00 +08:00
|
|
|
declare type CompiledResult = {
|
|
|
|
ast: ?ASTElement,
|
|
|
|
render: string,
|
|
|
|
staticRenderFns: Array<string>,
|
|
|
|
errors?: Array<string>
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type CompiledFunctionResult = {
|
|
|
|
render: Function,
|
|
|
|
staticRenderFns: Array<Function>
|
|
|
|
}
|
|
|
|
|
2016-05-17 09:02:13 +08:00
|
|
|
declare type ModuleOptions = {
|
2016-06-08 06:33:34 +08:00
|
|
|
transformNode: (el: ASTElement) => void, // transform an element's AST node
|
|
|
|
genData: (el: ASTElement) => string, // generate extra data string for an element
|
|
|
|
transformCode?: (el: ASTElement, code: string) => string, // further transform generated code for an element
|
|
|
|
staticKeys?: Array<string> // AST properties to be considered static
|
2016-05-17 09:02:13 +08:00
|
|
|
}
|
|
|
|
|
2016-05-14 18:20:54 +08:00
|
|
|
declare type ASTElementHandler = {
|
|
|
|
value: string,
|
|
|
|
modifiers: ?{ [key: string]: true }
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type ASTElementHandlers = {
|
|
|
|
[key: string]: ASTElementHandler | Array<ASTElementHandler>
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type ASTElementHooks = { [key: string]: Array<string> }
|
|
|
|
|
2016-05-14 19:40:56 +08:00
|
|
|
declare type ASTDirective = {
|
|
|
|
name: string,
|
|
|
|
value: ?string,
|
|
|
|
arg: ?string,
|
|
|
|
modifiers: ?{ [key: string]: true }
|
|
|
|
}
|
|
|
|
|
2016-05-17 03:28:10 +08:00
|
|
|
declare type ASTNode = ASTElement | ASTText | ASTExpression
|
2016-05-14 17:08:54 +08:00
|
|
|
|
|
|
|
declare type ASTElement = {
|
2016-05-17 03:28:10 +08:00
|
|
|
type: 1,
|
2016-05-14 17:08:54 +08:00
|
|
|
tag: string,
|
|
|
|
attrsList: Array<{ name: string, value: string }>,
|
2016-05-14 18:20:54 +08:00
|
|
|
attrsMap: { [key: string]: string | null },
|
2016-05-14 17:08:54 +08:00
|
|
|
parent: ASTElement | void,
|
2016-05-17 03:28:10 +08:00
|
|
|
children: Array<ASTNode>,
|
2016-05-14 17:54:52 +08:00
|
|
|
|
|
|
|
static?: boolean,
|
2016-05-27 11:51:34 +08:00
|
|
|
staticRoot?: boolean,
|
2016-06-27 23:18:06 +08:00
|
|
|
staticProcessed?: boolean,
|
2016-05-14 17:08:54 +08:00
|
|
|
|
|
|
|
text?: string,
|
|
|
|
attrs?: Array<{ name: string, value: string }>,
|
2016-05-14 18:20:54 +08:00
|
|
|
props?: Array<{ name: string, value: string }>,
|
|
|
|
staticAttrs?: Array<{ name: string, value: string }>,
|
2016-05-14 17:08:54 +08:00
|
|
|
plain?: boolean,
|
|
|
|
pre?: true,
|
|
|
|
ns?: string,
|
|
|
|
|
|
|
|
component?: string,
|
2016-06-04 07:32:45 +08:00
|
|
|
keepAlive?: boolean,
|
2016-05-14 17:08:54 +08:00
|
|
|
inlineTemplate?: true,
|
2016-06-04 07:32:45 +08:00
|
|
|
transitionMode?: string | null,
|
2016-05-14 18:20:54 +08:00
|
|
|
slotName?: ?string,
|
|
|
|
slotTarget?: ?string,
|
2016-05-14 17:08:54 +08:00
|
|
|
|
2016-06-02 07:52:42 +08:00
|
|
|
ref?: string,
|
|
|
|
refInFor?: boolean,
|
|
|
|
|
2016-06-15 23:31:43 +08:00
|
|
|
if?: string,
|
|
|
|
ifProcessed?: boolean,
|
2016-05-14 17:08:54 +08:00
|
|
|
else?: true,
|
|
|
|
elseBlock?: ASTElement,
|
|
|
|
|
2016-06-15 23:31:43 +08:00
|
|
|
for?: string,
|
|
|
|
forProcessed?: boolean,
|
2016-05-14 17:08:54 +08:00
|
|
|
key?: string,
|
|
|
|
alias?: string,
|
2016-06-14 02:55:53 +08:00
|
|
|
iterator1?: string,
|
|
|
|
iterator2?: string,
|
2016-05-14 17:08:54 +08:00
|
|
|
|
|
|
|
staticClass?: string,
|
|
|
|
classBinding?: string,
|
|
|
|
styleBinding?: string,
|
2016-05-14 18:20:54 +08:00
|
|
|
hooks?: ASTElementHooks,
|
|
|
|
events?: ASTElementHandlers,
|
2016-07-20 06:56:10 +08:00
|
|
|
nativeEvents?: ASTElementHandlers,
|
2016-05-14 17:08:54 +08:00
|
|
|
|
|
|
|
transition?: string | true,
|
|
|
|
transitionOnAppear?: boolean,
|
|
|
|
|
2016-05-14 19:40:56 +08:00
|
|
|
directives?: Array<ASTDirective>,
|
2016-05-14 17:54:52 +08:00
|
|
|
|
2016-05-14 17:08:54 +08:00
|
|
|
forbidden?: true,
|
|
|
|
once?: true
|
|
|
|
}
|
2016-05-17 03:28:10 +08:00
|
|
|
|
|
|
|
declare type ASTExpression = {
|
|
|
|
type: 2,
|
|
|
|
expression: string,
|
2016-06-07 02:15:21 +08:00
|
|
|
text: string,
|
2016-05-17 03:28:10 +08:00
|
|
|
static?: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type ASTText = {
|
|
|
|
type: 3,
|
|
|
|
text: string,
|
|
|
|
static?: boolean
|
|
|
|
}
|
2016-06-08 09:36:00 +08:00
|
|
|
|
|
|
|
// SFC-parser related declarations
|
|
|
|
|
|
|
|
// an object format describing a single-file component.
|
|
|
|
declare type SFCDescriptor = {
|
|
|
|
template: ?SFCBlock,
|
|
|
|
script: ?SFCBlock,
|
|
|
|
styles: Array<SFCBlock>
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type SFCBlock = {
|
2016-06-11 01:19:04 +08:00
|
|
|
type: string,
|
2016-06-08 09:36:00 +08:00
|
|
|
content: string,
|
2016-06-11 01:19:04 +08:00
|
|
|
start?: number,
|
|
|
|
end?: number,
|
2016-06-08 09:36:00 +08:00
|
|
|
lang?: string,
|
2016-06-11 01:19:04 +08:00
|
|
|
src?: string,
|
2016-06-21 13:23:24 +08:00
|
|
|
scoped?: boolean
|
2016-06-08 09:36:00 +08:00
|
|
|
}
|