vue/flow/compiler.js

156 lines
4.0 KiB
JavaScript
Raw Normal View History

2016-05-14 17:08:54 +08:00
declare type CompilerOptions = {
2016-07-26 09:28:46 +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
isPreTag?: (attr: string) => ?boolean; // check if a tag needs to preserve whitespace
2016-07-26 09:28:46 +08:00
getTagNamespace?: (tag: string) => ?string; // check the namespace for a tag
transforms?: Array<Function>; // a list of transforms on parsed AST before codegen
preserveWhitespace?: boolean;
isFromDOM?: boolean;
shouldDecodeTags?: boolean;
shouldDecodeNewlines?: boolean;
2016-06-08 06:33:34 +08:00
// runtime user-configurable
2016-07-26 09:28:46 +08:00
delimiters?: [string, string]; // template delimiters
2016-05-14 17:08:54 +08:00
}
2016-06-08 09:36:00 +08:00
declare type CompiledResult = {
2016-07-26 09:28:46 +08:00
ast: ?ASTElement;
render: string;
staticRenderFns: Array<string>;
errors?: Array<string>;
2016-06-08 09:36:00 +08:00
}
declare type CompiledFunctionResult = {
2016-07-26 09:28:46 +08:00
render: Function;
staticRenderFns: Array<Function>;
2016-06-08 09:36:00 +08:00
}
declare type ModuleOptions = {
preTransformNode: (el: ASTElement) => void;
2016-07-26 09:28:46 +08:00
transformNode: (el: ASTElement) => void; // transform an element's AST node
postTransformNode: (el: ASTElement) => void;
2016-07-26 09:28:46 +08:00
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
}
declare type ASTModifiers = { [key: string]: boolean }
2016-05-14 18:20:54 +08:00
declare type ASTElementHandler = {
2016-07-26 09:28:46 +08:00
value: string;
modifiers: ?ASTModifiers;
2016-05-14 18:20:54 +08:00
}
declare type ASTElementHandlers = {
2016-07-26 09:28:46 +08:00
[key: string]: ASTElementHandler | Array<ASTElementHandler>;
2016-05-14 18:20:54 +08:00
}
2016-05-14 19:40:56 +08:00
declare type ASTDirective = {
2016-07-26 09:28:46 +08:00
name: string;
2016-10-12 08:50:28 +08:00
rawName: string;
2016-08-28 23:33:39 +08:00
value: string;
2016-07-26 09:28:46 +08:00
arg: ?string;
modifiers: ?ASTModifiers;
2016-05-14 19:40:56 +08:00
}
declare type ASTNode = ASTElement | ASTText | ASTExpression
2016-05-14 17:08:54 +08:00
declare type ASTElement = {
2016-07-26 09:28:46 +08:00
type: 1;
tag: string;
attrsList: Array<{ name: string; value: string }>;
attrsMap: { [key: string]: string | null };
parent: ASTElement | void;
children: Array<ASTNode>;
static?: boolean;
staticRoot?: boolean;
staticInFor?: boolean;
2016-07-26 09:28:46 +08:00
staticProcessed?: boolean;
2016-07-29 22:45:43 +08:00
hasBindings?: boolean;
2016-07-26 09:28:46 +08:00
text?: string;
attrs?: Array<{ name: string; value: string }>;
props?: Array<{ name: string; value: string }>;
plain?: boolean;
pre?: true;
ns?: string;
component?: string;
inlineTemplate?: true;
transitionMode?: string | null;
slotName?: ?string;
slotTarget?: ?string;
ref?: string;
refInFor?: boolean;
if?: string;
ifProcessed?: boolean;
else?: true;
elseBlock?: ASTElement;
for?: string;
forProcessed?: boolean;
key?: string;
alias?: string;
iterator1?: string;
iterator2?: string;
staticClass?: string;
classBinding?: string;
styleBinding?: string;
events?: ASTElementHandlers;
nativeEvents?: ASTElementHandlers;
transition?: string | true;
transitionOnAppear?: boolean;
directives?: Array<ASTDirective>;
forbidden?: true;
once?: true;
2016-11-03 10:34:36 +08:00
onceProcessed?: boolean;
wrapData?: (code: string) => string;
2016-05-14 17:08:54 +08:00
}
declare type ASTExpression = {
2016-07-26 09:28:46 +08:00
type: 2;
expression: string;
text: string;
static?: boolean;
}
declare type ASTText = {
2016-07-26 09:28:46 +08:00
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 = {
2016-07-26 09:28:46 +08:00
template: ?SFCBlock;
script: ?SFCBlock;
styles: Array<SFCBlock>;
2016-06-08 09:36:00 +08:00
}
declare type SFCBlock = {
2016-07-26 09:28:46 +08:00
type: string;
content: string;
start?: number;
end?: number;
lang?: string;
src?: string;
scoped?: boolean;
module?: string | boolean;
2016-06-08 09:36:00 +08:00
}