component.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 sealedOptions: Object;
  13. static super: Class<Component>;
  14. // assets
  15. static directive: (id: string, def?: Function | Object) => Function | Object | void;
  16. static component: (id: string, def?: Class<Component> | Object) => Class<Component>;
  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. $props: Object;
  22. $options: ComponentOptions;
  23. $parent: Component | void;
  24. $root: Component;
  25. $children: Array<Component>;
  26. $refs: { [key: string]: Component | Element | Array<Component | Element> | void };
  27. $slots: { [key: string]: Array<VNode> };
  28. $scopedSlots: { [key: string]: () => VNodeChildren };
  29. $vnode: VNode; // the placeholder node for the component in parent's render tree
  30. $attrs: { [key: string] : string };
  31. $listeners: { [key: string]: Function | Array<Function> };
  32. $isServer: boolean;
  33. // public methods
  34. $mount: (el?: Element | string, hydrating?: boolean) => Component;
  35. $forceUpdate: () => void;
  36. $destroy: () => void;
  37. $set: <T>(target: Object | Array<T>, key: string | number, val: T) => T;
  38. $delete: <T>(target: Object | Array<T>, key: string | number) => void;
  39. $watch: (expOrFn: string | Function, cb: Function, options?: Object) => Function;
  40. $on: (event: string | Array<string>, fn: Function) => Component;
  41. $once: (event: string, fn: Function) => Component;
  42. $off: (event?: string | Array<string>, fn?: Function) => Component;
  43. $emit: (event: string, ...args: Array<mixed>) => Component;
  44. $nextTick: (fn: Function) => void | Promise<*>;
  45. $createElement: (tag?: string | Component, data?: Object, children?: VNodeChildren) => VNode;
  46. // private properties
  47. _uid: number | string;
  48. _name: string; // this only exists in dev mode
  49. _isVue: true;
  50. _self: Component;
  51. _renderProxy: Component;
  52. _renderContext: ?Component;
  53. _watcher: Watcher;
  54. _watchers: Array<Watcher>;
  55. _computedWatchers: { [key: string]: Watcher };
  56. _data: Object;
  57. _props: Object;
  58. _events: Object;
  59. _inactive: boolean | null;
  60. _directInactive: boolean;
  61. _isMounted: boolean;
  62. _isDestroyed: boolean;
  63. _isBeingDestroyed: boolean;
  64. _vnode: ?VNode; // self root node
  65. _staticTrees: ?Array<VNode>; // v-once cached trees
  66. _hasHookEvent: boolean;
  67. _provided: ?Object;
  68. _inlineComputed: ?{ [key: string]: Watcher }; // inline computed watchers for literal props
  69. // private methods
  70. // lifecycle
  71. _init: Function;
  72. _mount: (el?: Element | void, hydrating?: boolean) => Component;
  73. _update: (vnode: VNode, hydrating?: boolean) => void;
  74. // rendering
  75. _render: () => VNode;
  76. __patch__: (
  77. a: Element | VNode | void,
  78. b: VNode,
  79. hydrating?: boolean,
  80. removeOnly?: boolean,
  81. parentElm?: any,
  82. refElm?: any
  83. ) => any;
  84. // createElement
  85. // _c is internal that accepts `normalizationType` optimization hint
  86. _c: (
  87. vnode?: VNode,
  88. data?: VNodeData,
  89. children?: VNodeChildren,
  90. normalizationType?: number
  91. ) => VNode | void;
  92. // renderStatic
  93. _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren;
  94. // markOnce
  95. _o: (vnode: VNode | Array<VNode>, index: number, key: string) => VNode | VNodeChildren;
  96. // toString
  97. _s: (value: mixed) => string;
  98. // text to VNode
  99. _v: (value: string | number) => VNode;
  100. // toNumber
  101. _n: (value: string) => number | string;
  102. // empty vnode
  103. _e: () => VNode;
  104. // loose equal
  105. _q: (a: mixed, b: mixed) => boolean;
  106. // loose indexOf
  107. _i: (arr: Array<mixed>, val: mixed) => number;
  108. // resolveFilter
  109. _f: (id: string) => Function;
  110. // renderList
  111. _l: (val: mixed, render: Function) => ?Array<VNode>;
  112. // renderSlot
  113. _t: (name: string, fallback: ?Array<VNode>, props: ?Object) => ?Array<VNode>;
  114. // apply v-bind object
  115. _b: (data: any, tag: string, value: any, asProp: boolean, isSync?: boolean) => VNodeData;
  116. // apply v-on object
  117. _g: (data: any, value: any) => VNodeData;
  118. // check custom keyCode
  119. _k: (eventKeyCode: number, key: string, builtInAlias?: number | Array<number>, eventKeyName?: string) => ?boolean;
  120. // resolve scoped slots
  121. _u: (scopedSlots: ScopedSlotsData, res?: Object) => { [key: string]: Function };
  122. // create / return value from inline computed
  123. _a: (id: number, getter: Function) => any;
  124. // SSR specific
  125. _ssrNode: Function;
  126. _ssrList: Function;
  127. _ssrEscape: Function;
  128. _ssrAttr: Function;
  129. _ssrAttrs: Function;
  130. _ssrDOMProps: Function;
  131. _ssrClass: Function;
  132. _ssrStyle: Function;
  133. // allow dynamic method registration
  134. [key: string]: any
  135. };