component.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. declare interface Component {
  5. // constructor information
  6. static cid: number;
  7. static options: Object;
  8. // extend
  9. static extend: (options: Object) => Function;
  10. // assets
  11. static directive: (id: string, def?: Function | Object) => Function | Object | void;
  12. static component: (id: string, def?: Class<Component> | Object) => Class<Component>;
  13. static transition: (id: string, def?: Object) => Object | void;
  14. static filter: (id: string, def?: Function) => Function | void;
  15. // public properties
  16. $el: Element | void;
  17. $data: Object;
  18. $options: ComponentOptions;
  19. $parent: Component | void;
  20. $root: Component;
  21. $children: Array<Component>;
  22. $refs: { [key: string]: Component | Element | Array<Component | Element> | void };
  23. $slots: { [key: string]: Array<VNode> };
  24. $isServer: boolean;
  25. // public methods
  26. $mount: (el?: Element | string, hydrating?: boolean) => Component;
  27. $forceUpdate: () => void;
  28. $destroy: () => void;
  29. $watch: (expOrFn: string | Function, cb: Function, options?: Object) => Function;
  30. $on: (event: string, fn: Function) => Component;
  31. $once: (event: string, fn: Function) => Component;
  32. $off: (event?: string, fn?: Function) => Component;
  33. $emit: (event: string, ...args: Array<any>) => Component;
  34. $nextTick: (fn: Function) => void;
  35. $createElement: (
  36. tag?: string | Component,
  37. data?: Object,
  38. children?: VNodeChildren,
  39. namespace?: string
  40. ) => VNode;
  41. // private properties
  42. _uid: number;
  43. _isVue: true;
  44. _self: Component;
  45. _renderProxy: Component;
  46. _renderParent: ?Component;
  47. _watcher: Watcher;
  48. _watchers: Array<Watcher>;
  49. _data: Object;
  50. _events: Object;
  51. _isMounted: boolean;
  52. _isDestroyed: boolean;
  53. _isBeingDestroyed: boolean;
  54. _vnode: ?VNode;
  55. _staticTrees: ?Array<VNode>;
  56. // private methods
  57. // lifecycle
  58. _init: Function;
  59. _mount: (el?: Element | void, hydrating?: boolean) => Component;
  60. _update: (vnode: VNode, hydrating?: boolean) => void;
  61. _updateListeners: (listeners: Object, oldListeners: ?Object) => void;
  62. _updateFromParent: (
  63. propsData: ?Object,
  64. listeners: ?{ [key: string]: Function | Array<Function> },
  65. parentVnode: VNode,
  66. renderChildren: ?VNodeChildren
  67. ) => void;
  68. // rendering
  69. _render: () => VNode;
  70. __patch__: (a: Element | VNode | void, b: VNode) => Element;
  71. // renderElementWithChildren
  72. _h: (
  73. vnode?: VNode,
  74. children?: VNodeChildren
  75. ) => VNode | void;
  76. // renderElement
  77. _e: (
  78. tag?: string | Component | Object,
  79. data?: Object,
  80. namespace?: string
  81. ) => VNode | void;
  82. // renderText
  83. _t: (
  84. str?: string
  85. ) => string;
  86. // renderStaticTree
  87. _m: (
  88. index?: number
  89. ) => Object | void;
  90. // toString
  91. _s: (value: any) => string;
  92. // resolveFilter
  93. _f: (id: string) => Function;
  94. // renderList
  95. _l: (
  96. val: any,
  97. render: Function
  98. ) => ?Array<VNode>;
  99. // apply v-bind object
  100. _b: (vnode: VNodeWithData, value: any) => void;
  101. // allow dynamic method registration
  102. [key: string]: any
  103. }