component.js 3.3 KB

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