@vue/reactivity 3.1.0 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactivity.cjs.js +114 -101
- package/dist/reactivity.cjs.prod.js +114 -101
- package/dist/reactivity.d.ts +1 -1
- package/dist/reactivity.esm-browser.js +114 -101
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +114 -101
- package/dist/reactivity.global.js +114 -101
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
|
@@ -254,34 +254,38 @@ const get = /*#__PURE__*/ createGetter();
|
|
|
254
254
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
255
255
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
256
256
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
257
|
-
const arrayInstrumentations =
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
257
|
+
const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
|
258
|
+
function createArrayInstrumentations() {
|
|
259
|
+
const instrumentations = {};
|
|
260
|
+
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
|
|
261
|
+
const method = Array.prototype[key];
|
|
262
|
+
instrumentations[key] = function (...args) {
|
|
263
|
+
const arr = toRaw(this);
|
|
264
|
+
for (let i = 0, l = this.length; i < l; i++) {
|
|
265
|
+
track(arr, "get" /* GET */, i + '');
|
|
266
|
+
}
|
|
267
|
+
// we run the method using the original args first (which may be reactive)
|
|
268
|
+
const res = method.apply(arr, args);
|
|
269
|
+
if (res === -1 || res === false) {
|
|
270
|
+
// if that didn't work, run it again using raw values.
|
|
271
|
+
return method.apply(arr, args.map(toRaw));
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return res;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
|
279
|
+
const method = Array.prototype[key];
|
|
280
|
+
instrumentations[key] = function (...args) {
|
|
281
|
+
pauseTracking();
|
|
282
|
+
const res = method.apply(this, args);
|
|
283
|
+
resetTracking();
|
|
272
284
|
return res;
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const method = Array.prototype[key];
|
|
278
|
-
arrayInstrumentations[key] = function (...args) {
|
|
279
|
-
pauseTracking();
|
|
280
|
-
const res = method.apply(this, args);
|
|
281
|
-
resetTracking();
|
|
282
|
-
return res;
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
return instrumentations;
|
|
288
|
+
}
|
|
285
289
|
function createGetter(isReadonly = false, shallow = false) {
|
|
286
290
|
return function get(target, key, receiver) {
|
|
287
291
|
if (key === "__v_isReactive" /* IS_REACTIVE */) {
|
|
@@ -400,14 +404,14 @@ const readonlyHandlers = {
|
|
|
400
404
|
return true;
|
|
401
405
|
}
|
|
402
406
|
};
|
|
403
|
-
const shallowReactiveHandlers = extend({}, mutableHandlers, {
|
|
407
|
+
const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
|
|
404
408
|
get: shallowGet,
|
|
405
409
|
set: shallowSet
|
|
406
410
|
});
|
|
407
411
|
// Props handlers are special in the sense that it should not unwrap top-level
|
|
408
412
|
// refs (in order to allow refs to be explicitly passed down), but should
|
|
409
413
|
// retain the reactivity of the normal readonly object.
|
|
410
|
-
const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
|
|
414
|
+
const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
|
|
411
415
|
get: shallowReadonlyGet
|
|
412
416
|
});
|
|
413
417
|
|
|
@@ -577,73 +581,82 @@ function createReadonlyMethod(type) {
|
|
|
577
581
|
return type === "delete" /* DELETE */ ? false : this;
|
|
578
582
|
};
|
|
579
583
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
iteratorMethods
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
584
|
+
function createInstrumentations() {
|
|
585
|
+
const mutableInstrumentations = {
|
|
586
|
+
get(key) {
|
|
587
|
+
return get$1(this, key);
|
|
588
|
+
},
|
|
589
|
+
get size() {
|
|
590
|
+
return size(this);
|
|
591
|
+
},
|
|
592
|
+
has: has$1,
|
|
593
|
+
add,
|
|
594
|
+
set: set$1,
|
|
595
|
+
delete: deleteEntry,
|
|
596
|
+
clear,
|
|
597
|
+
forEach: createForEach(false, false)
|
|
598
|
+
};
|
|
599
|
+
const shallowInstrumentations = {
|
|
600
|
+
get(key) {
|
|
601
|
+
return get$1(this, key, false, true);
|
|
602
|
+
},
|
|
603
|
+
get size() {
|
|
604
|
+
return size(this);
|
|
605
|
+
},
|
|
606
|
+
has: has$1,
|
|
607
|
+
add,
|
|
608
|
+
set: set$1,
|
|
609
|
+
delete: deleteEntry,
|
|
610
|
+
clear,
|
|
611
|
+
forEach: createForEach(false, true)
|
|
612
|
+
};
|
|
613
|
+
const readonlyInstrumentations = {
|
|
614
|
+
get(key) {
|
|
615
|
+
return get$1(this, key, true);
|
|
616
|
+
},
|
|
617
|
+
get size() {
|
|
618
|
+
return size(this, true);
|
|
619
|
+
},
|
|
620
|
+
has(key) {
|
|
621
|
+
return has$1.call(this, key, true);
|
|
622
|
+
},
|
|
623
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
624
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
625
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
626
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
627
|
+
forEach: createForEach(true, false)
|
|
628
|
+
};
|
|
629
|
+
const shallowReadonlyInstrumentations = {
|
|
630
|
+
get(key) {
|
|
631
|
+
return get$1(this, key, true, true);
|
|
632
|
+
},
|
|
633
|
+
get size() {
|
|
634
|
+
return size(this, true);
|
|
635
|
+
},
|
|
636
|
+
has(key) {
|
|
637
|
+
return has$1.call(this, key, true);
|
|
638
|
+
},
|
|
639
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
640
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
641
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
642
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
643
|
+
forEach: createForEach(true, true)
|
|
644
|
+
};
|
|
645
|
+
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
|
|
646
|
+
iteratorMethods.forEach(method => {
|
|
647
|
+
mutableInstrumentations[method] = createIterableMethod(method, false, false);
|
|
648
|
+
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
|
|
649
|
+
shallowInstrumentations[method] = createIterableMethod(method, false, true);
|
|
650
|
+
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
|
|
651
|
+
});
|
|
652
|
+
return [
|
|
653
|
+
mutableInstrumentations,
|
|
654
|
+
readonlyInstrumentations,
|
|
655
|
+
shallowInstrumentations,
|
|
656
|
+
shallowReadonlyInstrumentations
|
|
657
|
+
];
|
|
658
|
+
}
|
|
659
|
+
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
|
|
647
660
|
function createInstrumentationGetter(isReadonly, shallow) {
|
|
648
661
|
const instrumentations = shallow
|
|
649
662
|
? isReadonly
|
|
@@ -668,16 +681,16 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
668
681
|
};
|
|
669
682
|
}
|
|
670
683
|
const mutableCollectionHandlers = {
|
|
671
|
-
get: createInstrumentationGetter(false, false)
|
|
684
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
|
|
672
685
|
};
|
|
673
686
|
const shallowCollectionHandlers = {
|
|
674
|
-
get: createInstrumentationGetter(false, true)
|
|
687
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
|
|
675
688
|
};
|
|
676
689
|
const readonlyCollectionHandlers = {
|
|
677
|
-
get: createInstrumentationGetter(true, false)
|
|
690
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
|
678
691
|
};
|
|
679
692
|
const shallowReadonlyCollectionHandlers = {
|
|
680
|
-
get: createInstrumentationGetter(true, true)
|
|
693
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
|
681
694
|
};
|
|
682
695
|
function checkIdentityKeys(target, has, key) {
|
|
683
696
|
const rawKey = toRaw(key);
|
|
@@ -803,7 +816,7 @@ function shallowRef(value) {
|
|
|
803
816
|
return createRef(value, true);
|
|
804
817
|
}
|
|
805
818
|
class RefImpl {
|
|
806
|
-
constructor(_rawValue, _shallow
|
|
819
|
+
constructor(_rawValue, _shallow) {
|
|
807
820
|
this._rawValue = _rawValue;
|
|
808
821
|
this._shallow = _shallow;
|
|
809
822
|
this.__v_isRef = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=Object.create(null),r=t.split(",");for(let s=0;s<r.length;s++)n[r[s]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e={},n=()=>{},r=Object.assign,s=Object.prototype.hasOwnProperty,
|
|
1
|
+
function t(t,e){const n=Object.create(null),r=t.split(",");for(let s=0;s<r.length;s++)n[r[s]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e={},n=()=>{},r=Object.assign,s=Object.prototype.hasOwnProperty,o=(t,e)=>s.call(t,e),i=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,d=(t,e)=>t!==e&&(t==t||e==e),v=new WeakMap,g=[];let p;const y=Symbol(""),w=Symbol("");function R(t,n=e){(function(t){return t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(){if(!n.active)return t();if(!g.includes(n)){E(n);try{return O(),g.push(n),p=n,t()}finally{g.pop(),M(),p=g[g.length-1]}}};return n.id=k++,n.allowRecurse=!!e.allowRecurse,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}function b(t){t.active&&(E(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let k=0;function E(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let S=!0;const j=[];function m(){j.push(S),S=!1}function O(){j.push(S),S=!0}function M(){const t=j.pop();S=void 0===t||t}function P(t,e,n){if(!S||void 0===p)return;let r=v.get(t);r||v.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(p)||(s.add(p),p.deps.push(s))}function x(t,e,n,r,s,o){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(y)),c(t)&&l(u.get(w)));break;case"delete":i(t)||(l(u.get(y)),c(t)&&l(u.get(w)));break;case"set":c(t)&&l(u.get(y))}a.forEach((t=>{t.options.scheduler?t.options.scheduler(t):t()}))}const z=t("__proto__,__v_isRef,__isVue"),W=new Set(Object.getOwnPropertyNames(Symbol).map((t=>Symbol[t])).filter(a)),A=C(),N=C(!1,!0),V=C(!0),I=C(!0,!0),K=B();function B(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{const n=Array.prototype[e];t[e]=function(...t){const e=Mt(this);for(let n=0,s=this.length;n<s;n++)P(e,0,n+"");const r=n.apply(e,t);return-1===r||!1===r?n.apply(e,t.map(Mt)):r}})),["push","pop","shift","unshift","splice"].forEach((e=>{const n=Array.prototype[e];t[e]=function(...t){m();const e=n.apply(this,t);return M(),e}})),t}function C(t=!1,e=!1){return function(n,r,s){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&s===(t?e?yt:pt:e?gt:vt).get(n))return n;const c=i(n);if(!t&&c&&o(K,r))return Reflect.get(K,r,s);const u=Reflect.get(n,r,s);if(a(r)?W.has(r):z(r))return u;if(t||P(n,0,r),e)return u;if(zt(u)){return!c||!h(r)?u.value:u}return l(u)?t?kt(u):Rt(u):u}}function L(t=!1){return function(e,n,r,s){let c=e[n];if(!t&&(r=Mt(r),c=Mt(c),!i(e)&&zt(c)&&!zt(r)))return c.value=r,!0;const u=i(e)&&h(n)?Number(n)<e.length:o(e,n),a=Reflect.set(e,n,r,s);return e===Mt(s)&&(u?d(r,c)&&x(e,"set",n,r):x(e,"add",n,r)),a}}const q={get:A,set:L(),deleteProperty:function(t,e){const n=o(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&x(t,"delete",e,void 0),r},has:function(t,e){const n=Reflect.has(t,e);return a(e)&&W.has(e)||P(t,0,e),n},ownKeys:function(t){return P(t,0,i(t)?"length":y),Reflect.ownKeys(t)}},D={get:V,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},F=r({},q,{get:N,set:L(!0)}),G=r({},D,{get:I}),H=t=>l(t)?Rt(t):t,J=t=>l(t)?kt(t):t,Q=t=>t,T=t=>Reflect.getPrototypeOf(t);function U(t,e,n=!1,r=!1){const s=Mt(t=t.__v_raw),o=Mt(e);e!==o&&!n&&P(s,0,e),!n&&P(s,0,o);const{has:i}=T(s),c=r?Q:n?J:H;return i.call(s,e)?c(t.get(e)):i.call(s,o)?c(t.get(o)):void(t!==s&&t.get(e))}function X(t,e=!1){const n=this.__v_raw,r=Mt(n),s=Mt(t);return t!==s&&!e&&P(r,0,t),!e&&P(r,0,s),t===s?n.has(t):n.has(t)||n.has(s)}function Y(t,e=!1){return t=t.__v_raw,!e&&P(Mt(t),0,y),Reflect.get(t,"size",t)}function Z(t){t=Mt(t);const e=Mt(this);return T(e).has.call(e,t)||(e.add(t),x(e,"add",t,t)),this}function $(t,e){e=Mt(e);const n=Mt(this),{has:r,get:s}=T(n);let o=r.call(n,t);o||(t=Mt(t),o=r.call(n,t));const i=s.call(n,t);return n.set(t,e),o?d(e,i)&&x(n,"set",t,e):x(n,"add",t,e),this}function tt(t){const e=Mt(this),{has:n,get:r}=T(e);let s=n.call(e,t);s||(t=Mt(t),s=n.call(e,t)),r&&r.call(e,t);const o=e.delete(t);return s&&x(e,"delete",t,void 0),o}function et(){const t=Mt(this),e=0!==t.size,n=t.clear();return e&&x(t,"clear",void 0,void 0),n}function nt(t,e){return function(n,r){const s=this,o=s.__v_raw,i=Mt(o),c=e?Q:t?J:H;return!t&&P(i,0,y),o.forEach(((t,e)=>n.call(r,c(t),c(e),s)))}}function rt(t,e,n){return function(...r){const s=this.__v_raw,o=Mt(s),i=c(o),u="entries"===t||t===Symbol.iterator&&i,a="keys"===t&&i,l=s[t](...r),f=n?Q:e?J:H;return!e&&P(o,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 st(t){return function(...e){return"delete"!==t&&this}}function ot(){const t={get(t){return U(this,t)},get size(){return Y(this)},has:X,add:Z,set:$,delete:tt,clear:et,forEach:nt(!1,!1)},e={get(t){return U(this,t,!1,!0)},get size(){return Y(this)},has:X,add:Z,set:$,delete:tt,clear:et,forEach:nt(!1,!0)},n={get(t){return U(this,t,!0)},get size(){return Y(this,!0)},has(t){return X.call(this,t,!0)},add:st("add"),set:st("set"),delete:st("delete"),clear:st("clear"),forEach:nt(!0,!1)},r={get(t){return U(this,t,!0,!0)},get size(){return Y(this,!0)},has(t){return X.call(this,t,!0)},add:st("add"),set:st("set"),delete:st("delete"),clear:st("clear"),forEach:nt(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((s=>{t[s]=rt(s,!1,!1),n[s]=rt(s,!0,!1),e[s]=rt(s,!1,!0),r[s]=rt(s,!0,!0)})),[t,n,e,r]}const[it,ct,ut,at]=ot();function lt(t,e){const n=e?t?at:ut:t?ct:it;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)}const ft={get:lt(!1,!1)},_t={get:lt(!1,!0)},ht={get:lt(!0,!1)},dt={get:lt(!0,!0)},vt=new WeakMap,gt=new WeakMap,pt=new WeakMap,yt=new WeakMap;function wt(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 Rt(t){return t&&t.__v_isReadonly?t:St(t,!1,q,ft,vt)}function bt(t){return St(t,!1,F,_t,gt)}function kt(t){return St(t,!0,D,ht,pt)}function Et(t){return St(t,!0,G,dt,yt)}function St(t,e,n,r,s){if(!l(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const o=s.get(t);if(o)return o;const i=wt(t);if(0===i)return t;const c=new Proxy(t,2===i?r:n);return s.set(t,c),c}function jt(t){return mt(t)?jt(t.__v_raw):!(!t||!t.__v_isReactive)}function mt(t){return!(!t||!t.__v_isReadonly)}function Ot(t){return jt(t)||mt(t)}function Mt(t){return t&&Mt(t.__v_raw)||t}function Pt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const xt=t=>l(t)?Rt(t):t;function zt(t){return Boolean(t&&!0===t.__v_isRef)}function Wt(t){return Vt(t)}function At(t){return Vt(t,!0)}class Nt{constructor(t,e){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:xt(t)}get value(){return P(Mt(this),0,"value"),this._value}set value(t){d(Mt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:xt(t),x(Mt(this),"set","value",t))}}function Vt(t,e=!1){return zt(t)?t:new Nt(t,e)}function It(t){x(Mt(t),"set","value",void 0)}function Kt(t){return zt(t)?t.value:t}const Bt={get:(t,e,n)=>Kt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return zt(s)&&!zt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};function Ct(t){return jt(t)?t:new Proxy(t,Bt)}class Lt{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 qt(t){return new Lt(t)}function Dt(t){const e=i(t)?new Array(t.length):{};for(const n in t)e[n]=Gt(t,n);return e}class Ft{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 Gt(t,e){return zt(t[e])?t[e]:new Ft(t,e)}class Ht{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=R(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,x(Mt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){const t=Mt(this);return t._dirty&&(t._value=this.effect(),t._dirty=!1),P(t,0,"value"),t._value}set value(t){this._setter(t)}}function Jt(t){let e,r;return u(t)?(e=t,r=n):(e=t.get,r=t.set),new Ht(e,r,u(t)||!t.set)}export{y as ITERATE_KEY,Jt as computed,qt as customRef,R as effect,O as enableTracking,Ot as isProxy,jt as isReactive,mt as isReadonly,zt as isRef,Pt as markRaw,m as pauseTracking,Ct as proxyRefs,Rt as reactive,kt as readonly,Wt as ref,M as resetTracking,bt as shallowReactive,Et as shallowReadonly,At as shallowRef,b as stop,Mt as toRaw,Gt as toRef,Dt as toRefs,P as track,x as trigger,It as triggerRef,Kt as unref};
|
|
@@ -197,34 +197,38 @@ const get = /*#__PURE__*/ createGetter();
|
|
|
197
197
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
198
198
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
199
199
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
200
|
-
const arrayInstrumentations =
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
200
|
+
const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
|
201
|
+
function createArrayInstrumentations() {
|
|
202
|
+
const instrumentations = {};
|
|
203
|
+
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
|
|
204
|
+
const method = Array.prototype[key];
|
|
205
|
+
instrumentations[key] = function (...args) {
|
|
206
|
+
const arr = toRaw(this);
|
|
207
|
+
for (let i = 0, l = this.length; i < l; i++) {
|
|
208
|
+
track(arr, "get" /* GET */, i + '');
|
|
209
|
+
}
|
|
210
|
+
// we run the method using the original args first (which may be reactive)
|
|
211
|
+
const res = method.apply(arr, args);
|
|
212
|
+
if (res === -1 || res === false) {
|
|
213
|
+
// if that didn't work, run it again using raw values.
|
|
214
|
+
return method.apply(arr, args.map(toRaw));
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
return res;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
|
222
|
+
const method = Array.prototype[key];
|
|
223
|
+
instrumentations[key] = function (...args) {
|
|
224
|
+
pauseTracking();
|
|
225
|
+
const res = method.apply(this, args);
|
|
226
|
+
resetTracking();
|
|
215
227
|
return res;
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const method = Array.prototype[key];
|
|
221
|
-
arrayInstrumentations[key] = function (...args) {
|
|
222
|
-
pauseTracking();
|
|
223
|
-
const res = method.apply(this, args);
|
|
224
|
-
resetTracking();
|
|
225
|
-
return res;
|
|
226
|
-
};
|
|
227
|
-
});
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
return instrumentations;
|
|
231
|
+
}
|
|
228
232
|
function createGetter(isReadonly = false, shallow = false) {
|
|
229
233
|
return function get(target, key, receiver) {
|
|
230
234
|
if (key === "__v_isReactive" /* IS_REACTIVE */) {
|
|
@@ -343,14 +347,14 @@ const readonlyHandlers = {
|
|
|
343
347
|
return true;
|
|
344
348
|
}
|
|
345
349
|
};
|
|
346
|
-
const shallowReactiveHandlers = extend({}, mutableHandlers, {
|
|
350
|
+
const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
|
|
347
351
|
get: shallowGet,
|
|
348
352
|
set: shallowSet
|
|
349
353
|
});
|
|
350
354
|
// Props handlers are special in the sense that it should not unwrap top-level
|
|
351
355
|
// refs (in order to allow refs to be explicitly passed down), but should
|
|
352
356
|
// retain the reactivity of the normal readonly object.
|
|
353
|
-
const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
|
|
357
|
+
const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
|
|
354
358
|
get: shallowReadonlyGet
|
|
355
359
|
});
|
|
356
360
|
|
|
@@ -521,73 +525,82 @@ function createReadonlyMethod(type) {
|
|
|
521
525
|
return type === "delete" /* DELETE */ ? false : this;
|
|
522
526
|
};
|
|
523
527
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
iteratorMethods
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
528
|
+
function createInstrumentations() {
|
|
529
|
+
const mutableInstrumentations = {
|
|
530
|
+
get(key) {
|
|
531
|
+
return get$1(this, key);
|
|
532
|
+
},
|
|
533
|
+
get size() {
|
|
534
|
+
return size(this);
|
|
535
|
+
},
|
|
536
|
+
has: has$1,
|
|
537
|
+
add,
|
|
538
|
+
set: set$1,
|
|
539
|
+
delete: deleteEntry,
|
|
540
|
+
clear,
|
|
541
|
+
forEach: createForEach(false, false)
|
|
542
|
+
};
|
|
543
|
+
const shallowInstrumentations = {
|
|
544
|
+
get(key) {
|
|
545
|
+
return get$1(this, key, false, true);
|
|
546
|
+
},
|
|
547
|
+
get size() {
|
|
548
|
+
return size(this);
|
|
549
|
+
},
|
|
550
|
+
has: has$1,
|
|
551
|
+
add,
|
|
552
|
+
set: set$1,
|
|
553
|
+
delete: deleteEntry,
|
|
554
|
+
clear,
|
|
555
|
+
forEach: createForEach(false, true)
|
|
556
|
+
};
|
|
557
|
+
const readonlyInstrumentations = {
|
|
558
|
+
get(key) {
|
|
559
|
+
return get$1(this, key, true);
|
|
560
|
+
},
|
|
561
|
+
get size() {
|
|
562
|
+
return size(this, true);
|
|
563
|
+
},
|
|
564
|
+
has(key) {
|
|
565
|
+
return has$1.call(this, key, true);
|
|
566
|
+
},
|
|
567
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
568
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
569
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
570
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
571
|
+
forEach: createForEach(true, false)
|
|
572
|
+
};
|
|
573
|
+
const shallowReadonlyInstrumentations = {
|
|
574
|
+
get(key) {
|
|
575
|
+
return get$1(this, key, true, true);
|
|
576
|
+
},
|
|
577
|
+
get size() {
|
|
578
|
+
return size(this, true);
|
|
579
|
+
},
|
|
580
|
+
has(key) {
|
|
581
|
+
return has$1.call(this, key, true);
|
|
582
|
+
},
|
|
583
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
584
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
585
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
586
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
587
|
+
forEach: createForEach(true, true)
|
|
588
|
+
};
|
|
589
|
+
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
|
|
590
|
+
iteratorMethods.forEach(method => {
|
|
591
|
+
mutableInstrumentations[method] = createIterableMethod(method, false, false);
|
|
592
|
+
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
|
|
593
|
+
shallowInstrumentations[method] = createIterableMethod(method, false, true);
|
|
594
|
+
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
|
|
595
|
+
});
|
|
596
|
+
return [
|
|
597
|
+
mutableInstrumentations,
|
|
598
|
+
readonlyInstrumentations,
|
|
599
|
+
shallowInstrumentations,
|
|
600
|
+
shallowReadonlyInstrumentations
|
|
601
|
+
];
|
|
602
|
+
}
|
|
603
|
+
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
|
|
591
604
|
function createInstrumentationGetter(isReadonly, shallow) {
|
|
592
605
|
const instrumentations = shallow
|
|
593
606
|
? isReadonly
|
|
@@ -612,16 +625,16 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
612
625
|
};
|
|
613
626
|
}
|
|
614
627
|
const mutableCollectionHandlers = {
|
|
615
|
-
get: createInstrumentationGetter(false, false)
|
|
628
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
|
|
616
629
|
};
|
|
617
630
|
const shallowCollectionHandlers = {
|
|
618
|
-
get: createInstrumentationGetter(false, true)
|
|
631
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
|
|
619
632
|
};
|
|
620
633
|
const readonlyCollectionHandlers = {
|
|
621
|
-
get: createInstrumentationGetter(true, false)
|
|
634
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
|
622
635
|
};
|
|
623
636
|
const shallowReadonlyCollectionHandlers = {
|
|
624
|
-
get: createInstrumentationGetter(true, true)
|
|
637
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
|
625
638
|
};
|
|
626
639
|
function checkIdentityKeys(target, has, key) {
|
|
627
640
|
const rawKey = toRaw(key);
|
|
@@ -747,7 +760,7 @@ function shallowRef(value) {
|
|
|
747
760
|
return createRef(value, true);
|
|
748
761
|
}
|
|
749
762
|
class RefImpl {
|
|
750
|
-
constructor(_rawValue, _shallow
|
|
763
|
+
constructor(_rawValue, _shallow) {
|
|
751
764
|
this._rawValue = _rawValue;
|
|
752
765
|
this._shallow = _shallow;
|
|
753
766
|
this.__v_isRef = true;
|