mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 20:17:52 +08:00
2cb8ea3fee
* refactor(compiler): move postTransforms to after children are processed * feat(weex): recycle-list support WIP * refactor: fix types * feat(weex): split text into separate module * feat($compiler): supports compiling v-bind to the weex native directive in recycle-list * feat(compile): supports compiling v-if to the weex native directive * feat($compiler): supports compiling v-for to the weex native directive * feat($compiler): compile weex native directives in preTransformNode * feat($compiler): supports compiling v-else-if and v-else to the weex native directive * feat($event): support binding parameters on event handler within weex recycle-list * refactor: mark weex-specific block * feat(wip): recycle list template inline expand * build: add weex factory dev script * feat($compiler): support to compile "v-on" into weex native directive * feat($compiler): adjust handler params to fit the weex native renderer + Filter the non-expression params and the `$event`. + Use `$event` as the last argument of handler.
195 lines
5.3 KiB
JavaScript
195 lines
5.3 KiB
JavaScript
declare type CompilerOptions = {
|
|
warn?: Function; // allow customizing warning in different environments; e.g. node
|
|
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
|
|
canBeLeftOpenTag?: (tag: string) => ?boolean; // check if a tag can be left opened
|
|
isReservedTag?: (tag: string) => ?boolean; // check if a tag is a native for the platform
|
|
mustUseProp?: (tag: string, type: ?string, name: string) => boolean; // check if an attribute should be bound as a property
|
|
isPreTag?: (attr: string) => ?boolean; // check if a tag needs to preserve whitespace
|
|
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;
|
|
shouldDecodeNewlinesForHref?: boolean;
|
|
|
|
// for ssr optimization compiler
|
|
scopeId?: string;
|
|
|
|
// runtime user-configurable
|
|
delimiters?: [string, string]; // template delimiters
|
|
|
|
// allow user kept comments
|
|
comments?: boolean
|
|
};
|
|
|
|
declare type CompiledResult = {
|
|
ast: ?ASTElement;
|
|
render: string;
|
|
staticRenderFns: Array<string>;
|
|
stringRenderFns?: Array<string>;
|
|
errors?: Array<string>;
|
|
tips?: Array<string>;
|
|
};
|
|
|
|
declare type ModuleOptions = {
|
|
// transform an AST node before any attributes are processed
|
|
// returning an ASTElement from pre/transforms replaces the element
|
|
preTransformNode: (el: ASTElement) => ?ASTElement;
|
|
// transform an AST node after built-ins like v-if, v-for are processed
|
|
transformNode: (el: ASTElement) => ?ASTElement;
|
|
// transform an AST node after its children have been processed
|
|
// cannot return replacement in postTransform because tree is already finalized
|
|
postTransformNode: (el: ASTElement) => void;
|
|
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 };
|
|
declare type ASTIfCondition = { exp: ?string; block: ASTElement };
|
|
declare type ASTIfConditions = Array<ASTIfCondition>;
|
|
|
|
declare type ASTElementHandler = {
|
|
value: string;
|
|
params?: Array<any>;
|
|
modifiers: ?ASTModifiers;
|
|
};
|
|
|
|
declare type ASTElementHandlers = {
|
|
[key: string]: ASTElementHandler | Array<ASTElementHandler>;
|
|
};
|
|
|
|
declare type ASTDirective = {
|
|
name: string;
|
|
rawName: string;
|
|
value: string;
|
|
arg: ?string;
|
|
modifiers: ?ASTModifiers;
|
|
};
|
|
|
|
declare type ASTNode = ASTElement | ASTText | ASTExpression;
|
|
|
|
declare type ASTElement = {
|
|
type: 1;
|
|
tag: string;
|
|
attrsList: Array<{ name: string; value: any }>;
|
|
attrsMap: { [key: string]: any };
|
|
parent: ASTElement | void;
|
|
children: Array<ASTNode>;
|
|
|
|
processed?: true;
|
|
|
|
static?: boolean;
|
|
staticRoot?: boolean;
|
|
staticInFor?: boolean;
|
|
staticProcessed?: boolean;
|
|
hasBindings?: boolean;
|
|
|
|
text?: string;
|
|
attrs?: Array<{ name: string; value: any }>;
|
|
props?: Array<{ name: string; value: string }>;
|
|
plain?: boolean;
|
|
pre?: true;
|
|
ns?: string;
|
|
|
|
component?: string;
|
|
inlineTemplate?: true;
|
|
transitionMode?: string | null;
|
|
slotName?: ?string;
|
|
slotTarget?: ?string;
|
|
slotScope?: ?string;
|
|
scopedSlots?: { [name: string]: ASTElement };
|
|
|
|
ref?: string;
|
|
refInFor?: boolean;
|
|
|
|
if?: string;
|
|
ifProcessed?: boolean;
|
|
elseif?: string;
|
|
else?: true;
|
|
ifConditions?: ASTIfConditions;
|
|
|
|
for?: string;
|
|
forProcessed?: boolean;
|
|
key?: string;
|
|
alias?: string;
|
|
iterator1?: string;
|
|
iterator2?: string;
|
|
|
|
staticClass?: string;
|
|
classBinding?: string;
|
|
staticStyle?: string;
|
|
styleBinding?: string;
|
|
events?: ASTElementHandlers;
|
|
nativeEvents?: ASTElementHandlers;
|
|
|
|
transition?: string | true;
|
|
transitionOnAppear?: boolean;
|
|
|
|
model?: {
|
|
value: string;
|
|
callback: string;
|
|
expression: string;
|
|
};
|
|
|
|
directives?: Array<ASTDirective>;
|
|
|
|
forbidden?: true;
|
|
once?: true;
|
|
onceProcessed?: boolean;
|
|
wrapData?: (code: string) => string;
|
|
wrapListeners?: (code: string) => string;
|
|
|
|
// 2.4 ssr optimization
|
|
ssrOptimizability?: number;
|
|
|
|
// weex specific
|
|
appendAsTree?: boolean;
|
|
};
|
|
|
|
declare type ASTExpression = {
|
|
type: 2;
|
|
expression: string;
|
|
text: string;
|
|
tokens: Array<string | Object>;
|
|
static?: boolean;
|
|
// 2.4 ssr optimization
|
|
ssrOptimizability?: number;
|
|
};
|
|
|
|
declare type ASTText = {
|
|
type: 3;
|
|
text: string;
|
|
static?: boolean;
|
|
isComment?: boolean;
|
|
// 2.4 ssr optimization
|
|
ssrOptimizability?: number;
|
|
};
|
|
|
|
// SFC-parser related declarations
|
|
|
|
// an object format describing a single-file component.
|
|
declare type SFCDescriptor = {
|
|
template: ?SFCBlock;
|
|
script: ?SFCBlock;
|
|
styles: Array<SFCBlock>;
|
|
customBlocks: Array<SFCBlock>;
|
|
};
|
|
|
|
declare type SFCBlock = {
|
|
type: string;
|
|
content: string;
|
|
attrs: {[attribute:string]: string};
|
|
start?: number;
|
|
end?: number;
|
|
lang?: string;
|
|
src?: string;
|
|
scoped?: boolean;
|
|
module?: string | boolean;
|
|
};
|