component.js 3.3 KB

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