@vue/reactivity
Advanced tools
Comparing version 3.0.0-rc.7 to 3.0.0-rc.8
@@ -211,6 +211,3 @@ 'use strict'; | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === | ||
(isReadonly | ||
? target["__v_readonly" /* READONLY */] | ||
: target["__v_reactive" /* REACTIVE */])) { | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
return target; | ||
@@ -439,12 +436,12 @@ } | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const target = observed["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
// important: create sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
function wrappedCallback(value, key) { | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return target.forEach((value, key) => { | ||
// important: make sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
return callback.call(thisArg, wrap(value), wrap(key), observed); | ||
} | ||
return getProto(target).forEach.call(target, wrappedCallback); | ||
}); | ||
}; | ||
@@ -584,2 +581,4 @@ } | ||
const reactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -641,7 +640,6 @@ switch (rawType) { | ||
// target already has corresponding Proxy | ||
const reactiveFlag = isReadonly | ||
? "__v_readonly" /* READONLY */ | ||
: "__v_reactive" /* REACTIVE */; | ||
if (shared.hasOwn(target, reactiveFlag)) { | ||
return target[reactiveFlag]; | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
if (existingProxy) { | ||
return existingProxy; | ||
} | ||
@@ -653,5 +651,5 @@ // only a whitelist of value types can be observed. | ||
} | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
shared.def(target, reactiveFlag, observed); | ||
return observed; | ||
const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
proxyMap.set(target, proxy); | ||
return proxy; | ||
} | ||
@@ -658,0 +656,0 @@ function isReactive(value) { |
@@ -192,6 +192,3 @@ 'use strict'; | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === | ||
(isReadonly | ||
? target["__v_readonly" /* READONLY */] | ||
: target["__v_reactive" /* REACTIVE */])) { | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
return target; | ||
@@ -404,12 +401,12 @@ } | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const target = observed["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
// important: create sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
function wrappedCallback(value, key) { | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return target.forEach((value, key) => { | ||
// important: make sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
return callback.call(thisArg, wrap(value), wrap(key), observed); | ||
} | ||
return getProto(target).forEach.call(target, wrappedCallback); | ||
}); | ||
}; | ||
@@ -534,2 +531,4 @@ } | ||
const reactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -588,7 +587,6 @@ switch (rawType) { | ||
// target already has corresponding Proxy | ||
const reactiveFlag = isReadonly | ||
? "__v_readonly" /* READONLY */ | ||
: "__v_reactive" /* REACTIVE */; | ||
if (shared.hasOwn(target, reactiveFlag)) { | ||
return target[reactiveFlag]; | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
if (existingProxy) { | ||
return existingProxy; | ||
} | ||
@@ -600,5 +598,5 @@ // only a whitelist of value types can be observed. | ||
} | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
shared.def(target, reactiveFlag, observed); | ||
return observed; | ||
const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
proxyMap.set(target, proxy); | ||
return proxy; | ||
} | ||
@@ -605,0 +603,0 @@ function isReactive(value) { |
@@ -94,5 +94,3 @@ | ||
IS_READONLY = "__v_isReadonly", | ||
RAW = "__v_raw", | ||
REACTIVE = "__v_reactive", | ||
READONLY = "__v_readonly" | ||
RAW = "__v_raw" | ||
} | ||
@@ -99,0 +97,0 @@ |
@@ -242,6 +242,3 @@ const EMPTY_OBJ = Object.freeze({}) | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === | ||
(isReadonly | ||
? target["__v_readonly" /* READONLY */] | ||
: target["__v_reactive" /* REACTIVE */])) { | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
return target; | ||
@@ -470,12 +467,12 @@ } | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const target = observed["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
// important: create sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
function wrappedCallback(value, key) { | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return target.forEach((value, key) => { | ||
// important: make sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
return callback.call(thisArg, wrap(value), wrap(key), observed); | ||
} | ||
return getProto(target).forEach.call(target, wrappedCallback); | ||
}); | ||
}; | ||
@@ -615,2 +612,4 @@ } | ||
const reactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -672,7 +671,6 @@ switch (rawType) { | ||
// target already has corresponding Proxy | ||
const reactiveFlag = isReadonly | ||
? "__v_readonly" /* READONLY */ | ||
: "__v_reactive" /* REACTIVE */; | ||
if (hasOwn(target, reactiveFlag)) { | ||
return target[reactiveFlag]; | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
if (existingProxy) { | ||
return existingProxy; | ||
} | ||
@@ -684,5 +682,5 @@ // only a whitelist of value types can be observed. | ||
} | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
def(target, reactiveFlag, observed); | ||
return observed; | ||
const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
proxyMap.set(target, proxy); | ||
return proxy; | ||
} | ||
@@ -689,0 +687,0 @@ function isReactive(value) { |
@@ -1,1 +0,1 @@ | ||
const t={},e=()=>{},n=Object.assign,r=Object.prototype.hasOwnProperty,s=(t,e)=>r.call(t,e),i=Array.isArray,o=t=>"function"==typeof t,c=t=>"symbol"==typeof t,u=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>(t=>a.call(t))(t).slice(8,-1),f=(t,e)=>t!==e&&(t==t||e==e),_=(t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},h=new WeakMap,v=[];let d;const g=Symbol(""),y=Symbol("");function p(e,n=t){(function(t){return t&&!0===t._isEffect})(e)&&(e=e.raw);const r=function(t,e){const n=function(){if(!n.active)return e.scheduler?void 0:t();if(!v.includes(n)){b(n);try{return O(),v.push(n),d=n,t()}finally{v.pop(),j(),d=v[v.length-1]}}};return n.id=R++,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(e,n);return n.lazy||r(),r}function w(t){t.active&&(b(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let R=0;function b(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 E=[];function m(){E.push(S),S=!1}function O(){E.push(S),S=!0}function j(){const t=E.pop();S=void 0===t||t}function k(t,e,n){if(!S||void 0===d)return;let r=h.get(t);r||h.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(d)||(s.add(d),d.deps.push(s))}function P(t,e,n,r,s,o){const c=h.get(t);if(!c)return;const u=new Set,a=t=>{t&&t.forEach(t=>{t!==d&&u.add(t)})};if("clear"===e)c.forEach(a);else if("length"===n&&i(t))c.forEach((t,e)=>{("length"===e||e>=r)&&a(t)});else{void 0!==n&&a(c.get(n));const r="add"===e||"delete"===e&&!i(t);(r||"set"===e&&t instanceof Map)&&a(c.get(i(t)?"length":g)),r&&t instanceof Map&&a(c.get(y))}u.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const x=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(c)),z=W(),M=W(!1,!0),A=W(!0),K=W(!0,!0),V={};function W(t=!1,e=!1){return function(n,r,o){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&o===(t?n.__v_readonly:n.__v_reactive))return n;const a=i(n);if(a&&s(V,r))return Reflect.get(V,r,o);const l=Reflect.get(n,r,o),f=c(r);if(f?x.has(r):"__proto__"===r||"__v_isRef"===r)return l;if(t||k(n,0,r),e)return l;if(bt(l)){return!a||f||""+parseInt(r,10)!==r?l.value:l}return u(l)?t?_t(l):lt(l):l}}["includes","indexOf","lastIndexOf"].forEach(t=>{V[t]=function(...e){const n=pt(this);for(let t=0,e=this.length;t<e;t++)k(n,0,t+"");const r=n[t](...e);return-1===r||!1===r?n[t](...e.map(pt)):r}});function I(t=!1){return function(e,n,r,o){const c=e[n];if(!t&&(r=pt(r),!i(e)&&bt(c)&&!bt(r)))return c.value=r,!0;const u=s(e,n),a=Reflect.set(e,n,r,o);return e===pt(o)&&(u?f(r,c)&&P(e,"set",n,r):P(e,"add",n,r)),a}}function B(t,e){const n=Reflect.has(t,e);return c(e)&&x.has(e)||k(t,0,e),n}function N(t){return k(t,0,g),Reflect.ownKeys(t)}const q={get:z,set:I(),deleteProperty:function(t,e){const n=s(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&P(t,"delete",e,void 0),r},has:B,ownKeys:N},C={get:A,has:B,ownKeys:N,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},D=n({},q,{get:M,set:I(!0)}),F=n({},C,{get:K}),G=t=>u(t)?lt(t):t,H=t=>u(t)?_t(t):t,J=t=>t,L=t=>Reflect.getPrototypeOf(t);function Q(t,e,n=!1,r=!1){const s=pt(t=t.__v_raw),i=pt(e);e!==i&&!n&&k(s,0,e),!n&&k(s,0,i);const{has:o}=L(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 T(t,e=!1){const n=this.__v_raw,r=pt(n),s=pt(t);return t!==s&&!e&&k(r,0,t),!e&&k(r,0,s),n.has(t)||n.has(s)}function U(t,e=!1){return t=t.__v_raw,!e&&k(pt(t),0,g),Reflect.get(t,"size",t)}function X(t){t=pt(t);const e=pt(this),n=L(e),r=n.has.call(e,t),s=n.add.call(e,t);return r||P(e,"add",t,t),s}function Y(t,e){e=pt(e);const n=pt(this),{has:r,get:s,set:i}=L(n);let o=r.call(n,t);o||(t=pt(t),o=r.call(n,t));const c=s.call(n,t),u=i.call(n,t,e);return o?f(e,c)&&P(n,"set",t,e):P(n,"add",t,e),u}function Z(t){const e=pt(this),{has:n,get:r,delete:s}=L(e);let i=n.call(e,t);i||(t=pt(t),i=n.call(e,t));r&&r.call(e,t);const o=s.call(e,t);return i&&P(e,"delete",t,void 0),o}function $(){const t=pt(this),e=0!==t.size,n=L(t).clear.call(t);return e&&P(t,"clear",void 0,void 0),n}function tt(t,e){return function(n,r){const s=this,i=pt(s),o=t?H:e?J:G;return!t&&k(i,0,g),L(i).forEach.call(i,(function(t,e){return n.call(r,o(t),o(e),s)}))}}function et(t,e,n){return function(...r){const s=this.__v_raw,i=pt(s),o=i instanceof Map,c="entries"===t||t===Symbol.iterator&&o,u="keys"===t&&o,a=s[t](...r),l=e?H:n?J:G;return!e&&k(i,0,u?y:g),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:c?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function nt(t){return function(...e){return"delete"!==t&&this}}const rt={get(t){return Q(this,t)},get size(){return U(this)},has:T,add:X,set:Y,delete:Z,clear:$,forEach:tt(!1,!1)},st={get(t){return Q(this,t,!1,!0)},get size(){return U(this)},has:T,add:X,set:Y,delete:Z,clear:$,forEach:tt(!1,!0)},it={get(t){return Q(this,t,!0)},get size(){return U(this,!0)},has(t){return T.call(this,t,!0)},add:nt("add"),set:nt("set"),delete:nt("delete"),clear:nt("clear"),forEach:tt(!0,!1)};function ot(t,e){const n=e?st:t?it:rt;return(e,r,i)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(s(n,r)&&r in e?n:e,r,i)}["keys","values","entries",Symbol.iterator].forEach(t=>{rt[t]=et(t,!1,!1),it[t]=et(t,!0,!1),st[t]=et(t,!1,!0)});const ct={get:ot(!1,!1)},ut={get:ot(!1,!0)},at={get:ot(!0,!1)};function lt(t){return t&&t.__v_isReadonly?t:vt(t,!1,q,ct)}function ft(t){return vt(t,!1,D,ut)}function _t(t){return vt(t,!0,C,at)}function ht(t){return vt(t,!0,F,at)}function vt(t,e,n,r){if(!u(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const i=e?"__v_readonly":"__v_reactive";if(s(t,i))return t[i];const o=(c=t).__v_skip||!Object.isExtensible(c)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(l(c));var c;if(0===o)return t;const a=new Proxy(t,2===o?r:n);return _(t,i,a),a}function dt(t){return gt(t)?dt(t.__v_raw):!(!t||!t.__v_isReactive)}function gt(t){return!(!t||!t.__v_isReadonly)}function yt(t){return dt(t)||gt(t)}function pt(t){return t&&pt(t.__v_raw)||t}function wt(t){return _(t,"__v_skip",!0),t}const Rt=t=>u(t)?lt(t):t;function bt(t){return Boolean(t&&!0===t.__v_isRef)}function St(t){return Ot(t)}function Et(t){return Ot(t,!0)}class mt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:Rt(t)}get value(){return k(pt(this),0,"value"),this._value}set value(t){f(pt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:Rt(t),P(pt(this),"set","value",t))}}function Ot(t,e=!1){return bt(t)?t:new mt(t,e)}function jt(t){P(t,"set","value",void 0)}function kt(t){return bt(t)?t.value:t}const Pt={get:(t,e,n)=>kt(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)}};function xt(t){return dt(t)?t:new Proxy(t,Pt)}class zt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>k(this,0,"value"),()=>P(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function Mt(t){return new zt(t)}function At(t){const e=i(t)?new Array(t.length):{};for(const n in t)e[n]=Vt(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 Vt(t,e){return new Kt(t,e)}class Wt{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=p(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,P(pt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),k(pt(this),0,"value"),this._value}set value(t){this._setter(t)}}function It(t){let n,r;return o(t)?(n=t,r=e):(n=t.get,r=t.set),new Wt(n,r,o(t)||!t.set)}export{g as ITERATE_KEY,It as computed,Mt as customRef,p as effect,O as enableTracking,yt as isProxy,dt as isReactive,gt as isReadonly,bt as isRef,wt as markRaw,m as pauseTracking,xt as proxyRefs,lt as reactive,_t as readonly,St as ref,j as resetTracking,ft as shallowReactive,ht as shallowReadonly,Et as shallowRef,w as stop,pt as toRaw,Vt as toRef,At as toRefs,k as track,P as trigger,jt as triggerRef,kt as unref}; | ||
const t={},e=()=>{},n=Object.assign,r=Object.prototype.hasOwnProperty,s=(t,e)=>r.call(t,e),i=Array.isArray,o=t=>"function"==typeof t,c=t=>"symbol"==typeof t,u=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>(t=>a.call(t))(t).slice(8,-1),f=(t,e)=>t!==e&&(t==t||e==e),_=new WeakMap,h=[];let v;const d=Symbol(""),g=Symbol("");function p(e,n=t){(function(t){return t&&!0===t._isEffect})(e)&&(e=e.raw);const r=function(t,e){const n=function(){if(!n.active)return e.scheduler?void 0:t();if(!h.includes(n)){R(n);try{return k(),h.push(n),v=n,t()}finally{h.pop(),m(),v=h[h.length-1]}}};return n.id=w++,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(e,n);return n.lazy||r(),r}function y(t){t.active&&(R(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let w=0;function R(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let b=!0;const S=[];function E(){S.push(b),b=!1}function k(){S.push(b),b=!0}function m(){const t=S.pop();b=void 0===t||t}function O(t,e,n){if(!b||void 0===v)return;let r=_.get(t);r||_.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(v)||(s.add(v),v.deps.push(s))}function j(t,e,n,r,s,o){const c=_.get(t);if(!c)return;const u=new Set,a=t=>{t&&t.forEach(t=>{t!==v&&u.add(t)})};if("clear"===e)c.forEach(a);else if("length"===n&&i(t))c.forEach((t,e)=>{("length"===e||e>=r)&&a(t)});else{void 0!==n&&a(c.get(n));const r="add"===e||"delete"===e&&!i(t);(r||"set"===e&&t instanceof Map)&&a(c.get(i(t)?"length":d)),r&&t instanceof Map&&a(c.get(g))}u.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const M=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(c)),P=K(),x=K(!1,!0),z=K(!0),W=K(!0,!0),A={};function K(t=!1,e=!1){return function(n,r,o){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&o===(t?lt:at).get(n))return n;const a=i(n);if(a&&s(A,r))return Reflect.get(A,r,o);const l=Reflect.get(n,r,o),f=c(r);if(f?M.has(r):"__proto__"===r||"__v_isRef"===r)return l;if(t||O(n,0,r),e)return l;if(St(l)){return!a||f||""+parseInt(r,10)!==r?l.value:l}return u(l)?t?ht(l):ft(l):l}}["includes","indexOf","lastIndexOf"].forEach(t=>{A[t]=function(...e){const n=wt(this);for(let t=0,e=this.length;t<e;t++)O(n,0,t+"");const r=n[t](...e);return-1===r||!1===r?n[t](...e.map(wt)):r}});function V(t=!1){return function(e,n,r,o){const c=e[n];if(!t&&(r=wt(r),!i(e)&&St(c)&&!St(r)))return c.value=r,!0;const u=s(e,n),a=Reflect.set(e,n,r,o);return e===wt(o)&&(u?f(r,c)&&j(e,"set",n,r):j(e,"add",n,r)),a}}function I(t,e){const n=Reflect.has(t,e);return c(e)&&M.has(e)||O(t,0,e),n}function B(t){return O(t,0,d),Reflect.ownKeys(t)}const N={get:P,set:V(),deleteProperty:function(t,e){const n=s(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&j(t,"delete",e,void 0),r},has:I,ownKeys:B},q={get:z,has:I,ownKeys:B,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},C=n({},N,{get:x,set:V(!0)}),D=n({},q,{get:W}),F=t=>u(t)?ft(t):t,G=t=>u(t)?ht(t):t,H=t=>t,J=t=>Reflect.getPrototypeOf(t);function L(t,e,n=!1,r=!1){const s=wt(t=t.__v_raw),i=wt(e);e!==i&&!n&&O(s,0,e),!n&&O(s,0,i);const{has:o}=J(s),c=n?G:r?H:F;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&&O(r,0,t),!e&&O(r,0,s),n.has(t)||n.has(s)}function T(t,e=!1){return t=t.__v_raw,!e&&O(wt(t),0,d),Reflect.get(t,"size",t)}function U(t){t=wt(t);const e=wt(this),n=J(e),r=n.has.call(e,t),s=n.add.call(e,t);return r||j(e,"add",t,t),s}function X(t,e){e=wt(e);const n=wt(this),{has:r,get:s,set:i}=J(n);let o=r.call(n,t);o||(t=wt(t),o=r.call(n,t));const c=s.call(n,t),u=i.call(n,t,e);return o?f(e,c)&&j(n,"set",t,e):j(n,"add",t,e),u}function Y(t){const e=wt(this),{has:n,get:r,delete:s}=J(e);let i=n.call(e,t);i||(t=wt(t),i=n.call(e,t));r&&r.call(e,t);const o=s.call(e,t);return i&&j(e,"delete",t,void 0),o}function Z(){const t=wt(this),e=0!==t.size,n=J(t).clear.call(t);return e&&j(t,"clear",void 0,void 0),n}function $(t,e){return function(n,r){const s=this,i=s.__v_raw,o=wt(i),c=t?G:e?H:F;return!t&&O(o,0,d),i.forEach((t,e)=>n.call(r,c(t),c(e),s))}}function tt(t,e,n){return function(...r){const s=this.__v_raw,i=wt(s),o=i instanceof Map,c="entries"===t||t===Symbol.iterator&&o,u="keys"===t&&o,a=s[t](...r),l=e?G:n?H:F;return!e&&O(i,0,u?g:d),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:c?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function et(t){return function(...e){return"delete"!==t&&this}}const nt={get(t){return L(this,t)},get size(){return T(this)},has:Q,add:U,set:X,delete:Y,clear:Z,forEach:$(!1,!1)},rt={get(t){return L(this,t,!1,!0)},get size(){return T(this)},has:Q,add:U,set:X,delete:Y,clear:Z,forEach:$(!1,!0)},st={get(t){return L(this,t,!0)},get size(){return T(this,!0)},has(t){return Q.call(this,t,!0)},add:et("add"),set:et("set"),delete:et("delete"),clear:et("clear"),forEach:$(!0,!1)};function it(t,e){const n=e?rt:t?st:nt;return(e,r,i)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(s(n,r)&&r in e?n:e,r,i)}["keys","values","entries",Symbol.iterator].forEach(t=>{nt[t]=tt(t,!1,!1),st[t]=tt(t,!0,!1),rt[t]=tt(t,!1,!0)});const ot={get:it(!1,!1)},ct={get:it(!1,!0)},ut={get:it(!0,!1)},at=new WeakMap,lt=new WeakMap;function ft(t){return t&&t.__v_isReadonly?t:dt(t,!1,N,ot)}function _t(t){return dt(t,!1,C,ct)}function ht(t){return dt(t,!0,q,ut)}function vt(t){return dt(t,!0,D,ut)}function dt(t,e,n,r){if(!u(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?lt:at,i=s.get(t);if(i)return i;const o=(c=t).__v_skip||!Object.isExtensible(c)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(l(c));var c;if(0===o)return t;const a=new Proxy(t,2===o?r:n);return s.set(t,a),a}function gt(t){return pt(t)?gt(t.__v_raw):!(!t||!t.__v_isReactive)}function pt(t){return!(!t||!t.__v_isReadonly)}function yt(t){return gt(t)||pt(t)}function wt(t){return t&&wt(t.__v_raw)||t}function Rt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const bt=t=>u(t)?ft(t):t;function St(t){return Boolean(t&&!0===t.__v_isRef)}function Et(t){return Ot(t)}function kt(t){return Ot(t,!0)}class mt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:bt(t)}get value(){return O(wt(this),0,"value"),this._value}set value(t){f(wt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:bt(t),j(wt(this),"set","value",t))}}function Ot(t,e=!1){return St(t)?t:new mt(t,e)}function jt(t){j(t,"set","value",void 0)}function Mt(t){return St(t)?t.value:t}const Pt={get:(t,e,n)=>Mt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return St(s)&&!St(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};function xt(t){return gt(t)?t:new Proxy(t,Pt)}class zt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>O(this,0,"value"),()=>j(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function Wt(t){return new zt(t)}function At(t){const e=i(t)?new Array(t.length):{};for(const n in t)e[n]=Vt(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 Vt(t,e){return new Kt(t,e)}class It{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=p(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,j(wt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),O(wt(this),0,"value"),this._value}set value(t){this._setter(t)}}function Bt(t){let n,r;return o(t)?(n=t,r=e):(n=t.get,r=t.set),new It(n,r,o(t)||!t.set)}export{d as ITERATE_KEY,Bt as computed,Wt as customRef,p as effect,k as enableTracking,yt as isProxy,gt as isReactive,pt as isReadonly,St as isRef,Rt as markRaw,E as pauseTracking,xt as proxyRefs,ft as reactive,ht as readonly,Et as ref,m as resetTracking,_t as shallowReactive,vt as shallowReadonly,kt as shallowRef,y as stop,wt as toRaw,Vt as toRef,At as toRefs,O as track,j as trigger,jt as triggerRef,Mt as unref}; |
@@ -207,6 +207,3 @@ import { EMPTY_OBJ, isArray, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared'; | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === | ||
(isReadonly | ||
? target["__v_readonly" /* READONLY */] | ||
: target["__v_reactive" /* REACTIVE */])) { | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
return target; | ||
@@ -436,12 +433,12 @@ } | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const target = observed["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
// important: create sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
function wrappedCallback(value, key) { | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return target.forEach((value, key) => { | ||
// important: make sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
return callback.call(thisArg, wrap(value), wrap(key), observed); | ||
} | ||
return getProto(target).forEach.call(target, wrappedCallback); | ||
}); | ||
}; | ||
@@ -581,2 +578,4 @@ } | ||
const reactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -638,7 +637,6 @@ switch (rawType) { | ||
// target already has corresponding Proxy | ||
const reactiveFlag = isReadonly | ||
? "__v_readonly" /* READONLY */ | ||
: "__v_reactive" /* REACTIVE */; | ||
if (hasOwn(target, reactiveFlag)) { | ||
return target[reactiveFlag]; | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
if (existingProxy) { | ||
return existingProxy; | ||
} | ||
@@ -650,5 +648,5 @@ // only a whitelist of value types can be observed. | ||
} | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
def(target, reactiveFlag, observed); | ||
return observed; | ||
const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
proxyMap.set(target, proxy); | ||
return proxy; | ||
} | ||
@@ -655,0 +653,0 @@ function isReactive(value) { |
@@ -245,6 +245,3 @@ var VueReactivity = (function (exports) { | ||
else if (key === "__v_raw" /* RAW */ && | ||
receiver === | ||
(isReadonly | ||
? target["__v_readonly" /* READONLY */] | ||
: target["__v_reactive" /* REACTIVE */])) { | ||
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) { | ||
return target; | ||
@@ -473,12 +470,12 @@ } | ||
const observed = this; | ||
const target = toRaw(observed); | ||
const target = observed["__v_raw" /* RAW */]; | ||
const rawTarget = toRaw(target); | ||
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; | ||
!isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); | ||
// important: create sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
function wrappedCallback(value, key) { | ||
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY); | ||
return target.forEach((value, key) => { | ||
// important: make sure the callback is | ||
// 1. invoked with the reactive map as `this` and 3rd arg | ||
// 2. the value received should be a corresponding reactive/readonly. | ||
return callback.call(thisArg, wrap(value), wrap(key), observed); | ||
} | ||
return getProto(target).forEach.call(target, wrappedCallback); | ||
}); | ||
}; | ||
@@ -618,2 +615,4 @@ } | ||
const reactiveMap = new WeakMap(); | ||
const readonlyMap = new WeakMap(); | ||
function targetTypeMap(rawType) { | ||
@@ -675,7 +674,6 @@ switch (rawType) { | ||
// target already has corresponding Proxy | ||
const reactiveFlag = isReadonly | ||
? "__v_readonly" /* READONLY */ | ||
: "__v_reactive" /* REACTIVE */; | ||
if (hasOwn(target, reactiveFlag)) { | ||
return target[reactiveFlag]; | ||
const proxyMap = isReadonly ? readonlyMap : reactiveMap; | ||
const existingProxy = proxyMap.get(target); | ||
if (existingProxy) { | ||
return existingProxy; | ||
} | ||
@@ -687,5 +685,5 @@ // only a whitelist of value types can be observed. | ||
} | ||
const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
def(target, reactiveFlag, observed); | ||
return observed; | ||
const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); | ||
proxyMap.set(target, proxy); | ||
return proxy; | ||
} | ||
@@ -692,0 +690,0 @@ function isReactive(value) { |
@@ -1,1 +0,1 @@ | ||
var VueReactivity=function(t){"use strict";const e={},n=()=>{},r=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),o=Array.isArray,c=t=>"function"==typeof t,u=t=>"symbol"==typeof t,a=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>(t=>l.call(t))(t).slice(8,-1),_=(t,e)=>t!==e&&(t==t||e==e),h=(t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},v=new WeakMap,d=[];let g;const y=Symbol(""),p=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(!d.includes(n)){b(n);try{return m(),d.push(n),g=n,t()}finally{d.pop(),S(),g=d[d.length-1]}}};return n.id=w++,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}let w=0;function b(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 k=[];function m(){k.push(E),E=!0}function S(){const t=k.pop();E=void 0===t||t}function O(t,e,n){if(!E||void 0===g)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(g)||(s.add(g),g.deps.push(s))}function j(t,e,n,r,s,i){const c=v.get(t);if(!c)return;const u=new Set,a=t=>{t&&t.forEach(t=>{t!==g&&u.add(t)})};if("clear"===e)c.forEach(a);else if("length"===n&&o(t))c.forEach((t,e)=>{("length"===e||e>=r)&&a(t)});else{void 0!==n&&a(c.get(n));const r="add"===e||"delete"===e&&!o(t);(r||"set"===e&&t instanceof Map)&&a(c.get(o(t)?"length":y)),r&&t instanceof Map&&a(c.get(p))}u.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const P=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(u)),x=K(),z=K(!1,!0),M=K(!0),A=K(!0,!0),T={};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?n.__v_readonly:n.__v_reactive))return n;const c=o(n);if(c&&i(T,r))return Reflect.get(T,r,s);const l=Reflect.get(n,r,s),f=u(r);if(f?P.has(r):"__proto__"===r||"__v_isRef"===r)return l;if(t||O(n,0,r),e)return l;if(gt(l)){return!c||f||""+parseInt(r,10)!==r?l.value:l}return a(l)?t?lt(l):at(l):l}}["includes","indexOf","lastIndexOf"].forEach(t=>{T[t]=function(...e){const n=vt(this);for(let t=0,e=this.length;t<e;t++)O(n,0,t+"");const r=n[t](...e);return-1===r||!1===r?n[t](...e.map(vt)):r}});function V(t=!1){return function(e,n,r,s){const c=e[n];if(!t&&(r=vt(r),!o(e)&>(c)&&!gt(r)))return c.value=r,!0;const u=i(e,n),a=Reflect.set(e,n,r,s);return e===vt(s)&&(u?_(r,c)&&j(e,"set",n,r):j(e,"add",n,r)),a}}function I(t,e){const n=Reflect.has(t,e);return u(e)&&P.has(e)||O(t,0,e),n}function W(t){return O(t,0,y),Reflect.ownKeys(t)}const B={get:x,set:V(),deleteProperty:function(t,e){const n=i(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&j(t,"delete",e,void 0),r},has:I,ownKeys:W},N={get:M,has:I,ownKeys:W,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},Y=r({},B,{get:z,set:V(!0)}),q=r({},N,{get:A}),C=t=>a(t)?at(t):t,D=t=>a(t)?lt(t):t,F=t=>t,G=t=>Reflect.getPrototypeOf(t);function H(t,e,n=!1,r=!1){const s=vt(t=t.__v_raw),i=vt(e);e!==i&&!n&&O(s,0,e),!n&&O(s,0,i);const{has:o}=G(s),c=n?D:r?F:C;return o.call(s,e)?c(t.get(e)):o.call(s,i)?c(t.get(i)):void 0}function J(t,e=!1){const n=this.__v_raw,r=vt(n),s=vt(t);return t!==s&&!e&&O(r,0,t),!e&&O(r,0,s),n.has(t)||n.has(s)}function L(t,e=!1){return t=t.__v_raw,!e&&O(vt(t),0,y),Reflect.get(t,"size",t)}function Q(t){t=vt(t);const e=vt(this),n=G(e),r=n.has.call(e,t),s=n.add.call(e,t);return r||j(e,"add",t,t),s}function U(t,e){e=vt(e);const n=vt(this),{has:r,get:s,set:i}=G(n);let o=r.call(n,t);o||(t=vt(t),o=r.call(n,t));const c=s.call(n,t),u=i.call(n,t,e);return o?_(e,c)&&j(n,"set",t,e):j(n,"add",t,e),u}function X(t){const e=vt(this),{has:n,get:r,delete:s}=G(e);let i=n.call(e,t);i||(t=vt(t),i=n.call(e,t));r&&r.call(e,t);const o=s.call(e,t);return i&&j(e,"delete",t,void 0),o}function Z(){const t=vt(this),e=0!==t.size,n=G(t).clear.call(t);return e&&j(t,"clear",void 0,void 0),n}function $(t,e){return function(n,r){const s=this,i=vt(s),o=t?D:e?F:C;return!t&&O(i,0,y),G(i).forEach.call(i,(function(t,e){return n.call(r,o(t),o(e),s)}))}}function tt(t,e,n){return function(...r){const s=this.__v_raw,i=vt(s),o=i instanceof Map,c="entries"===t||t===Symbol.iterator&&o,u="keys"===t&&o,a=s[t](...r),l=e?D:n?F:C;return!e&&O(i,0,u?p:y),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:c?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function et(t){return function(...e){return"delete"!==t&&this}}const nt={get(t){return H(this,t)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!1)},rt={get(t){return H(this,t,!1,!0)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!0)},st={get(t){return H(this,t,!0)},get size(){return L(this,!0)},has(t){return J.call(this,t,!0)},add:et("add"),set:et("set"),delete:et("delete"),clear:et("clear"),forEach:$(!0,!1)};function it(t,e){const n=e?rt:t?st:nt;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=>{nt[t]=tt(t,!1,!1),st[t]=tt(t,!0,!1),rt[t]=tt(t,!1,!0)});const ot={get:it(!1,!1)},ct={get:it(!1,!0)},ut={get:it(!0,!1)};function at(t){return t&&t.__v_isReadonly?t:ft(t,!1,B,ot)}function lt(t){return ft(t,!0,N,ut)}function ft(t,e,n,r){if(!a(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?"__v_readonly":"__v_reactive";if(i(t,s))return t[s];const o=(c=t).__v_skip||!Object.isExtensible(c)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(c));var c;if(0===o)return t;const u=new Proxy(t,2===o?r:n);return h(t,s,u),u}function _t(t){return ht(t)?_t(t.__v_raw):!(!t||!t.__v_isReactive)}function ht(t){return!(!t||!t.__v_isReadonly)}function vt(t){return t&&vt(t.__v_raw)||t}const dt=t=>a(t)?at(t):t;function gt(t){return Boolean(t&&!0===t.__v_isRef)}class yt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:dt(t)}get value(){return O(vt(this),0,"value"),this._value}set value(t){_(vt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:dt(t),j(vt(this),"set","value",t))}}function pt(t,e=!1){return gt(t)?t:new yt(t,e)}function Rt(t){return gt(t)?t.value:t}const wt={get:(t,e,n)=>Rt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return gt(s)&&!gt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};class bt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>O(this,0,"value"),()=>j(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class Et{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 kt(t,e){return new Et(t,e)}class mt{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,j(vt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),O(vt(this),0,"value"),this._value}set value(t){this._setter(t)}}return t.ITERATE_KEY=y,t.computed=function(t){let e,r;return c(t)?(e=t,r=n):(e=t.get,r=t.set),new mt(e,r,c(t)||!t.set)},t.customRef=function(t){return new bt(t)},t.effect=R,t.enableTracking=m,t.isProxy=function(t){return _t(t)||ht(t)},t.isReactive=_t,t.isReadonly=ht,t.isRef=gt,t.markRaw=function(t){return h(t,"__v_skip",!0),t},t.pauseTracking=function(){k.push(E),E=!1},t.proxyRefs=function(t){return _t(t)?t:new Proxy(t,wt)},t.reactive=at,t.readonly=lt,t.ref=function(t){return pt(t)},t.resetTracking=S,t.shallowReactive=function(t){return ft(t,!1,Y,ct)},t.shallowReadonly=function(t){return ft(t,!0,q,ut)},t.shallowRef=function(t){return pt(t,!0)},t.stop=function(t){t.active&&(b(t),t.options.onStop&&t.options.onStop(),t.active=!1)},t.toRaw=vt,t.toRef=kt,t.toRefs=function(t){const e=o(t)?new Array(t.length):{};for(const n in t)e[n]=kt(t,n);return e},t.track=O,t.trigger=j,t.triggerRef=function(t){j(t,"set","value",void 0)},t.unref=Rt,t}({}); | ||
var VueReactivity=function(t){"use strict";const e={},n=()=>{},r=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),o=Array.isArray,c=t=>"function"==typeof t,u=t=>"symbol"==typeof t,a=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>(t=>l.call(t))(t).slice(8,-1),_=(t,e)=>t!==e&&(t==t||e==e),h=new WeakMap,v=[];let d;const g=Symbol(""),y=Symbol("");function p(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(!v.includes(n)){R(n);try{return E(),v.push(n),d=n,t()}finally{v.pop(),m(),d=v[v.length-1]}}};return n.id=w++,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}let w=0;function R(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let b=!0;const k=[];function E(){k.push(b),b=!0}function m(){const t=k.pop();b=void 0===t||t}function S(t,e,n){if(!b||void 0===d)return;let r=h.get(t);r||h.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(d)||(s.add(d),d.deps.push(s))}function O(t,e,n,r,s,i){const c=h.get(t);if(!c)return;const u=new Set,a=t=>{t&&t.forEach(t=>{t!==d&&u.add(t)})};if("clear"===e)c.forEach(a);else if("length"===n&&o(t))c.forEach((t,e)=>{("length"===e||e>=r)&&a(t)});else{void 0!==n&&a(c.get(n));const r="add"===e||"delete"===e&&!o(t);(r||"set"===e&&t instanceof Map)&&a(c.get(o(t)?"length":g)),r&&t instanceof Map&&a(c.get(y))}u.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const j=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(u)),P=T(),x=T(!1,!0),M=T(!0),z=T(!0,!0),A={};function T(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?at:ut).get(n))return n;const c=o(n);if(c&&i(A,r))return Reflect.get(A,r,s);const l=Reflect.get(n,r,s),f=u(r);if(f?j.has(r):"__proto__"===r||"__v_isRef"===r)return l;if(t||S(n,0,r),e)return l;if(yt(l)){return!c||f||""+parseInt(r,10)!==r?l.value:l}return a(l)?t?ft(l):lt(l):l}}["includes","indexOf","lastIndexOf"].forEach(t=>{A[t]=function(...e){const n=dt(this);for(let t=0,e=this.length;t<e;t++)S(n,0,t+"");const r=n[t](...e);return-1===r||!1===r?n[t](...e.map(dt)):r}});function W(t=!1){return function(e,n,r,s){const c=e[n];if(!t&&(r=dt(r),!o(e)&&yt(c)&&!yt(r)))return c.value=r,!0;const u=i(e,n),a=Reflect.set(e,n,r,s);return e===dt(s)&&(u?_(r,c)&&O(e,"set",n,r):O(e,"add",n,r)),a}}function K(t,e){const n=Reflect.has(t,e);return u(e)&&j.has(e)||S(t,0,e),n}function V(t){return S(t,0,g),Reflect.ownKeys(t)}const I={get:P,set:W(),deleteProperty:function(t,e){const n=i(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&O(t,"delete",e,void 0),r},has:K,ownKeys:V},B={get:M,has:K,ownKeys:V,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},N=r({},I,{get:x,set:W(!0)}),Y=r({},B,{get:z}),q=t=>a(t)?lt(t):t,C=t=>a(t)?ft(t):t,D=t=>t,F=t=>Reflect.getPrototypeOf(t);function G(t,e,n=!1,r=!1){const s=dt(t=t.__v_raw),i=dt(e);e!==i&&!n&&S(s,0,e),!n&&S(s,0,i);const{has:o}=F(s),c=n?C:r?D:q;return o.call(s,e)?c(t.get(e)):o.call(s,i)?c(t.get(i)):void 0}function H(t,e=!1){const n=this.__v_raw,r=dt(n),s=dt(t);return t!==s&&!e&&S(r,0,t),!e&&S(r,0,s),n.has(t)||n.has(s)}function J(t,e=!1){return t=t.__v_raw,!e&&S(dt(t),0,g),Reflect.get(t,"size",t)}function L(t){t=dt(t);const e=dt(this),n=F(e),r=n.has.call(e,t),s=n.add.call(e,t);return r||O(e,"add",t,t),s}function Q(t,e){e=dt(e);const n=dt(this),{has:r,get:s,set:i}=F(n);let o=r.call(n,t);o||(t=dt(t),o=r.call(n,t));const c=s.call(n,t),u=i.call(n,t,e);return o?_(e,c)&&O(n,"set",t,e):O(n,"add",t,e),u}function U(t){const e=dt(this),{has:n,get:r,delete:s}=F(e);let i=n.call(e,t);i||(t=dt(t),i=n.call(e,t));r&&r.call(e,t);const o=s.call(e,t);return i&&O(e,"delete",t,void 0),o}function X(){const t=dt(this),e=0!==t.size,n=F(t).clear.call(t);return e&&O(t,"clear",void 0,void 0),n}function Z(t,e){return function(n,r){const s=this,i=s.__v_raw,o=dt(i),c=t?C:e?D:q;return!t&&S(o,0,g),i.forEach((t,e)=>n.call(r,c(t),c(e),s))}}function $(t,e,n){return function(...r){const s=this.__v_raw,i=dt(s),o=i instanceof Map,c="entries"===t||t===Symbol.iterator&&o,u="keys"===t&&o,a=s[t](...r),l=e?C:n?D:q;return!e&&S(i,0,u?y:g),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:c?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function tt(t){return function(...e){return"delete"!==t&&this}}const et={get(t){return G(this,t)},get size(){return J(this)},has:H,add:L,set:Q,delete:U,clear:X,forEach:Z(!1,!1)},nt={get(t){return G(this,t,!1,!0)},get size(){return J(this)},has:H,add:L,set:Q,delete:U,clear:X,forEach:Z(!1,!0)},rt={get(t){return G(this,t,!0)},get size(){return J(this,!0)},has(t){return H.call(this,t,!0)},add:tt("add"),set:tt("set"),delete:tt("delete"),clear:tt("clear"),forEach:Z(!0,!1)};function st(t,e){const n=e?nt:t?rt:et;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=>{et[t]=$(t,!1,!1),rt[t]=$(t,!0,!1),nt[t]=$(t,!1,!0)});const it={get:st(!1,!1)},ot={get:st(!1,!0)},ct={get:st(!0,!1)},ut=new WeakMap,at=new WeakMap;function lt(t){return t&&t.__v_isReadonly?t:_t(t,!1,I,it)}function ft(t){return _t(t,!0,B,ct)}function _t(t,e,n,r){if(!a(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?at:ut,i=s.get(t);if(i)return i;const o=(c=t).__v_skip||!Object.isExtensible(c)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(c));var c;if(0===o)return t;const u=new Proxy(t,2===o?r:n);return s.set(t,u),u}function ht(t){return vt(t)?ht(t.__v_raw):!(!t||!t.__v_isReactive)}function vt(t){return!(!t||!t.__v_isReadonly)}function dt(t){return t&&dt(t.__v_raw)||t}const gt=t=>a(t)?lt(t):t;function yt(t){return Boolean(t&&!0===t.__v_isRef)}class pt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:gt(t)}get value(){return S(dt(this),0,"value"),this._value}set value(t){_(dt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:gt(t),O(dt(this),"set","value",t))}}function wt(t,e=!1){return yt(t)?t:new pt(t,e)}function Rt(t){return yt(t)?t.value:t}const bt={get:(t,e,n)=>Rt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return yt(s)&&!yt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};class kt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>S(this,0,"value"),()=>O(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class Et{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 mt(t,e){return new Et(t,e)}class St{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=p(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,O(dt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),S(dt(this),0,"value"),this._value}set value(t){this._setter(t)}}return t.ITERATE_KEY=g,t.computed=function(t){let e,r;return c(t)?(e=t,r=n):(e=t.get,r=t.set),new St(e,r,c(t)||!t.set)},t.customRef=function(t){return new kt(t)},t.effect=p,t.enableTracking=E,t.isProxy=function(t){return ht(t)||vt(t)},t.isReactive=ht,t.isReadonly=vt,t.isRef=yt,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=function(){k.push(b),b=!1},t.proxyRefs=function(t){return ht(t)?t:new Proxy(t,bt)},t.reactive=lt,t.readonly=ft,t.ref=function(t){return wt(t)},t.resetTracking=m,t.shallowReactive=function(t){return _t(t,!1,N,ot)},t.shallowReadonly=function(t){return _t(t,!0,Y,ct)},t.shallowRef=function(t){return wt(t,!0)},t.stop=function(t){t.active&&(R(t),t.options.onStop&&t.options.onStop(),t.active=!1)},t.toRaw=dt,t.toRef=mt,t.toRefs=function(t){const e=o(t)?new Array(t.length):{};for(const n in t)e[n]=mt(t,n);return e},t.track=S,t.trigger=O,t.triggerRef=function(t){O(t,"set","value",void 0)},t.unref=Rt,t}({}); |
{ | ||
"name": "@vue/reactivity", | ||
"version": "3.0.0-rc.7", | ||
"version": "3.0.0-rc.8", | ||
"description": "@vue/reactivity", | ||
@@ -38,4 +38,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vue/shared": "3.0.0-rc.7" | ||
"@vue/shared": "3.0.0-rc.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
168532
4413
+ Added@vue/shared@3.0.0-rc.8(transitive)
- Removed@vue/shared@3.0.0-rc.7(transitive)
Updated@vue/shared@3.0.0-rc.8