component.d.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. // private methods
  99. // lifecycle
  100. _init: Function
  101. _mount: (el?: Element | void, hydrating?: boolean) => Component
  102. _update: (vnode: VNode, hydrating?: boolean) => void
  103. // rendering
  104. _render: () => VNode
  105. __patch__: (
  106. a: Element | VNode | void | null,
  107. b: VNode | null,
  108. hydrating?: boolean,
  109. removeOnly?: boolean,
  110. parentElm?: any,
  111. refElm?: any
  112. ) => any
  113. // createElement
  114. // _c is internal that accepts `normalizationType` optimization hint
  115. _c: (
  116. vnode?: VNode,
  117. data?: VNodeData,
  118. children?: VNodeChildren,
  119. normalizationType?: number
  120. ) => VNode | void
  121. // renderStatic
  122. _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren
  123. // markOnce
  124. _o: (
  125. vnode: VNode | Array<VNode>,
  126. index: number,
  127. key: string
  128. ) => VNode | VNodeChildren
  129. // toString
  130. _s: (value: any) => string
  131. // text to VNode
  132. _v: (value: string | number) => VNode
  133. // toNumber
  134. _n: (value: string) => number | string
  135. // empty vnode
  136. _e: () => VNode
  137. // loose equal
  138. _q: (a: any, b: any) => boolean
  139. // loose indexOf
  140. _i: (arr: Array<any>, val: any) => number
  141. // resolveFilter
  142. _f: (id: string) => Function
  143. // renderList
  144. _l: (val: any, render: Function) => Array<VNode> | null
  145. // renderSlot
  146. _t: (
  147. name: string,
  148. fallback?: Array<VNode>,
  149. props?: Record<string, any>
  150. ) => Array<VNode> | null
  151. // apply v-bind object
  152. _b: (
  153. data: any,
  154. tag: string,
  155. value: any,
  156. asProp: boolean,
  157. isSync?: boolean
  158. ) => VNodeData
  159. // apply v-on object
  160. _g: (data: any, value: any) => VNodeData
  161. // check custom keyCode
  162. _k: (
  163. eventKeyCode: number,
  164. key: string,
  165. builtInAlias?: number | Array<number>,
  166. eventKeyName?: string
  167. ) => boolean | null
  168. // resolve scoped slots
  169. _u: (
  170. scopedSlots: ScopedSlotsData,
  171. res?: Record<string, any>
  172. ) => { [key: string]: Function }
  173. // SSR specific
  174. _ssrNode: Function
  175. _ssrList: Function
  176. _ssrEscape: Function
  177. _ssrAttr: Function
  178. _ssrAttrs: Function
  179. _ssrDOMProps: Function
  180. _ssrClass: Function
  181. _ssrStyle: Function;
  182. // allow dynamic method registration
  183. [key: string]: any
  184. }