@vue/reactivity 3.3.3 → 3.3.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.
- package/dist/reactivity.cjs.js +52 -64
- package/dist/reactivity.cjs.prod.js +52 -64
- package/dist/reactivity.d.ts +50 -74
- package/dist/reactivity.esm-browser.js +55 -67
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +76 -88
- package/dist/reactivity.global.js +55 -67
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
|
@@ -29,9 +29,9 @@ const cacheStringFunction = (fn) => {
|
|
|
29
29
|
return hit || (cache[str] = fn(str));
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
const capitalize = cacheStringFunction(
|
|
33
|
-
|
|
34
|
-
);
|
|
32
|
+
const capitalize = cacheStringFunction((str) => {
|
|
33
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
34
|
+
});
|
|
35
35
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
36
36
|
const def = (obj, key, value) => {
|
|
37
37
|
Object.defineProperty(obj, key, {
|
|
@@ -252,7 +252,7 @@ function cleanupEffect(effect2) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
function effect(fn, options) {
|
|
255
|
-
if (fn.effect) {
|
|
255
|
+
if (fn.effect instanceof ReactiveEffect) {
|
|
256
256
|
fn = fn.effect.fn;
|
|
257
257
|
}
|
|
258
258
|
const _effect = new ReactiveEffect(fn);
|
|
@@ -422,10 +422,6 @@ const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`
|
|
|
422
422
|
const builtInSymbols = new Set(
|
|
423
423
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
424
424
|
);
|
|
425
|
-
const get$1 = /* @__PURE__ */ createGetter();
|
|
426
|
-
const shallowGet = /* @__PURE__ */ createGetter(false, true);
|
|
427
|
-
const readonlyGet = /* @__PURE__ */ createGetter(true);
|
|
428
|
-
const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
|
|
429
425
|
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
430
426
|
function createArrayInstrumentations() {
|
|
431
427
|
const instrumentations = {};
|
|
@@ -458,8 +454,13 @@ function hasOwnProperty(key) {
|
|
|
458
454
|
track(obj, "has", key);
|
|
459
455
|
return obj.hasOwnProperty(key);
|
|
460
456
|
}
|
|
461
|
-
|
|
462
|
-
|
|
457
|
+
class BaseReactiveHandler {
|
|
458
|
+
constructor(_isReadonly = false, _shallow = false) {
|
|
459
|
+
this._isReadonly = _isReadonly;
|
|
460
|
+
this._shallow = _shallow;
|
|
461
|
+
}
|
|
462
|
+
get(target, key, receiver) {
|
|
463
|
+
const isReadonly2 = this._isReadonly, shallow = this._shallow;
|
|
463
464
|
if (key === "__v_isReactive") {
|
|
464
465
|
return !isReadonly2;
|
|
465
466
|
} else if (key === "__v_isReadonly") {
|
|
@@ -495,17 +496,18 @@ function createGetter(isReadonly2 = false, shallow = false) {
|
|
|
495
496
|
return isReadonly2 ? readonly(res) : reactive(res);
|
|
496
497
|
}
|
|
497
498
|
return res;
|
|
498
|
-
}
|
|
499
|
+
}
|
|
499
500
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
501
|
+
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
502
|
+
constructor(shallow = false) {
|
|
503
|
+
super(false, shallow);
|
|
504
|
+
}
|
|
505
|
+
set(target, key, value, receiver) {
|
|
504
506
|
let oldValue = target[key];
|
|
505
507
|
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
|
|
506
508
|
return false;
|
|
507
509
|
}
|
|
508
|
-
if (!
|
|
510
|
+
if (!this._shallow) {
|
|
509
511
|
if (!isShallow(value) && !isReadonly(value)) {
|
|
510
512
|
oldValue = toRaw(oldValue);
|
|
511
513
|
value = toRaw(value);
|
|
@@ -525,37 +527,36 @@ function createSetter(shallow = false) {
|
|
|
525
527
|
}
|
|
526
528
|
}
|
|
527
529
|
return result;
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
function deleteProperty(target, key) {
|
|
531
|
-
const hadKey = hasOwn(target, key);
|
|
532
|
-
const oldValue = target[key];
|
|
533
|
-
const result = Reflect.deleteProperty(target, key);
|
|
534
|
-
if (result && hadKey) {
|
|
535
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
536
530
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
531
|
+
deleteProperty(target, key) {
|
|
532
|
+
const hadKey = hasOwn(target, key);
|
|
533
|
+
const oldValue = target[key];
|
|
534
|
+
const result = Reflect.deleteProperty(target, key);
|
|
535
|
+
if (result && hadKey) {
|
|
536
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
540
|
+
has(target, key) {
|
|
541
|
+
const result = Reflect.has(target, key);
|
|
542
|
+
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
543
|
+
track(target, "has", key);
|
|
544
|
+
}
|
|
545
|
+
return result;
|
|
546
|
+
}
|
|
547
|
+
ownKeys(target) {
|
|
548
|
+
track(
|
|
549
|
+
target,
|
|
550
|
+
"iterate",
|
|
551
|
+
isArray(target) ? "length" : ITERATE_KEY
|
|
552
|
+
);
|
|
553
|
+
return Reflect.ownKeys(target);
|
|
543
554
|
}
|
|
544
|
-
return result;
|
|
545
|
-
}
|
|
546
|
-
function ownKeys(target) {
|
|
547
|
-
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
548
|
-
return Reflect.ownKeys(target);
|
|
549
555
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
has: has$1,
|
|
555
|
-
ownKeys
|
|
556
|
-
};
|
|
557
|
-
const readonlyHandlers = {
|
|
558
|
-
get: readonlyGet,
|
|
556
|
+
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
557
|
+
constructor(shallow = false) {
|
|
558
|
+
super(true, shallow);
|
|
559
|
+
}
|
|
559
560
|
set(target, key) {
|
|
560
561
|
{
|
|
561
562
|
warn(
|
|
@@ -564,7 +565,7 @@ const readonlyHandlers = {
|
|
|
564
565
|
);
|
|
565
566
|
}
|
|
566
567
|
return true;
|
|
567
|
-
}
|
|
568
|
+
}
|
|
568
569
|
deleteProperty(target, key) {
|
|
569
570
|
{
|
|
570
571
|
warn(
|
|
@@ -574,22 +575,13 @@ const readonlyHandlers = {
|
|
|
574
575
|
}
|
|
575
576
|
return true;
|
|
576
577
|
}
|
|
577
|
-
}
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
get: shallowGet,
|
|
583
|
-
set: shallowSet
|
|
584
|
-
}
|
|
585
|
-
);
|
|
586
|
-
const shallowReadonlyHandlers = /* @__PURE__ */ extend(
|
|
587
|
-
{},
|
|
588
|
-
readonlyHandlers,
|
|
589
|
-
{
|
|
590
|
-
get: shallowReadonlyGet
|
|
591
|
-
}
|
|
578
|
+
}
|
|
579
|
+
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
580
|
+
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
581
|
+
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
|
|
582
|
+
true
|
|
592
583
|
);
|
|
584
|
+
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
593
585
|
|
|
594
586
|
const toShallow = (value) => value;
|
|
595
587
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
@@ -598,7 +590,7 @@ function get(target, key, isReadonly = false, isShallow = false) {
|
|
|
598
590
|
const rawTarget = toRaw(target);
|
|
599
591
|
const rawKey = toRaw(key);
|
|
600
592
|
if (!isReadonly) {
|
|
601
|
-
if (key
|
|
593
|
+
if (hasChanged(key, rawKey)) {
|
|
602
594
|
track(rawTarget, "get", key);
|
|
603
595
|
}
|
|
604
596
|
track(rawTarget, "get", rawKey);
|
|
@@ -618,7 +610,7 @@ function has(key, isReadonly = false) {
|
|
|
618
610
|
const rawTarget = toRaw(target);
|
|
619
611
|
const rawKey = toRaw(key);
|
|
620
612
|
if (!isReadonly) {
|
|
621
|
-
if (key
|
|
613
|
+
if (hasChanged(key, rawKey)) {
|
|
622
614
|
track(rawTarget, "has", key);
|
|
623
615
|
}
|
|
624
616
|
track(rawTarget, "has", rawKey);
|
|
@@ -1148,11 +1140,7 @@ function toRef(source, key, defaultValue) {
|
|
|
1148
1140
|
}
|
|
1149
1141
|
function propertyToRef(source, key, defaultValue) {
|
|
1150
1142
|
const val = source[key];
|
|
1151
|
-
return isRef(val) ? val : new ObjectRefImpl(
|
|
1152
|
-
source,
|
|
1153
|
-
key,
|
|
1154
|
-
defaultValue
|
|
1155
|
-
);
|
|
1143
|
+
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1156
1144
|
}
|
|
1157
1145
|
|
|
1158
1146
|
class ComputedRefImpl {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=Object.create(null),s=t.split(",");for(let i=0;i<s.length;i++)n[s[i]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e=()=>{},n=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,_=(t,e)=>!Object.is(t,e);let d;class p{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=d,!t&&d&&(this.index=(d.scopes||(d.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=d;try{return d=this,t()}finally{d=e}}}on(){d=this}off(){d=this.parent}stop(t){if(this._active){let e,n;for(e=0,n=this.effects.length;e<n;e++)this.effects[e].stop();for(e=0,n=this.cleanups.length;e<n;e++)this.cleanups[e]();if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function v(t){return new p(t)}function g(t,e=d){e&&e.active&&e.effects.push(t)}function y(){return d}function w(t){d&&d.cleanups.push(t)}const b=t=>{const e=new Set(t);return e.w=0,e.n=0,e},R=t=>(t.w&O)>0,m=t=>(t.n&O)>0,S=new WeakMap;let k=0,O=1;let j;const x=Symbol(""),P=Symbol("");class E{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,g(this,n)}run(){if(!this.active)return this.fn();let t=j,e=V;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=j,j=this,V=!0,O=1<<++k,k<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=O})(this):M(this),this.fn()}finally{k<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];R(i)&&!m(i)?i.delete(t):e[n++]=i,i.w&=~O,i.n&=~O}e.length=n}})(this),O=1<<--k,j=this.parent,V=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(M(this),this.onStop&&this.onStop(),this.active=!1)}}function M(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}function z(t,e){t.effect&&(t=t.effect.fn);const s=new E(t);e&&(n(s,e),e.scope&&g(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i}function W(t){t.effect.stop()}let V=!0;const N=[];function A(){N.push(V),V=!1}function I(){N.push(V),V=!0}function K(){const t=N.pop();V=void 0===t||t}function C(t,e,n){if(V&&j){let e=S.get(t);e||S.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=b()),L(s)}}function L(t,e){let n=!1;k<=30?m(t)||(t.n|=O,n=!R(t)):n=!t.has(j),n&&(t.add(j),j.deps.push(t))}function q(t,e,n,s,i,o){const u=S.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===n&&r(t)){const t=Number(s);u.forEach(((e,n)=>{("length"===n||n>=t)&&h.push(e)}))}else switch(void 0!==n&&h.push(u.get(n)),e){case"add":r(t)?f(n)&&h.push(u.get("length")):(h.push(u.get(x)),c(t)&&h.push(u.get(P)));break;case"delete":r(t)||(h.push(u.get(x)),c(t)&&h.push(u.get(P)));break;case"set":c(t)&&h.push(u.get(x))}if(1===h.length)h[0]&&B(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);B(b(t))}}function B(t,e){const n=r(t)?t:[...t];for(const s of n)s.computed&&D(s);for(const s of n)s.computed||D(s)}function D(t,e){(t!==j||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const F=t("__proto__,__v_isRef,__isVue"),G=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),H=Z(),J=Z(!1,!0),Q=Z(!0),T=Z(!0,!0),U=X();function X(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=qt(this);for(let e=0,i=this.length;e<i;e++)C(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(qt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){A();const n=qt(this)[e].apply(this,t);return K(),n}})),t}function Y(t){const e=qt(this);return C(e,0,t),e.hasOwnProperty(t)}function Z(t=!1,e=!1){return function(n,s,c){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_isShallow"===s)return e;if("__v_raw"===s&&c===(t?e?Et:Pt:e?xt:jt).get(n))return n;const o=r(n);if(!t){if(o&&i(U,s))return Reflect.get(U,s,c);if("hasOwnProperty"===s)return Y}const a=Reflect.get(n,s,c);return(u(s)?G.has(s):F(s))?a:(t||C(n,0,s),e?a:Jt(a)?o&&f(s)?a:a.value:h(a)?t?Vt(a):zt(a):a)}}function $(t=!1){return function(e,n,s,c){let o=e[n];if(Kt(o)&&Jt(o)&&!Jt(s))return!1;if(!t&&(Ct(s)||Kt(s)||(o=qt(o),s=qt(s)),!r(e)&&Jt(o)&&!Jt(s)))return o.value=s,!0;const u=r(e)&&f(n)?Number(n)<e.length:i(e,n),h=Reflect.set(e,n,s,c);return e===qt(c)&&(u?_(s,o)&&q(e,"set",n,s):q(e,"add",n,s)),h}}const tt={get:H,set:$(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&q(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return u(e)&&G.has(e)||C(t,0,e),n},ownKeys:function(t){return C(t,0,r(t)?"length":x),Reflect.ownKeys(t)}},et={get:Q,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},nt=n({},tt,{get:J,set:$(!0)}),st=n({},et,{get:T}),it=t=>t,rt=t=>Reflect.getPrototypeOf(t);function ct(t,e,n=!1,s=!1){const i=qt(t=t.__v_raw),r=qt(e);n||(e!==r&&C(i,0,e),C(i,0,r));const{has:c}=rt(i),o=s?it:n?Ft:Dt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ot(t,e=!1){const n=this.__v_raw,s=qt(n),i=qt(t);return e||(t!==i&&C(s,0,t),C(s,0,i)),t===i?n.has(t):n.has(t)||n.has(i)}function ut(t,e=!1){return t=t.__v_raw,!e&&C(qt(t),0,x),Reflect.get(t,"size",t)}function ht(t){t=qt(t);const e=qt(this);return rt(e).has.call(e,t)||(e.add(t),q(e,"add",t,t)),this}function at(t,e){e=qt(e);const n=qt(this),{has:s,get:i}=rt(n);let r=s.call(n,t);r||(t=qt(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?_(e,c)&&q(n,"set",t,e):q(n,"add",t,e),this}function lt(t){const e=qt(this),{has:n,get:s}=rt(e);let i=n.call(e,t);i||(t=qt(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&q(e,"delete",t,void 0),r}function ft(){const t=qt(this),e=0!==t.size,n=t.clear();return e&&q(t,"clear",void 0,void 0),n}function _t(t,e){return function(n,s){const i=this,r=i.__v_raw,c=qt(r),o=e?it:t?Ft:Dt;return!t&&C(c,0,x),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function dt(t,e,n){return function(...s){const i=this.__v_raw,r=qt(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...s),l=n?it:e?Ft:Dt;return!e&&C(r,0,h?P:x),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function pt(t){return function(...e){return"delete"!==t&&this}}function vt(){const t={get(t){return ct(this,t)},get size(){return ut(this)},has:ot,add:ht,set:at,delete:lt,clear:ft,forEach:_t(!1,!1)},e={get(t){return ct(this,t,!1,!0)},get size(){return ut(this)},has:ot,add:ht,set:at,delete:lt,clear:ft,forEach:_t(!1,!0)},n={get(t){return ct(this,t,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:_t(!0,!1)},s={get(t){return ct(this,t,!0,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:_t(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=dt(i,!1,!1),n[i]=dt(i,!0,!1),e[i]=dt(i,!1,!0),s[i]=dt(i,!0,!0)})),[t,n,e,s]}const[gt,yt,wt,bt]=vt();function Rt(t,e){const n=e?t?bt:wt:t?yt:gt;return(e,s,r)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(i(n,s)&&s in e?n:e,s,r)}const mt={get:Rt(!1,!1)},St={get:Rt(!1,!0)},kt={get:Rt(!0,!1)},Ot={get:Rt(!0,!0)},jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap,Et=new WeakMap;function Mt(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=>l(t).slice(8,-1))(t))}function zt(t){return Kt(t)?t:At(t,!1,tt,mt,jt)}function Wt(t){return At(t,!1,nt,St,xt)}function Vt(t){return At(t,!0,et,kt,Pt)}function Nt(t){return At(t,!0,st,Ot,Et)}function At(t,e,n,s,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=Mt(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function It(t){return Kt(t)?It(t.__v_raw):!(!t||!t.__v_isReactive)}function Kt(t){return!(!t||!t.__v_isReadonly)}function Ct(t){return!(!t||!t.__v_isShallow)}function Lt(t){return It(t)||Kt(t)}function qt(t){const e=t&&t.__v_raw;return e?qt(e):t}function Bt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Dt=t=>h(t)?zt(t):t,Ft=t=>h(t)?Vt(t):t;function Gt(t){V&&j&&L((t=qt(t)).dep||(t.dep=b()))}function Ht(t,e){const n=(t=qt(t)).dep;n&&B(n)}function Jt(t){return!(!t||!0!==t.__v_isRef)}function Qt(t){return Ut(t,!1)}function Tt(t){return Ut(t,!0)}function Ut(t,e){return Jt(t)?t:new Xt(t,e)}class Xt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:qt(t),this._value=e?t:Dt(t)}get value(){return Gt(this),this._value}set value(t){const e=this.__v_isShallow||Ct(t)||Kt(t);t=e?t:qt(t),_(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Dt(t),Ht(this))}}function Yt(t){Ht(t)}function Zt(t){return Jt(t)?t.value:t}function $t(t){return o(t)?t():Zt(t)}const te={get:(t,e,n)=>Zt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Jt(i)&&!Jt(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};function ee(t){return It(t)?t:new Proxy(t,te)}class ne{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>Gt(this)),(()=>Ht(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function se(t){return new ne(t)}function ie(t){const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=ue(t,n);return e}class re{constructor(t,e,n){this._object=t,this._key=e,this._defaultValue=n,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=qt(this._object),e=this._key,null==(n=S.get(t))?void 0:n.get(e);var t,e,n}}class ce{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function oe(t,e,n){return Jt(t)?t:o(t)?new ce(t):h(t)&&arguments.length>1?ue(t,e,n):Qt(t)}function ue(t,e,n){const s=t[e];return Jt(s)?s:new re(t,e,n)}class he{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new E(t,(()=>{this._dirty||(this._dirty=!0,Ht(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=qt(this);return Gt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ae(t,n,s=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new he(i,r,c||!r,s)}const le=Promise.resolve(),fe=[];let _e=!1;const de=()=>{for(let t=0;t<fe.length;t++)fe[t]();fe.length=0,_e=!1};class pe{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let n=!1,s=!1;this.effect=new E(t,(t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,fe.push((()=>{this.effect.active&&this._get()!==t&&Ht(this),s=!1})),_e||(_e=!0,le.then(de))}for(const t of this.dep)t.computed instanceof pe&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Gt(this),qt(this)._get()}}function ve(t){return new pe(t)}export{p as EffectScope,x as ITERATE_KEY,E as ReactiveEffect,ae as computed,se as customRef,ve as deferredComputed,z as effect,v as effectScope,I as enableTracking,y as getCurrentScope,Lt as isProxy,It as isReactive,Kt as isReadonly,Jt as isRef,Ct as isShallow,Bt as markRaw,w as onScopeDispose,A as pauseTracking,ee as proxyRefs,zt as reactive,Vt as readonly,Qt as ref,K as resetTracking,Wt as shallowReactive,Nt as shallowReadonly,Tt as shallowRef,W as stop,qt as toRaw,oe as toRef,ie as toRefs,$t as toValue,C as track,q as trigger,Yt as triggerRef,Zt as unref};
|
|
1
|
+
function t(t,e){const s=Object.create(null),n=t.split(",");for(let i=0;i<n.length;i++)s[n[i]]=!0;return e?t=>!!s[t.toLowerCase()]:t=>!!s[t]}const e=()=>{},s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),f=t=>l(t).slice(8,-1),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=p,!t&&p&&(this.index=(p.scopes||(p.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=p;try{return p=this,t()}finally{p=e}}}on(){p=this}off(){p=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function g(t){return new v(t)}function y(t,e=p){e&&e.active&&e.effects.push(t)}function w(){return p}function b(t){p&&p.cleanups.push(t)}const R=t=>{const e=new Set(t);return e.w=0,e.n=0,e},m=t=>(t.w&j)>0,S=t=>(t.n&j)>0,k=new WeakMap;let O=0,j=1;const x=30;let P;const E=Symbol(""),M=Symbol("");class z{constructor(t,e=null,s){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,y(this,s)}run(){if(!this.active)return this.fn();let t=P,e=A;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=P,P=this,A=!0,j=1<<++O,O<=x?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=j})(this):W(this),this.fn()}finally{O<=x&&(t=>{const{deps:e}=t;if(e.length){let s=0;for(let n=0;n<e.length;n++){const i=e[n];m(i)&&!S(i)?i.delete(t):e[s++]=i,i.w&=~j,i.n&=~j}e.length=s}})(this),j=1<<--O,P=this.parent,A=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){P===this?this.deferStop=!0:this.active&&(W(this),this.onStop&&this.onStop(),this.active=!1)}}function W(t){const{deps:e}=t;if(e.length){for(let s=0;s<e.length;s++)e[s].delete(t);e.length=0}}function V(t,e){t.effect instanceof z&&(t=t.effect.fn);const n=new z(t);e&&(s(n,e),e.scope&&y(n,e.scope)),e&&e.lazy||n.run();const i=n.run.bind(n);return i.effect=n,i}function N(t){t.effect.stop()}let A=!0;const I=[];function K(){I.push(A),A=!1}function C(){I.push(A),A=!0}function L(){const t=I.pop();A=void 0===t||t}function q(t,e,s){if(A&&P){let e=k.get(t);e||k.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=R()),B(n)}}function B(t,e){let s=!1;O<=x?S(t)||(t.n|=j,s=!m(t)):s=!t.has(P),s&&(t.add(P),P.deps.push(t))}function D(t,e,s,n,i,o){const u=k.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===s&&r(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||s>=t)&&h.push(e)}))}else switch(void 0!==s&&h.push(u.get(s)),e){case"add":r(t)?_(s)&&h.push(u.get("length")):(h.push(u.get(E)),c(t)&&h.push(u.get(M)));break;case"delete":r(t)||(h.push(u.get(E)),c(t)&&h.push(u.get(M)));break;case"set":c(t)&&h.push(u.get(E))}if(1===h.length)h[0]&&F(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);F(R(t))}}function F(t,e){const s=r(t)?t:[...t];for(const n of s)n.computed&&G(n);for(const n of s)n.computed||G(n)}function G(t,e){(t!==P||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const H=t("__proto__,__v_isRef,__isVue"),J=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),Q=T();function T(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Ct(this);for(let e=0,i=this.length;e<i;e++)q(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Ct)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){K();const s=Ct(this)[e].apply(this,t);return L(),s}})),t}function U(t){const e=Ct(this);return q(e,0,t),e.hasOwnProperty(t)}class X{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,s){const n=this._isReadonly,c=this._shallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return c;if("__v_raw"===e&&s===(n?c?Pt:xt:c?jt:Ot).get(t))return t;const o=r(t);if(!n){if(o&&i(Q,e))return Reflect.get(Q,e,s);if("hasOwnProperty"===e)return U}const a=Reflect.get(t,e,s);return(u(e)?J.has(e):H(e))?a:(n||q(t,0,e),c?a:Gt(a)?o&&_(e)?a:a.value:h(a)?n?zt(a):Et(a):a)}}class Y extends X{constructor(t=!1){super(!1,t)}set(t,e,s,n){let c=t[e];if(At(c)&&Gt(c)&&!Gt(s))return!1;if(!this._shallow&&(It(s)||At(s)||(c=Ct(c),s=Ct(s)),!r(t)&&Gt(c)&&!Gt(s)))return c.value=s,!0;const o=r(t)&&_(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Ct(n)&&(o?d(s,c)&&D(t,"set",e,s):D(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&D(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&J.has(e)||q(t,0,e),s}ownKeys(t){return q(t,0,r(t)?"length":E),Reflect.ownKeys(t)}}class Z extends X{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const $=new Y,tt=new Z,et=new Y(!0),st=new Z(!0),nt=t=>t,it=t=>Reflect.getPrototypeOf(t);function rt(t,e,s=!1,n=!1){const i=Ct(t=t.__v_raw),r=Ct(e);s||(d(e,r)&&q(i,0,e),q(i,0,r));const{has:c}=it(i),o=n?nt:s?Bt:qt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ct(t,e=!1){const s=this.__v_raw,n=Ct(s),i=Ct(t);return e||(d(t,i)&&q(n,0,t),q(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ot(t,e=!1){return t=t.__v_raw,!e&&q(Ct(t),0,E),Reflect.get(t,"size",t)}function ut(t){t=Ct(t);const e=Ct(this);return it(e).has.call(e,t)||(e.add(t),D(e,"add",t,t)),this}function ht(t,e){e=Ct(e);const s=Ct(this),{has:n,get:i}=it(s);let r=n.call(s,t);r||(t=Ct(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?d(e,c)&&D(s,"set",t,e):D(s,"add",t,e),this}function at(t){const e=Ct(this),{has:s,get:n}=it(e);let i=s.call(e,t);i||(t=Ct(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&D(e,"delete",t,void 0),r}function lt(){const t=Ct(this),e=0!==t.size,s=t.clear();return e&&D(t,"clear",void 0,void 0),s}function ft(t,e){return function(s,n){const i=this,r=i.__v_raw,c=Ct(r),o=e?nt:t?Bt:qt;return!t&&q(c,0,E),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function _t(t,e,s){return function(...n){const i=this.__v_raw,r=Ct(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...n),l=s?nt:e?Bt:qt;return!e&&q(r,0,h?M:E),{next(){const{value:t,done:e}=a.next();return e?{value:t,done:e}:{value:u?[l(t[0]),l(t[1])]:l(t),done:e}},[Symbol.iterator](){return this}}}}function dt(t){return function(...e){return"delete"!==t&&this}}function pt(){const t={get(t){return rt(this,t)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!1)},e={get(t){return rt(this,t,!1,!0)},get size(){return ot(this)},has:ct,add:ut,set:ht,delete:at,clear:lt,forEach:ft(!1,!0)},s={get(t){return rt(this,t,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!1)},n={get(t){return rt(this,t,!0,!0)},get size(){return ot(this,!0)},has(t){return ct.call(this,t,!0)},add:dt("add"),set:dt("set"),delete:dt("delete"),clear:dt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=_t(i,!1,!1),s[i]=_t(i,!0,!1),e[i]=_t(i,!1,!0),n[i]=_t(i,!0,!0)})),[t,s,e,n]}const[vt,gt,yt,wt]=pt();function bt(t,e){const s=e?t?wt:yt:t?gt:vt;return(e,n,r)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(i(s,n)&&n in e?s:e,n,r)}const Rt={get:bt(!1,!1)},mt={get:bt(!1,!0)},St={get:bt(!0,!1)},kt={get:bt(!0,!0)},Ot=new WeakMap,jt=new WeakMap,xt=new WeakMap,Pt=new WeakMap;function Et(t){return At(t)?t:Vt(t,!1,$,Rt,Ot)}function Mt(t){return Vt(t,!1,et,mt,jt)}function zt(t){return Vt(t,!0,tt,St,xt)}function Wt(t){return Vt(t,!0,st,kt,Pt)}function Vt(t,e,s,n,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__v_skip||!Object.isExtensible(o)?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(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function Nt(t){return At(t)?Nt(t.__v_raw):!(!t||!t.__v_isReactive)}function At(t){return!(!t||!t.__v_isReadonly)}function It(t){return!(!t||!t.__v_isShallow)}function Kt(t){return Nt(t)||At(t)}function Ct(t){const e=t&&t.__v_raw;return e?Ct(e):t}function Lt(t){return((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t}const qt=t=>h(t)?Et(t):t,Bt=t=>h(t)?zt(t):t;function Dt(t){A&&P&&B((t=Ct(t)).dep||(t.dep=R()))}function Ft(t,e){const s=(t=Ct(t)).dep;s&&F(s)}function Gt(t){return!(!t||!0!==t.__v_isRef)}function Ht(t){return Qt(t,!1)}function Jt(t){return Qt(t,!0)}function Qt(t,e){return Gt(t)?t:new Tt(t,e)}class Tt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Ct(t),this._value=e?t:qt(t)}get value(){return Dt(this),this._value}set value(t){const e=this.__v_isShallow||It(t)||At(t);t=e?t:Ct(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:qt(t),Ft(this))}}function Ut(t){Ft(t)}function Xt(t){return Gt(t)?t.value:t}function Yt(t){return o(t)?t():Xt(t)}const Zt={get:(t,e,s)=>Xt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Gt(i)&&!Gt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function $t(t){return Nt(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:s}=t((()=>Dt(this)),(()=>Ft(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function se(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=ce(t,s);return e}class ne{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Ct(this._object),e=this._key,null==(s=k.get(t))?void 0:s.get(e);var t,e,s}}class ie{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function re(t,e,s){return Gt(t)?t:o(t)?new ie(t):h(t)&&arguments.length>1?ce(t,e,s):Ht(t)}function ce(t,e,s){const n=t[e];return Gt(n)?n:new ne(t,e,s)}class oe{constructor(t,e,s,n){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new z(t,(()=>{this._dirty||(this._dirty=!0,Ft(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=s}get value(){const t=Ct(this);return Dt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ue(t,s,n=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new oe(i,r,c||!r,n)}const he=Promise.resolve(),ae=[];let le=!1;const fe=()=>{for(let t=0;t<ae.length;t++)ae[t]();ae.length=0,le=!1};class _e{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.__v_isReadonly=!0;let s=!1,n=!1;this.effect=new z(t,(t=>{if(this.dep){if(t)e=this._value,s=!0;else if(!n){const t=s?e:this._value;n=!0,s=!1,ae.push((()=>{this.effect.active&&this._get()!==t&&Ft(this),n=!1})),le||(le=!0,he.then(fe))}for(const t of this.dep)t.computed instanceof _e&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=this}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Dt(this),Ct(this)._get()}}function de(t){return new _e(t)}export{v as EffectScope,E as ITERATE_KEY,z as ReactiveEffect,ue as computed,ee as customRef,de as deferredComputed,V as effect,g as effectScope,C as enableTracking,w as getCurrentScope,Kt as isProxy,Nt as isReactive,At as isReadonly,Gt as isRef,It as isShallow,Lt as markRaw,b as onScopeDispose,K as pauseTracking,$t as proxyRefs,Et as reactive,zt as readonly,Ht as ref,L as resetTracking,Mt as shallowReactive,Wt as shallowReadonly,Jt as shallowRef,N as stop,Ct as toRaw,re as toRef,se as toRefs,Yt as toValue,q as track,D as trigger,Ut as triggerRef,Xt as unref};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extend, isArray, isMap, isIntegerKey, hasOwn,
|
|
1
|
+
import { extend, isArray, isMap, isIntegerKey, isSymbol, hasOwn, hasChanged, isObject, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared';
|
|
2
2
|
|
|
3
3
|
function warn(msg, ...args) {
|
|
4
4
|
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
@@ -39,7 +39,7 @@ class EffectScope {
|
|
|
39
39
|
} finally {
|
|
40
40
|
activeEffectScope = currentEffectScope;
|
|
41
41
|
}
|
|
42
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
42
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
43
43
|
warn(`cannot run an inactive effect scope.`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -97,7 +97,7 @@ function getCurrentScope() {
|
|
|
97
97
|
function onScopeDispose(fn) {
|
|
98
98
|
if (activeEffectScope) {
|
|
99
99
|
activeEffectScope.cleanups.push(fn);
|
|
100
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
100
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
101
101
|
warn(
|
|
102
102
|
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
103
103
|
);
|
|
@@ -142,8 +142,8 @@ let effectTrackDepth = 0;
|
|
|
142
142
|
let trackOpBit = 1;
|
|
143
143
|
const maxMarkerBits = 30;
|
|
144
144
|
let activeEffect;
|
|
145
|
-
const ITERATE_KEY = Symbol(process.env.NODE_ENV !== "production" ? "iterate" : "");
|
|
146
|
-
const MAP_KEY_ITERATE_KEY = Symbol(process.env.NODE_ENV !== "production" ? "Map key iterate" : "");
|
|
145
|
+
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
|
|
146
|
+
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
|
|
147
147
|
class ReactiveEffect {
|
|
148
148
|
constructor(fn, scheduler = null, scope) {
|
|
149
149
|
this.fn = fn;
|
|
@@ -211,7 +211,7 @@ function cleanupEffect(effect2) {
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
function effect(fn, options) {
|
|
214
|
-
if (fn.effect) {
|
|
214
|
+
if (fn.effect instanceof ReactiveEffect) {
|
|
215
215
|
fn = fn.effect.fn;
|
|
216
216
|
}
|
|
217
217
|
const _effect = new ReactiveEffect(fn);
|
|
@@ -254,7 +254,7 @@ function track(target, type, key) {
|
|
|
254
254
|
if (!dep) {
|
|
255
255
|
depsMap.set(key, dep = createDep());
|
|
256
256
|
}
|
|
257
|
-
const eventInfo = process.env.NODE_ENV !== "production" ? { effect: activeEffect, target, type, key } : void 0;
|
|
257
|
+
const eventInfo = !!(process.env.NODE_ENV !== "production") ? { effect: activeEffect, target, type, key } : void 0;
|
|
258
258
|
trackEffects(dep, eventInfo);
|
|
259
259
|
}
|
|
260
260
|
}
|
|
@@ -271,7 +271,7 @@ function trackEffects(dep, debuggerEventExtraInfo) {
|
|
|
271
271
|
if (shouldTrack2) {
|
|
272
272
|
dep.add(activeEffect);
|
|
273
273
|
activeEffect.deps.push(dep);
|
|
274
|
-
if (process.env.NODE_ENV !== "production" && activeEffect.onTrack) {
|
|
274
|
+
if (!!(process.env.NODE_ENV !== "production") && activeEffect.onTrack) {
|
|
275
275
|
activeEffect.onTrack(
|
|
276
276
|
extend(
|
|
277
277
|
{
|
|
@@ -328,10 +328,10 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
328
328
|
break;
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
const eventInfo = process.env.NODE_ENV !== "production" ? { target, type, key, newValue, oldValue, oldTarget } : void 0;
|
|
331
|
+
const eventInfo = !!(process.env.NODE_ENV !== "production") ? { target, type, key, newValue, oldValue, oldTarget } : void 0;
|
|
332
332
|
if (deps.length === 1) {
|
|
333
333
|
if (deps[0]) {
|
|
334
|
-
if (process.env.NODE_ENV !== "production") {
|
|
334
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
335
335
|
triggerEffects(deps[0], eventInfo);
|
|
336
336
|
} else {
|
|
337
337
|
triggerEffects(deps[0]);
|
|
@@ -344,7 +344,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
344
344
|
effects.push(...dep);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
if (process.env.NODE_ENV !== "production") {
|
|
347
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
348
348
|
triggerEffects(createDep(effects), eventInfo);
|
|
349
349
|
} else {
|
|
350
350
|
triggerEffects(createDep(effects));
|
|
@@ -366,7 +366,7 @@ function triggerEffects(dep, debuggerEventExtraInfo) {
|
|
|
366
366
|
}
|
|
367
367
|
function triggerEffect(effect2, debuggerEventExtraInfo) {
|
|
368
368
|
if (effect2 !== activeEffect || effect2.allowRecurse) {
|
|
369
|
-
if (process.env.NODE_ENV !== "production" && effect2.onTrigger) {
|
|
369
|
+
if (!!(process.env.NODE_ENV !== "production") && effect2.onTrigger) {
|
|
370
370
|
effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
371
371
|
}
|
|
372
372
|
if (effect2.scheduler) {
|
|
@@ -385,10 +385,6 @@ const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`
|
|
|
385
385
|
const builtInSymbols = new Set(
|
|
386
386
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
387
387
|
);
|
|
388
|
-
const get$1 = /* @__PURE__ */ createGetter();
|
|
389
|
-
const shallowGet = /* @__PURE__ */ createGetter(false, true);
|
|
390
|
-
const readonlyGet = /* @__PURE__ */ createGetter(true);
|
|
391
|
-
const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
|
|
392
388
|
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
393
389
|
function createArrayInstrumentations() {
|
|
394
390
|
const instrumentations = {};
|
|
@@ -421,8 +417,13 @@ function hasOwnProperty(key) {
|
|
|
421
417
|
track(obj, "has", key);
|
|
422
418
|
return obj.hasOwnProperty(key);
|
|
423
419
|
}
|
|
424
|
-
|
|
425
|
-
|
|
420
|
+
class BaseReactiveHandler {
|
|
421
|
+
constructor(_isReadonly = false, _shallow = false) {
|
|
422
|
+
this._isReadonly = _isReadonly;
|
|
423
|
+
this._shallow = _shallow;
|
|
424
|
+
}
|
|
425
|
+
get(target, key, receiver) {
|
|
426
|
+
const isReadonly2 = this._isReadonly, shallow = this._shallow;
|
|
426
427
|
if (key === "__v_isReactive") {
|
|
427
428
|
return !isReadonly2;
|
|
428
429
|
} else if (key === "__v_isReadonly") {
|
|
@@ -458,17 +459,18 @@ function createGetter(isReadonly2 = false, shallow = false) {
|
|
|
458
459
|
return isReadonly2 ? readonly(res) : reactive(res);
|
|
459
460
|
}
|
|
460
461
|
return res;
|
|
461
|
-
}
|
|
462
|
+
}
|
|
462
463
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
464
|
+
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
465
|
+
constructor(shallow = false) {
|
|
466
|
+
super(false, shallow);
|
|
467
|
+
}
|
|
468
|
+
set(target, key, value, receiver) {
|
|
467
469
|
let oldValue = target[key];
|
|
468
470
|
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
|
|
469
471
|
return false;
|
|
470
472
|
}
|
|
471
|
-
if (!
|
|
473
|
+
if (!this._shallow) {
|
|
472
474
|
if (!isShallow(value) && !isReadonly(value)) {
|
|
473
475
|
oldValue = toRaw(oldValue);
|
|
474
476
|
value = toRaw(value);
|
|
@@ -488,48 +490,47 @@ function createSetter(shallow = false) {
|
|
|
488
490
|
}
|
|
489
491
|
}
|
|
490
492
|
return result;
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
function deleteProperty(target, key) {
|
|
494
|
-
const hadKey = hasOwn(target, key);
|
|
495
|
-
const oldValue = target[key];
|
|
496
|
-
const result = Reflect.deleteProperty(target, key);
|
|
497
|
-
if (result && hadKey) {
|
|
498
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
499
493
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
494
|
+
deleteProperty(target, key) {
|
|
495
|
+
const hadKey = hasOwn(target, key);
|
|
496
|
+
const oldValue = target[key];
|
|
497
|
+
const result = Reflect.deleteProperty(target, key);
|
|
498
|
+
if (result && hadKey) {
|
|
499
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
500
|
+
}
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
has(target, key) {
|
|
504
|
+
const result = Reflect.has(target, key);
|
|
505
|
+
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
506
|
+
track(target, "has", key);
|
|
507
|
+
}
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
ownKeys(target) {
|
|
511
|
+
track(
|
|
512
|
+
target,
|
|
513
|
+
"iterate",
|
|
514
|
+
isArray(target) ? "length" : ITERATE_KEY
|
|
515
|
+
);
|
|
516
|
+
return Reflect.ownKeys(target);
|
|
506
517
|
}
|
|
507
|
-
return result;
|
|
508
|
-
}
|
|
509
|
-
function ownKeys(target) {
|
|
510
|
-
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
511
|
-
return Reflect.ownKeys(target);
|
|
512
518
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
has: has$1,
|
|
518
|
-
ownKeys
|
|
519
|
-
};
|
|
520
|
-
const readonlyHandlers = {
|
|
521
|
-
get: readonlyGet,
|
|
519
|
+
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
520
|
+
constructor(shallow = false) {
|
|
521
|
+
super(true, shallow);
|
|
522
|
+
}
|
|
522
523
|
set(target, key) {
|
|
523
|
-
if (process.env.NODE_ENV !== "production") {
|
|
524
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
524
525
|
warn(
|
|
525
526
|
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
526
527
|
target
|
|
527
528
|
);
|
|
528
529
|
}
|
|
529
530
|
return true;
|
|
530
|
-
}
|
|
531
|
+
}
|
|
531
532
|
deleteProperty(target, key) {
|
|
532
|
-
if (process.env.NODE_ENV !== "production") {
|
|
533
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
533
534
|
warn(
|
|
534
535
|
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
535
536
|
target
|
|
@@ -537,22 +538,13 @@ const readonlyHandlers = {
|
|
|
537
538
|
}
|
|
538
539
|
return true;
|
|
539
540
|
}
|
|
540
|
-
}
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
get: shallowGet,
|
|
546
|
-
set: shallowSet
|
|
547
|
-
}
|
|
548
|
-
);
|
|
549
|
-
const shallowReadonlyHandlers = /* @__PURE__ */ extend(
|
|
550
|
-
{},
|
|
551
|
-
readonlyHandlers,
|
|
552
|
-
{
|
|
553
|
-
get: shallowReadonlyGet
|
|
554
|
-
}
|
|
541
|
+
}
|
|
542
|
+
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
543
|
+
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
544
|
+
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
|
|
545
|
+
true
|
|
555
546
|
);
|
|
547
|
+
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
556
548
|
|
|
557
549
|
const toShallow = (value) => value;
|
|
558
550
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
@@ -561,7 +553,7 @@ function get(target, key, isReadonly = false, isShallow = false) {
|
|
|
561
553
|
const rawTarget = toRaw(target);
|
|
562
554
|
const rawKey = toRaw(key);
|
|
563
555
|
if (!isReadonly) {
|
|
564
|
-
if (key
|
|
556
|
+
if (hasChanged(key, rawKey)) {
|
|
565
557
|
track(rawTarget, "get", key);
|
|
566
558
|
}
|
|
567
559
|
track(rawTarget, "get", rawKey);
|
|
@@ -581,7 +573,7 @@ function has(key, isReadonly = false) {
|
|
|
581
573
|
const rawTarget = toRaw(target);
|
|
582
574
|
const rawKey = toRaw(key);
|
|
583
575
|
if (!isReadonly) {
|
|
584
|
-
if (key
|
|
576
|
+
if (hasChanged(key, rawKey)) {
|
|
585
577
|
track(rawTarget, "has", key);
|
|
586
578
|
}
|
|
587
579
|
track(rawTarget, "has", rawKey);
|
|
@@ -612,7 +604,7 @@ function set(key, value) {
|
|
|
612
604
|
if (!hadKey) {
|
|
613
605
|
key = toRaw(key);
|
|
614
606
|
hadKey = has2.call(target, key);
|
|
615
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
607
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
616
608
|
checkIdentityKeys(target, has2, key);
|
|
617
609
|
}
|
|
618
610
|
const oldValue = get2.call(target, key);
|
|
@@ -631,7 +623,7 @@ function deleteEntry(key) {
|
|
|
631
623
|
if (!hadKey) {
|
|
632
624
|
key = toRaw(key);
|
|
633
625
|
hadKey = has2.call(target, key);
|
|
634
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
626
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
635
627
|
checkIdentityKeys(target, has2, key);
|
|
636
628
|
}
|
|
637
629
|
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
@@ -644,7 +636,7 @@ function deleteEntry(key) {
|
|
|
644
636
|
function clear() {
|
|
645
637
|
const target = toRaw(this);
|
|
646
638
|
const hadItems = target.size !== 0;
|
|
647
|
-
const oldTarget = process.env.NODE_ENV !== "production" ? isMap(target) ? new Map(target) : new Set(target) : void 0;
|
|
639
|
+
const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
|
|
648
640
|
const result = target.clear();
|
|
649
641
|
if (hadItems) {
|
|
650
642
|
trigger(target, "clear", void 0, void 0, oldTarget);
|
|
@@ -695,7 +687,7 @@ function createIterableMethod(method, isReadonly, isShallow) {
|
|
|
695
687
|
}
|
|
696
688
|
function createReadonlyMethod(type) {
|
|
697
689
|
return function(...args) {
|
|
698
|
-
if (process.env.NODE_ENV !== "production") {
|
|
690
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
699
691
|
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
700
692
|
console.warn(
|
|
701
693
|
`${capitalize(type)} operation ${key}failed: target is readonly.`,
|
|
@@ -903,7 +895,7 @@ function shallowReadonly(target) {
|
|
|
903
895
|
}
|
|
904
896
|
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
905
897
|
if (!isObject(target)) {
|
|
906
|
-
if (process.env.NODE_ENV !== "production") {
|
|
898
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
907
899
|
console.warn(`value cannot be made reactive: ${String(target)}`);
|
|
908
900
|
}
|
|
909
901
|
return target;
|
|
@@ -955,7 +947,7 @@ const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
|
955
947
|
function trackRefValue(ref2) {
|
|
956
948
|
if (shouldTrack && activeEffect) {
|
|
957
949
|
ref2 = toRaw(ref2);
|
|
958
|
-
if (process.env.NODE_ENV !== "production") {
|
|
950
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
959
951
|
trackEffects(ref2.dep || (ref2.dep = createDep()), {
|
|
960
952
|
target: ref2,
|
|
961
953
|
type: "get",
|
|
@@ -970,7 +962,7 @@ function triggerRefValue(ref2, newVal) {
|
|
|
970
962
|
ref2 = toRaw(ref2);
|
|
971
963
|
const dep = ref2.dep;
|
|
972
964
|
if (dep) {
|
|
973
|
-
if (process.env.NODE_ENV !== "production") {
|
|
965
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
974
966
|
triggerEffects(dep, {
|
|
975
967
|
target: ref2,
|
|
976
968
|
type: "set",
|
|
@@ -1020,7 +1012,7 @@ class RefImpl {
|
|
|
1020
1012
|
}
|
|
1021
1013
|
}
|
|
1022
1014
|
function triggerRef(ref2) {
|
|
1023
|
-
triggerRefValue(ref2, process.env.NODE_ENV !== "production" ? ref2.value : void 0);
|
|
1015
|
+
triggerRefValue(ref2, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
|
|
1024
1016
|
}
|
|
1025
1017
|
function unref(ref2) {
|
|
1026
1018
|
return isRef(ref2) ? ref2.value : ref2;
|
|
@@ -1065,7 +1057,7 @@ function customRef(factory) {
|
|
|
1065
1057
|
return new CustomRefImpl(factory);
|
|
1066
1058
|
}
|
|
1067
1059
|
function toRefs(object) {
|
|
1068
|
-
if (process.env.NODE_ENV !== "production" && !isProxy(object)) {
|
|
1060
|
+
if (!!(process.env.NODE_ENV !== "production") && !isProxy(object)) {
|
|
1069
1061
|
console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
|
1070
1062
|
}
|
|
1071
1063
|
const ret = isArray(object) ? new Array(object.length) : {};
|
|
@@ -1115,11 +1107,7 @@ function toRef(source, key, defaultValue) {
|
|
|
1115
1107
|
}
|
|
1116
1108
|
function propertyToRef(source, key, defaultValue) {
|
|
1117
1109
|
const val = source[key];
|
|
1118
|
-
return isRef(val) ? val : new ObjectRefImpl(
|
|
1119
|
-
source,
|
|
1120
|
-
key,
|
|
1121
|
-
defaultValue
|
|
1122
|
-
);
|
|
1110
|
+
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1123
1111
|
}
|
|
1124
1112
|
|
|
1125
1113
|
class ComputedRefImpl {
|
|
@@ -1158,7 +1146,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1158
1146
|
const onlyGetter = isFunction(getterOrOptions);
|
|
1159
1147
|
if (onlyGetter) {
|
|
1160
1148
|
getter = getterOrOptions;
|
|
1161
|
-
setter = process.env.NODE_ENV !== "production" ? () => {
|
|
1149
|
+
setter = !!(process.env.NODE_ENV !== "production") ? () => {
|
|
1162
1150
|
console.warn("Write operation failed: computed value is readonly");
|
|
1163
1151
|
} : NOOP;
|
|
1164
1152
|
} else {
|
|
@@ -1166,7 +1154,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1166
1154
|
setter = getterOrOptions.set;
|
|
1167
1155
|
}
|
|
1168
1156
|
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1169
|
-
if (process.env.NODE_ENV !== "production" && debugOptions && !isSSR) {
|
|
1157
|
+
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
|
|
1170
1158
|
cRef.effect.onTrack = debugOptions.onTrack;
|
|
1171
1159
|
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1172
1160
|
}
|