-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
419 changed files
with
52,328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
declare type CompilerOptions = { | ||
warn?: Function; // allow customizing warning in different environments; e.g. node | ||
modules?: Array<ModuleOptions>; // platform specific modules; e.g. style; class | ||
directives?: { [key: string]: Function }; // platform specific directives | ||
staticKeys?: string; // a list of AST properties to be considered static; for optimization | ||
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 | ||
preserveWhitespace?: boolean; // preserve whitespace between elements? (Deprecated) | ||
whitespace?: 'preserve' | 'condense'; // whitespace handling strategy | ||
optimize?: boolean; // optimize static content? | ||
|
||
// web specific | ||
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 | ||
expectHTML?: boolean; // only false for non-web builds | ||
isFromDOM?: boolean; | ||
shouldDecodeTags?: boolean; | ||
shouldDecodeNewlines?: boolean; | ||
shouldDecodeNewlinesForHref?: boolean; | ||
outputSourceRange?: boolean; | ||
|
||
// runtime user-configurable | ||
delimiters?: [string, string]; // template delimiters | ||
comments?: boolean; // preserve comments in template | ||
|
||
// for ssr optimization compiler | ||
scopeId?: string; | ||
}; | ||
|
||
declare type WarningMessage = { | ||
msg: string; | ||
start?: number; | ||
end?: number; | ||
}; | ||
|
||
declare type CompiledResult = { | ||
ast: ?ASTElement; | ||
render: string; | ||
staticRenderFns: Array<string>; | ||
stringRenderFns?: Array<string>; | ||
errors?: Array<string | WarningMessage>; | ||
tips?: Array<string | WarningMessage>; | ||
}; | ||
|
||
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 ASTAttr = { | ||
name: string; | ||
value: any; | ||
dynamic?: boolean; | ||
start?: number; | ||
end?: number | ||
}; | ||
|
||
declare type ASTElementHandler = { | ||
value: string; | ||
params?: Array<any>; | ||
modifiers: ?ASTModifiers; | ||
dynamic?: boolean; | ||
start?: number; | ||
end?: number; | ||
}; | ||
|
||
declare type ASTElementHandlers = { | ||
[key: string]: ASTElementHandler | Array<ASTElementHandler>; | ||
}; | ||
|
||
declare type ASTDirective = { | ||
name: string; | ||
rawName: string; | ||
value: string; | ||
arg: ?string; | ||
isDynamicArg: boolean; | ||
modifiers: ?ASTModifiers; | ||
start?: number; | ||
end?: number; | ||
}; | ||
|
||
declare type ASTNode = ASTElement | ASTText | ASTExpression; | ||
|
||
declare 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; | ||
slotTarget?: ?string; | ||
slotTargetDynamic?: boolean; | ||
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; | ||
start?: number; | ||
end?: number; | ||
}; | ||
|
||
declare type ASTText = { | ||
type: 3; | ||
text: string; | ||
static?: boolean; | ||
isComment?: boolean; | ||
// 2.4 ssr optimization | ||
ssrOptimizability?: number; | ||
start?: number; | ||
end?: 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>; | ||
errors: Array<string | WarningMessage>; | ||
} | ||
|
||
declare type SFCBlock = { | ||
type: string; | ||
content: string; | ||
attrs: {[attribute:string]: string}; | ||
start?: number; | ||
end?: number; | ||
lang?: string; | ||
src?: string; | ||
scoped?: boolean; | ||
module?: string | boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import type { Config } from '../src/core/config' | ||
import type VNode from '../src/core/vdom/vnode' | ||
import type Watcher from '../src/core/observer/watcher' | ||
|
||
declare interface Component { | ||
// constructor information | ||
static cid: number; | ||
static options: Object; | ||
// extend | ||
static extend: (options: Object) => Function; | ||
static superOptions: Object; | ||
static extendOptions: Object; | ||
static sealedOptions: Object; | ||
static super: Class<Component>; | ||
// assets | ||
static directive: (id: string, def?: Function | Object) => Function | Object | void; | ||
static component: (id: string, def?: Class<Component> | Object) => Class<Component>; | ||
static filter: (id: string, def?: Function) => Function | void; | ||
// functional context constructor | ||
static FunctionalRenderContext: Function; | ||
|
||
// public properties | ||
$el: any; // so that we can attach __vue__ to it | ||
$data: Object; | ||
$props: Object; | ||
$options: ComponentOptions; | ||
$parent: Component | void; | ||
$root: Component; | ||
$children: Array<Component>; | ||
$refs: { [key: string]: Component | Element | Array<Component | Element> | void }; | ||
$slots: { [key: string]: Array<VNode> }; | ||
$scopedSlots: { [key: string]: () => VNodeChildren }; | ||
$vnode: VNode; // the placeholder node for the component in parent's render tree | ||
$attrs: { [key: string] : string }; | ||
$listeners: { [key: string]: Function | Array<Function> }; | ||
$isServer: boolean; | ||
|
||
// public methods | ||
$mount: (el?: Element | string, hydrating?: boolean) => Component; | ||
$forceUpdate: () => void; | ||
$destroy: () => void; | ||
$set: <T>(target: Object | Array<T>, key: string | number, val: T) => T; | ||
$delete: <T>(target: Object | Array<T>, key: string | number) => void; | ||
$watch: (expOrFn: string | Function, cb: Function, options?: Object) => Function; | ||
$on: (event: string | Array<string>, fn: Function) => Component; | ||
$once: (event: string, fn: Function) => Component; | ||
$off: (event?: string | Array<string>, fn?: Function) => Component; | ||
$emit: (event: string, ...args: Array<mixed>) => Component; | ||
$nextTick: (fn: Function) => void | Promise<*>; | ||
$createElement: (tag?: string | Component, data?: Object, children?: VNodeChildren) => VNode; | ||
|
||
// private properties | ||
_uid: number | string; | ||
_name: string; // this only exists in dev mode | ||
_isVue: true; | ||
_self: Component; | ||
_renderProxy: Component; | ||
_renderContext: ?Component; | ||
_watcher: Watcher; | ||
_watchers: Array<Watcher>; | ||
_computedWatchers: { [key: string]: Watcher }; | ||
_data: Object; | ||
_props: Object; | ||
_events: Object; | ||
_inactive: boolean | null; | ||
_directInactive: boolean; | ||
_isMounted: boolean; | ||
_isDestroyed: boolean; | ||
_isBeingDestroyed: boolean; | ||
_vnode: ?VNode; // self root node | ||
_staticTrees: ?Array<VNode>; // v-once cached trees | ||
_hasHookEvent: boolean; | ||
_provided: ?Object; | ||
// _virtualComponents?: { [key: string]: Component }; | ||
|
||
// private methods | ||
|
||
// lifecycle | ||
_init: Function; | ||
_mount: (el?: Element | void, hydrating?: boolean) => Component; | ||
_update: (vnode: VNode, hydrating?: boolean) => void; | ||
|
||
// rendering | ||
_render: () => VNode; | ||
|
||
__patch__: ( | ||
a: Element | VNode | void, | ||
b: VNode, | ||
hydrating?: boolean, | ||
removeOnly?: boolean, | ||
parentElm?: any, | ||
refElm?: any | ||
) => any; | ||
|
||
// createElement | ||
|
||
// _c is internal that accepts `normalizationType` optimization hint | ||
_c: ( | ||
vnode?: VNode, | ||
data?: VNodeData, | ||
children?: VNodeChildren, | ||
normalizationType?: number | ||
) => VNode | void; | ||
|
||
// renderStatic | ||
_m: (index: number, isInFor?: boolean) => VNode | VNodeChildren; | ||
// markOnce | ||
_o: (vnode: VNode | Array<VNode>, index: number, key: string) => VNode | VNodeChildren; | ||
// toString | ||
_s: (value: mixed) => string; | ||
// text to VNode | ||
_v: (value: string | number) => VNode; | ||
// toNumber | ||
_n: (value: string) => number | string; | ||
// empty vnode | ||
_e: () => VNode; | ||
// loose equal | ||
_q: (a: mixed, b: mixed) => boolean; | ||
// loose indexOf | ||
_i: (arr: Array<mixed>, val: mixed) => number; | ||
// resolveFilter | ||
_f: (id: string) => Function; | ||
// renderList | ||
_l: (val: mixed, render: Function) => ?Array<VNode>; | ||
// renderSlot | ||
_t: (name: string, fallback: ?Array<VNode>, props: ?Object) => ?Array<VNode>; | ||
// apply v-bind object | ||
_b: (data: any, tag: string, value: any, asProp: boolean, isSync?: boolean) => VNodeData; | ||
// apply v-on object | ||
_g: (data: any, value: any) => VNodeData; | ||
// check custom keyCode | ||
_k: (eventKeyCode: number, key: string, builtInAlias?: number | Array<number>, eventKeyName?: string) => ?boolean; | ||
// resolve scoped slots | ||
_u: (scopedSlots: ScopedSlotsData, res?: Object) => { [key: string]: Function }; | ||
|
||
// SSR specific | ||
_ssrNode: Function; | ||
_ssrList: Function; | ||
_ssrEscape: Function; | ||
_ssrAttr: Function; | ||
_ssrAttrs: Function; | ||
_ssrDOMProps: Function; | ||
_ssrClass: Function; | ||
_ssrStyle: Function; | ||
|
||
// allow dynamic method registration | ||
[key: string]: any | ||
}; |
Oops, something went wrong.