chore:更换到主分支

This commit is contained in:
张益铭
2021-03-01 15:26:05 +08:00
parent 9064b372e8
commit 6a5f1810f9
3530 changed files with 59613 additions and 479452 deletions

View File

@@ -7,8 +7,8 @@ var shared = require('@vue/shared');
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -99,7 +99,7 @@ function track(target, type, key) {
if (!dep.has(activeEffect)) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
if (activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
@@ -172,7 +172,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
}
}
const run = (effect) => {
if ( effect.options.onTrigger) {
if (effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
@@ -193,6 +193,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(shared.isSymbol));
@@ -241,13 +242,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = shared.isArray(target);
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (shared.isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -396,11 +397,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -415,14 +416,14 @@ function set$1(key, value) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (shared.hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -446,7 +447,7 @@ function deleteEntry(key) {
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = shared.isMap(target)
const oldTarget = shared.isMap(target)
? new Map(target)
: new Set(target)
;
@@ -632,19 +633,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -732,7 +741,7 @@ function createRef(rawValue, shallow = false) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -773,7 +782,7 @@ function customRef(factory) {
return new CustomRefImpl(factory);
}
function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = shared.isArray(object) ? new Array(object.length) : {};
@@ -834,7 +843,7 @@ function computed(getterOrOptions) {
let setter;
if (shared.isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');
}
;

View File

@@ -7,8 +7,8 @@ var shared = require('@vue/shared');
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( '');
const MAP_KEY_ITERATE_KEY = Symbol( '');
const ITERATE_KEY = Symbol('');
const MAP_KEY_ITERATE_KEY = Symbol('');
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -174,6 +174,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(shared.isSymbol));
@@ -222,13 +223,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = shared.isArray(target);
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (shared.isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -281,7 +282,7 @@ function createSetter(shallow = false) {
}
function deleteProperty(target, key) {
const hadKey = shared.hasOwn(target, key);
const oldValue = target[key];
target[key];
const result = Reflect.deleteProperty(target, key);
if (result && hadKey) {
trigger(target, "delete" /* DELETE */, key, undefined);
@@ -371,11 +372,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -387,14 +388,14 @@ function set$1(key, value) {
hadKey = has.call(target, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (shared.hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -404,7 +405,7 @@ function deleteEntry(key) {
key = toRaw(key);
hadKey = has.call(target, key);
}
const oldValue = get ? get.call(target, key) : undefined;
get ? get.call(target, key) : undefined;
// forward the operation before queueing reactions
const result = target.delete(key);
if (hadKey) {
@@ -582,19 +583,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -679,7 +688,7 @@ function createRef(rawValue, shallow = false) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', void 0);
trigger(toRaw(ref), "set" /* SET */, 'value', void 0);
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -778,7 +787,7 @@ function computed(getterOrOptions) {
let setter;
if (shared.isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = shared.NOOP;
setter = shared.NOOP;
}
else {
getter = getterOrOptions.get;

View File

@@ -67,6 +67,28 @@ declare type Primitive = string | number | boolean | bigint | symbol | undefined
export declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
/**
* Creates a reactive copy of the original object.
*
* The reactive conversion is "deep"—it affects all nested properties. In the
* ES2015 Proxy based implementation, the returned proxy is **not** equal to the
* original object. It is recommended to work exclusively with the reactive
* proxy and avoid relying on the original object.
*
* A reactive object also automatically unwraps refs contained in it, so you
* don't need to use `.value` when accessing and mutating their value:
*
* ```js
* const count = ref(0)
* const obj = reactive({
* count
* })
*
* obj.count++
* obj.count // -> 1
* count.value // -> 1
* ```
*/
export declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
export declare interface ReactiveEffect<T = any> {
@@ -96,6 +118,10 @@ export declare const enum ReactiveFlags {
RAW = "__v_raw"
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
export declare interface Ref<T = any> {
@@ -109,7 +135,7 @@ export declare interface Ref<T = any> {
/* Excluded from this release type: _shallow */
}
export declare function ref<T extends object>(value: T): T extends Ref ? T : Ref<UnwrapRef<T>>;
export declare function ref<T extends object>(value: T): ToRef<T>;
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
@@ -139,8 +165,19 @@ export declare interface RefUnwrapBailTypes {
export declare function resetTracking(): void;
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
export declare function shallowReactive<T extends object>(target: T): T;
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
export declare function shallowReadonly<T extends object>(target: T): Readonly<{
[K in keyof T]: UnwrapNestedRefs<T[K]>;
}>;
@@ -214,10 +251,12 @@ declare type SymbolExtract<T> = (T extends {
export declare function toRaw<T>(observed: T): T;
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): Ref<T[K]>;
declare type ToRef<T> = [T] extends [Ref] ? T : Ref<UnwrapRef<T>>;
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
export declare type ToRefs<T = any> = {
[K in keyof T]: Ref<T[K]>;
[K in keyof T]: T[K] extends Ref ? T[K] : Ref<UnwrapRef<T[K]>>;
};
export declare function toRefs<T extends object>(object: T): ToRefs<T>;

View File

@@ -1,6 +1,22 @@
const EMPTY_OBJ = Object.freeze({})
/**
* Make a map and return a function for checking if a key
* is in that map.
* IMPORTANT: all calls of this function must be prefixed with
* \/\*#\_\_PURE\_\_\*\/
* So that rollup can tree-shake them if necessary.
*/
function makeMap(str, expectsLowerCase) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
const EMPTY_OBJ = Object.freeze({})
;
const EMPTY_ARR = Object.freeze([]) ;
Object.freeze([]) ;
const extend = Object.assign;
const hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
@@ -44,8 +60,8 @@ const def = (obj, key, value) => {
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -136,7 +152,7 @@ function track(target, type, key) {
if (!dep.has(activeEffect)) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
if (activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
@@ -209,7 +225,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
}
}
const run = (effect) => {
if ( effect.options.onTrigger) {
if (effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
@@ -230,6 +246,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(isSymbol));
@@ -278,13 +295,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -433,11 +450,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -452,14 +469,14 @@ function set$1(key, value) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -483,7 +500,7 @@ function deleteEntry(key) {
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = isMap(target)
const oldTarget = isMap(target)
? new Map(target)
: new Set(target)
;
@@ -669,19 +686,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -769,7 +794,7 @@ function createRef(rawValue, shallow = false) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -810,7 +835,7 @@ function customRef(factory) {
return new CustomRefImpl(factory);
}
function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = isArray(object) ? new Array(object.length) : {};
@@ -871,7 +896,7 @@ function computed(getterOrOptions) {
let setter;
if (isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');
}
;

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared';
import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared';
const targetMap = new WeakMap();
const effectStack = [];
@@ -189,6 +189,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(isSymbol));
@@ -237,13 +238,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -392,11 +393,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -411,14 +412,14 @@ function set$1(key, value) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -629,19 +630,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}

View File

@@ -1,9 +1,25 @@
var VueReactivity = (function (exports) {
'use strict';
const EMPTY_OBJ = Object.freeze({})
/**
* Make a map and return a function for checking if a key
* is in that map.
* IMPORTANT: all calls of this function must be prefixed with
* \/\*#\_\_PURE\_\_\*\/
* So that rollup can tree-shake them if necessary.
*/
function makeMap(str, expectsLowerCase) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
const EMPTY_OBJ = Object.freeze({})
;
const EMPTY_ARR = Object.freeze([]) ;
Object.freeze([]) ;
const extend = Object.assign;
const hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
@@ -47,8 +63,8 @@ var VueReactivity = (function (exports) {
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -139,7 +155,7 @@ var VueReactivity = (function (exports) {
if (!dep.has(activeEffect)) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
if (activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
@@ -212,7 +228,7 @@ var VueReactivity = (function (exports) {
}
}
const run = (effect) => {
if ( effect.options.onTrigger) {
if (effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
@@ -233,6 +249,7 @@ var VueReactivity = (function (exports) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(isSymbol));
@@ -281,13 +298,13 @@ var VueReactivity = (function (exports) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -436,11 +453,11 @@ var VueReactivity = (function (exports) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -455,14 +472,14 @@ var VueReactivity = (function (exports) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -486,7 +503,7 @@ var VueReactivity = (function (exports) {
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = isMap(target)
const oldTarget = isMap(target)
? new Map(target)
: new Set(target)
;
@@ -672,19 +689,27 @@ var VueReactivity = (function (exports) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -772,7 +797,7 @@ var VueReactivity = (function (exports) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -813,7 +838,7 @@ var VueReactivity = (function (exports) {
return new CustomRefImpl(factory);
}
function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = isArray(object) ? new Array(object.length) : {};
@@ -874,7 +899,7 @@ var VueReactivity = (function (exports) {
let setter;
if (isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');
}
;
@@ -914,6 +939,8 @@ var VueReactivity = (function (exports) {
exports.triggerRef = triggerRef;
exports.unref = unref;
Object.defineProperty(exports, '__esModule', { value: true });
return exports;
}({}));

File diff suppressed because one or more lines are too long