component.ts 5.5 KB

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