@vue/reactivity
Advanced tools
Comparing version 3.0.0-rc.6 to 3.0.0-rc.7
@@ -222,3 +222,4 @@ 'use strict'; | ||
const res = Reflect.get(target, key, receiver); | ||
if (shared.isSymbol(key) | ||
const keyIsSymbol = shared.isSymbol(key); | ||
if (keyIsSymbol | ||
? builtInSymbols.has(key) | ||
@@ -235,4 +236,7 @@ : key === `__proto__` || key === `__v_isRef`) { | ||
if (isRef(res)) { | ||
// ref unwrapping, only for Objects, not for Arrays. | ||
return targetIsArray ? res : res.value; | ||
// ref unwrapping - does not apply for Array + integer key. | ||
const shouldUnwrap = !targetIsArray || | ||
keyIsSymbol || | ||
'' + parseInt(key, 10) !== key; | ||
return shouldUnwrap ? res.value : res; | ||
} | ||
@@ -673,3 +677,3 @@ if (shared.isObject(res)) { | ||
function isRef(r) { | ||
return r ? r.__v_isRef === true : false; | ||
return Boolean(r && r.__v_isRef === true); | ||
} | ||
@@ -682,2 +686,21 @@ function ref(value) { | ||
} | ||
class RefImpl { | ||
constructor(_rawValue, _shallow = false) { | ||
this._rawValue = _rawValue; | ||
this._shallow = _shallow; | ||
this.__v_isRef = true; | ||
this._value = _shallow ? _rawValue : convert(_rawValue); | ||
} | ||
get value() { | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
if (shared.hasChanged(toRaw(newVal), this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = this._shallow ? newVal : convert(newVal); | ||
trigger(toRaw(this), "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
} | ||
function createRef(rawValue, shallow = false) { | ||
@@ -687,18 +710,3 @@ if (isRef(rawValue)) { | ||
} | ||
let value = shallow ? rawValue : convert(rawValue); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
track(r, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newVal) { | ||
if (shared.hasChanged(toRaw(newVal), rawValue)) { | ||
rawValue = newVal; | ||
value = shallow ? newVal : convert(newVal); | ||
trigger(r, "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
}; | ||
return r; | ||
return new RefImpl(rawValue, shallow); | ||
} | ||
@@ -729,14 +737,18 @@ function triggerRef(ref) { | ||
} | ||
class CustomRefImpl { | ||
constructor(factory) { | ||
this.__v_isRef = true; | ||
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value')); | ||
this._get = get; | ||
this._set = set; | ||
} | ||
get value() { | ||
return this._get(); | ||
} | ||
set value(newVal) { | ||
this._set(newVal); | ||
} | ||
} | ||
function customRef(factory) { | ||
const { get, set } = factory(() => track(r, "get" /* GET */, 'value'), () => trigger(r, "set" /* SET */, 'value')); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
return get(); | ||
}, | ||
set value(v) { | ||
set(v); | ||
} | ||
}; | ||
return r; | ||
return new CustomRefImpl(factory); | ||
} | ||
@@ -753,14 +765,47 @@ function toRefs(object) { | ||
} | ||
class ObjectRefImpl { | ||
constructor(_object, _key) { | ||
this._object = _object; | ||
this._key = _key; | ||
this.__v_isRef = true; | ||
} | ||
get value() { | ||
return this._object[this._key]; | ||
} | ||
set value(newVal) { | ||
this._object[this._key] = newVal; | ||
} | ||
} | ||
function toRef(object, key) { | ||
return { | ||
__v_isRef: true, | ||
get value() { | ||
return object[key]; | ||
}, | ||
set value(newVal) { | ||
object[key] = newVal; | ||
return new ObjectRefImpl(object, key); | ||
} | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly) { | ||
this._setter = _setter; | ||
this._dirty = true; | ||
this.__v_isRef = true; | ||
this.effect = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!this._dirty) { | ||
this._dirty = true; | ||
trigger(toRaw(this), "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
this["__v_isReadonly" /* IS_READONLY */] = isReadonly; | ||
} | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
} | ||
}; | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
} | ||
function computed(getterOrOptions) { | ||
@@ -780,32 +825,3 @@ let getter; | ||
} | ||
let dirty = true; | ||
let value; | ||
let computed; | ||
const runner = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!dirty) { | ||
dirty = true; | ||
trigger(computed, "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
computed = { | ||
__v_isRef: true, | ||
["__v_isReadonly" /* IS_READONLY */]: shared.isFunction(getterOrOptions) || !getterOrOptions.set, | ||
// expose effect so computed can be stopped | ||
effect: runner, | ||
get value() { | ||
if (dirty) { | ||
value = runner(); | ||
dirty = false; | ||
} | ||
track(computed, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newValue) { | ||
setter(newValue); | ||
} | ||
}; | ||
return computed; | ||
return new ComputedRefImpl(getter, setter, shared.isFunction(getterOrOptions) || !getterOrOptions.set); | ||
} | ||
@@ -812,0 +828,0 @@ |
@@ -203,3 +203,4 @@ 'use strict'; | ||
const res = Reflect.get(target, key, receiver); | ||
if (shared.isSymbol(key) | ||
const keyIsSymbol = shared.isSymbol(key); | ||
if (keyIsSymbol | ||
? builtInSymbols.has(key) | ||
@@ -216,4 +217,7 @@ : key === `__proto__` || key === `__v_isRef`) { | ||
if (isRef(res)) { | ||
// ref unwrapping, only for Objects, not for Arrays. | ||
return targetIsArray ? res : res.value; | ||
// ref unwrapping - does not apply for Array + integer key. | ||
const shouldUnwrap = !targetIsArray || | ||
keyIsSymbol || | ||
'' + parseInt(key, 10) !== key; | ||
return shouldUnwrap ? res.value : res; | ||
} | ||
@@ -620,3 +624,3 @@ if (shared.isObject(res)) { | ||
function isRef(r) { | ||
return r ? r.__v_isRef === true : false; | ||
return Boolean(r && r.__v_isRef === true); | ||
} | ||
@@ -629,2 +633,21 @@ function ref(value) { | ||
} | ||
class RefImpl { | ||
constructor(_rawValue, _shallow = false) { | ||
this._rawValue = _rawValue; | ||
this._shallow = _shallow; | ||
this.__v_isRef = true; | ||
this._value = _shallow ? _rawValue : convert(_rawValue); | ||
} | ||
get value() { | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
if (shared.hasChanged(toRaw(newVal), this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = this._shallow ? newVal : convert(newVal); | ||
trigger(toRaw(this), "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
} | ||
function createRef(rawValue, shallow = false) { | ||
@@ -634,18 +657,3 @@ if (isRef(rawValue)) { | ||
} | ||
let value = shallow ? rawValue : convert(rawValue); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
track(r, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newVal) { | ||
if (shared.hasChanged(toRaw(newVal), rawValue)) { | ||
rawValue = newVal; | ||
value = shallow ? newVal : convert(newVal); | ||
trigger(r, "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
}; | ||
return r; | ||
return new RefImpl(rawValue, shallow); | ||
} | ||
@@ -676,14 +684,18 @@ function triggerRef(ref) { | ||
} | ||
class CustomRefImpl { | ||
constructor(factory) { | ||
this.__v_isRef = true; | ||
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value')); | ||
this._get = get; | ||
this._set = set; | ||
} | ||
get value() { | ||
return this._get(); | ||
} | ||
set value(newVal) { | ||
this._set(newVal); | ||
} | ||
} | ||
function customRef(factory) { | ||
const { get, set } = factory(() => track(r, "get" /* GET */, 'value'), () => trigger(r, "set" /* SET */, 'value')); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
return get(); | ||
}, | ||
set value(v) { | ||
set(v); | ||
} | ||
}; | ||
return r; | ||
return new CustomRefImpl(factory); | ||
} | ||
@@ -697,14 +709,47 @@ function toRefs(object) { | ||
} | ||
class ObjectRefImpl { | ||
constructor(_object, _key) { | ||
this._object = _object; | ||
this._key = _key; | ||
this.__v_isRef = true; | ||
} | ||
get value() { | ||
return this._object[this._key]; | ||
} | ||
set value(newVal) { | ||
this._object[this._key] = newVal; | ||
} | ||
} | ||
function toRef(object, key) { | ||
return { | ||
__v_isRef: true, | ||
get value() { | ||
return object[key]; | ||
}, | ||
set value(newVal) { | ||
object[key] = newVal; | ||
return new ObjectRefImpl(object, key); | ||
} | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly) { | ||
this._setter = _setter; | ||
this._dirty = true; | ||
this.__v_isRef = true; | ||
this.effect = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!this._dirty) { | ||
this._dirty = true; | ||
trigger(toRaw(this), "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
this["__v_isReadonly" /* IS_READONLY */] = isReadonly; | ||
} | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
} | ||
}; | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
} | ||
function computed(getterOrOptions) { | ||
@@ -721,32 +766,3 @@ let getter; | ||
} | ||
let dirty = true; | ||
let value; | ||
let computed; | ||
const runner = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!dirty) { | ||
dirty = true; | ||
trigger(computed, "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
computed = { | ||
__v_isRef: true, | ||
["__v_isReadonly" /* IS_READONLY */]: shared.isFunction(getterOrOptions) || !getterOrOptions.set, | ||
// expose effect so computed can be stopped | ||
effect: runner, | ||
get value() { | ||
if (dirty) { | ||
value = runner(); | ||
dirty = false; | ||
} | ||
track(computed, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newValue) { | ||
setter(newValue); | ||
} | ||
}; | ||
return computed; | ||
return new ComputedRefImpl(getter, setter, shared.isFunction(getterOrOptions) || !getterOrOptions.set); | ||
} | ||
@@ -753,0 +769,0 @@ |
@@ -253,3 +253,4 @@ const EMPTY_OBJ = Object.freeze({}) | ||
const res = Reflect.get(target, key, receiver); | ||
if (isSymbol(key) | ||
const keyIsSymbol = isSymbol(key); | ||
if (keyIsSymbol | ||
? builtInSymbols.has(key) | ||
@@ -266,4 +267,7 @@ : key === `__proto__` || key === `__v_isRef`) { | ||
if (isRef(res)) { | ||
// ref unwrapping, only for Objects, not for Arrays. | ||
return targetIsArray ? res : res.value; | ||
// ref unwrapping - does not apply for Array + integer key. | ||
const shouldUnwrap = !targetIsArray || | ||
keyIsSymbol || | ||
'' + parseInt(key, 10) !== key; | ||
return shouldUnwrap ? res.value : res; | ||
} | ||
@@ -704,3 +708,3 @@ if (isObject(res)) { | ||
function isRef(r) { | ||
return r ? r.__v_isRef === true : false; | ||
return Boolean(r && r.__v_isRef === true); | ||
} | ||
@@ -713,2 +717,21 @@ function ref(value) { | ||
} | ||
class RefImpl { | ||
constructor(_rawValue, _shallow = false) { | ||
this._rawValue = _rawValue; | ||
this._shallow = _shallow; | ||
this.__v_isRef = true; | ||
this._value = _shallow ? _rawValue : convert(_rawValue); | ||
} | ||
get value() { | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
if (hasChanged(toRaw(newVal), this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = this._shallow ? newVal : convert(newVal); | ||
trigger(toRaw(this), "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
} | ||
function createRef(rawValue, shallow = false) { | ||
@@ -718,18 +741,3 @@ if (isRef(rawValue)) { | ||
} | ||
let value = shallow ? rawValue : convert(rawValue); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
track(r, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newVal) { | ||
if (hasChanged(toRaw(newVal), rawValue)) { | ||
rawValue = newVal; | ||
value = shallow ? newVal : convert(newVal); | ||
trigger(r, "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
}; | ||
return r; | ||
return new RefImpl(rawValue, shallow); | ||
} | ||
@@ -760,14 +768,18 @@ function triggerRef(ref) { | ||
} | ||
class CustomRefImpl { | ||
constructor(factory) { | ||
this.__v_isRef = true; | ||
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value')); | ||
this._get = get; | ||
this._set = set; | ||
} | ||
get value() { | ||
return this._get(); | ||
} | ||
set value(newVal) { | ||
this._set(newVal); | ||
} | ||
} | ||
function customRef(factory) { | ||
const { get, set } = factory(() => track(r, "get" /* GET */, 'value'), () => trigger(r, "set" /* SET */, 'value')); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
return get(); | ||
}, | ||
set value(v) { | ||
set(v); | ||
} | ||
}; | ||
return r; | ||
return new CustomRefImpl(factory); | ||
} | ||
@@ -784,14 +796,47 @@ function toRefs(object) { | ||
} | ||
class ObjectRefImpl { | ||
constructor(_object, _key) { | ||
this._object = _object; | ||
this._key = _key; | ||
this.__v_isRef = true; | ||
} | ||
get value() { | ||
return this._object[this._key]; | ||
} | ||
set value(newVal) { | ||
this._object[this._key] = newVal; | ||
} | ||
} | ||
function toRef(object, key) { | ||
return { | ||
__v_isRef: true, | ||
get value() { | ||
return object[key]; | ||
}, | ||
set value(newVal) { | ||
object[key] = newVal; | ||
return new ObjectRefImpl(object, key); | ||
} | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly) { | ||
this._setter = _setter; | ||
this._dirty = true; | ||
this.__v_isRef = true; | ||
this.effect = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!this._dirty) { | ||
this._dirty = true; | ||
trigger(toRaw(this), "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
this["__v_isReadonly" /* IS_READONLY */] = isReadonly; | ||
} | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
} | ||
}; | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
} | ||
function computed(getterOrOptions) { | ||
@@ -811,34 +856,5 @@ let getter; | ||
} | ||
let dirty = true; | ||
let value; | ||
let computed; | ||
const runner = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!dirty) { | ||
dirty = true; | ||
trigger(computed, "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
computed = { | ||
__v_isRef: true, | ||
["__v_isReadonly" /* IS_READONLY */]: isFunction(getterOrOptions) || !getterOrOptions.set, | ||
// expose effect so computed can be stopped | ||
effect: runner, | ||
get value() { | ||
if (dirty) { | ||
value = runner(); | ||
dirty = false; | ||
} | ||
track(computed, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newValue) { | ||
setter(newValue); | ||
} | ||
}; | ||
return computed; | ||
return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set); | ||
} | ||
export { ITERATE_KEY, computed, customRef, effect, enableTracking, isProxy, isReactive, isReadonly, isRef, markRaw, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref }; |
@@ -1,1 +0,1 @@ | ||
const e={},t=()=>{},n=Object.assign,r=Object.prototype.hasOwnProperty,o=(e,t)=>r.call(e,t),c=Array.isArray,s=e=>"function"==typeof e,u=e=>"symbol"==typeof e,i=e=>null!==e&&"object"==typeof e,a=Object.prototype.toString,l=e=>(e=>a.call(e))(e).slice(8,-1),f=(e,t)=>e!==t&&(e==e||t==t),_=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},v=new WeakMap,d=[];let h;const g=Symbol(""),p=Symbol("");function y(t,n=e){(function(e){return e&&!0===e._isEffect})(t)&&(t=t.raw);const r=function(e,t){const n=function(){if(!n.active)return t.scheduler?void 0:e();if(!d.includes(n)){b(n);try{return O(),d.push(n),h=n,e()}finally{d.pop(),P(),h=d[d.length-1]}}};return n.id=w++,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(t,n);return n.lazy||r(),r}function R(e){e.active&&(b(e),e.options.onStop&&e.options.onStop(),e.active=!1)}let w=0;function b(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let S=!0;const E=[];function m(){E.push(S),S=!1}function O(){E.push(S),S=!0}function P(){const e=E.pop();S=void 0===e||e}function j(e,t,n){if(!S||void 0===h)return;let r=v.get(e);r||v.set(e,r=new Map);let o=r.get(n);o||r.set(n,o=new Set),o.has(h)||(o.add(h),h.deps.push(o))}function x(e,t,n,r,o,s){const u=v.get(e);if(!u)return;const i=new Set,a=e=>{e&&e.forEach(e=>{e!==h&&i.add(e)})};if("clear"===t)u.forEach(a);else if("length"===n&&c(e))u.forEach((e,t)=>{("length"===t||t>=r)&&a(e)});else{void 0!==n&&a(u.get(n));const r="add"===t||"delete"===t&&!c(e);(r||"set"===t&&e instanceof Map)&&a(u.get(c(e)?"length":g)),r&&e instanceof Map&&a(u.get(p))}i.forEach(e=>{e.options.scheduler?e.options.scheduler(e):e()})}const k=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(u)),z=I(),M=I(!1,!0),A=I(!0),K=I(!0,!0),W={};function I(e=!1,t=!1){return function(n,r,s){if("__v_isReactive"===r)return!e;if("__v_isReadonly"===r)return e;if("__v_raw"===r&&s===(e?n.__v_readonly:n.__v_reactive))return n;const a=c(n);if(a&&o(W,r))return Reflect.get(W,r,s);const l=Reflect.get(n,r,s);return(u(r)?k.has(r):"__proto__"===r||"__v_isRef"===r)?l:(e||j(n,0,r),t?l:be(l)?a?l:l.value:i(l)?e?_e(l):le(l):l)}}["includes","indexOf","lastIndexOf"].forEach(e=>{W[e]=function(...t){const n=ye(this);for(let e=0,t=this.length;e<t;e++)j(n,0,e+"");const r=n[e](...t);return-1===r||!1===r?n[e](...t.map(ye)):r}});function N(e=!1){return function(t,n,r,s){const u=t[n];if(!e&&(r=ye(r),!c(t)&&be(u)&&!be(r)))return u.value=r,!0;const i=o(t,n),a=Reflect.set(t,n,r,s);return t===ye(s)&&(i?f(r,u)&&x(t,"set",n,r):x(t,"add",n,r)),a}}function q(e,t){const n=Reflect.has(e,t);return u(t)&&k.has(t)||j(e,0,t),n}function B(e){return j(e,0,g),Reflect.ownKeys(e)}const C={get:z,set:N(),deleteProperty:function(e,t){const n=o(e,t),r=Reflect.deleteProperty(e,t);return r&&n&&x(e,"delete",t,void 0),r},has:q,ownKeys:B},D={get:A,has:q,ownKeys:B,set:(e,t)=>!0,deleteProperty:(e,t)=>!0},F=n({},C,{get:M,set:N(!0)}),G=n({},D,{get:K}),H=e=>i(e)?le(e):e,J=e=>i(e)?_e(e):e,L=e=>e,Q=e=>Reflect.getPrototypeOf(e);function T(e,t,n=!1,r=!1){const o=ye(e=e.__v_raw),c=ye(t);t!==c&&!n&&j(o,0,t),!n&&j(o,0,c);const{has:s}=Q(o),u=n?J:r?L:H;return s.call(o,t)?u(e.get(t)):s.call(o,c)?u(e.get(c)):void 0}function U(e,t=!1){const n=this.__v_raw,r=ye(n),o=ye(e);return e!==o&&!t&&j(r,0,e),!t&&j(r,0,o),n.has(e)||n.has(o)}function V(e,t=!1){return e=e.__v_raw,!t&&j(ye(e),0,g),Reflect.get(e,"size",e)}function X(e){e=ye(e);const t=ye(this),n=Q(t),r=n.has.call(t,e),o=n.add.call(t,e);return r||x(t,"add",e,e),o}function Y(e,t){t=ye(t);const n=ye(this),{has:r,get:o,set:c}=Q(n);let s=r.call(n,e);s||(e=ye(e),s=r.call(n,e));const u=o.call(n,e),i=c.call(n,e,t);return s?f(t,u)&&x(n,"set",e,t):x(n,"add",e,t),i}function Z(e){const t=ye(this),{has:n,get:r,delete:o}=Q(t);let c=n.call(t,e);c||(e=ye(e),c=n.call(t,e));r&&r.call(t,e);const s=o.call(t,e);return c&&x(t,"delete",e,void 0),s}function $(){const e=ye(this),t=0!==e.size,n=Q(e).clear.call(e);return t&&x(e,"clear",void 0,void 0),n}function ee(e,t){return function(n,r){const o=this,c=ye(o),s=e?J:t?L:H;return!e&&j(c,0,g),Q(c).forEach.call(c,(function(e,t){return n.call(r,s(e),s(t),o)}))}}function te(e,t,n){return function(...r){const o=this.__v_raw,c=ye(o),s=c instanceof Map,u="entries"===e||e===Symbol.iterator&&s,i="keys"===e&&s,a=o[e](...r),l=t?J:n?L:H;return!t&&j(c,0,i?p:g),{next(){const{value:e,done:t}=a.next();return t?{value:e,done:t}:{value:u?[l(e[0]),l(e[1])]:l(e),done:t}},[Symbol.iterator](){return this}}}}function ne(e){return function(...t){return"delete"!==e&&this}}const re={get(e){return T(this,e)},get size(){return V(this)},has:U,add:X,set:Y,delete:Z,clear:$,forEach:ee(!1,!1)},oe={get(e){return T(this,e,!1,!0)},get size(){return V(this)},has:U,add:X,set:Y,delete:Z,clear:$,forEach:ee(!1,!0)},ce={get(e){return T(this,e,!0)},get size(){return V(this,!0)},has(e){return U.call(this,e,!0)},add:ne("add"),set:ne("set"),delete:ne("delete"),clear:ne("clear"),forEach:ee(!0,!1)};function se(e,t){const n=t?oe:e?ce:re;return(t,r,c)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(o(n,r)&&r in t?n:t,r,c)}["keys","values","entries",Symbol.iterator].forEach(e=>{re[e]=te(e,!1,!1),ce[e]=te(e,!0,!1),oe[e]=te(e,!1,!0)});const ue={get:se(!1,!1)},ie={get:se(!1,!0)},ae={get:se(!0,!1)};function le(e){return e&&e.__v_isReadonly?e:de(e,!1,C,ue)}function fe(e){return de(e,!1,F,ie)}function _e(e){return de(e,!0,D,ae)}function ve(e){return de(e,!0,G,ae)}function de(e,t,n,r){if(!i(e))return e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const c=t?"__v_readonly":"__v_reactive";if(o(e,c))return e[c];const s=(u=e).__v_skip||!Object.isExtensible(u)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(l(u));var u;if(0===s)return e;const a=new Proxy(e,2===s?r:n);return _(e,c,a),a}function he(e){return ge(e)?he(e.__v_raw):!(!e||!e.__v_isReactive)}function ge(e){return!(!e||!e.__v_isReadonly)}function pe(e){return he(e)||ge(e)}function ye(e){return e&&ye(e.__v_raw)||e}function Re(e){return _(e,"__v_skip",!0),e}const we=e=>i(e)?le(e):e;function be(e){return!!e&&!0===e.__v_isRef}function Se(e){return me(e)}function Ee(e){return me(e,!0)}function me(e,t=!1){if(be(e))return e;let n=t?e:we(e);const r={__v_isRef:!0,get value(){return j(r,0,"value"),n},set value(o){f(ye(o),e)&&(e=o,n=t?o:we(o),x(r,"set","value",o))}};return r}function Oe(e){x(e,"set","value",void 0)}function Pe(e){return be(e)?e.value:e}const je={get:(e,t,n)=>Pe(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return be(o)&&!be(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}};function xe(e){return he(e)?e:new Proxy(e,je)}function ke(e){const{get:t,set:n}=e(()=>j(r,0,"value"),()=>x(r,"set","value")),r={__v_isRef:!0,get value(){return t()},set value(e){n(e)}};return r}function ze(e){const t=c(e)?new Array(e.length):{};for(const n in e)t[n]=Me(e,n);return t}function Me(e,t){return{__v_isRef:!0,get value(){return e[t]},set value(n){e[t]=n}}}function Ae(e){let n,r;s(e)?(n=e,r=t):(n=e.get,r=e.set);let o,c,u=!0;const i=y(n,{lazy:!0,scheduler:()=>{u||(u=!0,x(c,"set","value"))}});return c={__v_isRef:!0,__v_isReadonly:s(e)||!e.set,effect:i,get value(){return u&&(o=i(),u=!1),j(c,0,"value"),o},set value(e){r(e)}},c}export{g as ITERATE_KEY,Ae as computed,ke as customRef,y as effect,O as enableTracking,pe as isProxy,he as isReactive,ge as isReadonly,be as isRef,Re as markRaw,m as pauseTracking,xe as proxyRefs,le as reactive,_e as readonly,Se as ref,P as resetTracking,fe as shallowReactive,ve as shallowReadonly,Ee as shallowRef,R as stop,ye as toRaw,Me as toRef,ze as toRefs,j as track,x as trigger,Oe as triggerRef,Pe as unref}; | ||
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}; |
@@ -218,3 +218,4 @@ import { EMPTY_OBJ, isArray, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared'; | ||
const res = Reflect.get(target, key, receiver); | ||
if (isSymbol(key) | ||
const keyIsSymbol = isSymbol(key); | ||
if (keyIsSymbol | ||
? builtInSymbols.has(key) | ||
@@ -231,4 +232,7 @@ : key === `__proto__` || key === `__v_isRef`) { | ||
if (isRef(res)) { | ||
// ref unwrapping, only for Objects, not for Arrays. | ||
return targetIsArray ? res : res.value; | ||
// ref unwrapping - does not apply for Array + integer key. | ||
const shouldUnwrap = !targetIsArray || | ||
keyIsSymbol || | ||
'' + parseInt(key, 10) !== key; | ||
return shouldUnwrap ? res.value : res; | ||
} | ||
@@ -670,3 +674,3 @@ if (isObject(res)) { | ||
function isRef(r) { | ||
return r ? r.__v_isRef === true : false; | ||
return Boolean(r && r.__v_isRef === true); | ||
} | ||
@@ -679,2 +683,21 @@ function ref(value) { | ||
} | ||
class RefImpl { | ||
constructor(_rawValue, _shallow = false) { | ||
this._rawValue = _rawValue; | ||
this._shallow = _shallow; | ||
this.__v_isRef = true; | ||
this._value = _shallow ? _rawValue : convert(_rawValue); | ||
} | ||
get value() { | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
if (hasChanged(toRaw(newVal), this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = this._shallow ? newVal : convert(newVal); | ||
trigger(toRaw(this), "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
} | ||
function createRef(rawValue, shallow = false) { | ||
@@ -684,18 +707,3 @@ if (isRef(rawValue)) { | ||
} | ||
let value = shallow ? rawValue : convert(rawValue); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
track(r, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newVal) { | ||
if (hasChanged(toRaw(newVal), rawValue)) { | ||
rawValue = newVal; | ||
value = shallow ? newVal : convert(newVal); | ||
trigger(r, "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
}; | ||
return r; | ||
return new RefImpl(rawValue, shallow); | ||
} | ||
@@ -726,14 +734,18 @@ function triggerRef(ref) { | ||
} | ||
class CustomRefImpl { | ||
constructor(factory) { | ||
this.__v_isRef = true; | ||
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value')); | ||
this._get = get; | ||
this._set = set; | ||
} | ||
get value() { | ||
return this._get(); | ||
} | ||
set value(newVal) { | ||
this._set(newVal); | ||
} | ||
} | ||
function customRef(factory) { | ||
const { get, set } = factory(() => track(r, "get" /* GET */, 'value'), () => trigger(r, "set" /* SET */, 'value')); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
return get(); | ||
}, | ||
set value(v) { | ||
set(v); | ||
} | ||
}; | ||
return r; | ||
return new CustomRefImpl(factory); | ||
} | ||
@@ -750,14 +762,47 @@ function toRefs(object) { | ||
} | ||
class ObjectRefImpl { | ||
constructor(_object, _key) { | ||
this._object = _object; | ||
this._key = _key; | ||
this.__v_isRef = true; | ||
} | ||
get value() { | ||
return this._object[this._key]; | ||
} | ||
set value(newVal) { | ||
this._object[this._key] = newVal; | ||
} | ||
} | ||
function toRef(object, key) { | ||
return { | ||
__v_isRef: true, | ||
get value() { | ||
return object[key]; | ||
}, | ||
set value(newVal) { | ||
object[key] = newVal; | ||
return new ObjectRefImpl(object, key); | ||
} | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly) { | ||
this._setter = _setter; | ||
this._dirty = true; | ||
this.__v_isRef = true; | ||
this.effect = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!this._dirty) { | ||
this._dirty = true; | ||
trigger(toRaw(this), "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
this["__v_isReadonly" /* IS_READONLY */] = isReadonly; | ||
} | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
} | ||
}; | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
} | ||
function computed(getterOrOptions) { | ||
@@ -778,34 +823,5 @@ let getter; | ||
} | ||
let dirty = true; | ||
let value; | ||
let computed; | ||
const runner = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!dirty) { | ||
dirty = true; | ||
trigger(computed, "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
computed = { | ||
__v_isRef: true, | ||
["__v_isReadonly" /* IS_READONLY */]: isFunction(getterOrOptions) || !getterOrOptions.set, | ||
// expose effect so computed can be stopped | ||
effect: runner, | ||
get value() { | ||
if (dirty) { | ||
value = runner(); | ||
dirty = false; | ||
} | ||
track(computed, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newValue) { | ||
setter(newValue); | ||
} | ||
}; | ||
return computed; | ||
return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set); | ||
} | ||
export { ITERATE_KEY, computed, customRef, effect, enableTracking, isProxy, isReactive, isReadonly, isRef, markRaw, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref }; |
@@ -256,3 +256,4 @@ var VueReactivity = (function (exports) { | ||
const res = Reflect.get(target, key, receiver); | ||
if (isSymbol(key) | ||
const keyIsSymbol = isSymbol(key); | ||
if (keyIsSymbol | ||
? builtInSymbols.has(key) | ||
@@ -269,4 +270,7 @@ : key === `__proto__` || key === `__v_isRef`) { | ||
if (isRef(res)) { | ||
// ref unwrapping, only for Objects, not for Arrays. | ||
return targetIsArray ? res : res.value; | ||
// ref unwrapping - does not apply for Array + integer key. | ||
const shouldUnwrap = !targetIsArray || | ||
keyIsSymbol || | ||
'' + parseInt(key, 10) !== key; | ||
return shouldUnwrap ? res.value : res; | ||
} | ||
@@ -707,3 +711,3 @@ if (isObject(res)) { | ||
function isRef(r) { | ||
return r ? r.__v_isRef === true : false; | ||
return Boolean(r && r.__v_isRef === true); | ||
} | ||
@@ -716,2 +720,21 @@ function ref(value) { | ||
} | ||
class RefImpl { | ||
constructor(_rawValue, _shallow = false) { | ||
this._rawValue = _rawValue; | ||
this._shallow = _shallow; | ||
this.__v_isRef = true; | ||
this._value = _shallow ? _rawValue : convert(_rawValue); | ||
} | ||
get value() { | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
if (hasChanged(toRaw(newVal), this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = this._shallow ? newVal : convert(newVal); | ||
trigger(toRaw(this), "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
} | ||
function createRef(rawValue, shallow = false) { | ||
@@ -721,18 +744,3 @@ if (isRef(rawValue)) { | ||
} | ||
let value = shallow ? rawValue : convert(rawValue); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
track(r, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newVal) { | ||
if (hasChanged(toRaw(newVal), rawValue)) { | ||
rawValue = newVal; | ||
value = shallow ? newVal : convert(newVal); | ||
trigger(r, "set" /* SET */, 'value', newVal); | ||
} | ||
} | ||
}; | ||
return r; | ||
return new RefImpl(rawValue, shallow); | ||
} | ||
@@ -763,14 +771,18 @@ function triggerRef(ref) { | ||
} | ||
class CustomRefImpl { | ||
constructor(factory) { | ||
this.__v_isRef = true; | ||
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value')); | ||
this._get = get; | ||
this._set = set; | ||
} | ||
get value() { | ||
return this._get(); | ||
} | ||
set value(newVal) { | ||
this._set(newVal); | ||
} | ||
} | ||
function customRef(factory) { | ||
const { get, set } = factory(() => track(r, "get" /* GET */, 'value'), () => trigger(r, "set" /* SET */, 'value')); | ||
const r = { | ||
__v_isRef: true, | ||
get value() { | ||
return get(); | ||
}, | ||
set value(v) { | ||
set(v); | ||
} | ||
}; | ||
return r; | ||
return new CustomRefImpl(factory); | ||
} | ||
@@ -787,14 +799,47 @@ function toRefs(object) { | ||
} | ||
class ObjectRefImpl { | ||
constructor(_object, _key) { | ||
this._object = _object; | ||
this._key = _key; | ||
this.__v_isRef = true; | ||
} | ||
get value() { | ||
return this._object[this._key]; | ||
} | ||
set value(newVal) { | ||
this._object[this._key] = newVal; | ||
} | ||
} | ||
function toRef(object, key) { | ||
return { | ||
__v_isRef: true, | ||
get value() { | ||
return object[key]; | ||
}, | ||
set value(newVal) { | ||
object[key] = newVal; | ||
return new ObjectRefImpl(object, key); | ||
} | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly) { | ||
this._setter = _setter; | ||
this._dirty = true; | ||
this.__v_isRef = true; | ||
this.effect = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!this._dirty) { | ||
this._dirty = true; | ||
trigger(toRaw(this), "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
this["__v_isReadonly" /* IS_READONLY */] = isReadonly; | ||
} | ||
get value() { | ||
if (this._dirty) { | ||
this._value = this.effect(); | ||
this._dirty = false; | ||
} | ||
}; | ||
track(toRaw(this), "get" /* GET */, 'value'); | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
} | ||
function computed(getterOrOptions) { | ||
@@ -814,32 +859,3 @@ let getter; | ||
} | ||
let dirty = true; | ||
let value; | ||
let computed; | ||
const runner = effect(getter, { | ||
lazy: true, | ||
scheduler: () => { | ||
if (!dirty) { | ||
dirty = true; | ||
trigger(computed, "set" /* SET */, 'value'); | ||
} | ||
} | ||
}); | ||
computed = { | ||
__v_isRef: true, | ||
["__v_isReadonly" /* IS_READONLY */]: isFunction(getterOrOptions) || !getterOrOptions.set, | ||
// expose effect so computed can be stopped | ||
effect: runner, | ||
get value() { | ||
if (dirty) { | ||
value = runner(); | ||
dirty = false; | ||
} | ||
track(computed, "get" /* GET */, 'value'); | ||
return value; | ||
}, | ||
set value(newValue) { | ||
setter(newValue); | ||
} | ||
}; | ||
return computed; | ||
return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set); | ||
} | ||
@@ -846,0 +862,0 @@ |
@@ -1,1 +0,1 @@ | ||
var VueReactivity=function(e){"use strict";const t={},n=()=>{},r=Object.assign,o=Object.prototype.hasOwnProperty,c=(e,t)=>o.call(e,t),s=Array.isArray,i=e=>"function"==typeof e,u=e=>"symbol"==typeof e,a=e=>null!==e&&"object"==typeof e,l=Object.prototype.toString,f=e=>(e=>l.call(e))(e).slice(8,-1),_=(e,t)=>e!==t&&(e==e||t==t),v=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},d=new WeakMap,h=[];let g;const p=Symbol(""),y=Symbol("");function R(e,n=t){(function(e){return e&&!0===e._isEffect})(e)&&(e=e.raw);const r=function(e,t){const n=function(){if(!n.active)return t.scheduler?void 0:e();if(!h.includes(n)){b(n);try{return S(),h.push(n),g=n,e()}finally{h.pop(),k(),g=h[h.length-1]}}};return n.id=w++,n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(e,n);return n.lazy||r(),r}let w=0;function b(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let E=!0;const m=[];function S(){m.push(E),E=!0}function k(){const e=m.pop();E=void 0===e||e}function O(e,t,n){if(!E||void 0===g)return;let r=d.get(e);r||d.set(e,r=new Map);let o=r.get(n);o||r.set(n,o=new Set),o.has(g)||(o.add(g),g.deps.push(o))}function P(e,t,n,r,o,c){const i=d.get(e);if(!i)return;const u=new Set,a=e=>{e&&e.forEach(e=>{e!==g&&u.add(e)})};if("clear"===t)i.forEach(a);else if("length"===n&&s(e))i.forEach((e,t)=>{("length"===t||t>=r)&&a(e)});else{void 0!==n&&a(i.get(n));const r="add"===t||"delete"===t&&!s(e);(r||"set"===t&&e instanceof Map)&&a(i.get(s(e)?"length":p)),r&&e instanceof Map&&a(i.get(y))}u.forEach(e=>{e.options.scheduler?e.options.scheduler(e):e()})}const x=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(u)),j=K(),z=K(!1,!0),M=K(!0),A=K(!0,!0),T={};function K(e=!1,t=!1){return function(n,r,o){if("__v_isReactive"===r)return!e;if("__v_isReadonly"===r)return e;if("__v_raw"===r&&o===(e?n.__v_readonly:n.__v_reactive))return n;const i=s(n);if(i&&c(T,r))return Reflect.get(T,r,o);const l=Reflect.get(n,r,o);return(u(r)?x.has(r):"__proto__"===r||"__v_isRef"===r)?l:(e||O(n,0,r),t?l:ge(l)?i?l:l.value:a(l)?e?le(l):ae(l):l)}}["includes","indexOf","lastIndexOf"].forEach(e=>{T[e]=function(...t){const n=de(this);for(let e=0,t=this.length;e<t;e++)O(n,0,e+"");const r=n[e](...t);return-1===r||!1===r?n[e](...t.map(de)):r}});function W(e=!1){return function(t,n,r,o){const i=t[n];if(!e&&(r=de(r),!s(t)&&ge(i)&&!ge(r)))return i.value=r,!0;const u=c(t,n),a=Reflect.set(t,n,r,o);return t===de(o)&&(u?_(r,i)&&P(t,"set",n,r):P(t,"add",n,r)),a}}function I(e,t){const n=Reflect.has(e,t);return u(t)&&x.has(t)||O(e,0,t),n}function N(e){return O(e,0,p),Reflect.ownKeys(e)}const V={get:j,set:W(),deleteProperty:function(e,t){const n=c(e,t),r=Reflect.deleteProperty(e,t);return r&&n&&P(e,"delete",t,void 0),r},has:I,ownKeys:N},Y={get:M,has:I,ownKeys:N,set:(e,t)=>!0,deleteProperty:(e,t)=>!0},q=r({},V,{get:z,set:W(!0)}),B=r({},Y,{get:A}),C=e=>a(e)?ae(e):e,D=e=>a(e)?le(e):e,F=e=>e,G=e=>Reflect.getPrototypeOf(e);function H(e,t,n=!1,r=!1){const o=de(e=e.__v_raw),c=de(t);t!==c&&!n&&O(o,0,t),!n&&O(o,0,c);const{has:s}=G(o),i=n?D:r?F:C;return s.call(o,t)?i(e.get(t)):s.call(o,c)?i(e.get(c)):void 0}function J(e,t=!1){const n=this.__v_raw,r=de(n),o=de(e);return e!==o&&!t&&O(r,0,e),!t&&O(r,0,o),n.has(e)||n.has(o)}function L(e,t=!1){return e=e.__v_raw,!t&&O(de(e),0,p),Reflect.get(e,"size",e)}function Q(e){e=de(e);const t=de(this),n=G(t),r=n.has.call(t,e),o=n.add.call(t,e);return r||P(t,"add",e,e),o}function U(e,t){t=de(t);const n=de(this),{has:r,get:o,set:c}=G(n);let s=r.call(n,e);s||(e=de(e),s=r.call(n,e));const i=o.call(n,e),u=c.call(n,e,t);return s?_(t,i)&&P(n,"set",e,t):P(n,"add",e,t),u}function X(e){const t=de(this),{has:n,get:r,delete:o}=G(t);let c=n.call(t,e);c||(e=de(e),c=n.call(t,e));r&&r.call(t,e);const s=o.call(t,e);return c&&P(t,"delete",e,void 0),s}function Z(){const e=de(this),t=0!==e.size,n=G(e).clear.call(e);return t&&P(e,"clear",void 0,void 0),n}function $(e,t){return function(n,r){const o=this,c=de(o),s=e?D:t?F:C;return!e&&O(c,0,p),G(c).forEach.call(c,(function(e,t){return n.call(r,s(e),s(t),o)}))}}function ee(e,t,n){return function(...r){const o=this.__v_raw,c=de(o),s=c instanceof Map,i="entries"===e||e===Symbol.iterator&&s,u="keys"===e&&s,a=o[e](...r),l=t?D:n?F:C;return!t&&O(c,0,u?y:p),{next(){const{value:e,done:t}=a.next();return t?{value:e,done:t}:{value:i?[l(e[0]),l(e[1])]:l(e),done:t}},[Symbol.iterator](){return this}}}}function te(e){return function(...t){return"delete"!==e&&this}}const ne={get(e){return H(this,e)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!1)},re={get(e){return H(this,e,!1,!0)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!0)},oe={get(e){return H(this,e,!0)},get size(){return L(this,!0)},has(e){return J.call(this,e,!0)},add:te("add"),set:te("set"),delete:te("delete"),clear:te("clear"),forEach:$(!0,!1)};function ce(e,t){const n=t?re:e?oe:ne;return(t,r,o)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(c(n,r)&&r in t?n:t,r,o)}["keys","values","entries",Symbol.iterator].forEach(e=>{ne[e]=ee(e,!1,!1),oe[e]=ee(e,!0,!1),re[e]=ee(e,!1,!0)});const se={get:ce(!1,!1)},ie={get:ce(!1,!0)},ue={get:ce(!0,!1)};function ae(e){return e&&e.__v_isReadonly?e:fe(e,!1,V,se)}function le(e){return fe(e,!0,Y,ue)}function fe(e,t,n,r){if(!a(e))return e;if(e.__v_raw&&(!t||!e.__v_isReactive))return e;const o=t?"__v_readonly":"__v_reactive";if(c(e,o))return e[o];const s=(i=e).__v_skip||!Object.isExtensible(i)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(f(i));var i;if(0===s)return e;const u=new Proxy(e,2===s?r:n);return v(e,o,u),u}function _e(e){return ve(e)?_e(e.__v_raw):!(!e||!e.__v_isReactive)}function ve(e){return!(!e||!e.__v_isReadonly)}function de(e){return e&&de(e.__v_raw)||e}const he=e=>a(e)?ae(e):e;function ge(e){return!!e&&!0===e.__v_isRef}function pe(e,t=!1){if(ge(e))return e;let n=t?e:he(e);const r={__v_isRef:!0,get value(){return O(r,0,"value"),n},set value(o){_(de(o),e)&&(e=o,n=t?o:he(o),P(r,"set","value",o))}};return r}function ye(e){return ge(e)?e.value:e}const Re={get:(e,t,n)=>ye(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return ge(o)&&!ge(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}};function we(e,t){return{__v_isRef:!0,get value(){return e[t]},set value(n){e[t]=n}}}return e.ITERATE_KEY=p,e.computed=function(e){let t,r;i(e)?(t=e,r=n):(t=e.get,r=e.set);let o,c,s=!0;const u=R(t,{lazy:!0,scheduler:()=>{s||(s=!0,P(c,"set","value"))}});return c={__v_isRef:!0,__v_isReadonly:i(e)||!e.set,effect:u,get value(){return s&&(o=u(),s=!1),O(c,0,"value"),o},set value(e){r(e)}},c},e.customRef=function(e){const{get:t,set:n}=e(()=>O(r,0,"value"),()=>P(r,"set","value")),r={__v_isRef:!0,get value(){return t()},set value(e){n(e)}};return r},e.effect=R,e.enableTracking=S,e.isProxy=function(e){return _e(e)||ve(e)},e.isReactive=_e,e.isReadonly=ve,e.isRef=ge,e.markRaw=function(e){return v(e,"__v_skip",!0),e},e.pauseTracking=function(){m.push(E),E=!1},e.proxyRefs=function(e){return _e(e)?e:new Proxy(e,Re)},e.reactive=ae,e.readonly=le,e.ref=function(e){return pe(e)},e.resetTracking=k,e.shallowReactive=function(e){return fe(e,!1,q,ie)},e.shallowReadonly=function(e){return fe(e,!0,B,ue)},e.shallowRef=function(e){return pe(e,!0)},e.stop=function(e){e.active&&(b(e),e.options.onStop&&e.options.onStop(),e.active=!1)},e.toRaw=de,e.toRef=we,e.toRefs=function(e){const t=s(e)?new Array(e.length):{};for(const n in e)t[n]=we(e,n);return t},e.track=O,e.trigger=P,e.triggerRef=function(e){P(e,"set","value",void 0)},e.unref=ye,e}({}); | ||
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}({}); |
{ | ||
"name": "@vue/reactivity", | ||
"version": "3.0.0-rc.6", | ||
"version": "3.0.0-rc.7", | ||
"description": "@vue/reactivity", | ||
@@ -38,4 +38,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vue/shared": "3.0.0-rc.6" | ||
"@vue/shared": "3.0.0-rc.7" | ||
} | ||
} |
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
169044
4426
+ Added@vue/shared@3.0.0-rc.7(transitive)
- Removed@vue/shared@3.0.0-rc.6(transitive)
Updated@vue/shared@3.0.0-rc.7