component.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. // assets
  11. static directive: (id: string, def?: Function | Object) => Function | Object | void;
  12. static component: (id: string, def?: Class<Component> | Object) => Class<Component>;
  13. static transition: (id: string, def?: Object) => Object | void;
  14. static filter: (id: string, def?: Function) => Function | void;
  15. // public properties
  16. $el: Element | void;
  17. $data: Object;
  18. $options: ComponentOptions;
  19. $parent: Component | void;
  20. $root: Component;
  21. $children: Array<Component>;
  22. $refs: { [key: string]: Component | Element | Array<Component | Element> | void };
  23. $slots: { [key: string]: Array<VNode> };
  24. $isServer: boolean;
  25. // public methods
  26. $mount: (el?: Element | string) => Component;
  27. $forceUpdate: () => void;
  28. $destroy: () => void;
  29. $watch: (expOrFn: string | Function, cb: Function, options?: Object) => Function;
  30. $on: (event: string, fn: Function) => Component;
  31. $once: (event: string, fn: Function) => Component;
  32. $off: (event?: string, fn?: Function) => Component;
  33. $emit: (event: string, ...args: Array<any>) => Component;
  34. $nextTick: (fn: Function) => void;
  35. $createElement: (
  36. tag?: string | Component,
  37. data?: Object,
  38. children?: VNodeChildren,
  39. namespace?: string
  40. ) => VNode;
  41. // private properties
  42. _uid: number;
  43. _isVue: true;
  44. _renderProxy: Component;
  45. _watcher: Watcher;
  46. _watchers: Array<Watcher>;
  47. _data: Object;
  48. _events: Object;
  49. _isMounted: boolean;
  50. _isDestroyed: boolean;
  51. _isBeingDestroyed: boolean;
  52. _vnode: ?VNode;
  53. _staticTrees: ?Array<VNode>;
  54. // private methods
  55. // lifecycle
  56. _init: Function;
  57. _mount: () => Component;
  58. _update: (vnode: VNode) => void;
  59. _updateFromParent: (
  60. propsData: ?Object,
  61. listeners: ?{ [key: string]: Function | Array<Function> },
  62. parentVnode: VNode,
  63. renderChildren: ?VNodeChildren
  64. ) => void;
  65. // rendering
  66. _render: () => VNode;
  67. __patch__: (a: Element | VNode | void, b: VNode) => Element;
  68. __r__: (
  69. vnode?: VNode,
  70. children?: VNodeChildren
  71. ) => VNode | void;
  72. __s__: (
  73. tag?: string | Component | Object,
  74. data?: Object,
  75. namespace?: string
  76. ) => VNode | void;
  77. __t__: (
  78. str?: string
  79. ) => string;
  80. __m__: (
  81. index?: number
  82. ) => Object | void;
  83. __toString__: (value: any) => string;
  84. __resolveFilter__: (id: string) => Function;
  85. __renderList__: (
  86. val: any,
  87. render: Function
  88. ) => ?Array<VNode>;
  89. __registerRef__: (
  90. key: string,
  91. ref: Component | Element,
  92. vFor: boolean,
  93. isRemoval: boolean
  94. ) => void;
  95. // allow dynamic method registration
  96. [key: string]: any
  97. }