vue 2.6.13 → 2.7.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/README.md +17 -295
  2. package/compiler-sfc/index.d.ts +1 -0
  3. package/compiler-sfc/index.js +1 -0
  4. package/compiler-sfc/index.mjs +1 -0
  5. package/compiler-sfc/package.json +5 -0
  6. package/dist/vue.common.dev.js +11481 -11946
  7. package/dist/vue.common.prod.js +8 -3
  8. package/dist/vue.esm.browser.js +11321 -12011
  9. package/dist/vue.esm.browser.min.js +8 -3
  10. package/dist/vue.esm.js +11476 -11984
  11. package/dist/vue.js +11484 -11949
  12. package/dist/vue.min.js +8 -3
  13. package/dist/vue.runtime.common.dev.js +8427 -8421
  14. package/dist/vue.runtime.common.prod.js +8 -3
  15. package/dist/vue.runtime.esm.js +8436 -8454
  16. package/dist/vue.runtime.js +8430 -8424
  17. package/dist/vue.runtime.min.js +8 -3
  18. package/package.json +88 -111
  19. package/packages/compiler-sfc/dist/compiler-sfc.js +7 -0
  20. package/packages/compiler-sfc/node_modules/.bin/parser +17 -0
  21. package/packages/compiler-sfc/node_modules/.bin/sass +17 -0
  22. package/packages/compiler-sfc/package.json +30 -0
  23. package/src/compiler/{codeframe.js → codeframe.ts} +9 -7
  24. package/src/compiler/codegen/{events.js → events.ts} +21 -41
  25. package/src/compiler/codegen/{index.js → index.ts} +146 -136
  26. package/src/compiler/{create-compiler.js → create-compiler.ts} +26 -18
  27. package/src/compiler/directives/bind.ts +9 -0
  28. package/src/compiler/directives/{index.js → index.ts} +0 -2
  29. package/src/compiler/directives/{model.js → model.ts} +15 -18
  30. package/src/compiler/directives/{on.js → on.ts} +3 -4
  31. package/src/compiler/{error-detector.js → error-detector.ts} +61 -31
  32. package/src/compiler/{helpers.js → helpers.ts} +73 -61
  33. package/src/compiler/{index.js → index.ts} +2 -3
  34. package/src/compiler/{optimizer.js → optimizer.ts} +30 -23
  35. package/src/compiler/parser/{entity-decoder.js → entity-decoder.ts} +1 -3
  36. package/src/compiler/parser/{filter-parser.js → filter-parser.ts} +43 -24
  37. package/src/compiler/parser/{html-parser.js → html-parser.ts} +50 -29
  38. package/src/compiler/parser/{index.js → index.ts} +190 -172
  39. package/src/compiler/parser/{text-parser.js → text-parser.ts} +8 -9
  40. package/src/compiler/{to-function.js → to-function.ts} +27 -22
  41. package/src/core/components/{index.js → index.ts} +0 -0
  42. package/src/core/components/{keep-alive.js → keep-alive.ts} +42 -30
  43. package/src/core/{config.js → config.ts} +28 -30
  44. package/src/core/global-api/{assets.js → assets.ts} +8 -7
  45. package/src/core/global-api/{extend.js → extend.ts} +10 -13
  46. package/src/core/global-api/{index.js → index.ts} +4 -5
  47. package/src/core/global-api/{mixin.js → mixin.ts} +2 -3
  48. package/src/core/global-api/use.ts +23 -0
  49. package/src/core/{index.js → index.ts} +1 -1
  50. package/src/core/instance/{events.js → events.ts} +41 -24
  51. package/src/core/instance/{index.js → index.ts} +9 -5
  52. package/src/core/instance/{init.js → init.ts} +26 -15
  53. package/src/core/instance/inject.ts +72 -0
  54. package/src/core/instance/{lifecycle.js → lifecycle.ts} +86 -44
  55. package/src/core/instance/{proxy.js → proxy.ts} +29 -24
  56. package/src/core/instance/render-helpers/{bind-dynamic-keys.js → bind-dynamic-keys.ts} +6 -5
  57. package/src/core/instance/render-helpers/{bind-object-listeners.js → bind-object-listeners.ts} +4 -8
  58. package/src/core/instance/render-helpers/{bind-object-props.js → bind-object-props.ts} +12 -17
  59. package/src/core/instance/render-helpers/{check-keycodes.js → check-keycodes.ts} +5 -7
  60. package/src/core/instance/render-helpers/{index.js → index.ts} +1 -3
  61. package/src/core/instance/render-helpers/{render-list.js → render-list.ts} +12 -13
  62. package/src/core/instance/render-helpers/{render-slot.js → render-slot.ts} +10 -11
  63. package/src/core/instance/render-helpers/{render-static.js → render-static.ts} +7 -10
  64. package/src/core/instance/render-helpers/{resolve-filter.js → resolve-filter.ts} +1 -3
  65. package/src/core/instance/render-helpers/{resolve-scoped-slots.js → resolve-scoped-slots.ts} +11 -8
  66. package/src/core/instance/render-helpers/{resolve-slots.js → resolve-slots.ts} +12 -11
  67. package/src/core/instance/{render.js → render.ts} +66 -29
  68. package/src/core/instance/{state.js → state.ts} +100 -83
  69. package/src/core/observer/{array.js → array.ts} +11 -2
  70. package/src/core/observer/{dep.js → dep.ts} +37 -15
  71. package/src/core/observer/{index.js → index.ts} +137 -71
  72. package/src/core/observer/{scheduler.js → scheduler.ts} +42 -43
  73. package/src/core/observer/{traverse.js → traverse.ts} +10 -7
  74. package/src/core/observer/{watcher.js → watcher.ts} +88 -60
  75. package/src/core/util/{debug.js → debug.ts} +38 -34
  76. package/src/core/util/{env.js → env.ts} +27 -30
  77. package/src/core/util/{error.js → error.ts} +12 -14
  78. package/src/core/util/{index.js → index.ts} +0 -2
  79. package/src/core/util/{lang.js → lang.ts} +6 -7
  80. package/src/core/util/{next-tick.js → next-tick.ts} +16 -10
  81. package/src/core/util/{options.js → options.ts} +119 -114
  82. package/src/core/util/{perf.js → perf.ts} +5 -1
  83. package/src/core/util/{props.js → props.ts} +54 -50
  84. package/src/core/vdom/{create-component.js → create-component.ts} +51 -50
  85. package/src/core/vdom/{create-element.js → create-element.ts} +49 -43
  86. package/src/core/vdom/{create-functional-component.js → create-functional-component.ts} +52 -27
  87. package/src/core/vdom/helpers/{extract-props.js → extract-props.ts} +18 -18
  88. package/src/core/vdom/helpers/{get-first-component-child.js → get-first-component-child.ts} +6 -5
  89. package/src/core/vdom/helpers/{index.js → index.ts} +0 -2
  90. package/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
  91. package/src/core/vdom/helpers/{merge-hook.js → merge-hook.ts} +7 -5
  92. package/src/core/vdom/helpers/{normalize-children.js → normalize-children.ts} +26 -16
  93. package/src/core/vdom/helpers/{normalize-scoped-slots.js → normalize-scoped-slots.ts} +23 -17
  94. package/src/core/vdom/helpers/{resolve-async-component.js → resolve-async-component.ts} +29 -37
  95. package/src/core/vdom/helpers/update-listeners.ts +101 -0
  96. package/src/core/vdom/modules/{directives.js → directives.ts} +20 -14
  97. package/src/core/vdom/modules/index.ts +4 -0
  98. package/src/core/vdom/modules/template-ref.ts +96 -0
  99. package/src/core/vdom/{patch.js → patch.ts} +239 -138
  100. package/src/core/vdom/{vnode.js → vnode.ts} +36 -31
  101. package/src/global.d.ts +15 -0
  102. package/src/platforms/web/compiler/directives/html.ts +8 -0
  103. package/src/platforms/web/compiler/directives/{index.js → index.ts} +0 -0
  104. package/src/platforms/web/compiler/directives/{model.js → model.ts} +47 -41
  105. package/src/platforms/web/compiler/directives/{text.js → text.ts} +2 -3
  106. package/src/platforms/web/compiler/{index.js → index.ts} +0 -2
  107. package/src/platforms/web/compiler/modules/{class.js → class.ts} +10 -15
  108. package/src/platforms/web/compiler/modules/{index.js → index.ts} +1 -5
  109. package/src/platforms/web/compiler/modules/{model.js → model.ts} +6 -11
  110. package/src/platforms/web/compiler/modules/{style.js → style.ts} +9 -14
  111. package/src/platforms/web/compiler/{options.js → options.ts} +1 -2
  112. package/src/platforms/web/compiler/{util.js → util.ts} +5 -7
  113. package/src/platforms/web/entry-compiler-sfc.ts +1 -0
  114. package/src/platforms/web/{entry-compiler.js → entry-compiler.ts} +1 -3
  115. package/src/platforms/web/{entry-runtime.js → entry-runtime-esm.ts} +2 -2
  116. package/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
  117. package/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
  118. package/src/platforms/web/entry-runtime.ts +7 -0
  119. package/src/platforms/web/runtime/{class-util.js → class-util.ts} +2 -4
  120. package/src/platforms/web/runtime/components/{index.js → index.ts} +0 -0
  121. package/src/platforms/web/runtime/components/{transition-group.js → transition-group.ts} +59 -46
  122. package/src/platforms/web/runtime/components/{transition.js → transition.ts} +43 -36
  123. package/src/platforms/web/runtime/directives/{index.js → index.ts} +0 -0
  124. package/src/platforms/web/runtime/directives/{model.js → model.ts} +22 -21
  125. package/src/platforms/web/runtime/directives/{show.js → show.ts} +11 -10
  126. package/src/platforms/web/runtime/{index.js → index.ts} +9 -10
  127. package/src/platforms/web/runtime/modules/{attrs.js → attrs.ts} +12 -16
  128. package/src/platforms/web/runtime/modules/{class.js → class.ts} +7 -18
  129. package/src/platforms/web/runtime/modules/{dom-props.js → dom-props.ts} +24 -17
  130. package/src/platforms/web/runtime/modules/{events.js → events.ts} +22 -15
  131. package/src/platforms/web/runtime/modules/{index.js → index.ts} +1 -8
  132. package/src/platforms/web/runtime/modules/{style.js → style.ts} +24 -13
  133. package/src/platforms/web/runtime/modules/{transition.js → transition.ts} +61 -63
  134. package/src/platforms/web/runtime/node-ops.ts +66 -0
  135. package/src/platforms/web/runtime/{patch.js → patch.ts} +0 -2
  136. package/src/platforms/web/runtime/{transition-util.js → transition-util.ts} +63 -38
  137. package/src/platforms/web/{entry-runtime-with-compiler.js → runtime-with-compiler.ts} +28 -19
  138. package/src/platforms/web/util/{attrs.js → attrs.ts} +18 -14
  139. package/src/platforms/web/util/{class.js → class.ts} +23 -21
  140. package/src/platforms/web/util/{compat.js → compat.ts} +4 -4
  141. package/src/platforms/web/util/{element.js → element.ts} +21 -22
  142. package/src/platforms/web/util/{index.js → index.ts} +2 -6
  143. package/src/platforms/web/util/{style.js → style.ts} +12 -12
  144. package/src/sfc/{parser.js → parser.ts} +18 -15
  145. package/src/shared/{constants.js → constants.ts} +2 -6
  146. package/src/shared/{util.js → util.ts} +78 -55
  147. package/src/types/compiler.ts +224 -0
  148. package/src/types/component.ts +209 -0
  149. package/src/types/global-api.ts +37 -0
  150. package/src/types/modules.d.ts +15 -0
  151. package/src/types/options.ts +120 -0
  152. package/src/types/ssr.ts +27 -0
  153. package/src/types/utils.ts +3 -0
  154. package/src/types/vnode.ts +127 -0
  155. package/src/v3/apiInject.ts +66 -0
  156. package/src/v3/apiLifecycle.ts +53 -0
  157. package/src/v3/apiSetup.ts +161 -0
  158. package/src/v3/apiWatch.ts +355 -0
  159. package/src/v3/currentInstance.ts +23 -0
  160. package/src/v3/debug.ts +21 -0
  161. package/src/v3/h.ts +18 -0
  162. package/src/v3/index.ts +77 -0
  163. package/src/v3/reactivity/computed.ts +100 -0
  164. package/src/v3/reactivity/effect.ts +20 -0
  165. package/src/v3/reactivity/effectScope.ts +134 -0
  166. package/src/v3/reactivity/operations.ts +14 -0
  167. package/src/v3/reactivity/reactive.ts +123 -0
  168. package/src/v3/reactivity/readonly.ts +121 -0
  169. package/src/v3/reactivity/ref.ts +249 -0
  170. package/types/index.d.ts +10 -13
  171. package/types/options.d.ts +265 -132
  172. package/types/plugin.d.ts +4 -4
  173. package/types/umd.d.ts +47 -27
  174. package/types/v3-generated.d.ts +389 -0
  175. package/types/v3.d.ts +16 -0
  176. package/types/vnode.d.ts +70 -57
  177. package/types/vue.d.ts +292 -88
  178. package/dist/README.md +0 -122
  179. package/src/compiler/directives/bind.js +0 -11
  180. package/src/core/global-api/use.js +0 -23
  181. package/src/core/instance/inject.js +0 -73
  182. package/src/core/vdom/helpers/is-async-placeholder.js +0 -5
  183. package/src/core/vdom/helpers/update-listeners.js +0 -95
  184. package/src/core/vdom/modules/index.js +0 -7
  185. package/src/core/vdom/modules/ref.js +0 -45
  186. package/src/platforms/web/compiler/directives/html.js +0 -9
  187. package/src/platforms/web/entry-server-basic-renderer.js +0 -13
  188. package/src/platforms/web/entry-server-renderer.js +0 -27
  189. package/src/platforms/web/runtime/node-ops.js +0 -59
  190. package/src/platforms/web/server/compiler.js +0 -11
  191. package/src/platforms/web/server/directives/index.js +0 -7
  192. package/src/platforms/web/server/directives/model.js +0 -44
  193. package/src/platforms/web/server/directives/show.js +0 -12
  194. package/src/platforms/web/server/modules/attrs.js +0 -67
  195. package/src/platforms/web/server/modules/class.js +0 -11
  196. package/src/platforms/web/server/modules/dom-props.js +0 -50
  197. package/src/platforms/web/server/modules/index.js +0 -11
  198. package/src/platforms/web/server/modules/style.js +0 -41
  199. package/src/platforms/web/server/util.js +0 -101
  200. package/src/platforms/weex/compiler/directives/index.js +0 -5
  201. package/src/platforms/weex/compiler/directives/model.js +0 -33
  202. package/src/platforms/weex/compiler/index.js +0 -52
  203. package/src/platforms/weex/compiler/modules/append.js +0 -27
  204. package/src/platforms/weex/compiler/modules/class.js +0 -74
  205. package/src/platforms/weex/compiler/modules/index.js +0 -13
  206. package/src/platforms/weex/compiler/modules/props.js +0 -37
  207. package/src/platforms/weex/compiler/modules/recycle-list/component-root.js +0 -13
  208. package/src/platforms/weex/compiler/modules/recycle-list/component.js +0 -16
  209. package/src/platforms/weex/compiler/modules/recycle-list/index.js +0 -60
  210. package/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js +0 -50
  211. package/src/platforms/weex/compiler/modules/recycle-list/text.js +0 -23
  212. package/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +0 -21
  213. package/src/platforms/weex/compiler/modules/recycle-list/v-for.js +0 -33
  214. package/src/platforms/weex/compiler/modules/recycle-list/v-if.js +0 -63
  215. package/src/platforms/weex/compiler/modules/recycle-list/v-on.js +0 -25
  216. package/src/platforms/weex/compiler/modules/recycle-list/v-once.js +0 -19
  217. package/src/platforms/weex/compiler/modules/style.js +0 -87
  218. package/src/platforms/weex/entry-compiler.js +0 -2
  219. package/src/platforms/weex/entry-framework.js +0 -187
  220. package/src/platforms/weex/entry-runtime-factory.js +0 -6
  221. package/src/platforms/weex/runtime/components/index.js +0 -9
  222. package/src/platforms/weex/runtime/components/richtext.js +0 -82
  223. package/src/platforms/weex/runtime/components/transition-group.js +0 -148
  224. package/src/platforms/weex/runtime/components/transition.js +0 -9
  225. package/src/platforms/weex/runtime/directives/index.js +0 -2
  226. package/src/platforms/weex/runtime/index.js +0 -42
  227. package/src/platforms/weex/runtime/modules/attrs.js +0 -44
  228. package/src/platforms/weex/runtime/modules/class.js +0 -76
  229. package/src/platforms/weex/runtime/modules/events.js +0 -54
  230. package/src/platforms/weex/runtime/modules/index.js +0 -13
  231. package/src/platforms/weex/runtime/modules/style.js +0 -84
  232. package/src/platforms/weex/runtime/modules/transition.js +0 -270
  233. package/src/platforms/weex/runtime/node-ops.js +0 -91
  234. package/src/platforms/weex/runtime/patch.js +0 -16
  235. package/src/platforms/weex/runtime/recycle-list/render-component-template.js +0 -34
  236. package/src/platforms/weex/runtime/recycle-list/virtual-component.js +0 -136
  237. package/src/platforms/weex/runtime/text-node.js +0 -9
  238. package/src/platforms/weex/util/element.js +0 -52
  239. package/src/platforms/weex/util/index.js +0 -40
  240. package/src/platforms/weex/util/parser.js +0 -60
  241. package/src/server/bundle-renderer/create-bundle-renderer.js +0 -151
  242. package/src/server/bundle-renderer/create-bundle-runner.js +0 -150
  243. package/src/server/bundle-renderer/source-map-support.js +0 -45
  244. package/src/server/create-basic-renderer.js +0 -37
  245. package/src/server/create-renderer.js +0 -152
  246. package/src/server/optimizing-compiler/codegen.js +0 -264
  247. package/src/server/optimizing-compiler/index.js +0 -20
  248. package/src/server/optimizing-compiler/modules.js +0 -124
  249. package/src/server/optimizing-compiler/optimizer.js +0 -141
  250. package/src/server/optimizing-compiler/runtime-helpers.js +0 -150
  251. package/src/server/render-context.js +0 -130
  252. package/src/server/render-stream.js +0 -95
  253. package/src/server/render.js +0 -437
  254. package/src/server/template-renderer/create-async-file-mapper.js +0 -57
  255. package/src/server/template-renderer/index.js +0 -277
  256. package/src/server/template-renderer/parse-template.js +0 -42
  257. package/src/server/template-renderer/template-stream.js +0 -82
  258. package/src/server/util.js +0 -18
  259. package/src/server/webpack-plugin/client.js +0 -65
  260. package/src/server/webpack-plugin/server.js +0 -66
  261. package/src/server/webpack-plugin/util.js +0 -34
  262. package/src/server/write.js +0 -50
@@ -0,0 +1,209 @@
1
+ import type VNode from 'core/vdom/vnode'
2
+ import type Watcher from 'core/observer/watcher'
3
+ import { ComponentOptions, SetupContext } from './options'
4
+ import { ScopedSlotsData, VNodeChildren, VNodeData } from './vnode'
5
+ import { GlobalAPI } from './global-api'
6
+ import { EffectScope } from 'v3/reactivity/effectScope'
7
+
8
+ // TODO this should be using the same as /component/
9
+
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare class Component {
14
+ constructor(options?: any)
15
+ // constructor information
16
+ static cid: number
17
+ static options: Record<string, any>
18
+ // extend
19
+ static extend: GlobalAPI['extend']
20
+ static superOptions: Record<string, any>
21
+ static extendOptions: Record<string, any>
22
+ static sealedOptions: Record<string, any>
23
+ static super: typeof Component
24
+ // assets
25
+ static directive: GlobalAPI['directive']
26
+ static component: GlobalAPI['component']
27
+ static filter: GlobalAPI['filter']
28
+ // functional context constructor
29
+ static FunctionalRenderContext: Function
30
+ static mixin: GlobalAPI['mixin']
31
+ static use: GlobalAPI['use']
32
+
33
+ // public properties
34
+ $el: any // so that we can attach __vue__ to it
35
+ $data: Record<string, any>
36
+ $props: Record<string, any>
37
+ $options: ComponentOptions
38
+ $parent: Component | undefined
39
+ $root: Component
40
+ $children: Array<Component>
41
+ $refs: {
42
+ [key: string]: Component | Element | Array<Component | Element> | undefined
43
+ }
44
+ $slots: { [key: string]: Array<VNode> }
45
+ $scopedSlots: { [key: string]: () => VNode[] | undefined }
46
+ $vnode: VNode // the placeholder node for the component in parent's render tree
47
+ $attrs: { [key: string]: string }
48
+ $listeners: Record<string, Function | Array<Function>>
49
+ $isServer: boolean
50
+
51
+ // public methods
52
+ $mount: (
53
+ el?: Element | string,
54
+ hydrating?: boolean
55
+ ) => Component & { [key: string]: any }
56
+ $forceUpdate: () => void
57
+ $destroy: () => void
58
+ $set: <T>(
59
+ target: Record<string, any> | Array<T>,
60
+ key: string | number,
61
+ val: T
62
+ ) => T
63
+ $delete: <T>(
64
+ target: Record<string, any> | Array<T>,
65
+ key: string | number
66
+ ) => void
67
+ $watch: (
68
+ expOrFn: string | (() => any),
69
+ cb: Function,
70
+ options?: Record<string, any>
71
+ ) => Function
72
+ $on: (event: string | Array<string>, fn: Function) => Component
73
+ $once: (event: string, fn: Function) => Component
74
+ $off: (event?: string | Array<string>, fn?: Function) => Component
75
+ $emit: (event: string, ...args: Array<any>) => Component
76
+ $nextTick: (fn: (...args: any[]) => any) => void | Promise<any>
77
+ $createElement: (
78
+ tag?: string | Component,
79
+ data?: Record<string, any>,
80
+ children?: VNodeChildren
81
+ ) => VNode
82
+
83
+ // private properties
84
+ _uid: number | string
85
+ _name: string // this only exists in dev mode
86
+ _isVue: true
87
+ __v_skip: true
88
+ _self: Component
89
+ _renderProxy: Component
90
+ _renderContext?: Component
91
+ _watcher: Watcher | null
92
+ _scope: EffectScope
93
+ _computedWatchers: { [key: string]: Watcher }
94
+ _data: Record<string, any>
95
+ _props: Record<string, any>
96
+ _events: Record<string, any>
97
+ _inactive: boolean | null
98
+ _directInactive: boolean
99
+ _isMounted: boolean
100
+ _isDestroyed: boolean
101
+ _isBeingDestroyed: boolean
102
+ _vnode?: VNode | null // self root node
103
+ _staticTrees?: Array<VNode> | null // v-once cached trees
104
+ _hasHookEvent: boolean
105
+ _provided: Record<string, any>
106
+ // _virtualComponents?: { [key: string]: Component };
107
+
108
+ // @v3
109
+ _setupState?: Record<string, any>
110
+ _setupContext?: SetupContext
111
+ _attrsProxy?: Record<string, any>
112
+ _slotsProxy?: Record<string, () => VNode[]>
113
+ _preWatchers?: Watcher[]
114
+
115
+ // private methods
116
+
117
+ // lifecycle
118
+ _init: Function
119
+ _mount: (el?: Element | void, hydrating?: boolean) => Component
120
+ _update: (vnode: VNode, hydrating?: boolean) => void
121
+
122
+ // rendering
123
+ _render: () => VNode
124
+
125
+ __patch__: (
126
+ a: Element | VNode | void | null,
127
+ b: VNode | null,
128
+ hydrating?: boolean,
129
+ removeOnly?: boolean,
130
+ parentElm?: any,
131
+ refElm?: any
132
+ ) => any
133
+
134
+ // createElement
135
+
136
+ // _c is internal that accepts `normalizationType` optimization hint
137
+ _c: (
138
+ vnode?: VNode,
139
+ data?: VNodeData,
140
+ children?: VNodeChildren,
141
+ normalizationType?: number
142
+ ) => VNode | void
143
+
144
+ // renderStatic
145
+ _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren
146
+ // markOnce
147
+ _o: (
148
+ vnode: VNode | Array<VNode>,
149
+ index: number,
150
+ key: string
151
+ ) => VNode | VNodeChildren
152
+ // toString
153
+ _s: (value: any) => string
154
+ // text to VNode
155
+ _v: (value: string | number) => VNode
156
+ // toNumber
157
+ _n: (value: string) => number | string
158
+ // empty vnode
159
+ _e: () => VNode
160
+ // loose equal
161
+ _q: (a: any, b: any) => boolean
162
+ // loose indexOf
163
+ _i: (arr: Array<any>, val: any) => number
164
+ // resolveFilter
165
+ _f: (id: string) => Function
166
+ // renderList
167
+ _l: (val: any, render: Function) => Array<VNode> | null
168
+ // renderSlot
169
+ _t: (
170
+ name: string,
171
+ fallback?: Array<VNode>,
172
+ props?: Record<string, any>
173
+ ) => Array<VNode> | null
174
+ // apply v-bind object
175
+ _b: (
176
+ data: any,
177
+ tag: string,
178
+ value: any,
179
+ asProp: boolean,
180
+ isSync?: boolean
181
+ ) => VNodeData
182
+ // apply v-on object
183
+ _g: (data: any, value: any) => VNodeData
184
+ // check custom keyCode
185
+ _k: (
186
+ eventKeyCode: number,
187
+ key: string,
188
+ builtInAlias?: number | Array<number>,
189
+ eventKeyName?: string
190
+ ) => boolean | null
191
+ // resolve scoped slots
192
+ _u: (
193
+ scopedSlots: ScopedSlotsData,
194
+ res?: Record<string, any>
195
+ ) => { [key: string]: Function }
196
+
197
+ // SSR specific
198
+ _ssrNode: Function
199
+ _ssrList: Function
200
+ _ssrEscape: Function
201
+ _ssrAttr: Function
202
+ _ssrAttrs: Function
203
+ _ssrDOMProps: Function
204
+ _ssrClass: Function
205
+ _ssrStyle: Function
206
+
207
+ // allow dynamic method registration
208
+ // [key: string]: any
209
+ }
@@ -0,0 +1,37 @@
1
+ import { Config } from 'core/config'
2
+ import { Component } from './component'
3
+
4
+ /**
5
+ * @internal
6
+ */
7
+ export interface GlobalAPI {
8
+ // new(options?: any): Component
9
+ (options?: any): void
10
+ cid: number
11
+ options: Record<string, any>
12
+ config: Config
13
+ util: Object
14
+
15
+ extend: (options: typeof Component | object) => typeof Component
16
+ set: <T>(target: Object | Array<T>, key: string | number, value: T) => T
17
+ delete: <T>(target: Object | Array<T>, key: string | number) => void
18
+ nextTick: (fn: Function, context?: Object) => void | Promise<any>
19
+ use: (plugin: Function | Object) => GlobalAPI
20
+ mixin: (mixin: Object) => GlobalAPI
21
+ compile: (template: string) => {
22
+ render: Function
23
+ staticRenderFns: Array<Function>
24
+ }
25
+
26
+ directive: (id: string, def?: Function | Object) => Function | Object | void
27
+ component: (
28
+ id: string,
29
+ def?: typeof Component | Object
30
+ ) => typeof Component | void
31
+ filter: (id: string, def?: Function) => Function | void
32
+
33
+ observable: <T>(value: T) => T
34
+
35
+ // allow dynamic method registration
36
+ [key: string]: any
37
+ }
@@ -0,0 +1,15 @@
1
+ declare module 'de-indent' {
2
+ export default function deindent(input: string): string
3
+ }
4
+
5
+ declare namespace jasmine {
6
+ interface Matchers<T> {
7
+ toHaveBeenWarned(): void
8
+ toHaveBeenTipped(): void
9
+ }
10
+
11
+ interface ArrayLikeMatchers<T> {
12
+ toHaveBeenWarned(): void
13
+ toHaveBeenTipped(): void
14
+ }
15
+ }
@@ -0,0 +1,120 @@
1
+ import VNode from 'core/vdom/vnode'
2
+ import { DebuggerEvent } from 'v3'
3
+ import { Component } from './component'
4
+
5
+ export type InternalComponentOptions = {
6
+ _isComponent: true
7
+ parent: Component
8
+ _parentVnode: VNode
9
+ render?: Function
10
+ staticRenderFns?: Array<Function>
11
+ }
12
+
13
+ type InjectKey = string | Symbol
14
+
15
+ /**
16
+ * @internal
17
+ */
18
+ export interface SetupContext {
19
+ attrs: Record<string, any>
20
+ slots: Record<string, () => VNode[]>
21
+ emit: (event: string, ...args: any[]) => any
22
+ }
23
+
24
+ /**
25
+ * @internal
26
+ */
27
+ export type ComponentOptions = {
28
+ // v3
29
+ setup?: (props: Record<string, any>, ctx: SetupContext) => unknown
30
+
31
+ [key: string]: any
32
+
33
+ componentId?: string
34
+
35
+ // data
36
+ data: object | Function | void
37
+ props?: { [key: string]: PropOptions }
38
+ propsData?: object
39
+ computed?: {
40
+ [key: string]:
41
+ | Function
42
+ | {
43
+ get?: Function
44
+ set?: Function
45
+ cache?: boolean
46
+ }
47
+ }
48
+ methods?: { [key: string]: Function }
49
+ watch?: { [key: string]: Function | string }
50
+
51
+ // DOM
52
+ el?: string | Element
53
+ template?: string
54
+ render: (h: () => VNode) => VNode
55
+ renderError?: (h: () => VNode, err: Error) => VNode
56
+ staticRenderFns?: Array<() => VNode>
57
+
58
+ // lifecycle
59
+ beforeCreate?: Function
60
+ created?: Function
61
+ beforeMount?: Function
62
+ mounted?: Function
63
+ beforeUpdate?: Function
64
+ updated?: Function
65
+ activated?: Function
66
+ deactivated?: Function
67
+ beforeDestroy?: Function
68
+ destroyed?: Function
69
+ errorCaptured?: () => boolean | void
70
+ serverPrefetch?: Function
71
+ renderTracked?(e: DebuggerEvent): void
72
+ renderTriggerd?(e: DebuggerEvent): void
73
+
74
+ // assets
75
+ directives?: { [key: string]: object }
76
+ components?: { [key: string]: Component }
77
+ transitions?: { [key: string]: object }
78
+ filters?: { [key: string]: Function }
79
+
80
+ // context
81
+ provide?: Record<string | symbol, any> | (() => Record<string | symbol, any>)
82
+ inject?:
83
+ | { [key: string]: InjectKey | { from?: InjectKey; default?: any } }
84
+ | Array<string>
85
+
86
+ // component v-model customization
87
+ model?: {
88
+ prop?: string
89
+ event?: string
90
+ }
91
+
92
+ // misc
93
+ parent?: Component
94
+ mixins?: Array<object>
95
+ name?: string
96
+ extends?: Component | object
97
+ delimiters?: [string, string]
98
+ comments?: boolean
99
+ inheritAttrs?: boolean
100
+
101
+ // Class API
102
+ abstract?: any
103
+
104
+ // private
105
+ _isComponent?: true
106
+ _propKeys?: Array<string>
107
+ _parentVnode?: VNode
108
+ _parentListeners?: object | null
109
+ _renderChildren?: Array<VNode> | null
110
+ _componentTag: string | null
111
+ _scopeId: string | null
112
+ _base: typeof Component
113
+ }
114
+
115
+ export type PropOptions = {
116
+ type: Function | Array<Function> | null
117
+ default: any
118
+ required: boolean | null
119
+ validator: Function | null
120
+ }
@@ -0,0 +1,27 @@
1
+ import VNode from 'core/vdom/vnode'
2
+ import { Component } from './component'
3
+
4
+ export type ComponentWithCacheContext = {
5
+ type: 'ComponentWithCache'
6
+ bufferIndex: number
7
+ buffer: Array<string>
8
+ key: string
9
+ }
10
+
11
+ export type ElementContext = {
12
+ type: 'Element'
13
+ children: Array<VNode>
14
+ rendered: number
15
+ endTag: string
16
+ total: number
17
+ }
18
+
19
+ export type ComponentContext = {
20
+ type: 'Component'
21
+ prevActive: Component
22
+ }
23
+
24
+ export type RenderState =
25
+ | ComponentContext
26
+ | ComponentWithCacheContext
27
+ | ElementContext
@@ -0,0 +1,3 @@
1
+ // If the the type T accepts type "any", output type Y, otherwise output type N.
2
+ // https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
3
+ export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N
@@ -0,0 +1,127 @@
1
+ import VNode from 'core/vdom/vnode'
2
+ import { Ref } from 'v3'
3
+ import { Component } from './component'
4
+ import { ASTModifiers } from './compiler'
5
+
6
+ /**
7
+ * @internal
8
+ */
9
+ export type VNodeChildren =
10
+ | Array<null | VNode | string | number | VNodeChildren>
11
+ | string
12
+
13
+ /**
14
+ * @internal
15
+ */
16
+ export type VNodeComponentOptions = {
17
+ Ctor: typeof Component
18
+ propsData?: Object
19
+ listeners?: Record<string, Function | Function[]>
20
+ children?: Array<VNode>
21
+ tag?: string
22
+ }
23
+
24
+ /**
25
+ * @internal
26
+ */
27
+ export type MountedComponentVNode = VNode & {
28
+ context: Component
29
+ componentOptions: VNodeComponentOptions
30
+ componentInstance: Component
31
+ parent: VNode
32
+ data: VNodeData
33
+ }
34
+
35
+ /**
36
+ * @internal
37
+ */
38
+ // interface for vnodes in update modules
39
+ export type VNodeWithData = VNode & {
40
+ tag: string
41
+ data: VNodeData
42
+ children: Array<VNode>
43
+ text: void
44
+ elm: any
45
+ ns: string | void
46
+ context: Component
47
+ key: string | number | undefined
48
+ parent?: VNodeWithData
49
+ componentOptions?: VNodeComponentOptions
50
+ componentInstance?: Component
51
+ isRootInsert: boolean
52
+ }
53
+
54
+ // // interface for vnodes in update modules
55
+ // export type VNodeWithData = {
56
+ // tag: string;
57
+ // data: VNodeData;
58
+ // children: Array<VNode>;
59
+ // text: void;
60
+ // elm: any;
61
+ // ns: string | void;
62
+ // context: Component;
63
+ // key: string | number | undefined;
64
+ // parent?: VNodeWithData;
65
+ // componentOptions?: VNodeComponentOptions;
66
+ // componentInstance?: Component;
67
+ // isRootInsert: boolean;
68
+ // };
69
+
70
+ /**
71
+ * @internal
72
+ */
73
+ export interface VNodeData {
74
+ key?: string | number
75
+ slot?: string
76
+ ref?: string | Ref | ((el: any) => void)
77
+ is?: string
78
+ pre?: boolean
79
+ tag?: string
80
+ staticClass?: string
81
+ class?: any
82
+ staticStyle?: { [key: string]: any }
83
+ style?: string | Array<Object> | Object
84
+ normalizedStyle?: Object
85
+ props?: { [key: string]: any }
86
+ attrs?: { [key: string]: string }
87
+ domProps?: { [key: string]: any }
88
+ hook?: { [key: string]: Function }
89
+ on?: { [key: string]: Function | Array<Function> }
90
+ nativeOn?: { [key: string]: Function | Array<Function> }
91
+ transition?: Object
92
+ show?: boolean // marker for v-show
93
+ inlineTemplate?: {
94
+ render: Function
95
+ staticRenderFns: Array<Function>
96
+ }
97
+ directives?: Array<VNodeDirective>
98
+ keepAlive?: boolean
99
+ scopedSlots?: { [key: string]: Function }
100
+ model?: {
101
+ value: any
102
+ callback: Function
103
+ }
104
+
105
+ [key: string]: any
106
+ }
107
+
108
+ /**
109
+ * @internal
110
+ */
111
+ export type VNodeDirective = {
112
+ name: string
113
+ rawName: string
114
+ value?: any
115
+ oldValue?: any
116
+ arg?: string
117
+ oldArg?: string
118
+ modifiers?: ASTModifiers
119
+ def?: Object
120
+ }
121
+
122
+ /**
123
+ * @internal
124
+ */
125
+ export type ScopedSlotsData = Array<
126
+ { key: string; fn: Function } | ScopedSlotsData
127
+ >
@@ -0,0 +1,66 @@
1
+ import { isFunction, warn } from 'core/util'
2
+ import { currentInstance } from './currentInstance'
3
+
4
+ export interface InjectionKey<T> extends Symbol {}
5
+
6
+ export function provide<T>(key: InjectionKey<T> | string | number, value: T) {
7
+ if (!currentInstance) {
8
+ if (__DEV__) {
9
+ warn(`provide() can only be used inside setup().`)
10
+ }
11
+ } else {
12
+ let provides = currentInstance._provided
13
+ // by default an instance inherits its parent's provides object
14
+ // but when it needs to provide values of its own, it creates its
15
+ // own provides object using parent provides object as prototype.
16
+ // this way in `inject` we can simply look up injections from direct
17
+ // parent and let the prototype chain do the work.
18
+ const parentProvides =
19
+ currentInstance.$parent && currentInstance.$parent._provided
20
+ if (parentProvides === provides) {
21
+ provides = currentInstance._provided = Object.create(parentProvides)
22
+ }
23
+ // TS doesn't allow symbol as index type
24
+ provides[key as string] = value
25
+ }
26
+ }
27
+
28
+ export function inject<T>(key: InjectionKey<T> | string): T | undefined
29
+ export function inject<T>(
30
+ key: InjectionKey<T> | string,
31
+ defaultValue: T,
32
+ treatDefaultAsFactory?: false
33
+ ): T
34
+ export function inject<T>(
35
+ key: InjectionKey<T> | string,
36
+ defaultValue: T | (() => T),
37
+ treatDefaultAsFactory: true
38
+ ): T
39
+ export function inject(
40
+ key: InjectionKey<any> | string,
41
+ defaultValue?: unknown,
42
+ treatDefaultAsFactory = false
43
+ ) {
44
+ // fallback to `currentRenderingInstance` so that this can be called in
45
+ // a functional component
46
+ const instance = currentInstance
47
+ if (instance) {
48
+ // #2400
49
+ // to support `app.use` plugins,
50
+ // fallback to appContext's `provides` if the instance is at root
51
+ const provides = instance.$parent && instance.$parent._provided
52
+
53
+ if (provides && (key as string | symbol) in provides) {
54
+ // TS doesn't allow symbol as index type
55
+ return provides[key as string]
56
+ } else if (arguments.length > 1) {
57
+ return treatDefaultAsFactory && isFunction(defaultValue)
58
+ ? defaultValue.call(instance)
59
+ : defaultValue
60
+ } else if (__DEV__) {
61
+ warn(`injection "${String(key)}" not found.`)
62
+ }
63
+ } else if (__DEV__) {
64
+ warn(`inject() can only be used inside setup() or functional components.`)
65
+ }
66
+ }
@@ -0,0 +1,53 @@
1
+ import { DebuggerEvent } from './debug'
2
+ import { Component } from 'types/component'
3
+ import { mergeLifecycleHook, warn } from '../core/util'
4
+ import { currentInstance } from './currentInstance'
5
+
6
+ function createLifeCycle<T extends (...args: any[]) => any = () => void>(
7
+ hookName: string
8
+ ) {
9
+ return (fn: T, target: any = currentInstance) => {
10
+ if (!target) {
11
+ __DEV__ &&
12
+ warn(
13
+ `${formatName(
14
+ hookName
15
+ )} is called when there is no active component instance to be ` +
16
+ `associated with. ` +
17
+ `Lifecycle injection APIs can only be used during execution of setup().`
18
+ )
19
+ return
20
+ }
21
+ return injectHook(target, hookName, fn)
22
+ }
23
+ }
24
+
25
+ function formatName(name: string) {
26
+ if (name === 'beforeDestroy') {
27
+ name = 'beforeUnmount'
28
+ } else if (name === 'destroyed') {
29
+ name = 'unmounted'
30
+ }
31
+ return `on${name[0].toUpperCase() + name.slice(1)}`
32
+ }
33
+
34
+ function injectHook(instance: Component, hookName: string, fn: () => void) {
35
+ const options = instance.$options
36
+ options[hookName] = mergeLifecycleHook(options[hookName], fn)
37
+ }
38
+
39
+ export const onBeforeMount = createLifeCycle('beforeMount')
40
+ export const onMounted = createLifeCycle('mounted')
41
+ export const onBeforeUpdate = createLifeCycle('beforeUpdate')
42
+ export const onUpdated = createLifeCycle('updated')
43
+ export const onBeforeUnmount = createLifeCycle('beforeDestroy')
44
+ export const onUnmounted = createLifeCycle('destroyed')
45
+ export const onErrorCaptured = createLifeCycle('errorCaptured')
46
+ export const onActivated = createLifeCycle('activated')
47
+ export const onDeactivated = createLifeCycle('deactivated')
48
+ export const onServerPrefetch = createLifeCycle('serverPrefetch')
49
+
50
+ export const onRenderTracked =
51
+ createLifeCycle<(e: DebuggerEvent) => any>('renderTracked')
52
+ export const onRenderTriggered =
53
+ createLifeCycle<(e: DebuggerEvent) => any>('renderTriggered')