@vue/reactivity
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -10,4 +10,4 @@ 'use strict'; | ||
let activeEffect; | ||
const ITERATE_KEY = Symbol( 'iterate' ); | ||
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' ); | ||
const ITERATE_KEY = Symbol('iterate' ); | ||
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' ); | ||
function isEffect(fn) { | ||
@@ -103,3 +103,3 @@ return fn && fn._isEffect === true; | ||
activeEffect.deps.push(dep); | ||
if ( activeEffect.options.onTrack) { | ||
if (activeEffect.options.onTrack) { | ||
activeEffect.options.onTrack({ | ||
@@ -177,3 +177,3 @@ effect: activeEffect, | ||
const run = (effect) => { | ||
if ( effect.options.onTrigger) { | ||
if (effect.options.onTrigger) { | ||
effect.options.onTrigger({ | ||
@@ -199,2 +199,3 @@ effect, | ||
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`); | ||
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol) | ||
@@ -254,3 +255,3 @@ .map(key => Symbol[key]) | ||
? builtInSymbols.has(key) | ||
: key === `__proto__` || key === `__v_isRef`) { | ||
: isNonTrackableKeys(key)) { | ||
return res; | ||
@@ -454,3 +455,3 @@ } | ||
const hadItems = target.size !== 0; | ||
const oldTarget = shared.isMap(target) | ||
const oldTarget = shared.isMap(target) | ||
? new Map(target) | ||
@@ -749,3 +750,3 @@ : new Set(target) | ||
function triggerRef(ref) { | ||
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value ); | ||
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value ); | ||
} | ||
@@ -791,3 +792,3 @@ function unref(ref) { | ||
function toRefs(object) { | ||
if ( !isProxy(object)) { | ||
if (!isProxy(object)) { | ||
console.warn(`toRefs() expects a reactive object but received a plain one.`); | ||
@@ -853,3 +854,3 @@ } | ||
getter = getterOrOptions; | ||
setter = () => { | ||
setter = () => { | ||
console.warn('Write operation failed: computed value is readonly'); | ||
@@ -856,0 +857,0 @@ } |
@@ -10,4 +10,4 @@ 'use strict'; | ||
let activeEffect; | ||
const ITERATE_KEY = Symbol( ''); | ||
const MAP_KEY_ITERATE_KEY = Symbol( ''); | ||
const ITERATE_KEY = Symbol(''); | ||
const MAP_KEY_ITERATE_KEY = Symbol(''); | ||
function isEffect(fn) { | ||
@@ -178,2 +178,3 @@ return fn && fn._isEffect === true; | ||
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`); | ||
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol) | ||
@@ -233,3 +234,3 @@ .map(key => Symbol[key]) | ||
? builtInSymbols.has(key) | ||
: key === `__proto__` || key === `__v_isRef`) { | ||
: isNonTrackableKeys(key)) { | ||
return res; | ||
@@ -287,3 +288,3 @@ } | ||
const hadKey = shared.hasOwn(target, key); | ||
const oldValue = target[key]; | ||
target[key]; | ||
const result = Reflect.deleteProperty(target, key); | ||
@@ -411,3 +412,3 @@ if (result && hadKey) { | ||
} | ||
const oldValue = get ? get.call(target, key) : undefined; | ||
get ? get.call(target, key) : undefined; | ||
// forward the operation before queueing reactions | ||
@@ -695,3 +696,3 @@ const result = target.delete(key); | ||
function triggerRef(ref) { | ||
trigger(toRaw(ref), "set" /* SET */, 'value', void 0); | ||
trigger(toRaw(ref), "set" /* SET */, 'value', void 0); | ||
} | ||
@@ -795,3 +796,3 @@ function unref(ref) { | ||
getter = getterOrOptions; | ||
setter = shared.NOOP; | ||
setter = shared.NOOP; | ||
} | ||
@@ -798,0 +799,0 @@ else { |
@@ -254,3 +254,3 @@ | ||
declare type ToRef<T> = T extends Ref ? T : Ref<UnwrapRef<T>>; | ||
declare type ToRef<T> = [T] extends [Ref] ? T : Ref<UnwrapRef<T>>; | ||
@@ -257,0 +257,0 @@ export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>; |
@@ -1,4 +0,20 @@ | ||
const EMPTY_OBJ = Object.freeze({}) | ||
/** | ||
* Make a map and return a function for checking if a key | ||
* is in that map. | ||
* IMPORTANT: all calls of this function must be prefixed with | ||
* \/\*#\_\_PURE\_\_\*\/ | ||
* So that rollup can tree-shake them if necessary. | ||
*/ | ||
function makeMap(str, expectsLowerCase) { | ||
const map = Object.create(null); | ||
const list = str.split(','); | ||
for (let i = 0; i < list.length; i++) { | ||
map[list[i]] = true; | ||
} | ||
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; | ||
} | ||
const EMPTY_OBJ = Object.freeze({}) | ||
; | ||
const EMPTY_ARR = Object.freeze([]) ; | ||
Object.freeze([]) ; | ||
const extend = Object.assign; | ||
@@ -47,4 +63,4 @@ const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
let activeEffect; | ||
const ITERATE_KEY = Symbol( 'iterate' ); | ||
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' ); | ||
const ITERATE_KEY = Symbol('iterate' ); | ||
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' ); | ||
function isEffect(fn) { | ||
@@ -140,3 +156,3 @@ return fn && fn._isEffect === true; | ||
activeEffect.deps.push(dep); | ||
if ( activeEffect.options.onTrack) { | ||
if (activeEffect.options.onTrack) { | ||
activeEffect.options.onTrack({ | ||
@@ -214,3 +230,3 @@ effect: activeEffect, | ||
const run = (effect) => { | ||
if ( effect.options.onTrigger) { | ||
if (effect.options.onTrigger) { | ||
effect.options.onTrigger({ | ||
@@ -236,2 +252,3 @@ effect, | ||
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`); | ||
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol) | ||
@@ -291,3 +308,3 @@ .map(key => Symbol[key]) | ||
? builtInSymbols.has(key) | ||
: key === `__proto__` || key === `__v_isRef`) { | ||
: isNonTrackableKeys(key)) { | ||
return res; | ||
@@ -491,3 +508,3 @@ } | ||
const hadItems = target.size !== 0; | ||
const oldTarget = isMap(target) | ||
const oldTarget = isMap(target) | ||
? new Map(target) | ||
@@ -786,3 +803,3 @@ : new Set(target) | ||
function triggerRef(ref) { | ||
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value ); | ||
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value ); | ||
} | ||
@@ -828,3 +845,3 @@ function unref(ref) { | ||
function toRefs(object) { | ||
if ( !isProxy(object)) { | ||
if (!isProxy(object)) { | ||
console.warn(`toRefs() expects a reactive object but received a plain one.`); | ||
@@ -890,3 +907,3 @@ } | ||
getter = getterOrOptions; | ||
setter = () => { | ||
setter = () => { | ||
console.warn('Write operation failed: computed value is readonly'); | ||
@@ -893,0 +910,0 @@ } |
@@ -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=>"[object Map]"===f(t),c=t=>"function"==typeof t,u=t=>"symbol"==typeof t,a=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),h=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,_=(t,e)=>t!==e&&(t==t||e==e),v=new WeakMap,d=[];let p;const g=Symbol(""),y=Symbol("");function w(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(!d.includes(n)){S(n);try{return j(),d.push(n),p=n,t()}finally{d.pop(),O(),p=d[d.length-1]}}};return n.id=b++,n.allowRecurse=!!e.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(e,n);return n.lazy||r(),r}function R(t){t.active&&(S(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let b=0;function S(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let k=!0;const E=[];function m(){E.push(k),k=!1}function j(){E.push(k),k=!0}function O(){const t=E.pop();k=void 0===t||t}function P(t,e,n){if(!k||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,c){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&&i(t))u.forEach((t,e)=>{("length"===e||e>=r)&&l(t)});else switch(void 0!==n&&l(u.get(n)),e){case"add":i(t)?h(n)&&l(u.get("length")):(l(u.get(g)),o(t)&&l(u.get(y)));break;case"delete":i(t)||(l(u.get(g)),o(t)&&l(u.get(y)));break;case"set":o(t)&&l(u.get(g))}a.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const z=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(u)),M=I(),A=I(!1,!0),W=I(!0),N=I(!0,!0),V={};function I(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 c=i(n);if(!t&&c&&s(V,r))return Reflect.get(V,r,o);const l=Reflect.get(n,r,o);if(u(r)?z.has(r):"__proto__"===r||"__v_isRef"===r)return l;if(t||P(n,0,r),e)return l;if(kt(l)){return!c||!h(r)?l.value:l}return a(l)?t?vt(l):ht(l):l}}["includes","indexOf","lastIndexOf"].forEach(t=>{const e=Array.prototype[t];V[t]=function(...t){const n=Rt(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(Rt)):r}}),["push","pop","shift","unshift","splice"].forEach(t=>{const e=Array.prototype[t];V[t]=function(...t){m();const n=e.apply(this,t);return O(),n}});function K(t=!1){return function(e,n,r,o){const c=e[n];if(!t&&(r=Rt(r),!i(e)&&kt(c)&&!kt(r)))return c.value=r,!0;const u=i(e)&&h(n)?Number(n)<e.length:s(e,n),a=Reflect.set(e,n,r,o);return e===Rt(o)&&(u?_(r,c)&&x(e,"set",n,r):x(e,"add",n,r)),a}}const B={get:M,set:K(),deleteProperty:function(t,e){const n=s(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 u(e)&&z.has(e)||P(t,0,e),n},ownKeys:function(t){return P(t,0,i(t)?"length":g),Reflect.ownKeys(t)}},q={get:W,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},C=n({},B,{get:A,set:K(!0)}),D=n({},q,{get:N}),F=t=>a(t)?ht(t):t,G=t=>a(t)?vt(t):t,H=t=>t,J=t=>Reflect.getPrototypeOf(t);function L(t,e,n=!1,r=!1){const s=Rt(t=t.__v_raw),i=Rt(e);e!==i&&!n&&P(s,0,e),!n&&P(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=Rt(n),s=Rt(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 T(t,e=!1){return t=t.__v_raw,!e&&P(Rt(t),0,g),Reflect.get(t,"size",t)}function U(t){t=Rt(t);const e=Rt(this),n=J(e).has.call(e,t);return e.add(t),n||x(e,"add",t,t),this}function X(t,e){e=Rt(e);const n=Rt(this),{has:r,get:s}=J(n);let i=r.call(n,t);i||(t=Rt(t),i=r.call(n,t));const o=s.call(n,t);return n.set(t,e),i?_(e,o)&&x(n,"set",t,e):x(n,"add",t,e),this}function Y(t){const e=Rt(this),{has:n,get:r}=J(e);let s=n.call(e,t);s||(t=Rt(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 Z(){const t=Rt(this),e=0!==t.size,n=t.clear();return e&&x(t,"clear",void 0,void 0),n}function $(t,e){return function(n,r){const s=this,i=s.__v_raw,o=Rt(i),c=t?G:e?H:F;return!t&&P(o,0,g),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=Rt(s),c=o(i),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,l=s[t](...r),f=e?G:n?H:F;return!e&&P(i,0,a?y:g),{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 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.__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=>f(t).slice(8,-1))(t))}function ht(t){return t&&t.__v_isReadonly?t:pt(t,!1,B,ot)}function _t(t){return pt(t,!1,C,ct)}function vt(t){return pt(t,!0,q,ut)}function dt(t){return pt(t,!0,D,ut)}function pt(t,e,n,r){if(!a(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=ft(t);if(0===o)return t;const c=new Proxy(t,2===o?r:n);return s.set(t,c),c}function gt(t){return yt(t)?gt(t.__v_raw):!(!t||!t.__v_isReactive)}function yt(t){return!(!t||!t.__v_isReadonly)}function wt(t){return gt(t)||yt(t)}function Rt(t){return t&&Rt(t.__v_raw)||t}function bt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const St=t=>a(t)?ht(t):t;function kt(t){return Boolean(t&&!0===t.__v_isRef)}function Et(t){return Ot(t)}function mt(t){return Ot(t,!0)}class jt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:St(t)}get value(){return P(Rt(this),0,"value"),this._value}set value(t){_(Rt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:St(t),x(Rt(this),"set","value",t))}}function Ot(t,e=!1){return kt(t)?t:new jt(t,e)}function Pt(t){x(Rt(t),"set","value",void 0)}function xt(t){return kt(t)?t.value:t}const zt={get:(t,e,n)=>xt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return kt(s)&&!kt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};function Mt(t){return gt(t)?t:new Proxy(t,zt)}class At{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 Wt(t){return new At(t)}function Nt(t){const e=i(t)?new Array(t.length):{};for(const n in t)e[n]=It(t,n);return e}class Vt{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 It(t,e){return kt(t[e])?t[e]:new Vt(t,e)}class Kt{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=w(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,x(Rt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),P(Rt(this),0,"value"),this._value}set value(t){this._setter(t)}}function Bt(t){let n,r;return c(t)?(n=t,r=e):(n=t.get,r=t.set),new Kt(n,r,c(t)||!t.set)}export{g as ITERATE_KEY,Bt as computed,Wt as customRef,w as effect,j as enableTracking,wt as isProxy,gt as isReactive,yt as isReadonly,kt as isRef,bt as markRaw,m as pauseTracking,Mt as proxyRefs,ht as reactive,vt as readonly,Et as ref,O as resetTracking,_t as shallowReactive,dt as shallowReadonly,mt as shallowRef,R as stop,Rt as toRaw,It as toRef,Nt as toRefs,P as track,x as trigger,Pt as triggerRef,xt 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]"===_(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),n=Q(e).has.call(e,t);return e.add(t),n||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}; |
@@ -1,2 +0,2 @@ | ||
import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared'; | ||
import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared'; | ||
@@ -192,2 +192,3 @@ const targetMap = new WeakMap(); | ||
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`); | ||
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol) | ||
@@ -247,3 +248,3 @@ .map(key => Symbol[key]) | ||
? builtInSymbols.has(key) | ||
: key === `__proto__` || key === `__v_isRef`) { | ||
: isNonTrackableKeys(key)) { | ||
return res; | ||
@@ -250,0 +251,0 @@ } |
var VueReactivity = (function (exports) { | ||
'use strict'; | ||
const EMPTY_OBJ = Object.freeze({}) | ||
/** | ||
* Make a map and return a function for checking if a key | ||
* is in that map. | ||
* IMPORTANT: all calls of this function must be prefixed with | ||
* \/\*#\_\_PURE\_\_\*\/ | ||
* So that rollup can tree-shake them if necessary. | ||
*/ | ||
function makeMap(str, expectsLowerCase) { | ||
const map = Object.create(null); | ||
const list = str.split(','); | ||
for (let i = 0; i < list.length; i++) { | ||
map[list[i]] = true; | ||
} | ||
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; | ||
} | ||
const EMPTY_OBJ = Object.freeze({}) | ||
; | ||
const EMPTY_ARR = Object.freeze([]) ; | ||
Object.freeze([]) ; | ||
const extend = Object.assign; | ||
@@ -50,4 +66,4 @@ const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
let activeEffect; | ||
const ITERATE_KEY = Symbol( 'iterate' ); | ||
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' ); | ||
const ITERATE_KEY = Symbol('iterate' ); | ||
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' ); | ||
function isEffect(fn) { | ||
@@ -143,3 +159,3 @@ return fn && fn._isEffect === true; | ||
activeEffect.deps.push(dep); | ||
if ( activeEffect.options.onTrack) { | ||
if (activeEffect.options.onTrack) { | ||
activeEffect.options.onTrack({ | ||
@@ -217,3 +233,3 @@ effect: activeEffect, | ||
const run = (effect) => { | ||
if ( effect.options.onTrigger) { | ||
if (effect.options.onTrigger) { | ||
effect.options.onTrigger({ | ||
@@ -239,2 +255,3 @@ effect, | ||
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`); | ||
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol) | ||
@@ -294,3 +311,3 @@ .map(key => Symbol[key]) | ||
? builtInSymbols.has(key) | ||
: key === `__proto__` || key === `__v_isRef`) { | ||
: isNonTrackableKeys(key)) { | ||
return res; | ||
@@ -494,3 +511,3 @@ } | ||
const hadItems = target.size !== 0; | ||
const oldTarget = isMap(target) | ||
const oldTarget = isMap(target) | ||
? new Map(target) | ||
@@ -789,3 +806,3 @@ : new Set(target) | ||
function triggerRef(ref) { | ||
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value ); | ||
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value ); | ||
} | ||
@@ -831,3 +848,3 @@ function unref(ref) { | ||
function toRefs(object) { | ||
if ( !isProxy(object)) { | ||
if (!isProxy(object)) { | ||
console.warn(`toRefs() expects a reactive object but received a plain one.`); | ||
@@ -893,3 +910,3 @@ } | ||
getter = getterOrOptions; | ||
setter = () => { | ||
setter = () => { | ||
console.warn('Write operation failed: computed value is readonly'); | ||
@@ -896,0 +913,0 @@ } |
@@ -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=>"[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,v=(t,e)=>t!==e&&(t==t||e==e),d=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)){k(n);try{return j(),g.push(n),p=n,t()}finally{g.pop(),O(),p=g[g.length-1]}}};return n.id=b++,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}let b=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 m=[];function S(){m.push(E),E=!1}function j(){m.push(E),E=!0}function O(){const t=m.pop();E=void 0===t||t}function P(t,e,n){if(!E||void 0===p)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(p)||(s.add(p),p.deps.push(s))}function x(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!==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 M=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(a)),z=V(),A=V(!1,!0),T=V(!0),W=V(!0,!0),N={};function V(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?lt:at).get(n))return n;const c=o(n);if(!t&&c&&i(N,r))return Reflect.get(N,r,s);const u=Reflect.get(n,r,s);if(a(r)?M.has(r):"__proto__"===r||"__v_isRef"===r)return u;if(t||P(n,0,r),e)return u;if(wt(u)){return!c||!_(r)?u.value:u}return l(u)?t?_t(u):ht(u):u}}["includes","indexOf","lastIndexOf"].forEach(t=>{const e=Array.prototype[t];N[t]=function(...t){const n=pt(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(pt)):r}}),["push","pop","shift","unshift","splice"].forEach(t=>{const e=Array.prototype[t];N[t]=function(...t){S();const n=e.apply(this,t);return O(),n}});function I(t=!1){return function(e,n,r,s){const c=e[n];if(!t&&(r=pt(r),!o(e)&&wt(c)&&!wt(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===pt(s)&&(u?v(r,c)&&x(e,"set",n,r):x(e,"add",n,r)),a}}const K={get:z,set:I(),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)&&M.has(e)||P(t,0,e),n},ownKeys:function(t){return P(t,0,o(t)?"length":y),Reflect.ownKeys(t)}},B={get:T,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},Y=r({},K,{get:A,set:I(!0)}),q=r({},B,{get:W}),C=t=>l(t)?ht(t):t,D=t=>l(t)?_t(t):t,F=t=>t,G=t=>Reflect.getPrototypeOf(t);function H(t,e,n=!1,r=!1){const s=pt(t=t.__v_raw),i=pt(e);e!==i&&!n&&P(s,0,e),!n&&P(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=pt(n),s=pt(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 L(t,e=!1){return t=t.__v_raw,!e&&P(pt(t),0,y),Reflect.get(t,"size",t)}function Q(t){t=pt(t);const e=pt(this),n=G(e).has.call(e,t);return e.add(t),n||x(e,"add",t,t),this}function U(t,e){e=pt(e);const n=pt(this),{has:r,get:s}=G(n);let i=r.call(n,t);i||(t=pt(t),i=r.call(n,t));const o=s.call(n,t);return n.set(t,e),i?v(e,o)&&x(n,"set",t,e):x(n,"add",t,e),this}function X(t){const e=pt(this),{has:n,get:r}=G(e);let s=n.call(e,t);s||(t=pt(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 Z(){const t=pt(this),e=0!==t.size,n=t.clear();return e&&x(t,"clear",void 0,void 0),n}function $(t,e){return function(n,r){const s=this,i=s.__v_raw,o=pt(i),c=t?D:e?F:C;return!t&&P(o,0,y),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=pt(s),o=c(i),u="entries"===t||t===Symbol.iterator&&o,a="keys"===t&&o,l=s[t](...r),f=e?D:n?F:C;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 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)},at=new WeakMap,lt=new WeakMap;function ft(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 ht(t){return t&&t.__v_isReadonly?t:vt(t,!1,K,ot)}function _t(t){return vt(t,!0,B,ut)}function vt(t,e,n,r){if(!l(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=ft(t);if(0===o)return t;const c=new Proxy(t,2===o?r:n);return s.set(t,c),c}function dt(t){return gt(t)?dt(t.__v_raw):!(!t||!t.__v_isReactive)}function gt(t){return!(!t||!t.__v_isReadonly)}function pt(t){return t&&pt(t.__v_raw)||t}const yt=t=>l(t)?ht(t):t;function wt(t){return Boolean(t&&!0===t.__v_isRef)}class Rt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:yt(t)}get value(){return P(pt(this),0,"value"),this._value}set value(t){v(pt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:yt(t),x(pt(this),"set","value",t))}}function bt(t,e=!1){return wt(t)?t:new Rt(t,e)}function kt(t){return wt(t)?t.value:t}const Et={get:(t,e,n)=>kt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return wt(s)&&!wt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};class mt{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)}}class St{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 jt(t,e){return wt(t[e])?t[e]:new St(t,e)}class Ot{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(pt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),P(pt(this),0,"value"),this._value}set value(t){this._setter(t)}}return t.ITERATE_KEY=y,t.computed=function(t){let e,r;return u(t)?(e=t,r=n):(e=t.get,r=t.set),new Ot(e,r,u(t)||!t.set)},t.customRef=function(t){return new mt(t)},t.effect=R,t.enableTracking=j,t.isProxy=function(t){return dt(t)||gt(t)},t.isReactive=dt,t.isReadonly=gt,t.isRef=wt,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=S,t.proxyRefs=function(t){return dt(t)?t:new Proxy(t,Et)},t.reactive=ht,t.readonly=_t,t.ref=function(t){return bt(t)},t.resetTracking=O,t.shallowReactive=function(t){return vt(t,!1,Y,ct)},t.shallowReadonly=function(t){return vt(t,!0,q,ut)},t.shallowRef=function(t){return bt(t,!0)},t.stop=function(t){t.active&&(k(t),t.options.onStop&&t.options.onStop(),t.active=!1)},t.toRaw=pt,t.toRef=jt,t.toRefs=function(t){const e=o(t)?new Array(t.length):{};for(const n in t)e[n]=jt(t,n);return e},t.track=P,t.trigger=x,t.triggerRef=function(t){x(pt(t),"set","value",void 0)},t.unref=kt,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
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),n=H(e).has.call(e,t);return e.add(t),n||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}({}); |
{ | ||
"name": "@vue/reactivity", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "@vue/reactivity", | ||
@@ -39,4 +39,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vue/shared": "3.0.5" | ||
"@vue/shared": "3.0.6" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
179500
4696
+ Added@vue/shared@3.0.6(transitive)
- Removed@vue/shared@3.0.5(transitive)
Updated@vue/shared@3.0.6