vue 2.7.2 → 2.7.5
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.
- package/dist/vue.common.dev.js +3395 -3308
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +3351 -3265
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +3628 -3539
- package/dist/vue.js +3408 -3318
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +2788 -2701
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +2737 -2648
- package/dist/vue.runtime.js +2810 -2720
- package/dist/vue.runtime.min.js +3 -3
- package/dist/vue.runtime.mjs +73 -8604
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +1004 -1000
- package/packages/compiler-sfc/package.json +1 -1
- package/packages/compiler-sfc/src/parseComponent.ts +7 -4
- package/packages/compiler-sfc/test/parseComponent.spec.ts +6 -7
- package/src/core/components/keep-alive.ts +5 -4
- package/src/core/global-api/extend.ts +3 -1
- package/src/core/instance/init.ts +1 -1
- package/src/core/instance/lifecycle.ts +8 -3
- package/src/core/instance/render-helpers/render-static.ts +1 -1
- package/src/core/observer/index.ts +54 -55
- package/src/core/observer/traverse.ts +3 -0
- package/src/core/util/debug.ts +2 -1
- package/src/core/vdom/create-component.ts +5 -1
- package/src/platforms/web/runtime/components/transition-group.ts +2 -1
- package/src/shared/constants.ts +3 -1
- package/src/v3/apiAsyncComponent.ts +117 -0
- package/src/v3/apiWatch.ts +6 -8
- package/src/v3/index.ts +6 -0
- package/src/v3/reactivity/reactive.ts +13 -2
- package/src/v3/reactivity/ref.ts +17 -4
- package/types/jsx.d.ts +6 -0
- package/types/options.d.ts +5 -3
- package/types/v3-component-public-instance.d.ts +36 -32
- package/types/v3-define-async-component.d.ts +26 -0
- package/types/v3-define-component.d.ts +25 -1
- package/types/v3-generated.d.ts +23 -0
- package/types/vue.d.ts +27 -12
package/src/v3/reactivity/ref.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from './reactive'
|
|
7
7
|
import type { IfAny } from 'types/utils'
|
|
8
8
|
import Dep from 'core/observer/dep'
|
|
9
|
-
import { warn, isArray, def } from 'core/util'
|
|
9
|
+
import { warn, isArray, def, isServerRendering } from 'core/util'
|
|
10
10
|
import { TrackOpTypes, TriggerOpTypes } from './operations'
|
|
11
11
|
|
|
12
12
|
declare const RefSymbol: unique symbol
|
|
@@ -68,8 +68,12 @@ function createRef(rawValue: unknown, shallow: boolean) {
|
|
|
68
68
|
}
|
|
69
69
|
const ref: any = {}
|
|
70
70
|
def(ref, RefFlag, true)
|
|
71
|
-
def(ref, ReactiveFlags.IS_SHALLOW,
|
|
72
|
-
|
|
71
|
+
def(ref, ReactiveFlags.IS_SHALLOW, shallow)
|
|
72
|
+
def(
|
|
73
|
+
ref,
|
|
74
|
+
'dep',
|
|
75
|
+
defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering())
|
|
76
|
+
)
|
|
73
77
|
return ref
|
|
74
78
|
}
|
|
75
79
|
|
|
@@ -115,7 +119,16 @@ export function proxyWithRefUnwrap(
|
|
|
115
119
|
Object.defineProperty(target, key, {
|
|
116
120
|
enumerable: true,
|
|
117
121
|
configurable: true,
|
|
118
|
-
get: () =>
|
|
122
|
+
get: () => {
|
|
123
|
+
const val = source[key]
|
|
124
|
+
if (isRef(val)) {
|
|
125
|
+
return val.value
|
|
126
|
+
} else {
|
|
127
|
+
const ob = val && val.__ob__
|
|
128
|
+
if (ob) ob.dep.depend()
|
|
129
|
+
return val
|
|
130
|
+
}
|
|
131
|
+
},
|
|
119
132
|
set: value => {
|
|
120
133
|
const oldValue = source[key]
|
|
121
134
|
if (isRef(oldValue) && !isRef(value)) {
|
package/types/jsx.d.ts
CHANGED
|
@@ -1303,6 +1303,12 @@ type EventHandlers<E> = {
|
|
|
1303
1303
|
type ReservedProps = {
|
|
1304
1304
|
key?: string | number | symbol
|
|
1305
1305
|
ref?: VNodeData['ref']
|
|
1306
|
+
/**
|
|
1307
|
+
* @deprecated Old named slot syntax has been deprecated, use the new syntax
|
|
1308
|
+
* instead: `<template v-slot:name>`
|
|
1309
|
+
* https://v2.vuejs.org/v2/guide/components-slots.html#Named-Slots
|
|
1310
|
+
*/
|
|
1311
|
+
slot?: string
|
|
1306
1312
|
}
|
|
1307
1313
|
|
|
1308
1314
|
type ElementAttrs<T> = T & ReservedProps
|
package/types/options.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type Component<
|
|
|
20
20
|
| typeof Vue
|
|
21
21
|
| FunctionalComponentOptions<Props>
|
|
22
22
|
| ComponentOptions<never, Data, Methods, Computed, Props, SetupBindings>
|
|
23
|
-
| DefineComponent<any, any, any, any, any>
|
|
23
|
+
| DefineComponent<any, any, any, any, any, any, any, any, any, any, any>
|
|
24
24
|
|
|
25
25
|
type EsModule<T> = T | { default: T }
|
|
26
26
|
|
|
@@ -201,9 +201,9 @@ export interface ComponentOptions<
|
|
|
201
201
|
directives?: { [key: string]: DirectiveFunction | DirectiveOptions }
|
|
202
202
|
components?: {
|
|
203
203
|
[key: string]:
|
|
204
|
-
|
|
|
204
|
+
| {}
|
|
205
|
+
| Component<any, any, any, any, any>
|
|
205
206
|
| AsyncComponent<any, any, any, any>
|
|
206
|
-
| DefineComponent<any, any, any, any, any, any, any, any, any, any>
|
|
207
207
|
}
|
|
208
208
|
transitions?: { [key: string]: object }
|
|
209
209
|
filters?: { [key: string]: Function }
|
|
@@ -219,6 +219,8 @@ export interface ComponentOptions<
|
|
|
219
219
|
parent?: Vue
|
|
220
220
|
mixins?: (ComponentOptions<Vue> | typeof Vue)[]
|
|
221
221
|
name?: string
|
|
222
|
+
// for SFC auto name inference w/ ts-loader check
|
|
223
|
+
__name?: string
|
|
222
224
|
// TODO: support properly inferred 'extends'
|
|
223
225
|
extends?: ComponentOptions<Vue> | typeof Vue
|
|
224
226
|
delimiters?: [string, string]
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { ExtractDefaultPropTypes, ExtractPropTypes } from './v3-component-props'
|
|
2
1
|
import {
|
|
3
2
|
DebuggerEvent,
|
|
4
|
-
nextTick,
|
|
5
3
|
ShallowUnwrapRef,
|
|
6
|
-
UnwrapNestedRefs
|
|
7
|
-
WatchOptions,
|
|
8
|
-
WatchStopHandle
|
|
4
|
+
UnwrapNestedRefs
|
|
9
5
|
} from './v3-generated'
|
|
10
|
-
import {
|
|
6
|
+
import { UnionToIntersection } from './common'
|
|
11
7
|
|
|
12
|
-
import { VueConstructor } from './vue'
|
|
8
|
+
import { Vue, VueConstructor } from './vue'
|
|
13
9
|
import {
|
|
14
10
|
ComputedOptions,
|
|
15
11
|
MethodOptions,
|
|
@@ -17,7 +13,7 @@ import {
|
|
|
17
13
|
ComponentOptionsMixin,
|
|
18
14
|
ComponentOptionsBase
|
|
19
15
|
} from './v3-component-options'
|
|
20
|
-
import { EmitFn, EmitsOptions
|
|
16
|
+
import { EmitFn, EmitsOptions } from './v3-setup-context'
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* Custom properties added to component instances in any way and can be accessed through `this`
|
|
@@ -152,36 +148,44 @@ export type ComponentPublicInstance<
|
|
|
152
148
|
any,
|
|
153
149
|
any
|
|
154
150
|
>
|
|
155
|
-
> =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
$slots: Slots
|
|
166
|
-
$root: ComponentPublicInstance | null
|
|
167
|
-
$parent: ComponentPublicInstance | null
|
|
168
|
-
$emit: EmitFn<E>
|
|
169
|
-
$el: any
|
|
170
|
-
$options: Options & MergedComponentOptionsOverride
|
|
171
|
-
$forceUpdate: () => void
|
|
172
|
-
$nextTick: typeof nextTick
|
|
173
|
-
$watch(
|
|
174
|
-
source: string | Function,
|
|
175
|
-
cb: Function,
|
|
176
|
-
options?: WatchOptions
|
|
177
|
-
): WatchStopHandle
|
|
178
|
-
} & Readonly<P> &
|
|
151
|
+
> = Vue3Instance<
|
|
152
|
+
D,
|
|
153
|
+
P,
|
|
154
|
+
PublicProps,
|
|
155
|
+
E,
|
|
156
|
+
Defaults,
|
|
157
|
+
MakeDefaultsOptional,
|
|
158
|
+
Options
|
|
159
|
+
> &
|
|
160
|
+
Readonly<P> &
|
|
179
161
|
ShallowUnwrapRef<B> &
|
|
180
162
|
UnwrapNestedRefs<D> &
|
|
181
163
|
ExtractComputedReturns<C> &
|
|
182
164
|
M &
|
|
183
165
|
ComponentCustomProperties
|
|
184
166
|
|
|
167
|
+
interface Vue3Instance<
|
|
168
|
+
D,
|
|
169
|
+
P,
|
|
170
|
+
PublicProps,
|
|
171
|
+
E,
|
|
172
|
+
Defaults,
|
|
173
|
+
MakeDefaultsOptional,
|
|
174
|
+
Options
|
|
175
|
+
> extends Vue<
|
|
176
|
+
D,
|
|
177
|
+
Readonly<
|
|
178
|
+
MakeDefaultsOptional extends true
|
|
179
|
+
? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults>
|
|
180
|
+
: P & PublicProps
|
|
181
|
+
>,
|
|
182
|
+
ComponentPublicInstance | null,
|
|
183
|
+
ComponentPublicInstance,
|
|
184
|
+
ComponentPublicInstance[],
|
|
185
|
+
Options & MergedComponentOptionsOverride,
|
|
186
|
+
EmitFn<E>
|
|
187
|
+
> {}
|
|
188
|
+
|
|
185
189
|
type MergedHook<T = () => void> = T | T[]
|
|
186
190
|
|
|
187
191
|
export type MergedComponentOptionsOverride = {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AsyncComponent, Component } from './options'
|
|
2
|
+
|
|
3
|
+
export type AsyncComponentResolveResult<T = Component> = T | { default: T } // es modules
|
|
4
|
+
|
|
5
|
+
export type AsyncComponentLoader<T = any> = () => Promise<
|
|
6
|
+
AsyncComponentResolveResult<T>
|
|
7
|
+
>
|
|
8
|
+
|
|
9
|
+
export interface AsyncComponentOptions {
|
|
10
|
+
loader: AsyncComponentLoader
|
|
11
|
+
loadingComponent?: Component
|
|
12
|
+
errorComponent?: Component
|
|
13
|
+
delay?: number
|
|
14
|
+
timeout?: number
|
|
15
|
+
// suspensible?: boolean
|
|
16
|
+
onError?: (
|
|
17
|
+
error: Error,
|
|
18
|
+
retry: () => void,
|
|
19
|
+
fail: () => void,
|
|
20
|
+
attempts: number
|
|
21
|
+
) => any
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function defineAsyncComponent(
|
|
25
|
+
source: AsyncComponentLoader | AsyncComponentOptions
|
|
26
|
+
): AsyncComponent
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Component } from '..'
|
|
2
1
|
import {
|
|
3
2
|
ComponentPropsOptions,
|
|
4
3
|
ExtractDefaultPropTypes,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
} from './v3-component-public-instance'
|
|
20
19
|
import { Data, HasDefined } from './common'
|
|
21
20
|
import { EmitsOptions } from './v3-setup-context'
|
|
21
|
+
import { CreateElement, RenderContext } from './umd'
|
|
22
22
|
|
|
23
23
|
type DefineComponent<
|
|
24
24
|
PropsOrPropOptions = {},
|
|
@@ -67,6 +67,30 @@ type DefineComponent<
|
|
|
67
67
|
props: PropsOrPropOptions
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* overload 0.0: functional component with array props
|
|
72
|
+
*/
|
|
73
|
+
export function defineComponent<
|
|
74
|
+
PropNames extends string,
|
|
75
|
+
Props = Readonly<{ [key in PropNames]?: any }>
|
|
76
|
+
>(options: {
|
|
77
|
+
functional: true
|
|
78
|
+
props?: PropNames[]
|
|
79
|
+
render?: (h: CreateElement, context: RenderContext<Props>) => any
|
|
80
|
+
}): DefineComponent<Props>
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* overload 0.1: functional component with object props
|
|
84
|
+
*/
|
|
85
|
+
export function defineComponent<
|
|
86
|
+
PropsOptions extends ComponentPropsOptions = ComponentPropsOptions,
|
|
87
|
+
Props = ExtractPropTypes<PropsOptions>
|
|
88
|
+
>(options: {
|
|
89
|
+
functional: true
|
|
90
|
+
props?: PropsOptions
|
|
91
|
+
render?: (h: CreateElement, context: RenderContext<Props>) => any
|
|
92
|
+
}): DefineComponent<PropsOptions>
|
|
93
|
+
|
|
70
94
|
/**
|
|
71
95
|
* overload 1: object format with no props
|
|
72
96
|
*/
|
package/types/v3-generated.d.ts
CHANGED
|
@@ -2,6 +2,24 @@ declare type ASTModifiers = {
|
|
|
2
2
|
[key: string]: boolean;
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
+
declare type AsyncComponentFactory = () => {
|
|
6
|
+
component: Promise<any>;
|
|
7
|
+
loading?: any;
|
|
8
|
+
error?: any;
|
|
9
|
+
delay?: number;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare interface AsyncComponentOptions {
|
|
14
|
+
loader: Function;
|
|
15
|
+
loadingComponent?: any;
|
|
16
|
+
errorComponent?: any;
|
|
17
|
+
delay?: number;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
suspensible?: boolean;
|
|
20
|
+
onError?: (error: Error, retry: () => void, fail: () => void, attempts: number) => any;
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
declare type BaseTypes = string | number | boolean;
|
|
6
24
|
|
|
7
25
|
declare type Builtin = Primitive | Function | Date | Error | RegExp;
|
|
@@ -57,6 +75,8 @@ export declare type DeepReadonly<T> = T extends Builtin ? T : T extends Map<infe
|
|
|
57
75
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
58
76
|
} : Readonly<T>;
|
|
59
77
|
|
|
78
|
+
/* Excluded from this release type: defineAsyncComponent */
|
|
79
|
+
|
|
60
80
|
/* Excluded from this release type: defineComponent */
|
|
61
81
|
|
|
62
82
|
/**
|
|
@@ -346,6 +366,9 @@ export declare function useCssVars(getter: (vm: Record<string, any>, setupProxy:
|
|
|
346
366
|
|
|
347
367
|
/* Excluded from this release type: useSlots */
|
|
348
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Note: also update dist/vue.runtime.mjs when adding new exports to this file.
|
|
371
|
+
*/
|
|
349
372
|
export declare const version: string;
|
|
350
373
|
|
|
351
374
|
/* Excluded from this release type: VNode */
|
package/types/vue.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
AsyncComponent,
|
|
4
4
|
ComponentOptions,
|
|
5
5
|
FunctionalComponentOptions,
|
|
6
|
-
WatchOptionsWithHandler,
|
|
7
|
-
WatchHandler,
|
|
8
6
|
DirectiveOptions,
|
|
9
7
|
DirectiveFunction,
|
|
10
8
|
RecordPropsDefinition,
|
|
@@ -14,6 +12,8 @@ import {
|
|
|
14
12
|
} from './options'
|
|
15
13
|
import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from './vnode'
|
|
16
14
|
import { PluginFunction, PluginObject } from './plugin'
|
|
15
|
+
import { DefineComponent } from './v3-define-component'
|
|
16
|
+
import { nextTick } from './v3-generated'
|
|
17
17
|
|
|
18
18
|
export interface CreateElement {
|
|
19
19
|
(
|
|
@@ -35,20 +35,33 @@ export interface CreateElement {
|
|
|
35
35
|
): VNode
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export interface Vue
|
|
39
|
-
|
|
38
|
+
export interface Vue<
|
|
39
|
+
Data = Record<string, any>,
|
|
40
|
+
Props = Record<string, any>,
|
|
41
|
+
Parent = never,
|
|
42
|
+
Root = never,
|
|
43
|
+
Children = never,
|
|
44
|
+
Options = never,
|
|
45
|
+
Emit = (event: string, ...args: any[]) => Vue
|
|
46
|
+
> {
|
|
47
|
+
// properties with different types in defineComponent()
|
|
48
|
+
readonly $data: Data
|
|
49
|
+
readonly $props: Props
|
|
50
|
+
readonly $parent: Parent extends never ? Vue : Parent
|
|
51
|
+
readonly $root: Root extends never ? Vue : Root
|
|
52
|
+
readonly $children: Children extends never ? Vue[] : Children
|
|
40
53
|
readonly $options: ComponentOptions<Vue>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
$emit: Emit
|
|
55
|
+
|
|
56
|
+
// Vue 2 only or shared
|
|
57
|
+
readonly $el: Element
|
|
44
58
|
readonly $refs: {
|
|
45
59
|
[key: string]: Vue | Element | (Vue | Element)[] | undefined
|
|
46
60
|
}
|
|
47
61
|
readonly $slots: { [key: string]: VNode[] | undefined }
|
|
48
62
|
readonly $scopedSlots: { [key: string]: NormalizedScopedSlot | undefined }
|
|
49
63
|
readonly $isServer: boolean
|
|
50
|
-
|
|
51
|
-
readonly $props: Record<string, any>
|
|
64
|
+
|
|
52
65
|
readonly $ssrContext: any
|
|
53
66
|
readonly $vnode: VNode
|
|
54
67
|
readonly $attrs: Record<string, string>
|
|
@@ -72,9 +85,7 @@ export interface Vue {
|
|
|
72
85
|
$on(event: string | string[], callback: Function): this
|
|
73
86
|
$once(event: string | string[], callback: Function): this
|
|
74
87
|
$off(event?: string | string[], callback?: Function): this
|
|
75
|
-
$
|
|
76
|
-
$nextTick(callback: (this: this) => void): void
|
|
77
|
-
$nextTick(): Promise<void>
|
|
88
|
+
$nextTick: typeof nextTick
|
|
78
89
|
$createElement: CreateElement
|
|
79
90
|
}
|
|
80
91
|
|
|
@@ -313,6 +324,10 @@ export interface VueConstructor<V extends Vue = Vue> {
|
|
|
313
324
|
id: string,
|
|
314
325
|
definition?: ComponentOptions<V>
|
|
315
326
|
): ExtendedVue<V, {}, {}, {}, {}, {}>
|
|
327
|
+
component<T extends DefineComponent<any, any, any, any, any, any, any, any>>(
|
|
328
|
+
id: string,
|
|
329
|
+
definition?: T
|
|
330
|
+
): T
|
|
316
331
|
|
|
317
332
|
use<T>(
|
|
318
333
|
plugin: PluginObject<T> | PluginFunction<T>,
|