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,36 +1,73 @@
1
- import { Vue, CreateElement, CombinedVueInstance } from "./vue";
2
- import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from "./vnode";
1
+ import { Vue, CreateElement, CombinedVueInstance } from './vue'
2
+ import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from './vnode'
3
+ import { SetupContext } from './v3'
3
4
 
4
5
  type Constructor = {
5
- new (...args: any[]): any;
6
+ new (...args: any[]): any
6
7
  }
7
8
 
8
9
  // we don't support infer props in async component
9
10
  // N.B. ComponentOptions<V> is contravariant, the default generic should be bottom type
10
- export type Component<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> =
11
+ export type Component<
12
+ Data = DefaultData<never>,
13
+ Methods = DefaultMethods<never>,
14
+ Computed = DefaultComputed,
15
+ Props = DefaultProps,
16
+ SetupBindings = {}
17
+ > =
11
18
  | typeof Vue
12
19
  | FunctionalComponentOptions<Props>
13
- | ComponentOptions<never, Data, Methods, Computed, Props>
14
-
15
- interface EsModuleComponent {
16
- default: Component
17
- }
18
-
19
- export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps>
20
- = AsyncComponentPromise<Data, Methods, Computed, Props>
21
- | AsyncComponentFactory<Data, Methods, Computed, Props>
22
-
23
- export type AsyncComponentPromise<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = (
24
- resolve: (component: Component<Data, Methods, Computed, Props>) => void,
20
+ | ComponentOptions<never, Data, Methods, Computed, Props, SetupBindings>
21
+
22
+ type EsModule<T> = T | { default: T }
23
+
24
+ type ImportedComponent<
25
+ Data = DefaultData<never>,
26
+ Methods = DefaultMethods<never>,
27
+ Computed = DefaultComputed,
28
+ Props = DefaultProps,
29
+ SetupBindings = {}
30
+ > = EsModule<Component<Data, Methods, Computed, Props, SetupBindings>>
31
+
32
+ export type AsyncComponent<
33
+ Data = DefaultData<never>,
34
+ Methods = DefaultMethods<never>,
35
+ Computed = DefaultComputed,
36
+ Props = DefaultProps,
37
+ SetupBindings = {}
38
+ > =
39
+ | AsyncComponentPromise<Data, Methods, Computed, Props, SetupBindings>
40
+ | AsyncComponentFactory<Data, Methods, Computed, Props, SetupBindings>
41
+
42
+ export type AsyncComponentPromise<
43
+ Data = DefaultData<never>,
44
+ Methods = DefaultMethods<never>,
45
+ Computed = DefaultComputed,
46
+ Props = DefaultProps,
47
+ SetupBindings = {}
48
+ > = (
49
+ resolve: (
50
+ component: Component<Data, Methods, Computed, Props, SetupBindings>
51
+ ) => void,
25
52
  reject: (reason?: any) => void
26
- ) => Promise<Component | EsModuleComponent> | void;
27
-
28
- export type AsyncComponentFactory<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = () => {
29
- component: AsyncComponentPromise<Data, Methods, Computed, Props>;
30
- loading?: Component | EsModuleComponent;
31
- error?: Component | EsModuleComponent;
32
- delay?: number;
33
- timeout?: number;
53
+ ) => Promise<
54
+ ImportedComponent<Data, Methods, Computed, Props, SetupBindings>
55
+ > | void
56
+
57
+ export type AsyncComponentFactory<
58
+ Data = DefaultData<never>,
59
+ Methods = DefaultMethods<never>,
60
+ Computed = DefaultComputed,
61
+ Props = DefaultProps,
62
+ SetupBindings = {}
63
+ > = () => {
64
+ component: Promise<
65
+ ImportedComponent<Data, Methods, Computed, Props, SetupBindings>
66
+ >
67
+ loading?: ImportedComponent
68
+ error?: ImportedComponent
69
+ delay?: number
70
+ timeout?: number
34
71
  }
35
72
 
36
73
  /**
@@ -47,141 +84,214 @@ type DataDef<Data, Props, V> = Data | ((this: Readonly<Props> & V) => Data)
47
84
  /**
48
85
  * This type should be used when an array of strings is used for a component's `props` value.
49
86
  */
50
- export type ThisTypedComponentOptionsWithArrayProps<V extends Vue, Data, Methods, Computed, PropNames extends string> =
51
- object &
52
- ComponentOptions<V, DataDef<Data, Record<PropNames, any>, V>, Methods, Computed, PropNames[], Record<PropNames, any>> &
53
- ThisType<CombinedVueInstance<V, Data, Methods, Computed, Readonly<Record<PropNames, any>>>>;
87
+ export type ThisTypedComponentOptionsWithArrayProps<
88
+ V extends Vue,
89
+ Data,
90
+ Methods,
91
+ Computed,
92
+ PropNames extends string,
93
+ SetupBindings
94
+ > = object &
95
+ ComponentOptions<
96
+ V,
97
+ DataDef<Data, Record<PropNames, any>, V>,
98
+ Methods,
99
+ Computed,
100
+ PropNames[],
101
+ Record<PropNames, any>,
102
+ SetupBindings
103
+ > &
104
+ ThisType<
105
+ CombinedVueInstance<
106
+ V,
107
+ Data,
108
+ Methods,
109
+ Computed,
110
+ Readonly<Record<PropNames, any>>,
111
+ SetupBindings
112
+ >
113
+ >
54
114
 
55
115
  /**
56
116
  * This type should be used when an object mapped to `PropOptions` is used for a component's `props` value.
57
117
  */
58
- export type ThisTypedComponentOptionsWithRecordProps<V extends Vue, Data, Methods, Computed, Props> =
59
- object &
60
- ComponentOptions<V, DataDef<Data, Props, V>, Methods, Computed, RecordPropsDefinition<Props>, Props> &
61
- ThisType<CombinedVueInstance<V, Data, Methods, Computed, Readonly<Props>>>;
62
-
63
- type DefaultData<V> = object | ((this: V) => object);
64
- type DefaultProps = Record<string, any>;
65
- type DefaultMethods<V> = { [key: string]: (this: V, ...args: any[]) => any };
66
- type DefaultComputed = { [key: string]: any };
118
+ export type ThisTypedComponentOptionsWithRecordProps<
119
+ V extends Vue,
120
+ Data,
121
+ Methods,
122
+ Computed,
123
+ Props,
124
+ SetupBindings
125
+ > = object &
126
+ ComponentOptions<
127
+ V,
128
+ DataDef<Data, Props, V>,
129
+ Methods,
130
+ Computed,
131
+ RecordPropsDefinition<Props>,
132
+ Props,
133
+ SetupBindings
134
+ > &
135
+ ThisType<
136
+ CombinedVueInstance<
137
+ V,
138
+ Data,
139
+ Methods,
140
+ Computed,
141
+ Readonly<Props>,
142
+ SetupBindings
143
+ >
144
+ >
145
+
146
+ type DefaultData<V> = object | ((this: V) => object)
147
+ type DefaultProps = Record<string, any>
148
+ type DefaultMethods<V> = { [key: string]: (this: V, ...args: any[]) => any }
149
+ type DefaultComputed = { [key: string]: any }
150
+
67
151
  export interface ComponentOptions<
68
152
  V extends Vue,
69
- Data=DefaultData<V>,
70
- Methods=DefaultMethods<V>,
71
- Computed=DefaultComputed,
72
- PropsDef=PropsDefinition<DefaultProps>,
73
- Props=DefaultProps> {
74
- data?: Data;
75
- props?: PropsDef;
76
- propsData?: object;
77
- computed?: Accessors<Computed>;
78
- methods?: Methods;
79
- watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any>>;
80
-
81
- el?: Element | string;
82
- template?: string;
153
+ Data = DefaultData<V>,
154
+ Methods = DefaultMethods<V>,
155
+ Computed = DefaultComputed,
156
+ PropsDef = PropsDefinition<DefaultProps>,
157
+ Props = DefaultProps,
158
+ RawBindings = {}
159
+ > {
160
+ data?: Data
161
+ props?: PropsDef
162
+ propsData?: object
163
+ computed?: Accessors<Computed>
164
+ methods?: Methods
165
+ watch?: Record<string, WatchOptionsWithHandler<any> | WatchHandler<any>>
166
+
167
+ setup?: (
168
+ this: void,
169
+ props: Props,
170
+ ctx: SetupContext
171
+ ) => Promise<RawBindings> | RawBindings | ((h: CreateElement) => VNode) | void
172
+
173
+ el?: Element | string
174
+ template?: string
83
175
  // hack is for functional component type inference, should not be used in user code
84
- render?(createElement: CreateElement, hack: RenderContext<Props>): VNode;
85
- renderError?(createElement: CreateElement, err: Error): VNode;
86
- staticRenderFns?: ((createElement: CreateElement) => VNode)[];
87
-
88
- beforeCreate?(this: V): void;
89
- created?(): void;
90
- beforeDestroy?(): void;
91
- destroyed?(): void;
92
- beforeMount?(): void;
93
- mounted?(): void;
94
- beforeUpdate?(): void;
95
- updated?(): void;
96
- activated?(): void;
97
- deactivated?(): void;
98
- errorCaptured?(err: Error, vm: Vue, info: string): boolean | void;
99
- serverPrefetch?(this: V): Promise<void>;
100
-
101
- directives?: { [key: string]: DirectiveFunction | DirectiveOptions };
102
- components?: { [key: string]: Component<any, any, any, any> | AsyncComponent<any, any, any, any> };
103
- transitions?: { [key: string]: object };
104
- filters?: { [key: string]: Function };
105
-
106
- provide?: object | (() => object);
107
- inject?: InjectOptions;
176
+ render?(createElement: CreateElement, hack: RenderContext<Props>): VNode
177
+ renderError?(createElement: CreateElement, err: Error): VNode
178
+ staticRenderFns?: ((createElement: CreateElement) => VNode)[]
179
+
180
+ beforeCreate?(this: V): void
181
+ created?(): void
182
+ beforeDestroy?(): void
183
+ destroyed?(): void
184
+ beforeMount?(): void
185
+ mounted?(): void
186
+ beforeUpdate?(): void
187
+ updated?(): void
188
+ activated?(): void
189
+ deactivated?(): void
190
+ errorCaptured?(err: Error, vm: Vue, info: string): boolean | void
191
+ serverPrefetch?(this: V): Promise<void>
192
+ renderTracked?(e: DebuggerEvent): void
193
+ renderTriggerd?(e: DebuggerEvent): void
194
+
195
+ directives?: { [key: string]: DirectiveFunction | DirectiveOptions }
196
+ components?: {
197
+ [key: string]:
198
+ | Component<any, any, any, any>
199
+ | AsyncComponent<any, any, any, any>
200
+ }
201
+ transitions?: { [key: string]: object }
202
+ filters?: { [key: string]: Function }
203
+
204
+ provide?: object | (() => object)
205
+ inject?: InjectOptions
108
206
 
109
207
  model?: {
110
- prop?: string;
111
- event?: string;
112
- };
208
+ prop?: string
209
+ event?: string
210
+ }
113
211
 
114
- parent?: Vue;
115
- mixins?: (ComponentOptions<Vue> | typeof Vue)[];
116
- name?: string;
212
+ parent?: Vue
213
+ mixins?: (ComponentOptions<Vue> | typeof Vue)[]
214
+ name?: string
117
215
  // TODO: support properly inferred 'extends'
118
- extends?: ComponentOptions<Vue> | typeof Vue;
119
- delimiters?: [string, string];
120
- comments?: boolean;
121
- inheritAttrs?: boolean;
216
+ extends?: ComponentOptions<Vue> | typeof Vue
217
+ delimiters?: [string, string]
218
+ comments?: boolean
219
+ inheritAttrs?: boolean
122
220
  }
123
221
 
124
- export interface FunctionalComponentOptions<Props = DefaultProps, PropDefs = PropsDefinition<Props>> {
125
- name?: string;
126
- props?: PropDefs;
222
+ export interface FunctionalComponentOptions<
223
+ Props = DefaultProps,
224
+ PropDefs = PropsDefinition<Props>
225
+ > {
226
+ name?: string
227
+ props?: PropDefs
127
228
  model?: {
128
- prop?: string;
129
- event?: string;
130
- };
131
- inject?: InjectOptions;
132
- functional: boolean;
133
- render?(this: undefined, createElement: CreateElement, context: RenderContext<Props>): VNode | VNode[];
134
- }
135
-
136
- export interface RenderContext<Props=DefaultProps> {
137
- props: Props;
138
- children: VNode[];
139
- slots(): any;
140
- data: VNodeData;
141
- parent: Vue;
142
- listeners: { [key: string]: Function | Function[] };
143
- scopedSlots: { [key: string]: NormalizedScopedSlot };
229
+ prop?: string
230
+ event?: string
231
+ }
232
+ inject?: InjectOptions
233
+ functional: boolean
234
+ render?(
235
+ this: undefined,
236
+ createElement: CreateElement,
237
+ context: RenderContext<Props>
238
+ ): VNode | VNode[]
239
+ }
240
+
241
+ export interface RenderContext<Props = DefaultProps> {
242
+ props: Props
243
+ children: VNode[]
244
+ slots(): any
245
+ data: VNodeData
246
+ parent: Vue
247
+ listeners: { [key: string]: Function | Function[] }
248
+ scopedSlots: { [key: string]: NormalizedScopedSlot }
144
249
  injections: any
145
250
  }
146
251
 
147
- export type Prop<T> = { (): T } | { new(...args: never[]): T & object } | { new(...args: string[]): Function }
252
+ export type Prop<T> =
253
+ | { (): T }
254
+ | { new (...args: never[]): T & object }
255
+ | { new (...args: string[]): Function }
148
256
 
149
- export type PropType<T> = Prop<T> | Prop<T>[];
257
+ export type PropType<T> = Prop<T> | Prop<T>[]
150
258
 
151
- export type PropValidator<T> = PropOptions<T> | PropType<T>;
259
+ export type PropValidator<T> = PropOptions<T> | PropType<T>
152
260
 
153
- export interface PropOptions<T=any> {
154
- type?: PropType<T>;
155
- required?: boolean;
156
- default?: T | null | undefined | (() => T | null | undefined);
157
- validator?(value: T): boolean;
261
+ export interface PropOptions<T = any> {
262
+ type?: PropType<T>
263
+ required?: boolean
264
+ default?: T | null | undefined | (() => T | null | undefined)
265
+ validator?(value: T): boolean
158
266
  }
159
267
 
160
268
  export type RecordPropsDefinition<T> = {
161
269
  [K in keyof T]: PropValidator<T[K]>
162
270
  }
163
- export type ArrayPropsDefinition<T> = (keyof T)[];
164
- export type PropsDefinition<T> = ArrayPropsDefinition<T> | RecordPropsDefinition<T>;
271
+ export type ArrayPropsDefinition<T> = (keyof T)[]
272
+ export type PropsDefinition<T> =
273
+ | ArrayPropsDefinition<T>
274
+ | RecordPropsDefinition<T>
165
275
 
166
276
  export interface ComputedOptions<T> {
167
- get?(): T;
168
- set?(value: T): void;
169
- cache?: boolean;
277
+ get?(): T
278
+ set?(value: T): void
279
+ cache?: boolean
170
280
  }
171
281
 
172
- export type WatchHandler<T> = string | ((val: T, oldVal: T) => void);
282
+ export type WatchHandler<T> = string | ((val: T, oldVal: T) => void)
173
283
 
174
284
  export interface WatchOptions {
175
- deep?: boolean;
176
- immediate?: boolean;
285
+ deep?: boolean
286
+ immediate?: boolean
177
287
  }
178
288
 
179
289
  export interface WatchOptionsWithHandler<T> extends WatchOptions {
180
- handler: WatchHandler<T>;
290
+ handler: WatchHandler<T>
181
291
  }
182
292
 
183
293
  export interface DirectiveBinding extends Readonly<VNodeDirective> {
184
- readonly modifiers: { [key: string]: boolean };
294
+ readonly modifiers: { [key: string]: boolean }
185
295
  }
186
296
 
187
297
  export type DirectiveFunction = (
@@ -189,18 +299,41 @@ export type DirectiveFunction = (
189
299
  binding: DirectiveBinding,
190
300
  vnode: VNode,
191
301
  oldVnode: VNode
192
- ) => void;
302
+ ) => void
193
303
 
194
304
  export interface DirectiveOptions {
195
- bind?: DirectiveFunction;
196
- inserted?: DirectiveFunction;
197
- update?: DirectiveFunction;
198
- componentUpdated?: DirectiveFunction;
199
- unbind?: DirectiveFunction;
305
+ bind?: DirectiveFunction
306
+ inserted?: DirectiveFunction
307
+ update?: DirectiveFunction
308
+ componentUpdated?: DirectiveFunction
309
+ unbind?: DirectiveFunction
200
310
  }
201
311
 
202
- export type InjectKey = string | symbol;
312
+ export type InjectKey = string | symbol
313
+
314
+ export type InjectOptions =
315
+ | {
316
+ [key: string]: InjectKey | { from?: InjectKey; default?: any }
317
+ }
318
+ | string[]
319
+
320
+ export type DebuggerEvent = {
321
+ target: object
322
+ type: TrackOpTypes | TriggerOpTypes
323
+ key?: any
324
+ newValue?: any
325
+ oldValue?: any
326
+ oldTarget?: Map<any, any> | Set<any>
327
+ }
203
328
 
204
- export type InjectOptions = {
205
- [key: string]: InjectKey | { from?: InjectKey, default?: any }
206
- } | string[];
329
+ export const enum TrackOpTypes {
330
+ GET = 'get',
331
+ TOUCH = 'touch'
332
+ }
333
+
334
+ export const enum TriggerOpTypes {
335
+ SET = 'set',
336
+ ADD = 'add',
337
+ DELETE = 'delete',
338
+ ARRAY_MUTATION = 'array mutation'
339
+ }
package/types/plugin.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Vue as _Vue } from "./vue";
1
+ import { Vue as _Vue } from './vue'
2
2
 
3
- export type PluginFunction<T> = (Vue: typeof _Vue, options?: T) => void;
3
+ export type PluginFunction<T> = (Vue: typeof _Vue, options?: T) => void
4
4
 
5
5
  export interface PluginObject<T> {
6
- install: PluginFunction<T>;
7
- [key: string]: any;
6
+ install: PluginFunction<T>
7
+ [key: string]: any
8
8
  }
package/types/umd.d.ts CHANGED
@@ -1,48 +1,68 @@
1
- import * as V from "./index";
1
+ import * as V from './index'
2
2
  import {
3
3
  DefaultData,
4
4
  DefaultProps,
5
5
  DefaultMethods,
6
6
  DefaultComputed,
7
7
  PropsDefinition
8
- } from "./options";
8
+ } from './options'
9
9
 
10
10
  // Expose some types for backward compatibility...
11
11
  declare namespace Vue {
12
12
  // vue.d.ts
13
- export type CreateElement = V.CreateElement;
14
- export type VueConstructor<V extends Vue = Vue> = V.VueConstructor<V>;
13
+ export type CreateElement = V.CreateElement
14
+ export type VueConstructor<V extends Vue = Vue> = V.VueConstructor<V>
15
15
 
16
16
  // options.d.ts
17
- export type Component<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = V.Component<Data, Methods, Computed, Props>;
18
- export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = V.AsyncComponent<Data, Methods, Computed, Props>;
19
- export type ComponentOptions<V extends Vue, Data=DefaultData<V>, Methods=DefaultMethods<V>, Computed=DefaultComputed, PropsDef=PropsDefinition<DefaultProps>, Props=DefaultProps> = V.ComponentOptions<V, Data, Methods, Computed, PropsDef, Props>;
20
- export type FunctionalComponentOptions<Props = DefaultProps, PropDefs = PropsDefinition<Props>> = V.FunctionalComponentOptions<Props, PropDefs>;
21
- export type RenderContext<Props=DefaultProps> = V.RenderContext<Props>;
22
- export type PropType<T> = V.PropType<T>;
23
- export type PropOptions<T=any> = V.PropOptions<T>;
24
- export type ComputedOptions<T> = V.ComputedOptions<T>;
25
- export type WatchHandler<T> = V.WatchHandler<T>;
26
- export type WatchOptions = V.WatchOptions;
27
- export type WatchOptionsWithHandler<T> = V.WatchOptionsWithHandler<T>;
28
- export type DirectiveFunction = V.DirectiveFunction;
29
- export type DirectiveOptions = V.DirectiveOptions;
17
+ export type Component<
18
+ Data = DefaultData<never>,
19
+ Methods = DefaultMethods<never>,
20
+ Computed = DefaultComputed,
21
+ Props = DefaultProps
22
+ > = V.Component<Data, Methods, Computed, Props>
23
+ export type AsyncComponent<
24
+ Data = DefaultData<never>,
25
+ Methods = DefaultMethods<never>,
26
+ Computed = DefaultComputed,
27
+ Props = DefaultProps
28
+ > = V.AsyncComponent<Data, Methods, Computed, Props>
29
+ export type ComponentOptions<
30
+ V extends Vue,
31
+ Data = DefaultData<V>,
32
+ Methods = DefaultMethods<V>,
33
+ Computed = DefaultComputed,
34
+ PropsDef = PropsDefinition<DefaultProps>,
35
+ Props = DefaultProps
36
+ > = V.ComponentOptions<V, Data, Methods, Computed, PropsDef, Props>
37
+ export type FunctionalComponentOptions<
38
+ Props = DefaultProps,
39
+ PropDefs = PropsDefinition<Props>
40
+ > = V.FunctionalComponentOptions<Props, PropDefs>
41
+ export type RenderContext<Props = DefaultProps> = V.RenderContext<Props>
42
+ export type PropType<T> = V.PropType<T>
43
+ export type PropOptions<T = any> = V.PropOptions<T>
44
+ export type ComputedOptions<T> = V.ComputedOptions<T>
45
+ export type WatchHandler<T> = V.WatchHandler<T>
46
+ export type WatchOptions = V.WatchOptions
47
+ export type WatchOptionsWithHandler<T> = V.WatchOptionsWithHandler<T>
48
+ export type DirectiveFunction = V.DirectiveFunction
49
+ export type DirectiveOptions = V.DirectiveOptions
30
50
 
31
51
  // plugin.d.ts
32
- export type PluginFunction<T> = V.PluginFunction<T>;
33
- export type PluginObject<T> = V.PluginObject<T>;
52
+ export type PluginFunction<T> = V.PluginFunction<T>
53
+ export type PluginObject<T> = V.PluginObject<T>
34
54
 
35
55
  // vnode.d.ts
36
- export type VNodeChildren = V.VNodeChildren;
37
- export type VNodeChildrenArrayContents = V.VNodeChildrenArrayContents;
38
- export type VNode = V.VNode;
39
- export type VNodeComponentOptions = V.VNodeComponentOptions;
40
- export type VNodeData = V.VNodeData;
41
- export type VNodeDirective = V.VNodeDirective;
56
+ export type VNodeChildren = V.VNodeChildren
57
+ export type VNodeChildrenArrayContents = V.VNodeChildrenArrayContents
58
+ export type VNode = V.VNode
59
+ export type VNodeComponentOptions = V.VNodeComponentOptions
60
+ export type VNodeData = V.VNodeData
61
+ export type VNodeDirective = V.VNodeDirective
42
62
  }
43
63
 
44
64
  declare class Vue extends V.default {}
45
65
 
46
- export = Vue;
66
+ export = Vue
47
67
 
48
- export as namespace Vue;
68
+ export as namespace Vue