component.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. _isMounted: boolean;
  55. _isDestroyed: boolean;
  56. _isBeingDestroyed: boolean;
  57. _vnode: ?VNode;
  58. _staticTrees: ?Array<VNode>;
  59. // private methods
  60. // lifecycle
  61. _init: Function;
  62. _mount: (el?: Element | void, hydrating?: boolean) => Component;
  63. _update: (vnode: VNode, hydrating?: boolean) => void;
  64. _updateListeners: (listeners: Object, oldListeners: ?Object) => void;
  65. _updateFromParent: (
  66. propsData: ?Object,
  67. listeners: ?{ [key: string]: Function | Array<Function> },
  68. parentVnode: VNode,
  69. renderChildren: ?VNodeChildren
  70. ) => void;
  71. // rendering
  72. _render: () => VNode;
  73. __patch__: (a: Element | VNode | void, b: VNode) => any;
  74. // renderElementWithChildren
  75. _h: (
  76. vnode?: VNode,
  77. children?: VNodeChildren
  78. ) => VNode | void;
  79. // renderElement
  80. _e: (
  81. tag?: string | Component | Object,
  82. data?: Object,
  83. namespace?: string
  84. ) => VNode | void;
  85. // renderStaticTree
  86. _m: (
  87. index?: number
  88. ) => Object | void;
  89. // toString
  90. _s: (value: any) => string;
  91. // toNumber
  92. _n: (value: string) => number | string;
  93. // resolveFilter
  94. _f: (id: string) => Function;
  95. // renderList
  96. _l: (
  97. val: any,
  98. render: Function
  99. ) => ?Array<VNode>;
  100. // apply v-bind object
  101. _b: (vnode: VNodeWithData, value: any) => void;
  102. // retrive custom keyCode
  103. _k: (key: string) => ?number;
  104. // allow dynamic method registration
  105. [key: string]: any
  106. }