import { BindingMetadata } from 'sfc/types'
export type CompilerOptions = {
warn?: Function
modules?: Array<ModuleOptions>
directives?: { [key: string]: Function }
staticKeys?: string
isUnaryTag?: (tag: string) => boolean | undefined
canBeLeftOpenTag?: (tag: string) => boolean | undefined
isReservedTag?: (tag: string) => boolean | undefined
preserveWhitespace?: boolean
whitespace?: 'preserve' | 'condense'
optimize?: boolean
mustUseProp?: (tag: string, type: string | null, name: string) => boolean
isPreTag?: (attr: string) => boolean | null
getTagNamespace?: (tag: string) => string | undefined
expectHTML?: boolean
isFromDOM?: boolean
shouldDecodeTags?: boolean
shouldDecodeNewlines?: boolean
shouldDecodeNewlinesForHref?: boolean
outputSourceRange?: boolean
shouldKeepComment?: boolean
delimiters?: [string, string]
comments?: boolean
scopeId?: string
bindings?: BindingMetadata
}
export type WarningMessage = {
msg: string
start?: number
end?: number
}
export type CompiledResult = {
ast: ASTElement | null
render: string
staticRenderFns: Array<string>
stringRenderFns?: Array<string>
errors?: Array<string | WarningMessage>
tips?: Array<string | WarningMessage>
}
export type ModuleOptions = {
preTransformNode?: (el: ASTElement) => ASTElement | null | void
transformNode?: (el: ASTElement) => ASTElement | null | void
postTransformNode?: (el: ASTElement) => void
genData?: (el: ASTElement) => string
transformCode?: (el: ASTElement, code: string) => string
staticKeys?: Array<string>
}
export type ASTModifiers = { [key: string]: boolean }
export type ASTIfCondition = { exp: string | null; block: ASTElement }
export type ASTIfConditions = Array<ASTIfCondition>
export type ASTAttr = {
name: string
value: any
dynamic?: boolean
start?: number
end?: number
}
export type ASTElementHandler = {
value: string
params?: Array<any>
modifiers: ASTModifiers | null
dynamic?: boolean
start?: number
end?: number
}
export type ASTElementHandlers = {
[key: string]: ASTElementHandler | Array<ASTElementHandler>
}
export type ASTDirective = {
name: string
rawName: string
value: string
arg: string | null
isDynamicArg: boolean
modifiers: ASTModifiers | null
start?: number
end?: number
}
export type ASTNode = ASTElement | ASTText | ASTExpression
export type ASTElement = {
type: 1
tag: string
attrsList: Array<ASTAttr>
attrsMap: { [key: string]: any }
rawAttrsMap: { [key: string]: ASTAttr }
parent: ASTElement | void
children: Array<ASTNode>
start?: number
end?: number
processed?: true
static?: boolean
staticRoot?: boolean
staticInFor?: boolean
staticProcessed?: boolean
hasBindings?: boolean
text?: string
attrs?: Array<ASTAttr>
dynamicAttrs?: Array<ASTAttr>
props?: Array<ASTAttr>
plain?: boolean
pre?: true
ns?: string
component?: string
inlineTemplate?: true
transitionMode?: string | null
slotName?: string | null
slotTarget?: string | null
slotTargetDynamic?: boolean
slotScope?: string | null
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
ssrOptimizability?: number
}
export type ASTExpression = {
type: 2
expression: string
text: string
tokens: Array<string | Object>
static?: boolean
ssrOptimizability?: number
start?: number
end?: number
}
export type ASTText = {
type: 3
text: string
static?: boolean
isComment?: boolean
ssrOptimizability?: number
start?: number
end?: number
}