component.d.ts 5.3 KB

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