component.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import type VNode from '../src/core/vdom/vnode'
  2. import type Watcher from '../src/core/observer/watcher'
  3. import { ComponentOptions } from './options'
  4. import { ScopedSlotsData, VNodeChildren, VNodeData } from './vnode'
  5. import { GlobalAPI } from './global-api'
  6. // TODO this should be using the same as /component/
  7. export declare class Component {
  8. constructor(options?: any)
  9. // constructor information
  10. static cid: number
  11. static options: Record<string, any>
  12. // extend
  13. static extend: GlobalAPI['extend']
  14. static superOptions: Record<string, any>
  15. static extendOptions: Record<string, any>
  16. static sealedOptions: Record<string, any>
  17. static super: Component
  18. // assets
  19. static directive: GlobalAPI['directive']
  20. static component: GlobalAPI['component']
  21. static filter: GlobalAPI['filter']
  22. // functional context constructor
  23. static FunctionalRenderContext: Function
  24. static mixin: GlobalAPI['mixin']
  25. static use: GlobalAPI['use']
  26. // public properties
  27. $el: any // so that we can attach __vue__ to it
  28. $data: Record<string, any>
  29. $props: Record<string, any>
  30. $options: ComponentOptions
  31. $parent: Component | undefined
  32. $root: Component
  33. $children: Array<Component>
  34. $refs: {
  35. [key: string]: Component | Element | Array<Component | Element> | undefined
  36. }
  37. $slots: { [key: string]: Array<VNode> }
  38. $scopedSlots: { [key: string]: () => VNode[] | undefined }
  39. $vnode: VNode // the placeholder node for the component in parent's render tree
  40. $attrs: { [key: string]: string }
  41. $listeners: Record<string, Function | Array<Function>>
  42. $isServer: boolean
  43. // public methods
  44. $mount: (el?: Element | string, hydrating?: boolean) => Component
  45. $forceUpdate: () => void
  46. $destroy: () => void
  47. $set: <T>(
  48. target: Record<string, any> | Array<T>,
  49. key: string | number,
  50. val: T
  51. ) => T
  52. $delete: <T>(
  53. target: Record<string, any> | Array<T>,
  54. key: string | number
  55. ) => void
  56. $watch: (
  57. expOrFn: string | Function,
  58. cb: Function,
  59. options?: Record<string, any>
  60. ) => Function
  61. $on: (event: string | Array<string>, fn: Function) => Component
  62. $once: (event: string, fn: Function) => Component
  63. $off: (event?: string | Array<string>, fn?: Function) => Component
  64. $emit: (event: string, ...args: Array<any>) => Component
  65. $nextTick: (fn: Function) => void | Promise<any>
  66. $createElement: (
  67. tag?: string | Component,
  68. data?: Record<string, any>,
  69. children?: VNodeChildren
  70. ) => VNode
  71. // private properties
  72. _uid: number | string
  73. _name: string // this only exists in dev mode
  74. _isVue: true
  75. _self: Component
  76. _renderProxy: Component
  77. _renderContext?: Component
  78. _watcher: Watcher | null
  79. _watchers: Array<Watcher>
  80. _computedWatchers: { [key: string]: Watcher }
  81. _data: Record<string, any>
  82. _props: Record<string, any>
  83. _events: Record<string, any>
  84. _inactive: boolean | null
  85. _directInactive: boolean
  86. _isMounted: boolean
  87. _isDestroyed: boolean
  88. _isBeingDestroyed: boolean
  89. _vnode?: VNode | null // self root node
  90. _staticTrees?: Array<VNode> | null // v-once cached trees
  91. _hasHookEvent: boolean
  92. _provided?: Record<string, any>
  93. // _virtualComponents?: { [key: string]: Component };
  94. // @v3
  95. _setupState?: Record<string, any>
  96. _attrsProxy?: Record<string, any>
  97. _slotsProxy?: Record<string, () => VNode[]>
  98. _preWatchers?: Watcher[]
  99. // private methods
  100. // lifecycle
  101. _init: Function
  102. _mount: (el?: Element | void, hydrating?: boolean) => Component
  103. _update: (vnode: VNode, hydrating?: boolean) => void
  104. // rendering
  105. _render: () => VNode
  106. __patch__: (
  107. a: Element | VNode | void | null,
  108. b: VNode | null,
  109. hydrating?: boolean,
  110. removeOnly?: boolean,
  111. parentElm?: any,
  112. refElm?: any
  113. ) => any
  114. // createElement
  115. // _c is internal that accepts `normalizationType` optimization hint
  116. _c: (
  117. vnode?: VNode,
  118. data?: VNodeData,
  119. children?: VNodeChildren,
  120. normalizationType?: number
  121. ) => VNode | void
  122. // renderStatic
  123. _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren
  124. // markOnce
  125. _o: (
  126. vnode: VNode | Array<VNode>,
  127. index: number,
  128. key: string
  129. ) => VNode | VNodeChildren
  130. // toString
  131. _s: (value: any) => string
  132. // text to VNode
  133. _v: (value: string | number) => VNode
  134. // toNumber
  135. _n: (value: string) => number | string
  136. // empty vnode
  137. _e: () => VNode
  138. // loose equal
  139. _q: (a: any, b: any) => boolean
  140. // loose indexOf
  141. _i: (arr: Array<any>, val: any) => number
  142. // resolveFilter
  143. _f: (id: string) => Function
  144. // renderList
  145. _l: (val: any, render: Function) => Array<VNode> | null
  146. // renderSlot
  147. _t: (
  148. name: string,
  149. fallback?: Array<VNode>,
  150. props?: Record<string, any>
  151. ) => Array<VNode> | null
  152. // apply v-bind object
  153. _b: (
  154. data: any,
  155. tag: string,
  156. value: any,
  157. asProp: boolean,
  158. isSync?: boolean
  159. ) => VNodeData
  160. // apply v-on object
  161. _g: (data: any, value: any) => VNodeData
  162. // check custom keyCode
  163. _k: (
  164. eventKeyCode: number,
  165. key: string,
  166. builtInAlias?: number | Array<number>,
  167. eventKeyName?: string
  168. ) => boolean | null
  169. // resolve scoped slots
  170. _u: (
  171. scopedSlots: ScopedSlotsData,
  172. res?: Record<string, any>
  173. ) => { [key: string]: Function }
  174. // SSR specific
  175. _ssrNode: Function
  176. _ssrList: Function
  177. _ssrEscape: Function
  178. _ssrAttr: Function
  179. _ssrAttrs: Function
  180. _ssrDOMProps: Function
  181. _ssrClass: Function
  182. _ssrStyle: Function;
  183. // allow dynamic method registration
  184. [key: string]: any
  185. }