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