component.d.ts 5.5 KB

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