@vue/reactivity 3.1.1 → 3.1.5

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