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