component.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. import type StringNode from '../src/server/optimizing-compiler/runtime-helpers'
  5. declare interface Component {
  6. // constructor information
  7. static cid: number;
  8. static options: Object;
  9. // extend
  10. static extend: (options: Object) => Function;
  11. static superOptions: Object;
  12. static extendOptions: Object;
  13. static sealedOptions: Object;
  14. static super: Class<Component>;
  15. // assets
  16. static directive: (id: string, def?: Function | Object) => Function | Object | void;
  17. static component: (id: string, def?: Class<Component> | Object) => Class<Component>;
  18. static filter: (id: string, def?: Function) => Function | void;
  19. // public properties
  20. $el: any; // so that we can attach __vue__ to it
  21. $data: 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. $isServer: boolean;
  31. $props: Object;
  32. // public methods
  33. $mount: (el?: Element | string, hydrating?: boolean) => Component;
  34. $forceUpdate: () => void;
  35. $destroy: () => void;
  36. $set: <T>(target: Object | Array<T>, key: string | number, val: T) => T;
  37. $delete: <T>(target: Object | Array<T>, key: string | number) => void;
  38. $watch: (expOrFn: string | Function, cb: Function, options?: Object) => Function;
  39. $on: (event: string | Array<string>, fn: Function) => Component;
  40. $once: (event: string, fn: Function) => Component;
  41. $off: (event?: string | Array<string>, fn?: Function) => Component;
  42. $emit: (event: string, ...args: Array<mixed>) => Component;
  43. $nextTick: (fn: Function) => void | Promise<*>;
  44. $createElement: (tag?: string | Component, data?: Object, children?: VNodeChildren) => VNode;
  45. // private properties
  46. _uid: number;
  47. _name: string; // this only exists in dev mode
  48. _isVue: true;
  49. _self: Component;
  50. _renderProxy: Component;
  51. _renderContext: ?Component;
  52. _watcher: Watcher;
  53. _watchers: Array<Watcher>;
  54. _computedWatchers: { [key: string]: Watcher };
  55. _data: Object;
  56. _props: Object;
  57. _events: Object;
  58. _inactive: boolean | null;
  59. _directInactive: boolean;
  60. _isMounted: boolean;
  61. _isDestroyed: boolean;
  62. _isBeingDestroyed: boolean;
  63. _vnode: ?VNode; // self root node
  64. _staticTrees: ?Array<VNode>;
  65. _hasHookEvent: boolean;
  66. _provided: ?Object;
  67. // private methods
  68. // lifecycle
  69. _init: Function;
  70. _mount: (el?: Element | void, hydrating?: boolean) => Component;
  71. _update: (vnode: VNode, hydrating?: boolean) => void;
  72. // rendering
  73. _render: () => VNode;
  74. __patch__: (a: Element | VNode | void, b: VNode) => any;
  75. // createElement
  76. // _c is internal that accepts `normalizationType` optimization hint
  77. _c: (vnode?: VNode, data?: VNodeData, children?: VNodeChildren, normalizationType?: number) => VNode | void;
  78. // renderStatic
  79. _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren;
  80. // markOnce
  81. _o: (vnode: VNode | Array<VNode>, index: number, key: string) => VNode | VNodeChildren;
  82. // toString
  83. _s: (value: mixed) => string;
  84. // text to VNode
  85. _v: (value: string | number) => VNode;
  86. // toNumber
  87. _n: (value: string) => number | string;
  88. // empty vnode
  89. _e: () => VNode;
  90. // loose equal
  91. _q: (a: mixed, b: mixed) => boolean;
  92. // loose indexOf
  93. _i: (arr: Array<mixed>, val: mixed) => number;
  94. // resolveFilter
  95. _f: (id: string) => Function;
  96. // renderList
  97. _l: (val: mixed, render: Function) => ?Array<VNode>;
  98. // renderSlot
  99. _t: (name: string, fallback: ?Array<VNode>, props: ?Object) => ?Array<VNode>;
  100. // apply v-bind object
  101. _b: (data: any, value: any, asProp?: boolean) => VNodeData;
  102. // check custom keyCode
  103. _k: (eventKeyCode: number, key: string, builtInAlias: number | Array<number> | void) => boolean;
  104. // resolve scoped slots
  105. _u: (scopedSlots: ScopedSlotsData, res?: Object) => { [key: string]: Function };
  106. // SSR specific
  107. _ssrNode: (open: string, close?: string, ) => StringNode;
  108. _ssrList: (val: any, render: () => string) => string;
  109. _ssrEscape: (v: string) => string;
  110. // allow dynamic method registration
  111. [key: string]: any
  112. };