component.d.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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: (el?: Element | string, hydrating?: boolean) => Component
  46. $forceUpdate: () => void
  47. $destroy: () => void
  48. $set: <T>(
  49. target: Record<string, any> | Array<T>,
  50. key: string | number,
  51. val: T
  52. ) => T
  53. $delete: <T>(
  54. target: Record<string, any> | Array<T>,
  55. key: string | number
  56. ) => void
  57. $watch: (
  58. expOrFn: string | (() => any),
  59. cb: Function,
  60. options?: Record<string, any>
  61. ) => Function
  62. $on: (event: string | Array<string>, fn: Function) => Component
  63. $once: (event: string, fn: Function) => Component
  64. $off: (event?: string | Array<string>, fn?: Function) => Component
  65. $emit: (event: string, ...args: Array<any>) => Component
  66. $nextTick: (fn: (...args: any[]) => any) => void | Promise<any>
  67. $createElement: (
  68. tag?: string | Component,
  69. data?: Record<string, any>,
  70. children?: VNodeChildren
  71. ) => VNode
  72. // private properties
  73. _uid: number | string
  74. _name: string // this only exists in dev mode
  75. _isVue: true
  76. __v_skip: true
  77. _self: Component
  78. _renderProxy: Component
  79. _renderContext?: Component
  80. _watcher: Watcher | null
  81. _scope: EffectScope
  82. _computedWatchers: { [key: string]: Watcher }
  83. _data: Record<string, any>
  84. _props: Record<string, any>
  85. _events: Record<string, any>
  86. _inactive: boolean | null
  87. _directInactive: boolean
  88. _isMounted: boolean
  89. _isDestroyed: boolean
  90. _isBeingDestroyed: boolean
  91. _vnode?: VNode | null // self root node
  92. _staticTrees?: Array<VNode> | null // v-once cached trees
  93. _hasHookEvent: boolean
  94. _provided?: Record<string, any>
  95. // _virtualComponents?: { [key: string]: Component };
  96. // @v3
  97. _setupState?: Record<string, any>
  98. _setupContext?: SetupContext
  99. _attrsProxy?: Record<string, any>
  100. _slotsProxy?: Record<string, () => VNode[]>
  101. _preWatchers?: Watcher[]
  102. // private methods
  103. // lifecycle
  104. _init: Function
  105. _mount: (el?: Element | void, hydrating?: boolean) => Component
  106. _update: (vnode: VNode, hydrating?: boolean) => void
  107. // rendering
  108. _render: () => VNode
  109. __patch__: (
  110. a: Element | VNode | void | null,
  111. b: VNode | null,
  112. hydrating?: boolean,
  113. removeOnly?: boolean,
  114. parentElm?: any,
  115. refElm?: any
  116. ) => any
  117. // createElement
  118. // _c is internal that accepts `normalizationType` optimization hint
  119. _c: (
  120. vnode?: VNode,
  121. data?: VNodeData,
  122. children?: VNodeChildren,
  123. normalizationType?: number
  124. ) => VNode | void
  125. // renderStatic
  126. _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren
  127. // markOnce
  128. _o: (
  129. vnode: VNode | Array<VNode>,
  130. index: number,
  131. key: string
  132. ) => VNode | VNodeChildren
  133. // toString
  134. _s: (value: any) => string
  135. // text to VNode
  136. _v: (value: string | number) => VNode
  137. // toNumber
  138. _n: (value: string) => number | string
  139. // empty vnode
  140. _e: () => VNode
  141. // loose equal
  142. _q: (a: any, b: any) => boolean
  143. // loose indexOf
  144. _i: (arr: Array<any>, val: any) => number
  145. // resolveFilter
  146. _f: (id: string) => Function
  147. // renderList
  148. _l: (val: any, render: Function) => Array<VNode> | null
  149. // renderSlot
  150. _t: (
  151. name: string,
  152. fallback?: Array<VNode>,
  153. props?: Record<string, any>
  154. ) => Array<VNode> | null
  155. // apply v-bind object
  156. _b: (
  157. data: any,
  158. tag: string,
  159. value: any,
  160. asProp: boolean,
  161. isSync?: boolean
  162. ) => VNodeData
  163. // apply v-on object
  164. _g: (data: any, value: any) => VNodeData
  165. // check custom keyCode
  166. _k: (
  167. eventKeyCode: number,
  168. key: string,
  169. builtInAlias?: number | Array<number>,
  170. eventKeyName?: string
  171. ) => boolean | null
  172. // resolve scoped slots
  173. _u: (
  174. scopedSlots: ScopedSlotsData,
  175. res?: Record<string, any>
  176. ) => { [key: string]: Function }
  177. // SSR specific
  178. _ssrNode: Function
  179. _ssrList: Function
  180. _ssrEscape: Function
  181. _ssrAttr: Function
  182. _ssrAttrs: Function
  183. _ssrDOMProps: Function
  184. _ssrClass: Function
  185. _ssrStyle: Function
  186. // allow dynamic method registration
  187. // [key: string]: any
  188. }