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
@@ -1,38 +1,43 @@
1
- /* @flow */
1
+ import type { Component } from 'types/component'
2
+ import type { ComponentOptions } from 'types/options'
3
+ import type { VNodeComponentOptions, VNodeData } from 'types/vnode'
2
4
 
5
+ /**
6
+ * @internal
7
+ */
3
8
  export default class VNode {
4
- tag: string | void;
5
- data: VNodeData | void;
6
- children: ?Array<VNode>;
7
- text: string | void;
8
- elm: Node | void;
9
- ns: string | void;
10
- context: Component | void; // rendered in this component's scope
11
- key: string | number | void;
12
- componentOptions: VNodeComponentOptions | void;
13
- componentInstance: Component | void; // component instance
14
- parent: VNode | void; // component placeholder node
9
+ tag?: string
10
+ data: VNodeData | undefined
11
+ children?: Array<VNode> | null
12
+ text?: string
13
+ elm: Node | undefined
14
+ ns?: string
15
+ context?: Component // rendered in this component's scope
16
+ key: string | number | undefined
17
+ componentOptions?: VNodeComponentOptions
18
+ componentInstance?: Component // component instance
19
+ parent: VNode | undefined | null // component placeholder node
15
20
 
16
21
  // strictly internal
17
- raw: boolean; // contains raw HTML? (server only)
18
- isStatic: boolean; // hoisted static node
19
- isRootInsert: boolean; // necessary for enter transition check
20
- isComment: boolean; // empty comment placeholder?
21
- isCloned: boolean; // is a cloned node?
22
- isOnce: boolean; // is a v-once node?
23
- asyncFactory: Function | void; // async component factory function
24
- asyncMeta: Object | void;
25
- isAsyncPlaceholder: boolean;
26
- ssrContext: Object | void;
27
- fnContext: Component | void; // real context vm for functional nodes
28
- fnOptions: ?ComponentOptions; // for SSR caching
29
- devtoolsMeta: ?Object; // used to store functional render context for devtools
30
- fnScopeId: ?string; // functional scope id support
22
+ raw: boolean // contains raw HTML? (server only)
23
+ isStatic: boolean // hoisted static node
24
+ isRootInsert: boolean // necessary for enter transition check
25
+ isComment: boolean // empty comment placeholder?
26
+ isCloned: boolean // is a cloned node?
27
+ isOnce: boolean // is a v-once node?
28
+ asyncFactory?: Function // async component factory function
29
+ asyncMeta: Object | void
30
+ isAsyncPlaceholder: boolean
31
+ ssrContext?: Object | void
32
+ fnContext: Component | void // real context vm for functional nodes
33
+ fnOptions?: ComponentOptions | null // for SSR caching
34
+ devtoolsMeta?: Object | null // used to store functional render context for devtools
35
+ fnScopeId?: string | null // functional scope id support
31
36
 
32
- constructor (
37
+ constructor(
33
38
  tag?: string,
34
39
  data?: VNodeData,
35
- children?: ?Array<VNode>,
40
+ children?: Array<VNode> | null,
36
41
  text?: string,
37
42
  elm?: Node,
38
43
  context?: Component,
@@ -66,7 +71,7 @@ export default class VNode {
66
71
 
67
72
  // DEPRECATED: alias for componentInstance for backwards compat.
68
73
  /* istanbul ignore next */
69
- get child (): Component | void {
74
+ get child(): Component | void {
70
75
  return this.componentInstance
71
76
  }
72
77
  }
@@ -78,7 +83,7 @@ export const createEmptyVNode = (text: string = '') => {
78
83
  return node
79
84
  }
80
85
 
81
- export function createTextVNode (val: string | number) {
86
+ export function createTextVNode(val: string | number) {
82
87
  return new VNode(undefined, undefined, undefined, String(val))
83
88
  }
84
89
 
@@ -86,7 +91,7 @@ export function createTextVNode (val: string | number) {
86
91
  // used for static nodes and slot nodes because they may be reused across
87
92
  // multiple renders, cloning them avoids errors when DOM manipulations rely
88
93
  // on their elm reference.
89
- export function cloneVNode (vnode: VNode): VNode {
94
+ export function cloneVNode(vnode: VNode): VNode {
90
95
  const cloned = new VNode(
91
96
  vnode.tag,
92
97
  vnode.data,
@@ -0,0 +1,15 @@
1
+ declare const __DEV__: boolean
2
+
3
+ interface Window {
4
+ __VUE_DEVTOOLS_GLOBAL_HOOK__: DevtoolsHook
5
+ }
6
+
7
+ // from https://github.com/vuejs/vue-devtools/blob/bc719c95a744614f5c3693460b64dc21dfa339a8/packages/app-backend-api/src/global-hook.ts#L3
8
+ interface DevtoolsHook {
9
+ emit: (event: string, ...payload: any[]) => void
10
+ on: (event: string, handler: Function) => void
11
+ once: (event: string, handler: Function) => void
12
+ off: (event?: string, handler?: Function) => void
13
+ Vue?: any
14
+ // apps: AppRecordOptions[]
15
+ }
@@ -0,0 +1,8 @@
1
+ import { addProp } from 'compiler/helpers'
2
+ import { ASTDirective, ASTElement } from 'types/compiler'
3
+
4
+ export default function html(el: ASTElement, dir: ASTDirective) {
5
+ if (dir.value) {
6
+ addProp(el, 'innerHTML', `_s(${dir.value})`, dir)
7
+ }
8
+ }
@@ -1,8 +1,7 @@
1
- /* @flow */
2
-
3
1
  import config from 'core/config'
4
2
  import { addHandler, addProp, getBindingAttr } from 'compiler/helpers'
5
3
  import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
4
+ import { ASTDirective, ASTElement, ASTModifiers } from 'types/compiler'
6
5
 
7
6
  let warn
8
7
 
@@ -11,24 +10,24 @@ let warn
11
10
  export const RANGE_TOKEN = '__r'
12
11
  export const CHECKBOX_RADIO_TOKEN = '__c'
13
12
 
14
- export default function model (
13
+ export default function model(
15
14
  el: ASTElement,
16
15
  dir: ASTDirective,
17
16
  _warn: Function
18
- ): ?boolean {
17
+ ): boolean | undefined {
19
18
  warn = _warn
20
19
  const value = dir.value
21
20
  const modifiers = dir.modifiers
22
21
  const tag = el.tag
23
22
  const type = el.attrsMap.type
24
23
 
25
- if (process.env.NODE_ENV !== 'production') {
24
+ if (__DEV__) {
26
25
  // inputs with type="file" are read only and setting the input's
27
26
  // value will throw an error.
28
27
  if (tag === 'input' && type === 'file') {
29
28
  warn(
30
29
  `<${el.tag} v-model="${value}" type="file">:\n` +
31
- `File inputs are read only. Use a v-on:change listener instead.`,
30
+ `File inputs are read only. Use a v-on:change listener instead.`,
32
31
  el.rawAttrsMap['v-model']
33
32
  )
34
33
  }
@@ -50,12 +49,12 @@ export default function model (
50
49
  genComponentModel(el, value, modifiers)
51
50
  // component v-model doesn't need extra runtime
52
51
  return false
53
- } else if (process.env.NODE_ENV !== 'production') {
52
+ } else if (__DEV__) {
54
53
  warn(
55
54
  `<${el.tag} v-model="${value}">: ` +
56
- `v-model is not supported on this element type. ` +
57
- 'If you are working with contenteditable, it\'s recommended to ' +
58
- 'wrap a library dedicated for that purpose inside a custom component.',
55
+ `v-model is not supported on this element type. ` +
56
+ "If you are working with contenteditable, it's recommended to " +
57
+ 'wrap a library dedicated for that purpose inside a custom component.',
59
58
  el.rawAttrsMap['v-model']
60
59
  )
61
60
  }
@@ -64,41 +63,51 @@ export default function model (
64
63
  return true
65
64
  }
66
65
 
67
- function genCheckboxModel (
66
+ function genCheckboxModel(
68
67
  el: ASTElement,
69
68
  value: string,
70
- modifiers: ?ASTModifiers
69
+ modifiers?: ASTModifiers | null
71
70
  ) {
72
71
  const number = modifiers && modifiers.number
73
72
  const valueBinding = getBindingAttr(el, 'value') || 'null'
74
73
  const trueValueBinding = getBindingAttr(el, 'true-value') || 'true'
75
74
  const falseValueBinding = getBindingAttr(el, 'false-value') || 'false'
76
- addProp(el, 'checked',
75
+ addProp(
76
+ el,
77
+ 'checked',
77
78
  `Array.isArray(${value})` +
78
- `?_i(${value},${valueBinding})>-1` + (
79
- trueValueBinding === 'true'
79
+ `?_i(${value},${valueBinding})>-1` +
80
+ (trueValueBinding === 'true'
80
81
  ? `:(${value})`
81
- : `:_q(${value},${trueValueBinding})`
82
- )
82
+ : `:_q(${value},${trueValueBinding})`)
83
83
  )
84
- addHandler(el, 'change',
84
+ addHandler(
85
+ el,
86
+ 'change',
85
87
  `var $$a=${value},` +
86
- '$$el=$event.target,' +
87
- `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
88
- 'if(Array.isArray($$a)){' +
88
+ '$$el=$event.target,' +
89
+ `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
90
+ 'if(Array.isArray($$a)){' +
89
91
  `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
90
- '$$i=_i($$a,$$v);' +
91
- `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
92
- `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
93
- `}else{${genAssignmentCode(value, '$$c')}}`,
94
- null, true
92
+ '$$i=_i($$a,$$v);' +
93
+ `if($$el.checked){$$i<0&&(${genAssignmentCode(
94
+ value,
95
+ '$$a.concat([$$v])'
96
+ )})}` +
97
+ `else{$$i>-1&&(${genAssignmentCode(
98
+ value,
99
+ '$$a.slice(0,$$i).concat($$a.slice($$i+1))'
100
+ )})}` +
101
+ `}else{${genAssignmentCode(value, '$$c')}}`,
102
+ null,
103
+ true
95
104
  )
96
105
  }
97
106
 
98
- function genRadioModel (
107
+ function genRadioModel(
99
108
  el: ASTElement,
100
109
  value: string,
101
- modifiers: ?ASTModifiers
110
+ modifiers?: ASTModifiers | null
102
111
  ) {
103
112
  const number = modifiers && modifiers.number
104
113
  let valueBinding = getBindingAttr(el, 'value') || 'null'
@@ -107,13 +116,14 @@ function genRadioModel (
107
116
  addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true)
108
117
  }
109
118
 
110
- function genSelect (
119
+ function genSelect(
111
120
  el: ASTElement,
112
121
  value: string,
113
- modifiers: ?ASTModifiers
122
+ modifiers?: ASTModifiers | null
114
123
  ) {
115
124
  const number = modifiers && modifiers.number
116
- const selectedVal = `Array.prototype.filter` +
125
+ const selectedVal =
126
+ `Array.prototype.filter` +
117
127
  `.call($event.target.options,function(o){return o.selected})` +
118
128
  `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
119
129
  `return ${number ? '_n(val)' : 'val'}})`
@@ -124,23 +134,23 @@ function genSelect (
124
134
  addHandler(el, 'change', code, null, true)
125
135
  }
126
136
 
127
- function genDefaultModel (
137
+ function genDefaultModel(
128
138
  el: ASTElement,
129
139
  value: string,
130
- modifiers: ?ASTModifiers
131
- ): ?boolean {
140
+ modifiers?: ASTModifiers | null
141
+ ): boolean | void {
132
142
  const type = el.attrsMap.type
133
143
 
134
144
  // warn if v-bind:value conflicts with v-model
135
145
  // except for inputs with v-bind:type
136
- if (process.env.NODE_ENV !== 'production') {
146
+ if (__DEV__) {
137
147
  const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value']
138
148
  const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type']
139
149
  if (value && !typeBinding) {
140
150
  const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'
141
151
  warn(
142
152
  `${binding}="${value}" conflicts with v-model on the same element ` +
143
- 'because the latter already expands to a value binding internally',
153
+ 'because the latter already expands to a value binding internally',
144
154
  el.rawAttrsMap[binding]
145
155
  )
146
156
  }
@@ -148,11 +158,7 @@ function genDefaultModel (
148
158
 
149
159
  const { lazy, number, trim } = modifiers || {}
150
160
  const needCompositionGuard = !lazy && type !== 'range'
151
- const event = lazy
152
- ? 'change'
153
- : type === 'range'
154
- ? RANGE_TOKEN
155
- : 'input'
161
+ const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input'
156
162
 
157
163
  let valueExpression = '$event.target.value'
158
164
  if (trim) {
@@ -1,8 +1,7 @@
1
- /* @flow */
2
-
3
1
  import { addProp } from 'compiler/helpers'
2
+ import { ASTDirective, ASTElement } from 'types/compiler'
4
3
 
5
- export default function text (el: ASTElement, dir: ASTDirective) {
4
+ export default function text(el: ASTElement, dir: ASTDirective) {
6
5
  if (dir.value) {
7
6
  addProp(el, 'textContent', `_s(${dir.value})`, dir)
8
7
  }
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import { baseOptions } from './options'
4
2
  import { createCompiler } from 'compiler/index'
5
3
 
@@ -1,29 +1,24 @@
1
- /* @flow */
2
-
3
1
  import { parseText } from 'compiler/parser/text-parser'
4
- import {
5
- getAndRemoveAttr,
6
- getBindingAttr,
7
- baseWarn
8
- } from 'compiler/helpers'
2
+ import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
3
+ import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
9
4
 
10
- function transformNode (el: ASTElement, options: CompilerOptions) {
5
+ function transformNode(el: ASTElement, options: CompilerOptions) {
11
6
  const warn = options.warn || baseWarn
12
7
  const staticClass = getAndRemoveAttr(el, 'class')
13
- if (process.env.NODE_ENV !== 'production' && staticClass) {
8
+ if (__DEV__ && staticClass) {
14
9
  const res = parseText(staticClass, options.delimiters)
15
10
  if (res) {
16
11
  warn(
17
12
  `class="${staticClass}": ` +
18
- 'Interpolation inside attributes has been removed. ' +
19
- 'Use v-bind or the colon shorthand instead. For example, ' +
20
- 'instead of <div class="{{ val }}">, use <div :class="val">.',
13
+ 'Interpolation inside attributes has been removed. ' +
14
+ 'Use v-bind or the colon shorthand instead. For example, ' +
15
+ 'instead of <div class="{{ val }}">, use <div :class="val">.',
21
16
  el.rawAttrsMap['class']
22
17
  )
23
18
  }
24
19
  }
25
20
  if (staticClass) {
26
- el.staticClass = JSON.stringify(staticClass)
21
+ el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim())
27
22
  }
28
23
  const classBinding = getBindingAttr(el, 'class', false /* getStatic */)
29
24
  if (classBinding) {
@@ -31,7 +26,7 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
31
26
  }
32
27
  }
33
28
 
34
- function genData (el: ASTElement): string {
29
+ function genData(el: ASTElement): string {
35
30
  let data = ''
36
31
  if (el.staticClass) {
37
32
  data += `staticClass:${el.staticClass},`
@@ -46,4 +41,4 @@ export default {
46
41
  staticKeys: ['staticClass'],
47
42
  transformNode,
48
43
  genData
49
- }
44
+ } as ModuleOptions
@@ -2,8 +2,4 @@ import klass from './class'
2
2
  import style from './style'
3
3
  import model from './model'
4
4
 
5
- export default [
6
- klass,
7
- style,
8
- model
9
- ]
5
+ export default [klass, style, model]
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  /**
4
2
  * Expand input[v-model] with dynamic type bindings into v-if-else chains
5
3
  * Turn this:
@@ -10,11 +8,7 @@
10
8
  * <input v-else :type="type" v-model="data[type]">
11
9
  */
12
10
 
13
- import {
14
- addRawAttr,
15
- getBindingAttr,
16
- getAndRemoveAttr
17
- } from 'compiler/helpers'
11
+ import { addRawAttr, getBindingAttr, getAndRemoveAttr } from 'compiler/helpers'
18
12
 
19
13
  import {
20
14
  processFor,
@@ -22,8 +16,9 @@ import {
22
16
  addIfCondition,
23
17
  createASTElement
24
18
  } from 'compiler/parser/index'
19
+ import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
25
20
 
26
- function preTransformNode (el: ASTElement, options: CompilerOptions) {
21
+ function preTransformNode(el: ASTElement, options: CompilerOptions) {
27
22
  if (el.tag === 'input') {
28
23
  const map = el.attrsMap
29
24
  if (!map['v-model']) {
@@ -70,7 +65,7 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
70
65
  addRawAttr(branch2, ':type', typeBinding)
71
66
  processElement(branch2, options)
72
67
  addIfCondition(branch0, {
73
- exp: ifCondition,
68
+ exp: ifCondition!,
74
69
  block: branch2
75
70
  })
76
71
 
@@ -85,10 +80,10 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
85
80
  }
86
81
  }
87
82
 
88
- function cloneASTElement (el) {
83
+ function cloneASTElement(el) {
89
84
  return createASTElement(el.tag, el.attrsList.slice(), el.parent)
90
85
  }
91
86
 
92
87
  export default {
93
88
  preTransformNode
94
- }
89
+ } as ModuleOptions
@@ -1,26 +1,21 @@
1
- /* @flow */
2
-
3
1
  import { parseText } from 'compiler/parser/text-parser'
4
2
  import { parseStyleText } from 'web/util/style'
5
- import {
6
- getAndRemoveAttr,
7
- getBindingAttr,
8
- baseWarn
9
- } from 'compiler/helpers'
3
+ import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
4
+ import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
10
5
 
11
- function transformNode (el: ASTElement, options: CompilerOptions) {
6
+ function transformNode(el: ASTElement, options: CompilerOptions) {
12
7
  const warn = options.warn || baseWarn
13
8
  const staticStyle = getAndRemoveAttr(el, 'style')
14
9
  if (staticStyle) {
15
10
  /* istanbul ignore if */
16
- if (process.env.NODE_ENV !== 'production') {
11
+ if (__DEV__) {
17
12
  const res = parseText(staticStyle, options.delimiters)
18
13
  if (res) {
19
14
  warn(
20
15
  `style="${staticStyle}": ` +
21
- 'Interpolation inside attributes has been removed. ' +
22
- 'Use v-bind or the colon shorthand instead. For example, ' +
23
- 'instead of <div style="{{ val }}">, use <div :style="val">.',
16
+ 'Interpolation inside attributes has been removed. ' +
17
+ 'Use v-bind or the colon shorthand instead. For example, ' +
18
+ 'instead of <div style="{{ val }}">, use <div :style="val">.',
24
19
  el.rawAttrsMap['style']
25
20
  )
26
21
  }
@@ -34,7 +29,7 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
34
29
  }
35
30
  }
36
31
 
37
- function genData (el: ASTElement): string {
32
+ function genData(el: ASTElement): string {
38
33
  let data = ''
39
34
  if (el.staticStyle) {
40
35
  data += `staticStyle:${el.staticStyle},`
@@ -49,4 +44,4 @@ export default {
49
44
  staticKeys: ['staticStyle'],
50
45
  transformNode,
51
46
  genData
52
- }
47
+ } as ModuleOptions
@@ -1,5 +1,3 @@
1
- /* @flow */
2
-
3
1
  import {
4
2
  isPreTag,
5
3
  mustUseProp,
@@ -11,6 +9,7 @@ import modules from './modules/index'
11
9
  import directives from './directives/index'
12
10
  import { genStaticKeys } from 'shared/util'
13
11
  import { isUnaryTag, canBeLeftOpenTag } from './util'
12
+ import { CompilerOptions } from 'types/compiler'
14
13
 
15
14
  export const baseOptions: CompilerOptions = {
16
15
  expectHTML: true,
@@ -1,10 +1,8 @@
1
- /* @flow */
2
-
3
1
  import { makeMap } from 'shared/util'
4
2
 
5
3
  export const isUnaryTag = makeMap(
6
4
  'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
7
- 'link,meta,param,source,track,wbr'
5
+ 'link,meta,param,source,track,wbr'
8
6
  )
9
7
 
10
8
  // Elements that you can, intentionally, leave open
@@ -17,8 +15,8 @@ export const canBeLeftOpenTag = makeMap(
17
15
  // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
18
16
  export const isNonPhrasingTag = makeMap(
19
17
  'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
20
- 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
21
- 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
22
- 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
23
- 'title,tr,track'
18
+ 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
19
+ 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
20
+ 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
21
+ 'title,tr,track'
24
22
  )
@@ -0,0 +1 @@
1
+ export function compile() {}
@@ -1,6 +1,4 @@
1
- /* @flow */
2
-
3
1
  export { parseComponent } from 'sfc/parser'
4
2
  export { compile, compileToFunctions } from './compiler/index'
5
- export { ssrCompile, ssrCompileToFunctions } from './server/compiler'
3
+ export { ssrCompile, ssrCompileToFunctions } from 'server/compiler'
6
4
  export { generateCodeFrame } from 'compiler/codeframe'
@@ -1,5 +1,5 @@
1
- /* @flow */
2
-
3
1
  import Vue from './runtime/index'
4
2
 
5
3
  export default Vue
4
+
5
+ export * from 'v3'
@@ -0,0 +1,5 @@
1
+ import Vue from './runtime-with-compiler'
2
+
3
+ export default Vue
4
+
5
+ export * from 'v3'
@@ -0,0 +1,10 @@
1
+ import Vue from './runtime-with-compiler'
2
+ import * as vca from 'v3'
3
+ import { extend } from 'shared/util'
4
+
5
+ extend(Vue, vca)
6
+
7
+ import { effect } from 'v3/reactivity/effect'
8
+ Vue.effect = effect
9
+
10
+ export default Vue
@@ -0,0 +1,7 @@
1
+ import Vue from './runtime/index'
2
+ import * as vca from 'v3'
3
+ import { extend } from 'shared/util'
4
+
5
+ extend(Vue, vca)
6
+
7
+ export default Vue
@@ -1,12 +1,10 @@
1
- /* @flow */
2
-
3
1
  const whitespaceRE = /\s+/
4
2
 
5
3
  /**
6
4
  * Add class with compatibility for SVG since classList is not supported on
7
5
  * SVG elements in IE
8
6
  */
9
- export function addClass (el: HTMLElement, cls: ?string) {
7
+ export function addClass(el: HTMLElement, cls?: string) {
10
8
  /* istanbul ignore if */
11
9
  if (!cls || !(cls = cls.trim())) {
12
10
  return
@@ -31,7 +29,7 @@ export function addClass (el: HTMLElement, cls: ?string) {
31
29
  * Remove class with compatibility for SVG since classList is not supported on
32
30
  * SVG elements in IE
33
31
  */
34
- export function removeClass (el: HTMLElement, cls: ?string) {
32
+ export function removeClass(el: HTMLElement, cls?: string) {
35
33
  /* istanbul ignore if */
36
34
  if (!cls || !(cls = cls.trim())) {
37
35
  return