@vue/reactivity
Advanced tools
Comparing version 3.0.0-rc.5 to 3.0.0-rc.6
@@ -120,3 +120,7 @@ 'use strict'; | ||
if (effectsToAdd) { | ||
effectsToAdd.forEach(effect => effects.add(effect)); | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
effects.add(effect); | ||
} | ||
}); | ||
} | ||
@@ -328,31 +332,35 @@ }; | ||
const getProto = (v) => Reflect.getPrototypeOf(v); | ||
function get$1(target, key, wrap) { | ||
target = toRaw(target); | ||
function get$1(target, key, isReadonly = false, isShallow = false) { | ||
// #1772: readonly(reactive(Map)) should return readonly + reactive version | ||
// of the value | ||
target = target["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "get" /* GET */, key); | ||
!isReadonly && track(rawTarget, "get" /* GET */, key); | ||
} | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
!isReadonly && track(rawTarget, "get" /* GET */, rawKey); | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
return wrap(target.get(key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
else if (has.call(rawTarget, rawKey)) { | ||
return wrap(target.get(rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
function has$1(key, isReadonly = false) { | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "has" /* HAS */, key); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, key); | ||
} | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, rawKey); | ||
return target.has(key) || target.has(rawKey); | ||
} | ||
function size(target) { | ||
target = toRaw(target); | ||
track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(getProto(target), 'size', target); | ||
function size(target, isReadonly = false) { | ||
target = target["__v_raw" /* RAW */]; | ||
!isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(target, 'size', target); | ||
} | ||
@@ -425,7 +433,7 @@ function add(value) { | ||
} | ||
function createForEach(isReadonly, shallow) { | ||
function createForEach(isReadonly, isShallow) { | ||
return function forEach(callback, thisArg) { | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -441,12 +449,13 @@ // important: create sure the callback is | ||
} | ||
function createIterableMethod(method, isReadonly, shallow) { | ||
function createIterableMethod(method, isReadonly, isShallow) { | ||
return function (...args) { | ||
const target = toRaw(this); | ||
const isMap = target instanceof Map; | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const isMap = rawTarget instanceof Map; | ||
const isPair = method === 'entries' || (method === Symbol.iterator && isMap); | ||
const isKeyOnly = method === 'keys' && isMap; | ||
const innerIterator = getProto(target)[method].apply(target, args); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && | ||
track(target, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
// return a wrapped iterator which returns observed versions of the | ||
@@ -483,3 +492,3 @@ // values emitted from the real iterator | ||
get(key) { | ||
return get$1(this, key, toReactive); | ||
return get$1(this, key); | ||
}, | ||
@@ -498,3 +507,3 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toShallow); | ||
return get$1(this, key, false, true); | ||
}, | ||
@@ -513,8 +522,10 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toReadonly); | ||
return get$1(this, key, true); | ||
}, | ||
get size() { | ||
return size(this); | ||
return size(this, true); | ||
}, | ||
has: has$1, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
@@ -574,9 +585,21 @@ set: createReadonlyMethod("set" /* SET */), | ||
const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]); | ||
const isObservableType = /*#__PURE__*/ shared.makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const canObserve = (value) => { | ||
return (!value["__v_skip" /* SKIP */] && | ||
isObservableType(shared.toRawType(value)) && | ||
!Object.isFrozen(value)); | ||
}; | ||
function targetTypeMap(rawType) { | ||
switch (rawType) { | ||
case 'Object': | ||
case 'Array': | ||
return 1 /* COMMON */; | ||
case 'Map': | ||
case 'Set': | ||
case 'WeakMap': | ||
case 'WeakSet': | ||
return 2 /* COLLECTION */; | ||
default: | ||
return 0 /* INVALID */; | ||
} | ||
} | ||
function getTargetType(value) { | ||
return value["__v_skip" /* SKIP */] || !Object.isExtensible(value) | ||
? 0 /* INVALID */ | ||
: targetTypeMap(shared.toRawType(value)); | ||
} | ||
function reactive(target) { | ||
@@ -626,6 +649,7 @@ // if trying to observe a readonly proxy, return the readonly version. | ||
// only a whitelist of value types can be observed. | ||
if (!canObserve(target)) { | ||
const targetType = getTargetType(target); | ||
if (targetType === 0 /* INVALID */) { | ||
return target; | ||
} | ||
const observed = new Proxy(target, collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers); | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
shared.def(target, reactiveFlag, observed); | ||
@@ -726,3 +750,3 @@ return observed; | ||
} | ||
const ret = {}; | ||
const ret = shared.isArray(object) ? new Array(object.length) : {}; | ||
for (const key in object) { | ||
@@ -729,0 +753,0 @@ ret[key] = toRef(object, key); |
@@ -112,3 +112,7 @@ 'use strict'; | ||
if (effectsToAdd) { | ||
effectsToAdd.forEach(effect => effects.add(effect)); | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
effects.add(effect); | ||
} | ||
}); | ||
} | ||
@@ -303,31 +307,35 @@ }; | ||
const getProto = (v) => Reflect.getPrototypeOf(v); | ||
function get$1(target, key, wrap) { | ||
target = toRaw(target); | ||
function get$1(target, key, isReadonly = false, isShallow = false) { | ||
// #1772: readonly(reactive(Map)) should return readonly + reactive version | ||
// of the value | ||
target = target["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "get" /* GET */, key); | ||
!isReadonly && track(rawTarget, "get" /* GET */, key); | ||
} | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
!isReadonly && track(rawTarget, "get" /* GET */, rawKey); | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
return wrap(target.get(key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
else if (has.call(rawTarget, rawKey)) { | ||
return wrap(target.get(rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
function has$1(key, isReadonly = false) { | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "has" /* HAS */, key); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, key); | ||
} | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, rawKey); | ||
return target.has(key) || target.has(rawKey); | ||
} | ||
function size(target) { | ||
target = toRaw(target); | ||
track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(getProto(target), 'size', target); | ||
function size(target, isReadonly = false) { | ||
target = target["__v_raw" /* RAW */]; | ||
!isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(target, 'size', target); | ||
} | ||
@@ -390,7 +398,7 @@ function add(value) { | ||
} | ||
function createForEach(isReadonly, shallow) { | ||
function createForEach(isReadonly, isShallow) { | ||
return function forEach(callback, thisArg) { | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -406,12 +414,13 @@ // important: create sure the callback is | ||
} | ||
function createIterableMethod(method, isReadonly, shallow) { | ||
function createIterableMethod(method, isReadonly, isShallow) { | ||
return function (...args) { | ||
const target = toRaw(this); | ||
const isMap = target instanceof Map; | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const isMap = rawTarget instanceof Map; | ||
const isPair = method === 'entries' || (method === Symbol.iterator && isMap); | ||
const isKeyOnly = method === 'keys' && isMap; | ||
const innerIterator = getProto(target)[method].apply(target, args); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && | ||
track(target, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
// return a wrapped iterator which returns observed versions of the | ||
@@ -444,3 +453,3 @@ // values emitted from the real iterator | ||
get(key) { | ||
return get$1(this, key, toReactive); | ||
return get$1(this, key); | ||
}, | ||
@@ -459,3 +468,3 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toShallow); | ||
return get$1(this, key, false, true); | ||
}, | ||
@@ -474,8 +483,10 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toReadonly); | ||
return get$1(this, key, true); | ||
}, | ||
get size() { | ||
return size(this); | ||
return size(this, true); | ||
}, | ||
has: has$1, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
@@ -524,9 +535,21 @@ set: createReadonlyMethod("set" /* SET */), | ||
const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]); | ||
const isObservableType = /*#__PURE__*/ shared.makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const canObserve = (value) => { | ||
return (!value["__v_skip" /* SKIP */] && | ||
isObservableType(shared.toRawType(value)) && | ||
!Object.isFrozen(value)); | ||
}; | ||
function targetTypeMap(rawType) { | ||
switch (rawType) { | ||
case 'Object': | ||
case 'Array': | ||
return 1 /* COMMON */; | ||
case 'Map': | ||
case 'Set': | ||
case 'WeakMap': | ||
case 'WeakSet': | ||
return 2 /* COLLECTION */; | ||
default: | ||
return 0 /* INVALID */; | ||
} | ||
} | ||
function getTargetType(value) { | ||
return value["__v_skip" /* SKIP */] || !Object.isExtensible(value) | ||
? 0 /* INVALID */ | ||
: targetTypeMap(shared.toRawType(value)); | ||
} | ||
function reactive(target) { | ||
@@ -573,6 +596,7 @@ // if trying to observe a readonly proxy, return the readonly version. | ||
// only a whitelist of value types can be observed. | ||
if (!canObserve(target)) { | ||
const targetType = getTargetType(target); | ||
if (targetType === 0 /* INVALID */) { | ||
return target; | ||
} | ||
const observed = new Proxy(target, collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers); | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
shared.def(target, reactiveFlag, observed); | ||
@@ -670,3 +694,3 @@ return observed; | ||
function toRefs(object) { | ||
const ret = {}; | ||
const ret = shared.isArray(object) ? new Array(object.length) : {}; | ||
for (const key in object) { | ||
@@ -673,0 +697,0 @@ ret[key] = toRef(object, key); |
@@ -147,4 +147,6 @@ | ||
export declare function shallowRef<T>(value: T): T extends Ref ? T : Ref<T>; | ||
export declare function shallowRef<T extends object>(value: T): T extends Ref ? T : Ref<T>; | ||
export declare function shallowRef<T>(value: T): Ref<T>; | ||
export declare function shallowRef<T = any>(): Ref<T | undefined>; | ||
@@ -151,0 +153,0 @@ |
@@ -1,17 +0,1 @@ | ||
/** | ||
* 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({}) | ||
@@ -167,3 +151,7 @@ ; | ||
if (effectsToAdd) { | ||
effectsToAdd.forEach(effect => effects.add(effect)); | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
effects.add(effect); | ||
} | ||
}); | ||
} | ||
@@ -375,31 +363,35 @@ }; | ||
const getProto = (v) => Reflect.getPrototypeOf(v); | ||
function get$1(target, key, wrap) { | ||
target = toRaw(target); | ||
function get$1(target, key, isReadonly = false, isShallow = false) { | ||
// #1772: readonly(reactive(Map)) should return readonly + reactive version | ||
// of the value | ||
target = target["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "get" /* GET */, key); | ||
!isReadonly && track(rawTarget, "get" /* GET */, key); | ||
} | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
!isReadonly && track(rawTarget, "get" /* GET */, rawKey); | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
return wrap(target.get(key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
else if (has.call(rawTarget, rawKey)) { | ||
return wrap(target.get(rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
function has$1(key, isReadonly = false) { | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "has" /* HAS */, key); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, key); | ||
} | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, rawKey); | ||
return target.has(key) || target.has(rawKey); | ||
} | ||
function size(target) { | ||
target = toRaw(target); | ||
track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(getProto(target), 'size', target); | ||
function size(target, isReadonly = false) { | ||
target = target["__v_raw" /* RAW */]; | ||
!isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(target, 'size', target); | ||
} | ||
@@ -472,7 +464,7 @@ function add(value) { | ||
} | ||
function createForEach(isReadonly, shallow) { | ||
function createForEach(isReadonly, isShallow) { | ||
return function forEach(callback, thisArg) { | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -488,12 +480,13 @@ // important: create sure the callback is | ||
} | ||
function createIterableMethod(method, isReadonly, shallow) { | ||
function createIterableMethod(method, isReadonly, isShallow) { | ||
return function (...args) { | ||
const target = toRaw(this); | ||
const isMap = target instanceof Map; | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const isMap = rawTarget instanceof Map; | ||
const isPair = method === 'entries' || (method === Symbol.iterator && isMap); | ||
const isKeyOnly = method === 'keys' && isMap; | ||
const innerIterator = getProto(target)[method].apply(target, args); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && | ||
track(target, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
// return a wrapped iterator which returns observed versions of the | ||
@@ -530,3 +523,3 @@ // values emitted from the real iterator | ||
get(key) { | ||
return get$1(this, key, toReactive); | ||
return get$1(this, key); | ||
}, | ||
@@ -545,3 +538,3 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toShallow); | ||
return get$1(this, key, false, true); | ||
}, | ||
@@ -560,8 +553,10 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toReadonly); | ||
return get$1(this, key, true); | ||
}, | ||
get size() { | ||
return size(this); | ||
return size(this, true); | ||
}, | ||
has: has$1, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
@@ -621,9 +616,21 @@ set: createReadonlyMethod("set" /* SET */), | ||
const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]); | ||
const isObservableType = /*#__PURE__*/ makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const canObserve = (value) => { | ||
return (!value["__v_skip" /* SKIP */] && | ||
isObservableType(toRawType(value)) && | ||
!Object.isFrozen(value)); | ||
}; | ||
function targetTypeMap(rawType) { | ||
switch (rawType) { | ||
case 'Object': | ||
case 'Array': | ||
return 1 /* COMMON */; | ||
case 'Map': | ||
case 'Set': | ||
case 'WeakMap': | ||
case 'WeakSet': | ||
return 2 /* COLLECTION */; | ||
default: | ||
return 0 /* INVALID */; | ||
} | ||
} | ||
function getTargetType(value) { | ||
return value["__v_skip" /* SKIP */] || !Object.isExtensible(value) | ||
? 0 /* INVALID */ | ||
: targetTypeMap(toRawType(value)); | ||
} | ||
function reactive(target) { | ||
@@ -673,6 +680,7 @@ // if trying to observe a readonly proxy, return the readonly version. | ||
// only a whitelist of value types can be observed. | ||
if (!canObserve(target)) { | ||
const targetType = getTargetType(target); | ||
if (targetType === 0 /* INVALID */) { | ||
return target; | ||
} | ||
const observed = new Proxy(target, collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers); | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
def(target, reactiveFlag, observed); | ||
@@ -773,3 +781,3 @@ return observed; | ||
} | ||
const ret = {}; | ||
const ret = isArray(object) ? new Array(object.length) : {}; | ||
for (const key in object) { | ||
@@ -776,0 +784,0 @@ ret[key] = toRef(object, key); |
@@ -1,1 +0,1 @@ | ||
function e(e,t){const n=Object.create(null),r=e.split(",");for(let e=0;e<r.length;e++)n[r[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}const t={},n=()=>{},r=Object.assign,o=Object.prototype.hasOwnProperty,c=(e,t)=>o.call(e,t),s=Array.isArray,u=e=>"function"==typeof e,i=e=>"symbol"==typeof e,l=e=>null!==e&&"object"==typeof e,a=Object.prototype.toString,f=e=>(e=>a.call(e))(e).slice(8,-1),_=(e,t)=>e!==t&&(e==e||t==t),v=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},d=new WeakMap,h=[];let p;const g=Symbol(""),y=Symbol("");function R(e,n=t){(function(e){return e&&!0===e._isEffect})(e)&&(e=e.raw);const r=function(e,t){const n=function(){if(!n.active)return t.scheduler?void 0:e();if(!h.includes(n)){S(n);try{return j(),h.push(n),p=n,e()}finally{h.pop(),k(),p=h[h.length-1]}}};return n.id=b++,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(e,n);return n.lazy||r(),r}function w(e){e.active&&(S(e),e.options.onStop&&e.options.onStop(),e.active=!1)}let b=0;function S(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let O=!0;const m=[];function E(){m.push(O),O=!1}function j(){m.push(O),O=!0}function k(){const e=m.pop();O=void 0===e||e}function M(e,t,n){if(!O||void 0===p)return;let r=d.get(e);r||d.set(e,r=new Map);let o=r.get(n);o||r.set(n,o=new Set),o.has(p)||(o.add(p),p.deps.push(o))}function P(e,t,n,r,o,c){const u=d.get(e);if(!u)return;const i=new Set,l=e=>{e&&e.forEach(e=>i.add(e))};if("clear"===t)u.forEach(l);else if("length"===n&&s(e))u.forEach((e,t)=>{("length"===t||t>=r)&&l(e)});else{void 0!==n&&l(u.get(n));const r="add"===t||"delete"===t&&!s(e);(r||"set"===t&&e instanceof Map)&&l(u.get(s(e)?"length":g)),r&&e instanceof Map&&l(u.get(y))}i.forEach(e=>{e.options.scheduler?e.options.scheduler(e):e()})}const z=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(i)),x=F(),W=F(!1,!0),A=F(!0),K=F(!0,!0),C={};function F(e=!1,t=!1){return function(n,r,o){if("__v_isReactive"===r)return!e;if("__v_isReadonly"===r)return e;if("__v_raw"===r&&o===(e?n.__v_readonly:n.__v_reactive))return n;const u=s(n);if(u&&c(C,r))return Reflect.get(C,r,o);const a=Reflect.get(n,r,o);return(i(r)?z.has(r):"__proto__"===r||"__v_isRef"===r)?a:(e||M(n,0,r),t?a:me(a)?u?a:a.value:l(a)?e?he(a):ve(a):a)}}["includes","indexOf","lastIndexOf"].forEach(e=>{C[e]=function(...t){const n=be(this);for(let e=0,t=this.length;e<t;e++)M(n,0,e+"");const r=n[e](...t);return-1===r||!1===r?n[e](...t.map(be)):r}});function I(e=!1){return function(t,n,r,o){const u=t[n];if(!e&&(r=be(r),!s(t)&&me(u)&&!me(r)))return u.value=r,!0;const i=c(t,n),l=Reflect.set(t,n,r,o);return t===be(o)&&(i?_(r,u)&&P(t,"set",n,r):P(t,"add",n,r)),l}}function L(e,t){const n=Reflect.has(e,t);return i(t)&&z.has(t)||M(e,0,t),n}function N(e){return M(e,0,g),Reflect.ownKeys(e)}const q={get:x,set:I(),deleteProperty:function(e,t){const n=c(e,t),r=Reflect.deleteProperty(e,t);return r&&n&&P(e,"delete",t,void 0),r},has:L,ownKeys:N},B={get:A,has:L,ownKeys:N,set:(e,t)=>!0,deleteProperty:(e,t)=>!0},D=r({},q,{get:W,set:I(!0)}),G=r({},B,{get:K}),H=e=>l(e)?ve(e):e,J=e=>l(e)?he(e):e,Q=e=>e,T=e=>Reflect.getPrototypeOf(e);function U(e,t,n){e=be(e);const r=be(t);t!==r&&M(e,0,t),M(e,0,r);const{has:o,get:c}=T(e);return o.call(e,t)?n(c.call(e,t)):o.call(e,r)?n(c.call(e,r)):void 0}function V(e){const t=be(this),n=be(e);e!==n&&M(t,0,e),M(t,0,n);const r=T(t).has;return r.call(t,e)||r.call(t,n)}function X(e){return M(e=be(e),0,g),Reflect.get(T(e),"size",e)}function Y(e){e=be(e);const t=be(this),n=T(t),r=n.has.call(t,e),o=n.add.call(t,e);return r||P(t,"add",e,e),o}function Z(e,t){t=be(t);const n=be(this),{has:r,get:o,set:c}=T(n);let s=r.call(n,e);s||(e=be(e),s=r.call(n,e));const u=o.call(n,e),i=c.call(n,e,t);return s?_(t,u)&&P(n,"set",e,t):P(n,"add",e,t),i}function $(e){const t=be(this),{has:n,get:r,delete:o}=T(t);let c=n.call(t,e);c||(e=be(e),c=n.call(t,e));r&&r.call(t,e);const s=o.call(t,e);return c&&P(t,"delete",e,void 0),s}function ee(){const e=be(this),t=0!==e.size,n=T(e).clear.call(e);return t&&P(e,"clear",void 0,void 0),n}function te(e,t){return function(n,r){const o=this,c=be(o),s=e?J:t?Q:H;return!e&&M(c,0,g),T(c).forEach.call(c,(function(e,t){return n.call(r,s(e),s(t),o)}))}}function ne(e,t,n){return function(...r){const o=be(this),c=o instanceof Map,s="entries"===e||e===Symbol.iterator&&c,u="keys"===e&&c,i=T(o)[e].apply(o,r),l=t?J:n?Q:H;return!t&&M(o,0,u?y:g),{next(){const{value:e,done:t}=i.next();return t?{value:e,done:t}:{value:s?[l(e[0]),l(e[1])]:l(e),done:t}},[Symbol.iterator](){return this}}}}function re(e){return function(...t){return"delete"!==e&&this}}const oe={get(e){return U(this,e,H)},get size(){return X(this)},has:V,add:Y,set:Z,delete:$,clear:ee,forEach:te(!1,!1)},ce={get(e){return U(this,e,Q)},get size(){return X(this)},has:V,add:Y,set:Z,delete:$,clear:ee,forEach:te(!1,!0)},se={get(e){return U(this,e,J)},get size(){return X(this)},has:V,add:re("add"),set:re("set"),delete:re("delete"),clear:re("clear"),forEach:te(!0,!1)};function ue(e,t){const n=t?ce:e?se:oe;return(t,r,o)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(c(n,r)&&r in t?n:t,r,o)}["keys","values","entries",Symbol.iterator].forEach(e=>{oe[e]=ne(e,!1,!1),se[e]=ne(e,!0,!1),ce[e]=ne(e,!1,!0)});const ie={get:ue(!1,!1)},le={get:ue(!1,!0)},ae={get:ue(!0,!1)},fe=new Set([Set,Map,WeakMap,WeakSet]),_e=e("Object,Array,Map,Set,WeakMap,WeakSet");function ve(e){return e&&e.__v_isReadonly?e:ge(e,!1,q,ie)}function de(e){return ge(e,!1,D,le)}function he(e){return ge(e,!0,B,ae)}function pe(e){return ge(e,!0,G,ae)}function ge(e,t,n,r){if(!l(e))return e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const o=t?"__v_readonly":"__v_reactive";if(c(e,o))return e[o];if((s=e).__v_skip||!_e(f(s))||Object.isFrozen(s))return e;var s;const u=new Proxy(e,fe.has(e.constructor)?r:n);return v(e,o,u),u}function ye(e){return Re(e)?ye(e.__v_raw):!(!e||!e.__v_isReactive)}function Re(e){return!(!e||!e.__v_isReadonly)}function we(e){return ye(e)||Re(e)}function be(e){return e&&be(e.__v_raw)||e}function Se(e){return v(e,"__v_skip",!0),e}const Oe=e=>l(e)?ve(e):e;function me(e){return!!e&&!0===e.__v_isRef}function Ee(e){return ke(e)}function je(e){return ke(e,!0)}function ke(e,t=!1){if(me(e))return e;let n=t?e:Oe(e);const r={__v_isRef:!0,get value(){return M(r,0,"value"),n},set value(o){_(be(o),e)&&(e=o,n=t?o:Oe(o),P(r,"set","value",o))}};return r}function Me(e){P(e,"set","value",void 0)}function Pe(e){return me(e)?e.value:e}const ze={get:(e,t,n)=>Pe(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return me(o)&&!me(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}};function xe(e){return ye(e)?e:new Proxy(e,ze)}function We(e){const{get:t,set:n}=e(()=>M(r,0,"value"),()=>P(r,"set","value")),r={__v_isRef:!0,get value(){return t()},set value(e){n(e)}};return r}function Ae(e){const t={};for(const n in e)t[n]=Ke(e,n);return t}function Ke(e,t){return{__v_isRef:!0,get value(){return e[t]},set value(n){e[t]=n}}}function Ce(e){let t,r;u(e)?(t=e,r=n):(t=e.get,r=e.set);let o,c,s=!0;const i=R(t,{lazy:!0,scheduler:()=>{s||(s=!0,P(c,"set","value"))}});return c={__v_isRef:!0,__v_isReadonly:u(e)||!e.set,effect:i,get value(){return s&&(o=i(),s=!1),M(c,0,"value"),o},set value(e){r(e)}},c}export{g as ITERATE_KEY,Ce as computed,We as customRef,R as effect,j as enableTracking,we as isProxy,ye as isReactive,Re as isReadonly,me as isRef,Se as markRaw,E as pauseTracking,xe as proxyRefs,ve as reactive,he as readonly,Ee as ref,k as resetTracking,de as shallowReactive,pe as shallowReadonly,je as shallowRef,w as stop,be as toRaw,Ke as toRef,Ae as toRefs,M as track,P as trigger,Me as triggerRef,Pe as unref}; | ||
const e={},t=()=>{},n=Object.assign,r=Object.prototype.hasOwnProperty,o=(e,t)=>r.call(e,t),c=Array.isArray,s=e=>"function"==typeof e,u=e=>"symbol"==typeof e,i=e=>null!==e&&"object"==typeof e,a=Object.prototype.toString,l=e=>(e=>a.call(e))(e).slice(8,-1),f=(e,t)=>e!==t&&(e==e||t==t),_=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},v=new WeakMap,d=[];let h;const g=Symbol(""),p=Symbol("");function y(t,n=e){(function(e){return e&&!0===e._isEffect})(t)&&(t=t.raw);const r=function(e,t){const n=function(){if(!n.active)return t.scheduler?void 0:e();if(!d.includes(n)){b(n);try{return O(),d.push(n),h=n,e()}finally{d.pop(),P(),h=d[d.length-1]}}};return n.id=w++,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(t,n);return n.lazy||r(),r}function R(e){e.active&&(b(e),e.options.onStop&&e.options.onStop(),e.active=!1)}let w=0;function b(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let S=!0;const E=[];function m(){E.push(S),S=!1}function O(){E.push(S),S=!0}function P(){const e=E.pop();S=void 0===e||e}function j(e,t,n){if(!S||void 0===h)return;let r=v.get(e);r||v.set(e,r=new Map);let o=r.get(n);o||r.set(n,o=new Set),o.has(h)||(o.add(h),h.deps.push(o))}function x(e,t,n,r,o,s){const u=v.get(e);if(!u)return;const i=new Set,a=e=>{e&&e.forEach(e=>{e!==h&&i.add(e)})};if("clear"===t)u.forEach(a);else if("length"===n&&c(e))u.forEach((e,t)=>{("length"===t||t>=r)&&a(e)});else{void 0!==n&&a(u.get(n));const r="add"===t||"delete"===t&&!c(e);(r||"set"===t&&e instanceof Map)&&a(u.get(c(e)?"length":g)),r&&e instanceof Map&&a(u.get(p))}i.forEach(e=>{e.options.scheduler?e.options.scheduler(e):e()})}const k=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(u)),z=I(),M=I(!1,!0),A=I(!0),K=I(!0,!0),W={};function I(e=!1,t=!1){return function(n,r,s){if("__v_isReactive"===r)return!e;if("__v_isReadonly"===r)return e;if("__v_raw"===r&&s===(e?n.__v_readonly:n.__v_reactive))return n;const a=c(n);if(a&&o(W,r))return Reflect.get(W,r,s);const l=Reflect.get(n,r,s);return(u(r)?k.has(r):"__proto__"===r||"__v_isRef"===r)?l:(e||j(n,0,r),t?l:be(l)?a?l:l.value:i(l)?e?_e(l):le(l):l)}}["includes","indexOf","lastIndexOf"].forEach(e=>{W[e]=function(...t){const n=ye(this);for(let e=0,t=this.length;e<t;e++)j(n,0,e+"");const r=n[e](...t);return-1===r||!1===r?n[e](...t.map(ye)):r}});function N(e=!1){return function(t,n,r,s){const u=t[n];if(!e&&(r=ye(r),!c(t)&&be(u)&&!be(r)))return u.value=r,!0;const i=o(t,n),a=Reflect.set(t,n,r,s);return t===ye(s)&&(i?f(r,u)&&x(t,"set",n,r):x(t,"add",n,r)),a}}function q(e,t){const n=Reflect.has(e,t);return u(t)&&k.has(t)||j(e,0,t),n}function B(e){return j(e,0,g),Reflect.ownKeys(e)}const C={get:z,set:N(),deleteProperty:function(e,t){const n=o(e,t),r=Reflect.deleteProperty(e,t);return r&&n&&x(e,"delete",t,void 0),r},has:q,ownKeys:B},D={get:A,has:q,ownKeys:B,set:(e,t)=>!0,deleteProperty:(e,t)=>!0},F=n({},C,{get:M,set:N(!0)}),G=n({},D,{get:K}),H=e=>i(e)?le(e):e,J=e=>i(e)?_e(e):e,L=e=>e,Q=e=>Reflect.getPrototypeOf(e);function T(e,t,n=!1,r=!1){const o=ye(e=e.__v_raw),c=ye(t);t!==c&&!n&&j(o,0,t),!n&&j(o,0,c);const{has:s}=Q(o),u=n?J:r?L:H;return s.call(o,t)?u(e.get(t)):s.call(o,c)?u(e.get(c)):void 0}function U(e,t=!1){const n=this.__v_raw,r=ye(n),o=ye(e);return e!==o&&!t&&j(r,0,e),!t&&j(r,0,o),n.has(e)||n.has(o)}function V(e,t=!1){return e=e.__v_raw,!t&&j(ye(e),0,g),Reflect.get(e,"size",e)}function X(e){e=ye(e);const t=ye(this),n=Q(t),r=n.has.call(t,e),o=n.add.call(t,e);return r||x(t,"add",e,e),o}function Y(e,t){t=ye(t);const n=ye(this),{has:r,get:o,set:c}=Q(n);let s=r.call(n,e);s||(e=ye(e),s=r.call(n,e));const u=o.call(n,e),i=c.call(n,e,t);return s?f(t,u)&&x(n,"set",e,t):x(n,"add",e,t),i}function Z(e){const t=ye(this),{has:n,get:r,delete:o}=Q(t);let c=n.call(t,e);c||(e=ye(e),c=n.call(t,e));r&&r.call(t,e);const s=o.call(t,e);return c&&x(t,"delete",e,void 0),s}function $(){const e=ye(this),t=0!==e.size,n=Q(e).clear.call(e);return t&&x(e,"clear",void 0,void 0),n}function ee(e,t){return function(n,r){const o=this,c=ye(o),s=e?J:t?L:H;return!e&&j(c,0,g),Q(c).forEach.call(c,(function(e,t){return n.call(r,s(e),s(t),o)}))}}function te(e,t,n){return function(...r){const o=this.__v_raw,c=ye(o),s=c instanceof Map,u="entries"===e||e===Symbol.iterator&&s,i="keys"===e&&s,a=o[e](...r),l=t?J:n?L:H;return!t&&j(c,0,i?p:g),{next(){const{value:e,done:t}=a.next();return t?{value:e,done:t}:{value:u?[l(e[0]),l(e[1])]:l(e),done:t}},[Symbol.iterator](){return this}}}}function ne(e){return function(...t){return"delete"!==e&&this}}const re={get(e){return T(this,e)},get size(){return V(this)},has:U,add:X,set:Y,delete:Z,clear:$,forEach:ee(!1,!1)},oe={get(e){return T(this,e,!1,!0)},get size(){return V(this)},has:U,add:X,set:Y,delete:Z,clear:$,forEach:ee(!1,!0)},ce={get(e){return T(this,e,!0)},get size(){return V(this,!0)},has(e){return U.call(this,e,!0)},add:ne("add"),set:ne("set"),delete:ne("delete"),clear:ne("clear"),forEach:ee(!0,!1)};function se(e,t){const n=t?oe:e?ce:re;return(t,r,c)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(o(n,r)&&r in t?n:t,r,c)}["keys","values","entries",Symbol.iterator].forEach(e=>{re[e]=te(e,!1,!1),ce[e]=te(e,!0,!1),oe[e]=te(e,!1,!0)});const ue={get:se(!1,!1)},ie={get:se(!1,!0)},ae={get:se(!0,!1)};function le(e){return e&&e.__v_isReadonly?e:de(e,!1,C,ue)}function fe(e){return de(e,!1,F,ie)}function _e(e){return de(e,!0,D,ae)}function ve(e){return de(e,!0,G,ae)}function de(e,t,n,r){if(!i(e))return e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const c=t?"__v_readonly":"__v_reactive";if(o(e,c))return e[c];const s=(u=e).__v_skip||!Object.isExtensible(u)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(l(u));var u;if(0===s)return e;const a=new Proxy(e,2===s?r:n);return _(e,c,a),a}function he(e){return ge(e)?he(e.__v_raw):!(!e||!e.__v_isReactive)}function ge(e){return!(!e||!e.__v_isReadonly)}function pe(e){return he(e)||ge(e)}function ye(e){return e&&ye(e.__v_raw)||e}function Re(e){return _(e,"__v_skip",!0),e}const we=e=>i(e)?le(e):e;function be(e){return!!e&&!0===e.__v_isRef}function Se(e){return me(e)}function Ee(e){return me(e,!0)}function me(e,t=!1){if(be(e))return e;let n=t?e:we(e);const r={__v_isRef:!0,get value(){return j(r,0,"value"),n},set value(o){f(ye(o),e)&&(e=o,n=t?o:we(o),x(r,"set","value",o))}};return r}function Oe(e){x(e,"set","value",void 0)}function Pe(e){return be(e)?e.value:e}const je={get:(e,t,n)=>Pe(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return be(o)&&!be(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}};function xe(e){return he(e)?e:new Proxy(e,je)}function ke(e){const{get:t,set:n}=e(()=>j(r,0,"value"),()=>x(r,"set","value")),r={__v_isRef:!0,get value(){return t()},set value(e){n(e)}};return r}function ze(e){const t=c(e)?new Array(e.length):{};for(const n in e)t[n]=Me(e,n);return t}function Me(e,t){return{__v_isRef:!0,get value(){return e[t]},set value(n){e[t]=n}}}function Ae(e){let n,r;s(e)?(n=e,r=t):(n=e.get,r=e.set);let o,c,u=!0;const i=y(n,{lazy:!0,scheduler:()=>{u||(u=!0,x(c,"set","value"))}});return c={__v_isRef:!0,__v_isReadonly:s(e)||!e.set,effect:i,get value(){return u&&(o=i(),u=!1),j(c,0,"value"),o},set value(e){r(e)}},c}export{g as ITERATE_KEY,Ae as computed,ke as customRef,y as effect,O as enableTracking,pe as isProxy,he as isReactive,ge as isReadonly,be as isRef,Re as markRaw,m as pauseTracking,xe as proxyRefs,le as reactive,_e as readonly,Se as ref,P as resetTracking,fe as shallowReactive,ve as shallowReadonly,Ee as shallowRef,R as stop,ye as toRaw,Me as toRef,ze as toRefs,j as track,x as trigger,Oe as triggerRef,Pe as unref}; |
@@ -1,2 +0,2 @@ | ||
import { EMPTY_OBJ, isArray, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, makeMap, isFunction, NOOP } from '@vue/shared'; | ||
import { EMPTY_OBJ, isArray, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared'; | ||
@@ -116,3 +116,7 @@ const targetMap = new WeakMap(); | ||
if (effectsToAdd) { | ||
effectsToAdd.forEach(effect => effects.add(effect)); | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
effects.add(effect); | ||
} | ||
}); | ||
} | ||
@@ -324,31 +328,35 @@ }; | ||
const getProto = (v) => Reflect.getPrototypeOf(v); | ||
function get$1(target, key, wrap) { | ||
target = toRaw(target); | ||
function get$1(target, key, isReadonly = false, isShallow = false) { | ||
// #1772: readonly(reactive(Map)) should return readonly + reactive version | ||
// of the value | ||
target = target["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "get" /* GET */, key); | ||
!isReadonly && track(rawTarget, "get" /* GET */, key); | ||
} | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
!isReadonly && track(rawTarget, "get" /* GET */, rawKey); | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
return wrap(target.get(key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
else if (has.call(rawTarget, rawKey)) { | ||
return wrap(target.get(rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
function has$1(key, isReadonly = false) { | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "has" /* HAS */, key); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, key); | ||
} | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, rawKey); | ||
return target.has(key) || target.has(rawKey); | ||
} | ||
function size(target) { | ||
target = toRaw(target); | ||
track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(getProto(target), 'size', target); | ||
function size(target, isReadonly = false) { | ||
target = target["__v_raw" /* RAW */]; | ||
!isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(target, 'size', target); | ||
} | ||
@@ -422,7 +430,7 @@ function add(value) { | ||
} | ||
function createForEach(isReadonly, shallow) { | ||
function createForEach(isReadonly, isShallow) { | ||
return function forEach(callback, thisArg) { | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -438,12 +446,13 @@ // important: create sure the callback is | ||
} | ||
function createIterableMethod(method, isReadonly, shallow) { | ||
function createIterableMethod(method, isReadonly, isShallow) { | ||
return function (...args) { | ||
const target = toRaw(this); | ||
const isMap = target instanceof Map; | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const isMap = rawTarget instanceof Map; | ||
const isPair = method === 'entries' || (method === Symbol.iterator && isMap); | ||
const isKeyOnly = method === 'keys' && isMap; | ||
const innerIterator = getProto(target)[method].apply(target, args); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && | ||
track(target, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
// return a wrapped iterator which returns observed versions of the | ||
@@ -480,3 +489,3 @@ // values emitted from the real iterator | ||
get(key) { | ||
return get$1(this, key, toReactive); | ||
return get$1(this, key); | ||
}, | ||
@@ -495,3 +504,3 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toShallow); | ||
return get$1(this, key, false, true); | ||
}, | ||
@@ -510,8 +519,10 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toReadonly); | ||
return get$1(this, key, true); | ||
}, | ||
get size() { | ||
return size(this); | ||
return size(this, true); | ||
}, | ||
has: has$1, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
@@ -571,9 +582,21 @@ set: createReadonlyMethod("set" /* SET */), | ||
const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]); | ||
const isObservableType = /*#__PURE__*/ makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const canObserve = (value) => { | ||
return (!value["__v_skip" /* SKIP */] && | ||
isObservableType(toRawType(value)) && | ||
!Object.isFrozen(value)); | ||
}; | ||
function targetTypeMap(rawType) { | ||
switch (rawType) { | ||
case 'Object': | ||
case 'Array': | ||
return 1 /* COMMON */; | ||
case 'Map': | ||
case 'Set': | ||
case 'WeakMap': | ||
case 'WeakSet': | ||
return 2 /* COLLECTION */; | ||
default: | ||
return 0 /* INVALID */; | ||
} | ||
} | ||
function getTargetType(value) { | ||
return value["__v_skip" /* SKIP */] || !Object.isExtensible(value) | ||
? 0 /* INVALID */ | ||
: targetTypeMap(toRawType(value)); | ||
} | ||
function reactive(target) { | ||
@@ -623,6 +646,7 @@ // if trying to observe a readonly proxy, return the readonly version. | ||
// only a whitelist of value types can be observed. | ||
if (!canObserve(target)) { | ||
const targetType = getTargetType(target); | ||
if (targetType === 0 /* INVALID */) { | ||
return target; | ||
} | ||
const observed = new Proxy(target, collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers); | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
def(target, reactiveFlag, observed); | ||
@@ -723,3 +747,3 @@ return observed; | ||
} | ||
const ret = {}; | ||
const ret = isArray(object) ? new Array(object.length) : {}; | ||
for (const key in object) { | ||
@@ -726,0 +750,0 @@ ret[key] = toRef(object, key); |
var VueReactivity = (function (exports) { | ||
'use strict'; | ||
/** | ||
* 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({}) | ||
@@ -170,3 +154,7 @@ ; | ||
if (effectsToAdd) { | ||
effectsToAdd.forEach(effect => effects.add(effect)); | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
effects.add(effect); | ||
} | ||
}); | ||
} | ||
@@ -378,31 +366,35 @@ }; | ||
const getProto = (v) => Reflect.getPrototypeOf(v); | ||
function get$1(target, key, wrap) { | ||
target = toRaw(target); | ||
function get$1(target, key, isReadonly = false, isShallow = false) { | ||
// #1772: readonly(reactive(Map)) should return readonly + reactive version | ||
// of the value | ||
target = target["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "get" /* GET */, key); | ||
!isReadonly && track(rawTarget, "get" /* GET */, key); | ||
} | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
!isReadonly && track(rawTarget, "get" /* GET */, rawKey); | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
return wrap(target.get(key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
else if (has.call(rawTarget, rawKey)) { | ||
return wrap(target.get(rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
function has$1(key, isReadonly = false) { | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const rawKey = toRaw(key); | ||
if (key !== rawKey) { | ||
track(target, "has" /* HAS */, key); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, key); | ||
} | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
!isReadonly && track(rawTarget, "has" /* HAS */, rawKey); | ||
return target.has(key) || target.has(rawKey); | ||
} | ||
function size(target) { | ||
target = toRaw(target); | ||
track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(getProto(target), 'size', target); | ||
function size(target, isReadonly = false) { | ||
target = target["__v_raw" /* RAW */]; | ||
!isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY); | ||
return Reflect.get(target, 'size', target); | ||
} | ||
@@ -475,7 +467,7 @@ function add(value) { | ||
} | ||
function createForEach(isReadonly, shallow) { | ||
function createForEach(isReadonly, isShallow) { | ||
return function forEach(callback, thisArg) { | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -491,12 +483,13 @@ // important: create sure the callback is | ||
} | ||
function createIterableMethod(method, isReadonly, shallow) { | ||
function createIterableMethod(method, isReadonly, isShallow) { | ||
return function (...args) { | ||
const target = toRaw(this); | ||
const isMap = target instanceof Map; | ||
const target = this["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const isMap = rawTarget instanceof Map; | ||
const isPair = method === 'entries' || (method === Symbol.iterator && isMap); | ||
const isKeyOnly = method === 'keys' && isMap; | ||
const innerIterator = getProto(target)[method].apply(target, args); | ||
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive; | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && | ||
track(target, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
// return a wrapped iterator which returns observed versions of the | ||
@@ -533,3 +526,3 @@ // values emitted from the real iterator | ||
get(key) { | ||
return get$1(this, key, toReactive); | ||
return get$1(this, key); | ||
}, | ||
@@ -548,3 +541,3 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toShallow); | ||
return get$1(this, key, false, true); | ||
}, | ||
@@ -563,8 +556,10 @@ get size() { | ||
get(key) { | ||
return get$1(this, key, toReadonly); | ||
return get$1(this, key, true); | ||
}, | ||
get size() { | ||
return size(this); | ||
return size(this, true); | ||
}, | ||
has: has$1, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
@@ -624,9 +619,21 @@ set: createReadonlyMethod("set" /* SET */), | ||
const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]); | ||
const isObservableType = /*#__PURE__*/ makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const canObserve = (value) => { | ||
return (!value["__v_skip" /* SKIP */] && | ||
isObservableType(toRawType(value)) && | ||
!Object.isFrozen(value)); | ||
}; | ||
function targetTypeMap(rawType) { | ||
switch (rawType) { | ||
case 'Object': | ||
case 'Array': | ||
return 1 /* COMMON */; | ||
case 'Map': | ||
case 'Set': | ||
case 'WeakMap': | ||
case 'WeakSet': | ||
return 2 /* COLLECTION */; | ||
default: | ||
return 0 /* INVALID */; | ||
} | ||
} | ||
function getTargetType(value) { | ||
return value["__v_skip" /* SKIP */] || !Object.isExtensible(value) | ||
? 0 /* INVALID */ | ||
: targetTypeMap(toRawType(value)); | ||
} | ||
function reactive(target) { | ||
@@ -676,6 +683,7 @@ // if trying to observe a readonly proxy, return the readonly version. | ||
// only a whitelist of value types can be observed. | ||
if (!canObserve(target)) { | ||
const targetType = getTargetType(target); | ||
if (targetType === 0 /* INVALID */) { | ||
return target; | ||
} | ||
const observed = new Proxy(target, collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers); | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
def(target, reactiveFlag, observed); | ||
@@ -776,3 +784,3 @@ return observed; | ||
} | ||
const ret = {}; | ||
const ret = isArray(object) ? new Array(object.length) : {}; | ||
for (const key in object) { | ||
@@ -779,0 +787,0 @@ ret[key] = toRef(object, key); |
@@ -1,1 +0,1 @@ | ||
var VueReactivity=function(e){"use strict";function t(e,t){const n=Object.create(null),r=e.split(",");for(let e=0;e<r.length;e++)n[r[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}const n={},r=()=>{},o=Object.assign,c=Object.prototype.hasOwnProperty,s=(e,t)=>c.call(e,t),i=Array.isArray,u=e=>"function"==typeof e,a=e=>"symbol"==typeof e,l=e=>null!==e&&"object"==typeof e,f=Object.prototype.toString,_=e=>(e=>f.call(e))(e).slice(8,-1),v=(e,t)=>e!==t&&(e==e||t==t),d=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},h=new WeakMap,g=[];let p;const y=Symbol(""),R=Symbol("");function w(e,t=n){(function(e){return e&&!0===e._isEffect})(e)&&(e=e.raw);const r=function(e,t){const n=function(){if(!n.active)return t.scheduler?void 0:e();if(!g.includes(n)){S(n);try{return k(),g.push(n),p=n,e()}finally{g.pop(),O(),p=g[g.length-1]}}};return n.id=b++,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(e,t);return t.lazy||r(),r}let b=0;function S(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let m=!0;const E=[];function k(){E.push(m),m=!0}function O(){const e=E.pop();m=void 0===e||e}function P(e,t,n){if(!m||void 0===p)return;let r=h.get(e);r||h.set(e,r=new Map);let o=r.get(n);o||r.set(n,o=new Set),o.has(p)||(o.add(p),p.deps.push(o))}function j(e,t,n,r,o,c){const s=h.get(e);if(!s)return;const u=new Set,a=e=>{e&&e.forEach(e=>u.add(e))};if("clear"===t)s.forEach(a);else if("length"===n&&i(e))s.forEach((e,t)=>{("length"===t||t>=r)&&a(e)});else{void 0!==n&&a(s.get(n));const r="add"===t||"delete"===t&&!i(e);(r||"set"===t&&e instanceof Map)&&a(s.get(i(e)?"length":y)),r&&e instanceof Map&&a(s.get(R))}u.forEach(e=>{e.options.scheduler?e.options.scheduler(e):e()})}const M=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(a)),x=K(),z=K(!1,!0),T=K(!0),W=K(!0,!0),A={};function K(e=!1,t=!1){return function(n,r,o){if("__v_isReactive"===r)return!e;if("__v_isReadonly"===r)return e;if("__v_raw"===r&&o===(e?n.__v_readonly:n.__v_reactive))return n;const c=i(n);if(c&&s(A,r))return Reflect.get(A,r,o);const u=Reflect.get(n,r,o);return(a(r)?M.has(r):"__proto__"===r||"__v_isRef"===r)?u:(e||P(n,0,r),t?u:Re(u)?c?u:u.value:l(u)?e?ve(u):_e(u):u)}}["includes","indexOf","lastIndexOf"].forEach(e=>{A[e]=function(...t){const n=pe(this);for(let e=0,t=this.length;e<t;e++)P(n,0,e+"");const r=n[e](...t);return-1===r||!1===r?n[e](...t.map(pe)):r}});function I(e=!1){return function(t,n,r,o){const c=t[n];if(!e&&(r=pe(r),!i(t)&&Re(c)&&!Re(r)))return c.value=r,!0;const u=s(t,n),a=Reflect.set(t,n,r,o);return t===pe(o)&&(u?v(r,c)&&j(t,"set",n,r):j(t,"add",n,r)),a}}function C(e,t){const n=Reflect.has(e,t);return a(t)&&M.has(t)||P(e,0,t),n}function F(e){return P(e,0,y),Reflect.ownKeys(e)}const L={get:x,set:I(),deleteProperty:function(e,t){const n=s(e,t),r=Reflect.deleteProperty(e,t);return r&&n&&j(e,"delete",t,void 0),r},has:C,ownKeys:F},N={get:T,has:C,ownKeys:F,set:(e,t)=>!0,deleteProperty:(e,t)=>!0},V=o({},L,{get:z,set:I(!0)}),Y=o({},N,{get:W}),q=e=>l(e)?_e(e):e,B=e=>l(e)?ve(e):e,D=e=>e,G=e=>Reflect.getPrototypeOf(e);function H(e,t,n){e=pe(e);const r=pe(t);t!==r&&P(e,0,t),P(e,0,r);const{has:o,get:c}=G(e);return o.call(e,t)?n(c.call(e,t)):o.call(e,r)?n(c.call(e,r)):void 0}function J(e){const t=pe(this),n=pe(e);e!==n&&P(t,0,e),P(t,0,n);const r=G(t).has;return r.call(t,e)||r.call(t,n)}function Q(e){return P(e=pe(e),0,y),Reflect.get(G(e),"size",e)}function U(e){e=pe(e);const t=pe(this),n=G(t),r=n.has.call(t,e),o=n.add.call(t,e);return r||j(t,"add",e,e),o}function X(e,t){t=pe(t);const n=pe(this),{has:r,get:o,set:c}=G(n);let s=r.call(n,e);s||(e=pe(e),s=r.call(n,e));const i=o.call(n,e),u=c.call(n,e,t);return s?v(t,i)&&j(n,"set",e,t):j(n,"add",e,t),u}function Z(e){const t=pe(this),{has:n,get:r,delete:o}=G(t);let c=n.call(t,e);c||(e=pe(e),c=n.call(t,e));r&&r.call(t,e);const s=o.call(t,e);return c&&j(t,"delete",e,void 0),s}function $(){const e=pe(this),t=0!==e.size,n=G(e).clear.call(e);return t&&j(e,"clear",void 0,void 0),n}function ee(e,t){return function(n,r){const o=this,c=pe(o),s=e?B:t?D:q;return!e&&P(c,0,y),G(c).forEach.call(c,(function(e,t){return n.call(r,s(e),s(t),o)}))}}function te(e,t,n){return function(...r){const o=pe(this),c=o instanceof Map,s="entries"===e||e===Symbol.iterator&&c,i="keys"===e&&c,u=G(o)[e].apply(o,r),a=t?B:n?D:q;return!t&&P(o,0,i?R:y),{next(){const{value:e,done:t}=u.next();return t?{value:e,done:t}:{value:s?[a(e[0]),a(e[1])]:a(e),done:t}},[Symbol.iterator](){return this}}}}function ne(e){return function(...t){return"delete"!==e&&this}}const re={get(e){return H(this,e,q)},get size(){return Q(this)},has:J,add:U,set:X,delete:Z,clear:$,forEach:ee(!1,!1)},oe={get(e){return H(this,e,D)},get size(){return Q(this)},has:J,add:U,set:X,delete:Z,clear:$,forEach:ee(!1,!0)},ce={get(e){return H(this,e,B)},get size(){return Q(this)},has:J,add:ne("add"),set:ne("set"),delete:ne("delete"),clear:ne("clear"),forEach:ee(!0,!1)};function se(e,t){const n=t?oe:e?ce:re;return(t,r,o)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(s(n,r)&&r in t?n:t,r,o)}["keys","values","entries",Symbol.iterator].forEach(e=>{re[e]=te(e,!1,!1),ce[e]=te(e,!0,!1),oe[e]=te(e,!1,!0)});const ie={get:se(!1,!1)},ue={get:se(!1,!0)},ae={get:se(!0,!1)},le=new Set([Set,Map,WeakMap,WeakSet]),fe=t("Object,Array,Map,Set,WeakMap,WeakSet");function _e(e){return e&&e.__v_isReadonly?e:de(e,!1,L,ie)}function ve(e){return de(e,!0,N,ae)}function de(e,t,n,r){if(!l(e))return e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const o=t?"__v_readonly":"__v_reactive";if(s(e,o))return e[o];if((c=e).__v_skip||!fe(_(c))||Object.isFrozen(c))return e;var c;const i=new Proxy(e,le.has(e.constructor)?r:n);return d(e,o,i),i}function he(e){return ge(e)?he(e.__v_raw):!(!e||!e.__v_isReactive)}function ge(e){return!(!e||!e.__v_isReadonly)}function pe(e){return e&&pe(e.__v_raw)||e}const ye=e=>l(e)?_e(e):e;function Re(e){return!!e&&!0===e.__v_isRef}function we(e,t=!1){if(Re(e))return e;let n=t?e:ye(e);const r={__v_isRef:!0,get value(){return P(r,0,"value"),n},set value(o){v(pe(o),e)&&(e=o,n=t?o:ye(o),j(r,"set","value",o))}};return r}function be(e){return Re(e)?e.value:e}const Se={get:(e,t,n)=>be(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return Re(o)&&!Re(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}};function me(e,t){return{__v_isRef:!0,get value(){return e[t]},set value(n){e[t]=n}}}return e.ITERATE_KEY=y,e.computed=function(e){let t,n;u(e)?(t=e,n=r):(t=e.get,n=e.set);let o,c,s=!0;const i=w(t,{lazy:!0,scheduler:()=>{s||(s=!0,j(c,"set","value"))}});return c={__v_isRef:!0,__v_isReadonly:u(e)||!e.set,effect:i,get value(){return s&&(o=i(),s=!1),P(c,0,"value"),o},set value(e){n(e)}},c},e.customRef=function(e){const{get:t,set:n}=e(()=>P(r,0,"value"),()=>j(r,"set","value")),r={__v_isRef:!0,get value(){return t()},set value(e){n(e)}};return r},e.effect=w,e.enableTracking=k,e.isProxy=function(e){return he(e)||ge(e)},e.isReactive=he,e.isReadonly=ge,e.isRef=Re,e.markRaw=function(e){return d(e,"__v_skip",!0),e},e.pauseTracking=function(){E.push(m),m=!1},e.proxyRefs=function(e){return he(e)?e:new Proxy(e,Se)},e.reactive=_e,e.readonly=ve,e.ref=function(e){return we(e)},e.resetTracking=O,e.shallowReactive=function(e){return de(e,!1,V,ue)},e.shallowReadonly=function(e){return de(e,!0,Y,ae)},e.shallowRef=function(e){return we(e,!0)},e.stop=function(e){e.active&&(S(e),e.options.onStop&&e.options.onStop(),e.active=!1)},e.toRaw=pe,e.toRef=me,e.toRefs=function(e){const t={};for(const n in e)t[n]=me(e,n);return t},e.track=P,e.trigger=j,e.triggerRef=function(e){j(e,"set","value",void 0)},e.unref=be,e}({}); | ||
var VueReactivity=function(e){"use strict";const t={},n=()=>{},r=Object.assign,o=Object.prototype.hasOwnProperty,c=(e,t)=>o.call(e,t),s=Array.isArray,i=e=>"function"==typeof e,u=e=>"symbol"==typeof e,a=e=>null!==e&&"object"==typeof e,l=Object.prototype.toString,f=e=>(e=>l.call(e))(e).slice(8,-1),_=(e,t)=>e!==t&&(e==e||t==t),v=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},d=new WeakMap,h=[];let g;const p=Symbol(""),y=Symbol("");function R(e,n=t){(function(e){return e&&!0===e._isEffect})(e)&&(e=e.raw);const r=function(e,t){const n=function(){if(!n.active)return t.scheduler?void 0:e();if(!h.includes(n)){b(n);try{return S(),h.push(n),g=n,e()}finally{h.pop(),k(),g=h[h.length-1]}}};return n.id=w++,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(e,n);return n.lazy||r(),r}let w=0;function b(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let E=!0;const m=[];function S(){m.push(E),E=!0}function k(){const e=m.pop();E=void 0===e||e}function O(e,t,n){if(!E||void 0===g)return;let r=d.get(e);r||d.set(e,r=new Map);let o=r.get(n);o||r.set(n,o=new Set),o.has(g)||(o.add(g),g.deps.push(o))}function P(e,t,n,r,o,c){const i=d.get(e);if(!i)return;const u=new Set,a=e=>{e&&e.forEach(e=>{e!==g&&u.add(e)})};if("clear"===t)i.forEach(a);else if("length"===n&&s(e))i.forEach((e,t)=>{("length"===t||t>=r)&&a(e)});else{void 0!==n&&a(i.get(n));const r="add"===t||"delete"===t&&!s(e);(r||"set"===t&&e instanceof Map)&&a(i.get(s(e)?"length":p)),r&&e instanceof Map&&a(i.get(y))}u.forEach(e=>{e.options.scheduler?e.options.scheduler(e):e()})}const x=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(u)),j=K(),z=K(!1,!0),M=K(!0),A=K(!0,!0),T={};function K(e=!1,t=!1){return function(n,r,o){if("__v_isReactive"===r)return!e;if("__v_isReadonly"===r)return e;if("__v_raw"===r&&o===(e?n.__v_readonly:n.__v_reactive))return n;const i=s(n);if(i&&c(T,r))return Reflect.get(T,r,o);const l=Reflect.get(n,r,o);return(u(r)?x.has(r):"__proto__"===r||"__v_isRef"===r)?l:(e||O(n,0,r),t?l:ge(l)?i?l:l.value:a(l)?e?le(l):ae(l):l)}}["includes","indexOf","lastIndexOf"].forEach(e=>{T[e]=function(...t){const n=de(this);for(let e=0,t=this.length;e<t;e++)O(n,0,e+"");const r=n[e](...t);return-1===r||!1===r?n[e](...t.map(de)):r}});function W(e=!1){return function(t,n,r,o){const i=t[n];if(!e&&(r=de(r),!s(t)&&ge(i)&&!ge(r)))return i.value=r,!0;const u=c(t,n),a=Reflect.set(t,n,r,o);return t===de(o)&&(u?_(r,i)&&P(t,"set",n,r):P(t,"add",n,r)),a}}function I(e,t){const n=Reflect.has(e,t);return u(t)&&x.has(t)||O(e,0,t),n}function N(e){return O(e,0,p),Reflect.ownKeys(e)}const V={get:j,set:W(),deleteProperty:function(e,t){const n=c(e,t),r=Reflect.deleteProperty(e,t);return r&&n&&P(e,"delete",t,void 0),r},has:I,ownKeys:N},Y={get:M,has:I,ownKeys:N,set:(e,t)=>!0,deleteProperty:(e,t)=>!0},q=r({},V,{get:z,set:W(!0)}),B=r({},Y,{get:A}),C=e=>a(e)?ae(e):e,D=e=>a(e)?le(e):e,F=e=>e,G=e=>Reflect.getPrototypeOf(e);function H(e,t,n=!1,r=!1){const o=de(e=e.__v_raw),c=de(t);t!==c&&!n&&O(o,0,t),!n&&O(o,0,c);const{has:s}=G(o),i=n?D:r?F:C;return s.call(o,t)?i(e.get(t)):s.call(o,c)?i(e.get(c)):void 0}function J(e,t=!1){const n=this.__v_raw,r=de(n),o=de(e);return e!==o&&!t&&O(r,0,e),!t&&O(r,0,o),n.has(e)||n.has(o)}function L(e,t=!1){return e=e.__v_raw,!t&&O(de(e),0,p),Reflect.get(e,"size",e)}function Q(e){e=de(e);const t=de(this),n=G(t),r=n.has.call(t,e),o=n.add.call(t,e);return r||P(t,"add",e,e),o}function U(e,t){t=de(t);const n=de(this),{has:r,get:o,set:c}=G(n);let s=r.call(n,e);s||(e=de(e),s=r.call(n,e));const i=o.call(n,e),u=c.call(n,e,t);return s?_(t,i)&&P(n,"set",e,t):P(n,"add",e,t),u}function X(e){const t=de(this),{has:n,get:r,delete:o}=G(t);let c=n.call(t,e);c||(e=de(e),c=n.call(t,e));r&&r.call(t,e);const s=o.call(t,e);return c&&P(t,"delete",e,void 0),s}function Z(){const e=de(this),t=0!==e.size,n=G(e).clear.call(e);return t&&P(e,"clear",void 0,void 0),n}function $(e,t){return function(n,r){const o=this,c=de(o),s=e?D:t?F:C;return!e&&O(c,0,p),G(c).forEach.call(c,(function(e,t){return n.call(r,s(e),s(t),o)}))}}function ee(e,t,n){return function(...r){const o=this.__v_raw,c=de(o),s=c instanceof Map,i="entries"===e||e===Symbol.iterator&&s,u="keys"===e&&s,a=o[e](...r),l=t?D:n?F:C;return!t&&O(c,0,u?y:p),{next(){const{value:e,done:t}=a.next();return t?{value:e,done:t}:{value:i?[l(e[0]),l(e[1])]:l(e),done:t}},[Symbol.iterator](){return this}}}}function te(e){return function(...t){return"delete"!==e&&this}}const ne={get(e){return H(this,e)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!1)},re={get(e){return H(this,e,!1,!0)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!0)},oe={get(e){return H(this,e,!0)},get size(){return L(this,!0)},has(e){return J.call(this,e,!0)},add:te("add"),set:te("set"),delete:te("delete"),clear:te("clear"),forEach:$(!0,!1)};function ce(e,t){const n=t?re:e?oe:ne;return(t,r,o)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(c(n,r)&&r in t?n:t,r,o)}["keys","values","entries",Symbol.iterator].forEach(e=>{ne[e]=ee(e,!1,!1),oe[e]=ee(e,!0,!1),re[e]=ee(e,!1,!0)});const se={get:ce(!1,!1)},ie={get:ce(!1,!0)},ue={get:ce(!0,!1)};function ae(e){return e&&e.__v_isReadonly?e:fe(e,!1,V,se)}function le(e){return fe(e,!0,Y,ue)}function fe(e,t,n,r){if(!a(e))return e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const o=t?"__v_readonly":"__v_reactive";if(c(e,o))return e[o];const s=(i=e).__v_skip||!Object.isExtensible(i)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(i));var i;if(0===s)return e;const u=new Proxy(e,2===s?r:n);return v(e,o,u),u}function _e(e){return ve(e)?_e(e.__v_raw):!(!e||!e.__v_isReactive)}function ve(e){return!(!e||!e.__v_isReadonly)}function de(e){return e&&de(e.__v_raw)||e}const he=e=>a(e)?ae(e):e;function ge(e){return!!e&&!0===e.__v_isRef}function pe(e,t=!1){if(ge(e))return e;let n=t?e:he(e);const r={__v_isRef:!0,get value(){return O(r,0,"value"),n},set value(o){_(de(o),e)&&(e=o,n=t?o:he(o),P(r,"set","value",o))}};return r}function ye(e){return ge(e)?e.value:e}const Re={get:(e,t,n)=>ye(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return ge(o)&&!ge(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}};function we(e,t){return{__v_isRef:!0,get value(){return e[t]},set value(n){e[t]=n}}}return e.ITERATE_KEY=p,e.computed=function(e){let t,r;i(e)?(t=e,r=n):(t=e.get,r=e.set);let o,c,s=!0;const u=R(t,{lazy:!0,scheduler:()=>{s||(s=!0,P(c,"set","value"))}});return c={__v_isRef:!0,__v_isReadonly:i(e)||!e.set,effect:u,get value(){return s&&(o=u(),s=!1),O(c,0,"value"),o},set value(e){r(e)}},c},e.customRef=function(e){const{get:t,set:n}=e(()=>O(r,0,"value"),()=>P(r,"set","value")),r={__v_isRef:!0,get value(){return t()},set value(e){n(e)}};return r},e.effect=R,e.enableTracking=S,e.isProxy=function(e){return _e(e)||ve(e)},e.isReactive=_e,e.isReadonly=ve,e.isRef=ge,e.markRaw=function(e){return v(e,"__v_skip",!0),e},e.pauseTracking=function(){m.push(E),E=!1},e.proxyRefs=function(e){return _e(e)?e:new Proxy(e,Re)},e.reactive=ae,e.readonly=le,e.ref=function(e){return pe(e)},e.resetTracking=k,e.shallowReactive=function(e){return fe(e,!1,q,ie)},e.shallowReadonly=function(e){return fe(e,!0,B,ue)},e.shallowRef=function(e){return pe(e,!0)},e.stop=function(e){e.active&&(b(e),e.options.onStop&&e.options.onStop(),e.active=!1)},e.toRaw=de,e.toRef=we,e.toRefs=function(e){const t=s(e)?new Array(e.length):{};for(const n in e)t[n]=we(e,n);return t},e.track=O,e.trigger=P,e.triggerRef=function(e){P(e,"set","value",void 0)},e.unref=ye,e}({}); |
{ | ||
"name": "@vue/reactivity", | ||
"version": "3.0.0-rc.5", | ||
"version": "3.0.0-rc.6", | ||
"description": "@vue/reactivity", | ||
@@ -38,4 +38,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vue/shared": "3.0.0-rc.5" | ||
"@vue/shared": "3.0.0-rc.6" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164390
4341
+ Added@vue/shared@3.0.0-rc.6(transitive)
- Removed@vue/shared@3.0.0-rc.5(transitive)
Updated@vue/shared@3.0.0-rc.6