@vue/reactivity
Advanced tools
Comparing version 3.0.7 to 3.0.8
@@ -241,3 +241,10 @@ 'use strict'; | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
receiver === | ||
(isReadonly | ||
? shallow | ||
? shallowReadonlyMap | ||
: readonlyMap | ||
: shallow | ||
? shallowReactiveMap | ||
: reactiveMap).get(target)) { | ||
return target; | ||
@@ -371,3 +378,3 @@ } | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
@@ -468,3 +475,3 @@ return wrap(target.get(key)); | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -487,3 +494,3 @@ return target.forEach((value, key) => { | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && | ||
@@ -564,2 +571,18 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
}; | ||
const shallowReadonlyInstrumentations = { | ||
get(key) { | ||
return get$1(this, key, true, true); | ||
}, | ||
get size() { | ||
return size(this, true); | ||
}, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
set: createReadonlyMethod("set" /* SET */), | ||
delete: createReadonlyMethod("delete" /* DELETE */), | ||
clear: createReadonlyMethod("clear" /* CLEAR */), | ||
forEach: createForEach(true, true) | ||
}; | ||
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; | ||
@@ -570,6 +593,9 @@ iteratorMethods.forEach(method => { | ||
shallowInstrumentations[method] = createIterableMethod(method, false, true); | ||
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); | ||
}); | ||
function createInstrumentationGetter(isReadonly, shallow) { | ||
const instrumentations = shallow | ||
? shallowInstrumentations | ||
? isReadonly | ||
? shallowReadonlyInstrumentations | ||
: shallowInstrumentations | ||
: isReadonly | ||
@@ -602,2 +628,5 @@ ? readonlyInstrumentations | ||
}; | ||
const shallowReadonlyCollectionHandlers = { | ||
get: createInstrumentationGetter(true, true) | ||
}; | ||
function checkIdentityKeys(target, has, key) { | ||
@@ -616,3 +645,5 @@ const rawKey = toRaw(key); | ||
const reactiveMap = new WeakMap(); | ||
const shallowReactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
const shallowReadonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -642,3 +673,3 @@ switch (rawType) { | ||
} | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); | ||
} | ||
@@ -651,3 +682,3 @@ /** | ||
function shallowReactive(target) { | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers); | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); | ||
} | ||
@@ -659,3 +690,3 @@ /** | ||
function readonly(target) { | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); | ||
} | ||
@@ -669,5 +700,5 @@ /** | ||
function shallowReadonly(target) { | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); | ||
} | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { | ||
if (!shared.isObject(target)) { | ||
@@ -686,3 +717,2 @@ { | ||
// target already has corresponding Proxy | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
@@ -843,8 +873,10 @@ if (existingProxy) { | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
// the computed ref may get wrapped by other proxies e.g. readonly() #3376 | ||
const self = toRaw(this); | ||
if (self._dirty) { | ||
self._value = this.effect(); | ||
self._dirty = false; | ||
} | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
track(self, "get" /* GET */, 'value'); | ||
return self._value; | ||
} | ||
@@ -851,0 +883,0 @@ set value(newValue) { |
@@ -222,3 +222,10 @@ 'use strict'; | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
receiver === | ||
(isReadonly | ||
? shallow | ||
? shallowReadonlyMap | ||
: readonlyMap | ||
: shallow | ||
? shallowReactiveMap | ||
: reactiveMap).get(target)) { | ||
return target; | ||
@@ -346,3 +353,3 @@ } | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
@@ -433,3 +440,3 @@ return wrap(target.get(key)); | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -452,3 +459,3 @@ return target.forEach((value, key) => { | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && | ||
@@ -525,2 +532,18 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
}; | ||
const shallowReadonlyInstrumentations = { | ||
get(key) { | ||
return get$1(this, key, true, true); | ||
}, | ||
get size() { | ||
return size(this, true); | ||
}, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
set: createReadonlyMethod("set" /* SET */), | ||
delete: createReadonlyMethod("delete" /* DELETE */), | ||
clear: createReadonlyMethod("clear" /* CLEAR */), | ||
forEach: createForEach(true, true) | ||
}; | ||
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; | ||
@@ -531,6 +554,9 @@ iteratorMethods.forEach(method => { | ||
shallowInstrumentations[method] = createIterableMethod(method, false, true); | ||
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); | ||
}); | ||
function createInstrumentationGetter(isReadonly, shallow) { | ||
const instrumentations = shallow | ||
? shallowInstrumentations | ||
? isReadonly | ||
? shallowReadonlyInstrumentations | ||
: shallowInstrumentations | ||
: isReadonly | ||
@@ -563,5 +589,10 @@ ? readonlyInstrumentations | ||
}; | ||
const shallowReadonlyCollectionHandlers = { | ||
get: createInstrumentationGetter(true, true) | ||
}; | ||
const reactiveMap = new WeakMap(); | ||
const shallowReactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
const shallowReadonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -591,3 +622,3 @@ switch (rawType) { | ||
} | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); | ||
} | ||
@@ -600,3 +631,3 @@ /** | ||
function shallowReactive(target) { | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers); | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); | ||
} | ||
@@ -608,3 +639,3 @@ /** | ||
function readonly(target) { | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); | ||
} | ||
@@ -618,5 +649,5 @@ /** | ||
function shallowReadonly(target) { | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); | ||
} | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { | ||
if (!shared.isObject(target)) { | ||
@@ -632,3 +663,2 @@ return target; | ||
// target already has corresponding Proxy | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
@@ -786,8 +816,10 @@ if (existingProxy) { | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
// the computed ref may get wrapped by other proxies e.g. readonly() #3376 | ||
const self = toRaw(this); | ||
if (self._dirty) { | ||
self._value = this.effect(); | ||
self._dirty = false; | ||
} | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
track(self, "get" /* GET */, 'value'); | ||
return self._value; | ||
} | ||
@@ -794,0 +826,0 @@ set value(newValue) { |
@@ -285,3 +285,3 @@ | ||
declare type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRef<T>; | ||
export declare type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRef<T>; | ||
@@ -288,0 +288,0 @@ declare type UnwrappedObject<T> = { |
@@ -294,3 +294,10 @@ /** | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
receiver === | ||
(isReadonly | ||
? shallow | ||
? shallowReadonlyMap | ||
: readonlyMap | ||
: shallow | ||
? shallowReactiveMap | ||
: reactiveMap).get(target)) { | ||
return target; | ||
@@ -424,3 +431,3 @@ } | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
@@ -521,3 +528,3 @@ return wrap(target.get(key)); | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -540,3 +547,3 @@ return target.forEach((value, key) => { | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && | ||
@@ -617,2 +624,18 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
}; | ||
const shallowReadonlyInstrumentations = { | ||
get(key) { | ||
return get$1(this, key, true, true); | ||
}, | ||
get size() { | ||
return size(this, true); | ||
}, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
set: createReadonlyMethod("set" /* SET */), | ||
delete: createReadonlyMethod("delete" /* DELETE */), | ||
clear: createReadonlyMethod("clear" /* CLEAR */), | ||
forEach: createForEach(true, true) | ||
}; | ||
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; | ||
@@ -623,6 +646,9 @@ iteratorMethods.forEach(method => { | ||
shallowInstrumentations[method] = createIterableMethod(method, false, true); | ||
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); | ||
}); | ||
function createInstrumentationGetter(isReadonly, shallow) { | ||
const instrumentations = shallow | ||
? shallowInstrumentations | ||
? isReadonly | ||
? shallowReadonlyInstrumentations | ||
: shallowInstrumentations | ||
: isReadonly | ||
@@ -655,2 +681,5 @@ ? readonlyInstrumentations | ||
}; | ||
const shallowReadonlyCollectionHandlers = { | ||
get: createInstrumentationGetter(true, true) | ||
}; | ||
function checkIdentityKeys(target, has, key) { | ||
@@ -669,3 +698,5 @@ const rawKey = toRaw(key); | ||
const reactiveMap = new WeakMap(); | ||
const shallowReactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
const shallowReadonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -695,3 +726,3 @@ switch (rawType) { | ||
} | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); | ||
} | ||
@@ -704,3 +735,3 @@ /** | ||
function shallowReactive(target) { | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers); | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); | ||
} | ||
@@ -712,3 +743,3 @@ /** | ||
function readonly(target) { | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); | ||
} | ||
@@ -722,5 +753,5 @@ /** | ||
function shallowReadonly(target) { | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); | ||
} | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { | ||
if (!isObject(target)) { | ||
@@ -739,3 +770,2 @@ { | ||
// target already has corresponding Proxy | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
@@ -896,8 +926,10 @@ if (existingProxy) { | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
// the computed ref may get wrapped by other proxies e.g. readonly() #3376 | ||
const self = toRaw(this); | ||
if (self._dirty) { | ||
self._value = this.effect(); | ||
self._dirty = false; | ||
} | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
track(self, "get" /* GET */, 'value'); | ||
return self._value; | ||
} | ||
@@ -904,0 +936,0 @@ set value(newValue) { |
@@ -1,1 +0,1 @@ | ||
function t(t,e){const n=Object.create(null),r=t.split(",");for(let s=0;s<r.length;s++)n[r[s]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e={},n=()=>{},r=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),o=Array.isArray,c=t=>"[object Map]"===_(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,l=t=>null!==t&&"object"==typeof t,f=Object.prototype.toString,_=t=>f.call(t),h=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,v=(t,e)=>t!==e&&(t==t||e==e),d=new WeakMap,p=[];let g;const y=Symbol(""),w=Symbol("");function R(t,n=e){(function(t){return t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(){if(!n.active)return e.scheduler?void 0:t();if(!p.includes(n)){k(n);try{return O(),p.push(n),g=n,t()}finally{p.pop(),P(),g=p[p.length-1]}}};return n.id=S++,n.allowRecurse=!!e.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}function b(t){t.active&&(k(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let S=0;function k(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let E=!0;const j=[];function m(){j.push(E),E=!1}function O(){j.push(E),E=!0}function P(){const t=j.pop();E=void 0===t||t}function x(t,e,n){if(!E||void 0===g)return;let r=d.get(t);r||d.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(g)||(s.add(g),g.deps.push(s))}function z(t,e,n,r,s,i){const u=d.get(t);if(!u)return;const a=new Set,l=t=>{t&&t.forEach(t=>{(t!==g||t.allowRecurse)&&a.add(t)})};if("clear"===e)u.forEach(l);else if("length"===n&&o(t))u.forEach((t,e)=>{("length"===e||e>=r)&&l(t)});else switch(void 0!==n&&l(u.get(n)),e){case"add":o(t)?h(n)&&l(u.get("length")):(l(u.get(y)),c(t)&&l(u.get(w)));break;case"delete":o(t)||(l(u.get(y)),c(t)&&l(u.get(w)));break;case"set":c(t)&&l(u.get(y))}a.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const M=t("__proto__,__v_isRef,__isVue"),A=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(a)),W=B(),N=B(!1,!0),V=B(!0),I=B(!0,!0),K={};function B(t=!1,e=!1){return function(n,r,s){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&s===(t?_t:ft).get(n))return n;const c=o(n);if(!t&&c&&i(K,r))return Reflect.get(K,r,s);const u=Reflect.get(n,r,s);if(a(r)?A.has(r):M(r))return u;if(t||x(n,0,r),e)return u;if(jt(u)){return!c||!h(r)?u.value:u}return l(u)?t?pt(u):vt(u):u}}["includes","indexOf","lastIndexOf"].forEach(t=>{const e=Array.prototype[t];K[t]=function(...t){const n=St(this);for(let e=0,s=this.length;e<s;e++)x(n,0,e+"");const r=e.apply(n,t);return-1===r||!1===r?e.apply(n,t.map(St)):r}}),["push","pop","shift","unshift","splice"].forEach(t=>{const e=Array.prototype[t];K[t]=function(...t){m();const n=e.apply(this,t);return P(),n}});function C(t=!1){return function(e,n,r,s){const c=e[n];if(!t&&(r=St(r),!o(e)&&jt(c)&&!jt(r)))return c.value=r,!0;const u=o(e)&&h(n)?Number(n)<e.length:i(e,n),a=Reflect.set(e,n,r,s);return e===St(s)&&(u?v(r,c)&&z(e,"set",n,r):z(e,"add",n,r)),a}}const L={get:W,set:C(),deleteProperty:function(t,e){const n=i(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&z(t,"delete",e,void 0),r},has:function(t,e){const n=Reflect.has(t,e);return a(e)&&A.has(e)||x(t,0,e),n},ownKeys:function(t){return x(t,0,o(t)?"length":y),Reflect.ownKeys(t)}},q={get:V,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},D=r({},L,{get:N,set:C(!0)}),F=r({},q,{get:I}),G=t=>l(t)?vt(t):t,H=t=>l(t)?pt(t):t,J=t=>t,Q=t=>Reflect.getPrototypeOf(t);function T(t,e,n=!1,r=!1){const s=St(t=t.__v_raw),i=St(e);e!==i&&!n&&x(s,0,e),!n&&x(s,0,i);const{has:o}=Q(s),c=n?H:r?J:G;return o.call(s,e)?c(t.get(e)):o.call(s,i)?c(t.get(i)):void 0}function U(t,e=!1){const n=this.__v_raw,r=St(n),s=St(t);return t!==s&&!e&&x(r,0,t),!e&&x(r,0,s),t===s?n.has(t):n.has(t)||n.has(s)}function X(t,e=!1){return t=t.__v_raw,!e&&x(St(t),0,y),Reflect.get(t,"size",t)}function Y(t){t=St(t);const e=St(this);return Q(e).has.call(e,t)||(e.add(t),z(e,"add",t,t)),this}function Z(t,e){e=St(e);const n=St(this),{has:r,get:s}=Q(n);let i=r.call(n,t);i||(t=St(t),i=r.call(n,t));const o=s.call(n,t);return n.set(t,e),i?v(e,o)&&z(n,"set",t,e):z(n,"add",t,e),this}function $(t){const e=St(this),{has:n,get:r}=Q(e);let s=n.call(e,t);s||(t=St(t),s=n.call(e,t)),r&&r.call(e,t);const i=e.delete(t);return s&&z(e,"delete",t,void 0),i}function tt(){const t=St(this),e=0!==t.size,n=t.clear();return e&&z(t,"clear",void 0,void 0),n}function et(t,e){return function(n,r){const s=this,i=s.__v_raw,o=St(i),c=t?H:e?J:G;return!t&&x(o,0,y),i.forEach((t,e)=>n.call(r,c(t),c(e),s))}}function nt(t,e,n){return function(...r){const s=this.__v_raw,i=St(s),o=c(i),u="entries"===t||t===Symbol.iterator&&o,a="keys"===t&&o,l=s[t](...r),f=e?H:n?J:G;return!e&&x(i,0,a?w:y),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[f(t[0]),f(t[1])]:f(t),done:e}},[Symbol.iterator](){return this}}}}function rt(t){return function(...e){return"delete"!==t&&this}}const st={get(t){return T(this,t)},get size(){return X(this)},has:U,add:Y,set:Z,delete:$,clear:tt,forEach:et(!1,!1)},it={get(t){return T(this,t,!1,!0)},get size(){return X(this)},has:U,add:Y,set:Z,delete:$,clear:tt,forEach:et(!1,!0)},ot={get(t){return T(this,t,!0)},get size(){return X(this,!0)},has(t){return U.call(this,t,!0)},add:rt("add"),set:rt("set"),delete:rt("delete"),clear:rt("clear"),forEach:et(!0,!1)};function ct(t,e){const n=e?it:t?ot:st;return(e,r,s)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(i(n,r)&&r in e?n:e,r,s)}["keys","values","entries",Symbol.iterator].forEach(t=>{st[t]=nt(t,!1,!1),ot[t]=nt(t,!0,!1),it[t]=nt(t,!1,!0)});const ut={get:ct(!1,!1)},at={get:ct(!1,!0)},lt={get:ct(!0,!1)},ft=new WeakMap,_t=new WeakMap;function ht(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>_(t).slice(8,-1))(t))}function vt(t){return t&&t.__v_isReadonly?t:yt(t,!1,L,ut)}function dt(t){return yt(t,!1,D,at)}function pt(t){return yt(t,!0,q,lt)}function gt(t){return yt(t,!0,F,lt)}function yt(t,e,n,r){if(!l(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?_t:ft,i=s.get(t);if(i)return i;const o=ht(t);if(0===o)return t;const c=new Proxy(t,2===o?r:n);return s.set(t,c),c}function wt(t){return Rt(t)?wt(t.__v_raw):!(!t||!t.__v_isReactive)}function Rt(t){return!(!t||!t.__v_isReadonly)}function bt(t){return wt(t)||Rt(t)}function St(t){return t&&St(t.__v_raw)||t}function kt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Et=t=>l(t)?vt(t):t;function jt(t){return Boolean(t&&!0===t.__v_isRef)}function mt(t){return xt(t)}function Ot(t){return xt(t,!0)}class Pt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:Et(t)}get value(){return x(St(this),0,"value"),this._value}set value(t){v(St(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:Et(t),z(St(this),"set","value",t))}}function xt(t,e=!1){return jt(t)?t:new Pt(t,e)}function zt(t){z(St(t),"set","value",void 0)}function Mt(t){return jt(t)?t.value:t}const At={get:(t,e,n)=>Mt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return jt(s)&&!jt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};function Wt(t){return wt(t)?t:new Proxy(t,At)}class Nt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>x(this,0,"value"),()=>z(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function Vt(t){return new Nt(t)}function It(t){const e=o(t)?new Array(t.length):{};for(const n in t)e[n]=Bt(t,n);return e}class Kt{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function Bt(t,e){return jt(t[e])?t[e]:new Kt(t,e)}class Ct{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=R(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,z(St(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),x(St(this),0,"value"),this._value}set value(t){this._setter(t)}}function Lt(t){let e,r;return u(t)?(e=t,r=n):(e=t.get,r=t.set),new Ct(e,r,u(t)||!t.set)}export{y as ITERATE_KEY,Lt as computed,Vt as customRef,R as effect,O as enableTracking,bt as isProxy,wt as isReactive,Rt as isReadonly,jt as isRef,kt as markRaw,m as pauseTracking,Wt as proxyRefs,vt as reactive,pt as readonly,mt as ref,P as resetTracking,dt as shallowReactive,gt as shallowReadonly,Ot as shallowRef,b as stop,St as toRaw,Bt as toRef,It as toRefs,x as track,z as trigger,zt as triggerRef,Mt as unref}; | ||
function t(t,e){const n=Object.create(null),r=t.split(",");for(let s=0;s<r.length;s++)n[r[s]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e={},n=()=>{},r=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),o=Array.isArray,c=t=>"[object Map]"===h(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,l=t=>null!==t&&"object"==typeof t,f=Object.prototype.toString,h=t=>f.call(t),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>t!==e&&(t==t||e==e),v=new WeakMap,g=[];let p;const y=Symbol(""),w=Symbol("");function R(t,n=e){(function(t){return t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(){if(!n.active)return e.scheduler?void 0:t();if(!g.includes(n)){E(n);try{return O(),g.push(n),p=n,t()}finally{g.pop(),M(),p=g[g.length-1]}}};return n.id=k++,n.allowRecurse=!!e.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}function b(t){t.active&&(E(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let k=0;function E(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let S=!0;const j=[];function m(){j.push(S),S=!1}function O(){j.push(S),S=!0}function M(){const t=j.pop();S=void 0===t||t}function P(t,e,n){if(!S||void 0===p)return;let r=v.get(t);r||v.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(p)||(s.add(p),p.deps.push(s))}function x(t,e,n,r,s,i){const u=v.get(t);if(!u)return;const a=new Set,l=t=>{t&&t.forEach((t=>{(t!==p||t.allowRecurse)&&a.add(t)}))};if("clear"===e)u.forEach(l);else if("length"===n&&o(t))u.forEach(((t,e)=>{("length"===e||e>=r)&&l(t)}));else switch(void 0!==n&&l(u.get(n)),e){case"add":o(t)?_(n)&&l(u.get("length")):(l(u.get(y)),c(t)&&l(u.get(w)));break;case"delete":o(t)||(l(u.get(y)),c(t)&&l(u.get(w)));break;case"set":c(t)&&l(u.get(y))}a.forEach((t=>{t.options.scheduler?t.options.scheduler(t):t()}))}const z=t("__proto__,__v_isRef,__isVue"),W=new Set(Object.getOwnPropertyNames(Symbol).map((t=>Symbol[t])).filter(a)),A=B(),N=B(!1,!0),V=B(!0),I=B(!0,!0),K={};function B(t=!1,e=!1){return function(n,r,s){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&s===(t?e?gt:vt:e?dt:_t).get(n))return n;const c=o(n);if(!t&&c&&i(K,r))return Reflect.get(K,r,s);const u=Reflect.get(n,r,s);if(a(r)?W.has(r):z(r))return u;if(t||P(n,0,r),e)return u;if(Pt(u)){return!c||!_(r)?u.value:u}return l(u)?t?Rt(u):yt(u):u}}["includes","indexOf","lastIndexOf"].forEach((t=>{const e=Array.prototype[t];K[t]=function(...t){const n=mt(this);for(let e=0,s=this.length;e<s;e++)P(n,0,e+"");const r=e.apply(n,t);return-1===r||!1===r?e.apply(n,t.map(mt)):r}})),["push","pop","shift","unshift","splice"].forEach((t=>{const e=Array.prototype[t];K[t]=function(...t){m();const n=e.apply(this,t);return M(),n}}));function C(t=!1){return function(e,n,r,s){const c=e[n];if(!t&&(r=mt(r),!o(e)&&Pt(c)&&!Pt(r)))return c.value=r,!0;const u=o(e)&&_(n)?Number(n)<e.length:i(e,n),a=Reflect.set(e,n,r,s);return e===mt(s)&&(u?d(r,c)&&x(e,"set",n,r):x(e,"add",n,r)),a}}const L={get:A,set:C(),deleteProperty:function(t,e){const n=i(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&x(t,"delete",e,void 0),r},has:function(t,e){const n=Reflect.has(t,e);return a(e)&&W.has(e)||P(t,0,e),n},ownKeys:function(t){return P(t,0,o(t)?"length":y),Reflect.ownKeys(t)}},q={get:V,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},D=r({},L,{get:N,set:C(!0)}),F=r({},q,{get:I}),G=t=>l(t)?yt(t):t,H=t=>l(t)?Rt(t):t,J=t=>t,Q=t=>Reflect.getPrototypeOf(t);function T(t,e,n=!1,r=!1){const s=mt(t=t.__v_raw),i=mt(e);e!==i&&!n&&P(s,0,e),!n&&P(s,0,i);const{has:o}=Q(s),c=r?J:n?H:G;return o.call(s,e)?c(t.get(e)):o.call(s,i)?c(t.get(i)):void 0}function U(t,e=!1){const n=this.__v_raw,r=mt(n),s=mt(t);return t!==s&&!e&&P(r,0,t),!e&&P(r,0,s),t===s?n.has(t):n.has(t)||n.has(s)}function X(t,e=!1){return t=t.__v_raw,!e&&P(mt(t),0,y),Reflect.get(t,"size",t)}function Y(t){t=mt(t);const e=mt(this);return Q(e).has.call(e,t)||(e.add(t),x(e,"add",t,t)),this}function Z(t,e){e=mt(e);const n=mt(this),{has:r,get:s}=Q(n);let i=r.call(n,t);i||(t=mt(t),i=r.call(n,t));const o=s.call(n,t);return n.set(t,e),i?d(e,o)&&x(n,"set",t,e):x(n,"add",t,e),this}function $(t){const e=mt(this),{has:n,get:r}=Q(e);let s=n.call(e,t);s||(t=mt(t),s=n.call(e,t)),r&&r.call(e,t);const i=e.delete(t);return s&&x(e,"delete",t,void 0),i}function tt(){const t=mt(this),e=0!==t.size,n=t.clear();return e&&x(t,"clear",void 0,void 0),n}function et(t,e){return function(n,r){const s=this,i=s.__v_raw,o=mt(i),c=e?J:t?H:G;return!t&&P(o,0,y),i.forEach(((t,e)=>n.call(r,c(t),c(e),s)))}}function nt(t,e,n){return function(...r){const s=this.__v_raw,i=mt(s),o=c(i),u="entries"===t||t===Symbol.iterator&&o,a="keys"===t&&o,l=s[t](...r),f=n?J:e?H:G;return!e&&P(i,0,a?w:y),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[f(t[0]),f(t[1])]:f(t),done:e}},[Symbol.iterator](){return this}}}}function rt(t){return function(...e){return"delete"!==t&&this}}const st={get(t){return T(this,t)},get size(){return X(this)},has:U,add:Y,set:Z,delete:$,clear:tt,forEach:et(!1,!1)},it={get(t){return T(this,t,!1,!0)},get size(){return X(this)},has:U,add:Y,set:Z,delete:$,clear:tt,forEach:et(!1,!0)},ot={get(t){return T(this,t,!0)},get size(){return X(this,!0)},has(t){return U.call(this,t,!0)},add:rt("add"),set:rt("set"),delete:rt("delete"),clear:rt("clear"),forEach:et(!0,!1)},ct={get(t){return T(this,t,!0,!0)},get size(){return X(this,!0)},has(t){return U.call(this,t,!0)},add:rt("add"),set:rt("set"),delete:rt("delete"),clear:rt("clear"),forEach:et(!0,!0)};function ut(t,e){const n=e?t?ct:it:t?ot:st;return(e,r,s)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(i(n,r)&&r in e?n:e,r,s)}["keys","values","entries",Symbol.iterator].forEach((t=>{st[t]=nt(t,!1,!1),ot[t]=nt(t,!0,!1),it[t]=nt(t,!1,!0),ct[t]=nt(t,!0,!0)}));const at={get:ut(!1,!1)},lt={get:ut(!1,!0)},ft={get:ut(!0,!1)},ht={get:ut(!0,!0)},_t=new WeakMap,dt=new WeakMap,vt=new WeakMap,gt=new WeakMap;function pt(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>h(t).slice(8,-1))(t))}function yt(t){return t&&t.__v_isReadonly?t:kt(t,!1,L,at,_t)}function wt(t){return kt(t,!1,D,lt,dt)}function Rt(t){return kt(t,!0,q,ft,vt)}function bt(t){return kt(t,!0,F,ht,gt)}function kt(t,e,n,r,s){if(!l(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const i=s.get(t);if(i)return i;const o=pt(t);if(0===o)return t;const c=new Proxy(t,2===o?r:n);return s.set(t,c),c}function Et(t){return St(t)?Et(t.__v_raw):!(!t||!t.__v_isReactive)}function St(t){return!(!t||!t.__v_isReadonly)}function jt(t){return Et(t)||St(t)}function mt(t){return t&&mt(t.__v_raw)||t}function Ot(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Mt=t=>l(t)?yt(t):t;function Pt(t){return Boolean(t&&!0===t.__v_isRef)}function xt(t){return At(t)}function zt(t){return At(t,!0)}class Wt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:Mt(t)}get value(){return P(mt(this),0,"value"),this._value}set value(t){d(mt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:Mt(t),x(mt(this),"set","value",t))}}function At(t,e=!1){return Pt(t)?t:new Wt(t,e)}function Nt(t){x(mt(t),"set","value",void 0)}function Vt(t){return Pt(t)?t.value:t}const It={get:(t,e,n)=>Vt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return Pt(s)&&!Pt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};function Kt(t){return Et(t)?t:new Proxy(t,It)}class Bt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t((()=>P(this,0,"value")),(()=>x(this,"set","value")));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function Ct(t){return new Bt(t)}function Lt(t){const e=o(t)?new Array(t.length):{};for(const n in t)e[n]=Dt(t,n);return e}class qt{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function Dt(t,e){return Pt(t[e])?t[e]:new qt(t,e)}class Ft{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=R(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,x(mt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){const t=mt(this);return t._dirty&&(t._value=this.effect(),t._dirty=!1),P(t,0,"value"),t._value}set value(t){this._setter(t)}}function Gt(t){let e,r;return u(t)?(e=t,r=n):(e=t.get,r=t.set),new Ft(e,r,u(t)||!t.set)}export{y as ITERATE_KEY,Gt as computed,Ct as customRef,R as effect,O as enableTracking,jt as isProxy,Et as isReactive,St as isReadonly,Pt as isRef,Ot as markRaw,m as pauseTracking,Kt as proxyRefs,yt as reactive,Rt as readonly,xt as ref,M as resetTracking,wt as shallowReactive,bt as shallowReadonly,zt as shallowRef,b as stop,mt as toRaw,Dt as toRef,Lt as toRefs,P as track,x as trigger,Nt as triggerRef,Vt as unref}; |
@@ -237,3 +237,10 @@ import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared'; | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
receiver === | ||
(isReadonly | ||
? shallow | ||
? shallowReadonlyMap | ||
: readonlyMap | ||
: shallow | ||
? shallowReactiveMap | ||
: reactiveMap).get(target)) { | ||
return target; | ||
@@ -367,3 +374,3 @@ } | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
@@ -465,3 +472,3 @@ return wrap(target.get(key)); | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -484,3 +491,3 @@ return target.forEach((value, key) => { | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && | ||
@@ -561,2 +568,18 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
}; | ||
const shallowReadonlyInstrumentations = { | ||
get(key) { | ||
return get$1(this, key, true, true); | ||
}, | ||
get size() { | ||
return size(this, true); | ||
}, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
set: createReadonlyMethod("set" /* SET */), | ||
delete: createReadonlyMethod("delete" /* DELETE */), | ||
clear: createReadonlyMethod("clear" /* CLEAR */), | ||
forEach: createForEach(true, true) | ||
}; | ||
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; | ||
@@ -567,6 +590,9 @@ iteratorMethods.forEach(method => { | ||
shallowInstrumentations[method] = createIterableMethod(method, false, true); | ||
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); | ||
}); | ||
function createInstrumentationGetter(isReadonly, shallow) { | ||
const instrumentations = shallow | ||
? shallowInstrumentations | ||
? isReadonly | ||
? shallowReadonlyInstrumentations | ||
: shallowInstrumentations | ||
: isReadonly | ||
@@ -599,2 +625,5 @@ ? readonlyInstrumentations | ||
}; | ||
const shallowReadonlyCollectionHandlers = { | ||
get: createInstrumentationGetter(true, true) | ||
}; | ||
function checkIdentityKeys(target, has, key) { | ||
@@ -613,3 +642,5 @@ const rawKey = toRaw(key); | ||
const reactiveMap = new WeakMap(); | ||
const shallowReactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
const shallowReadonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -639,3 +670,3 @@ switch (rawType) { | ||
} | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); | ||
} | ||
@@ -648,3 +679,3 @@ /** | ||
function shallowReactive(target) { | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers); | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); | ||
} | ||
@@ -656,3 +687,3 @@ /** | ||
function readonly(target) { | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); | ||
} | ||
@@ -666,5 +697,5 @@ /** | ||
function shallowReadonly(target) { | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); | ||
} | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { | ||
if (!isObject(target)) { | ||
@@ -683,3 +714,2 @@ if ((process.env.NODE_ENV !== 'production')) { | ||
// target already has corresponding Proxy | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
@@ -840,8 +870,10 @@ if (existingProxy) { | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
// the computed ref may get wrapped by other proxies e.g. readonly() #3376 | ||
const self = toRaw(this); | ||
if (self._dirty) { | ||
self._value = this.effect(); | ||
self._dirty = false; | ||
} | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
track(self, "get" /* GET */, 'value'); | ||
return self._value; | ||
} | ||
@@ -848,0 +880,0 @@ set value(newValue) { |
@@ -297,3 +297,10 @@ var VueReactivity = (function (exports) { | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
receiver === | ||
(isReadonly | ||
? shallow | ||
? shallowReadonlyMap | ||
: readonlyMap | ||
: shallow | ||
? shallowReactiveMap | ||
: reactiveMap).get(target)) { | ||
return target; | ||
@@ -427,3 +434,3 @@ } | ||
const { has } = getProto(rawTarget); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
if (has.call(rawTarget, key)) { | ||
@@ -524,3 +531,3 @@ return wrap(target.get(key)); | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
@@ -543,3 +550,3 @@ return target.forEach((value, key) => { | ||
const innerIterator = target[method](...args); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; | ||
!isReadonly && | ||
@@ -620,2 +627,18 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); | ||
}; | ||
const shallowReadonlyInstrumentations = { | ||
get(key) { | ||
return get$1(this, key, true, true); | ||
}, | ||
get size() { | ||
return size(this, true); | ||
}, | ||
has(key) { | ||
return has$1.call(this, key, true); | ||
}, | ||
add: createReadonlyMethod("add" /* ADD */), | ||
set: createReadonlyMethod("set" /* SET */), | ||
delete: createReadonlyMethod("delete" /* DELETE */), | ||
clear: createReadonlyMethod("clear" /* CLEAR */), | ||
forEach: createForEach(true, true) | ||
}; | ||
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; | ||
@@ -626,6 +649,9 @@ iteratorMethods.forEach(method => { | ||
shallowInstrumentations[method] = createIterableMethod(method, false, true); | ||
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); | ||
}); | ||
function createInstrumentationGetter(isReadonly, shallow) { | ||
const instrumentations = shallow | ||
? shallowInstrumentations | ||
? isReadonly | ||
? shallowReadonlyInstrumentations | ||
: shallowInstrumentations | ||
: isReadonly | ||
@@ -658,2 +684,5 @@ ? readonlyInstrumentations | ||
}; | ||
const shallowReadonlyCollectionHandlers = { | ||
get: createInstrumentationGetter(true, true) | ||
}; | ||
function checkIdentityKeys(target, has, key) { | ||
@@ -672,3 +701,5 @@ const rawKey = toRaw(key); | ||
const reactiveMap = new WeakMap(); | ||
const shallowReactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
const shallowReadonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -698,3 +729,3 @@ switch (rawType) { | ||
} | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); | ||
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); | ||
} | ||
@@ -707,3 +738,3 @@ /** | ||
function shallowReactive(target) { | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers); | ||
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); | ||
} | ||
@@ -715,3 +746,3 @@ /** | ||
function readonly(target) { | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); | ||
} | ||
@@ -725,5 +756,5 @@ /** | ||
function shallowReadonly(target) { | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers); | ||
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); | ||
} | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { | ||
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { | ||
if (!isObject(target)) { | ||
@@ -742,3 +773,2 @@ { | ||
// target already has corresponding Proxy | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
@@ -899,8 +929,10 @@ if (existingProxy) { | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
// the computed ref may get wrapped by other proxies e.g. readonly() #3376 | ||
const self = toRaw(this); | ||
if (self._dirty) { | ||
self._value = this.effect(); | ||
self._dirty = false; | ||
} | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
track(self, "get" /* GET */, 'value'); | ||
return self._value; | ||
} | ||
@@ -907,0 +939,0 @@ set value(newValue) { |
@@ -1,1 +0,1 @@ | ||
var VueReactivity=function(t){"use strict";function e(t,e){const n=Object.create(null),r=t.split(",");for(let s=0;s<r.length;s++)n[r[s]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const n={},r=()=>{},s=Object.assign,i=Object.prototype.hasOwnProperty,o=(t,e)=>i.call(t,e),c=Array.isArray,u=t=>"[object Map]"===h(t),a=t=>"function"==typeof t,l=t=>"symbol"==typeof t,f=t=>null!==t&&"object"==typeof t,_=Object.prototype.toString,h=t=>_.call(t),v=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>t!==e&&(t==t||e==e),g=new WeakMap,p=[];let y;const w=Symbol(""),R=Symbol("");function b(t,e=n){(function(t){return t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(){if(!n.active)return e.scheduler?void 0:t();if(!p.includes(n)){E(n);try{return O(),p.push(n),y=n,t()}finally{p.pop(),P(),y=p[p.length-1]}}};return n.id=k++,n.allowRecurse=!!e.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,e);return e.lazy||r(),r}let k=0;function E(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let m=!0;const S=[];function j(){S.push(m),m=!1}function O(){S.push(m),m=!0}function P(){const t=S.pop();m=void 0===t||t}function x(t,e,n){if(!m||void 0===y)return;let r=g.get(t);r||g.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(y)||(s.add(y),y.deps.push(s))}function M(t,e,n,r,s,i){const o=g.get(t);if(!o)return;const a=new Set,l=t=>{t&&t.forEach(t=>{(t!==y||t.allowRecurse)&&a.add(t)})};if("clear"===e)o.forEach(l);else if("length"===n&&c(t))o.forEach((t,e)=>{("length"===e||e>=r)&&l(t)});else switch(void 0!==n&&l(o.get(n)),e){case"add":c(t)?v(n)&&l(o.get("length")):(l(o.get(w)),u(t)&&l(o.get(R)));break;case"delete":c(t)||(l(o.get(w)),u(t)&&l(o.get(R)));break;case"set":u(t)&&l(o.get(w))}a.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const z=e("__proto__,__v_isRef,__isVue"),A=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(l)),T=K(),V=K(!1,!0),W=K(!0),N=K(!0,!0),I={};function K(t=!1,e=!1){return function(n,r,s){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&s===(t?_t:ft).get(n))return n;const i=c(n);if(!t&&i&&o(I,r))return Reflect.get(I,r,s);const u=Reflect.get(n,r,s);if(l(r)?A.has(r):z(r))return u;if(t||x(n,0,r),e)return u;if(bt(u)){return!i||!v(r)?u.value:u}return f(u)?t?dt(u):vt(u):u}}["includes","indexOf","lastIndexOf"].forEach(t=>{const e=Array.prototype[t];I[t]=function(...t){const n=wt(this);for(let e=0,s=this.length;e<s;e++)x(n,0,e+"");const r=e.apply(n,t);return-1===r||!1===r?e.apply(n,t.map(wt)):r}}),["push","pop","shift","unshift","splice"].forEach(t=>{const e=Array.prototype[t];I[t]=function(...t){j();const n=e.apply(this,t);return P(),n}});function B(t=!1){return function(e,n,r,s){const i=e[n];if(!t&&(r=wt(r),!c(e)&&bt(i)&&!bt(r)))return i.value=r,!0;const u=c(e)&&v(n)?Number(n)<e.length:o(e,n),a=Reflect.set(e,n,r,s);return e===wt(s)&&(u?d(r,i)&&M(e,"set",n,r):M(e,"add",n,r)),a}}const C={get:T,set:B(),deleteProperty:function(t,e){const n=o(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&M(t,"delete",e,void 0),r},has:function(t,e){const n=Reflect.has(t,e);return l(e)&&A.has(e)||x(t,0,e),n},ownKeys:function(t){return x(t,0,c(t)?"length":w),Reflect.ownKeys(t)}},L={get:W,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},Y=s({},C,{get:V,set:B(!0)}),q=s({},L,{get:N}),D=t=>f(t)?vt(t):t,F=t=>f(t)?dt(t):t,G=t=>t,H=t=>Reflect.getPrototypeOf(t);function J(t,e,n=!1,r=!1){const s=wt(t=t.__v_raw),i=wt(e);e!==i&&!n&&x(s,0,e),!n&&x(s,0,i);const{has:o}=H(s),c=n?F:r?G:D;return o.call(s,e)?c(t.get(e)):o.call(s,i)?c(t.get(i)):void 0}function Q(t,e=!1){const n=this.__v_raw,r=wt(n),s=wt(t);return t!==s&&!e&&x(r,0,t),!e&&x(r,0,s),t===s?n.has(t):n.has(t)||n.has(s)}function U(t,e=!1){return t=t.__v_raw,!e&&x(wt(t),0,w),Reflect.get(t,"size",t)}function X(t){t=wt(t);const e=wt(this);return H(e).has.call(e,t)||(e.add(t),M(e,"add",t,t)),this}function Z(t,e){e=wt(e);const n=wt(this),{has:r,get:s}=H(n);let i=r.call(n,t);i||(t=wt(t),i=r.call(n,t));const o=s.call(n,t);return n.set(t,e),i?d(e,o)&&M(n,"set",t,e):M(n,"add",t,e),this}function $(t){const e=wt(this),{has:n,get:r}=H(e);let s=n.call(e,t);s||(t=wt(t),s=n.call(e,t)),r&&r.call(e,t);const i=e.delete(t);return s&&M(e,"delete",t,void 0),i}function tt(){const t=wt(this),e=0!==t.size,n=t.clear();return e&&M(t,"clear",void 0,void 0),n}function et(t,e){return function(n,r){const s=this,i=s.__v_raw,o=wt(i),c=t?F:e?G:D;return!t&&x(o,0,w),i.forEach((t,e)=>n.call(r,c(t),c(e),s))}}function nt(t,e,n){return function(...r){const s=this.__v_raw,i=wt(s),o=u(i),c="entries"===t||t===Symbol.iterator&&o,a="keys"===t&&o,l=s[t](...r),f=e?F:n?G:D;return!e&&x(i,0,a?R:w),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:c?[f(t[0]),f(t[1])]:f(t),done:e}},[Symbol.iterator](){return this}}}}function rt(t){return function(...e){return"delete"!==t&&this}}const st={get(t){return J(this,t)},get size(){return U(this)},has:Q,add:X,set:Z,delete:$,clear:tt,forEach:et(!1,!1)},it={get(t){return J(this,t,!1,!0)},get size(){return U(this)},has:Q,add:X,set:Z,delete:$,clear:tt,forEach:et(!1,!0)},ot={get(t){return J(this,t,!0)},get size(){return U(this,!0)},has(t){return Q.call(this,t,!0)},add:rt("add"),set:rt("set"),delete:rt("delete"),clear:rt("clear"),forEach:et(!0,!1)};function ct(t,e){const n=e?it:t?ot:st;return(e,r,s)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(o(n,r)&&r in e?n:e,r,s)}["keys","values","entries",Symbol.iterator].forEach(t=>{st[t]=nt(t,!1,!1),ot[t]=nt(t,!0,!1),it[t]=nt(t,!1,!0)});const ut={get:ct(!1,!1)},at={get:ct(!1,!0)},lt={get:ct(!0,!1)},ft=new WeakMap,_t=new WeakMap;function ht(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>h(t).slice(8,-1))(t))}function vt(t){return t&&t.__v_isReadonly?t:gt(t,!1,C,ut)}function dt(t){return gt(t,!0,L,lt)}function gt(t,e,n,r){if(!f(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?_t:ft,i=s.get(t);if(i)return i;const o=ht(t);if(0===o)return t;const c=new Proxy(t,2===o?r:n);return s.set(t,c),c}function pt(t){return yt(t)?pt(t.__v_raw):!(!t||!t.__v_isReactive)}function yt(t){return!(!t||!t.__v_isReadonly)}function wt(t){return t&&wt(t.__v_raw)||t}const Rt=t=>f(t)?vt(t):t;function bt(t){return Boolean(t&&!0===t.__v_isRef)}class kt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:Rt(t)}get value(){return x(wt(this),0,"value"),this._value}set value(t){d(wt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:Rt(t),M(wt(this),"set","value",t))}}function Et(t,e=!1){return bt(t)?t:new kt(t,e)}function mt(t){return bt(t)?t.value:t}const St={get:(t,e,n)=>mt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return bt(s)&&!bt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};class jt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>x(this,0,"value"),()=>M(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class Ot{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function Pt(t,e){return bt(t[e])?t[e]:new Ot(t,e)}class xt{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=b(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,M(wt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),x(wt(this),0,"value"),this._value}set value(t){this._setter(t)}}return t.ITERATE_KEY=w,t.computed=function(t){let e,n;return a(t)?(e=t,n=r):(e=t.get,n=t.set),new xt(e,n,a(t)||!t.set)},t.customRef=function(t){return new jt(t)},t.effect=b,t.enableTracking=O,t.isProxy=function(t){return pt(t)||yt(t)},t.isReactive=pt,t.isReadonly=yt,t.isRef=bt,t.markRaw=function(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t},t.pauseTracking=j,t.proxyRefs=function(t){return pt(t)?t:new Proxy(t,St)},t.reactive=vt,t.readonly=dt,t.ref=function(t){return Et(t)},t.resetTracking=P,t.shallowReactive=function(t){return gt(t,!1,Y,at)},t.shallowReadonly=function(t){return gt(t,!0,q,lt)},t.shallowRef=function(t){return Et(t,!0)},t.stop=function(t){t.active&&(E(t),t.options.onStop&&t.options.onStop(),t.active=!1)},t.toRaw=wt,t.toRef=Pt,t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const n in t)e[n]=Pt(t,n);return e},t.track=x,t.trigger=M,t.triggerRef=function(t){M(wt(t),"set","value",void 0)},t.unref=mt,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
var VueReactivity=function(e){"use strict";function t(e,t){const n=Object.create(null),r=e.split(",");for(let s=0;s<r.length;s++)n[r[s]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}const n={},r=()=>{},s=Object.assign,i=Object.prototype.hasOwnProperty,o=(e,t)=>i.call(e,t),c=Array.isArray,u=e=>"[object Map]"===_(e),a=e=>"function"==typeof e,l=e=>"symbol"==typeof e,f=e=>null!==e&&"object"==typeof e,h=Object.prototype.toString,_=e=>h.call(e),d=e=>"string"==typeof e&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,v=(e,t)=>e!==t&&(e==e||t==t),g=new WeakMap,p=[];let y;const w=Symbol(""),R=Symbol("");function b(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(!p.includes(n)){E(n);try{return O(),p.push(n),y=n,e()}finally{p.pop(),P(),y=p[p.length-1]}}};return n.id=k++,n.allowRecurse=!!t.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(e,t);return t.lazy||r(),r}let k=0;function E(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 S=[];function j(){S.push(m),m=!1}function O(){S.push(m),m=!0}function P(){const e=S.pop();m=void 0===e||e}function M(e,t,n){if(!m||void 0===y)return;let r=g.get(e);r||g.set(e,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(y)||(s.add(y),y.deps.push(s))}function x(e,t,n,r,s,i){const o=g.get(e);if(!o)return;const a=new Set,l=e=>{e&&e.forEach((e=>{(e!==y||e.allowRecurse)&&a.add(e)}))};if("clear"===t)o.forEach(l);else if("length"===n&&c(e))o.forEach(((e,t)=>{("length"===t||t>=r)&&l(e)}));else switch(void 0!==n&&l(o.get(n)),t){case"add":c(e)?d(n)&&l(o.get("length")):(l(o.get(w)),u(e)&&l(o.get(R)));break;case"delete":c(e)||(l(o.get(w)),u(e)&&l(o.get(R)));break;case"set":u(e)&&l(o.get(w))}a.forEach((e=>{e.options.scheduler?e.options.scheduler(e):e()}))}const z=t("__proto__,__v_isRef,__isVue"),A=new Set(Object.getOwnPropertyNames(Symbol).map((e=>Symbol[e])).filter(l)),W=K(),T=K(!1,!0),V=K(!0),N=K(!0,!0),I={};function K(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?t?ge:ve:t?de:_e).get(n))return n;const i=c(n);if(!e&&i&&o(I,r))return Reflect.get(I,r,s);const u=Reflect.get(n,r,s);if(l(r)?A.has(r):z(r))return u;if(e||M(n,0,r),t)return u;if(Se(u)){return!i||!d(r)?u.value:u}return f(u)?e?we(u):ye(u):u}}["includes","indexOf","lastIndexOf"].forEach((e=>{const t=Array.prototype[e];I[e]=function(...e){const n=Ee(this);for(let t=0,s=this.length;t<s;t++)M(n,0,t+"");const r=t.apply(n,e);return-1===r||!1===r?t.apply(n,e.map(Ee)):r}})),["push","pop","shift","unshift","splice"].forEach((e=>{const t=Array.prototype[e];I[e]=function(...e){j();const n=t.apply(this,e);return P(),n}}));function B(e=!1){return function(t,n,r,s){const i=t[n];if(!e&&(r=Ee(r),!c(t)&&Se(i)&&!Se(r)))return i.value=r,!0;const u=c(t)&&d(n)?Number(n)<t.length:o(t,n),a=Reflect.set(t,n,r,s);return t===Ee(s)&&(u?v(r,i)&&x(t,"set",n,r):x(t,"add",n,r)),a}}const C={get:W,set:B(),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:function(e,t){const n=Reflect.has(e,t);return l(t)&&A.has(t)||M(e,0,t),n},ownKeys:function(e){return M(e,0,c(e)?"length":w),Reflect.ownKeys(e)}},L={get:V,set:(e,t)=>!0,deleteProperty:(e,t)=>!0},Y=s({},C,{get:T,set:B(!0)}),q=s({},L,{get:N}),D=e=>f(e)?ye(e):e,F=e=>f(e)?we(e):e,G=e=>e,H=e=>Reflect.getPrototypeOf(e);function J(e,t,n=!1,r=!1){const s=Ee(e=e.__v_raw),i=Ee(t);t!==i&&!n&&M(s,0,t),!n&&M(s,0,i);const{has:o}=H(s),c=r?G:n?F:D;return o.call(s,t)?c(e.get(t)):o.call(s,i)?c(e.get(i)):void 0}function Q(e,t=!1){const n=this.__v_raw,r=Ee(n),s=Ee(e);return e!==s&&!t&&M(r,0,e),!t&&M(r,0,s),e===s?n.has(e):n.has(e)||n.has(s)}function U(e,t=!1){return e=e.__v_raw,!t&&M(Ee(e),0,w),Reflect.get(e,"size",e)}function X(e){e=Ee(e);const t=Ee(this);return H(t).has.call(t,e)||(t.add(e),x(t,"add",e,e)),this}function Z(e,t){t=Ee(t);const n=Ee(this),{has:r,get:s}=H(n);let i=r.call(n,e);i||(e=Ee(e),i=r.call(n,e));const o=s.call(n,e);return n.set(e,t),i?v(t,o)&&x(n,"set",e,t):x(n,"add",e,t),this}function $(e){const t=Ee(this),{has:n,get:r}=H(t);let s=n.call(t,e);s||(e=Ee(e),s=n.call(t,e)),r&&r.call(t,e);const i=t.delete(e);return s&&x(t,"delete",e,void 0),i}function ee(){const e=Ee(this),t=0!==e.size,n=e.clear();return t&&x(e,"clear",void 0,void 0),n}function te(e,t){return function(n,r){const s=this,i=s.__v_raw,o=Ee(i),c=t?G:e?F:D;return!e&&M(o,0,w),i.forEach(((e,t)=>n.call(r,c(e),c(t),s)))}}function ne(e,t,n){return function(...r){const s=this.__v_raw,i=Ee(s),o=u(i),c="entries"===e||e===Symbol.iterator&&o,a="keys"===e&&o,l=s[e](...r),f=n?G:t?F:D;return!t&&M(i,0,a?R:w),{next(){const{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:c?[f(e[0]),f(e[1])]:f(e),done:t}},[Symbol.iterator](){return this}}}}function re(e){return function(...t){return"delete"!==e&&this}}const se={get(e){return J(this,e)},get size(){return U(this)},has:Q,add:X,set:Z,delete:$,clear:ee,forEach:te(!1,!1)},ie={get(e){return J(this,e,!1,!0)},get size(){return U(this)},has:Q,add:X,set:Z,delete:$,clear:ee,forEach:te(!1,!0)},oe={get(e){return J(this,e,!0)},get size(){return U(this,!0)},has(e){return Q.call(this,e,!0)},add:re("add"),set:re("set"),delete:re("delete"),clear:re("clear"),forEach:te(!0,!1)},ce={get(e){return J(this,e,!0,!0)},get size(){return U(this,!0)},has(e){return Q.call(this,e,!0)},add:re("add"),set:re("set"),delete:re("delete"),clear:re("clear"),forEach:te(!0,!0)};function ue(e,t){const n=t?e?ce:ie:e?oe:se;return(t,r,s)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(o(n,r)&&r in t?n:t,r,s)}["keys","values","entries",Symbol.iterator].forEach((e=>{se[e]=ne(e,!1,!1),oe[e]=ne(e,!0,!1),ie[e]=ne(e,!1,!0),ce[e]=ne(e,!0,!0)}));const ae={get:ue(!1,!1)},le={get:ue(!1,!0)},fe={get:ue(!0,!1)},he={get:ue(!0,!0)},_e=new WeakMap,de=new WeakMap,ve=new WeakMap,ge=new WeakMap;function pe(e){return e.__v_skip||!Object.isExtensible(e)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((e=>_(e).slice(8,-1))(e))}function ye(e){return e&&e.__v_isReadonly?e:Re(e,!1,C,ae,_e)}function we(e){return Re(e,!0,L,fe,ve)}function Re(e,t,n,r,s){if(!f(e))return e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const i=s.get(e);if(i)return i;const o=pe(e);if(0===o)return e;const c=new Proxy(e,2===o?r:n);return s.set(e,c),c}function be(e){return ke(e)?be(e.__v_raw):!(!e||!e.__v_isReactive)}function ke(e){return!(!e||!e.__v_isReadonly)}function Ee(e){return e&&Ee(e.__v_raw)||e}const me=e=>f(e)?ye(e):e;function Se(e){return Boolean(e&&!0===e.__v_isRef)}class je{constructor(e,t=!1){this._rawValue=e,this._shallow=t,this.__v_isRef=!0,this._value=t?e:me(e)}get value(){return M(Ee(this),0,"value"),this._value}set value(e){v(Ee(e),this._rawValue)&&(this._rawValue=e,this._value=this._shallow?e:me(e),x(Ee(this),"set","value",e))}}function Oe(e,t=!1){return Se(e)?e:new je(e,t)}function Pe(e){return Se(e)?e.value:e}const Me={get:(e,t,n)=>Pe(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const s=e[t];return Se(s)&&!Se(n)?(s.value=n,!0):Reflect.set(e,t,n,r)}};class xe{constructor(e){this.__v_isRef=!0;const{get:t,set:n}=e((()=>M(this,0,"value")),(()=>x(this,"set","value")));this._get=t,this._set=n}get value(){return this._get()}set value(e){this._set(e)}}class ze{constructor(e,t){this._object=e,this._key=t,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(e){this._object[this._key]=e}}function Ae(e,t){return Se(e[t])?e[t]:new ze(e,t)}class We{constructor(e,t,n){this._setter=t,this._dirty=!0,this.__v_isRef=!0,this.effect=b(e,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,x(Ee(this),"set","value"))}}),this.__v_isReadonly=n}get value(){const e=Ee(this);return e._dirty&&(e._value=this.effect(),e._dirty=!1),M(e,0,"value"),e._value}set value(e){this._setter(e)}}return e.ITERATE_KEY=w,e.computed=function(e){let t,n;return a(e)?(t=e,n=r):(t=e.get,n=e.set),new We(t,n,a(e)||!e.set)},e.customRef=function(e){return new xe(e)},e.effect=b,e.enableTracking=O,e.isProxy=function(e){return be(e)||ke(e)},e.isReactive=be,e.isReadonly=ke,e.isRef=Se,e.markRaw=function(e){return((e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})})(e,"__v_skip",!0),e},e.pauseTracking=j,e.proxyRefs=function(e){return be(e)?e:new Proxy(e,Me)},e.reactive=ye,e.readonly=we,e.ref=function(e){return Oe(e)},e.resetTracking=P,e.shallowReactive=function(e){return Re(e,!1,Y,le,de)},e.shallowReadonly=function(e){return Re(e,!0,q,he,ge)},e.shallowRef=function(e){return Oe(e,!0)},e.stop=function(e){e.active&&(E(e),e.options.onStop&&e.options.onStop(),e.active=!1)},e.toRaw=Ee,e.toRef=Ae,e.toRefs=function(e){const t=c(e)?new Array(e.length):{};for(const n in e)t[n]=Ae(e,n);return t},e.track=M,e.trigger=x,e.triggerRef=function(e){x(Ee(e),"set","value",void 0)},e.unref=Pe,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
{ | ||
"name": "@vue/reactivity", | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"description": "@vue/reactivity", | ||
@@ -39,4 +39,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vue/shared": "3.0.7" | ||
"@vue/shared": "3.0.8" | ||
} | ||
} |
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
186151
4859
+ Added@vue/shared@3.0.8(transitive)
- Removed@vue/shared@3.0.7(transitive)
Updated@vue/shared@3.0.8