@vue/reactivity 3.2.45 → 3.2.46
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/README.md +1 -1
- package/dist/reactivity.cjs.js +55 -36
- package/dist/reactivity.cjs.prod.js +55 -36
- package/dist/reactivity.d.ts +2 -1
- package/dist/reactivity.esm-browser.js +57 -43
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +57 -36
- package/dist/reactivity.global.js +58 -46
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
|
@@ -14,12 +14,9 @@ function makeMap(str, expectsLowerCase) {
|
|
|
14
14
|
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
Object.freeze({})
|
|
18
|
-
;
|
|
19
|
-
Object.freeze([]) ;
|
|
20
17
|
const extend = Object.assign;
|
|
21
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
22
|
-
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
18
|
+
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
19
|
+
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
23
20
|
const isArray = Array.isArray;
|
|
24
21
|
const isMap = (val) => toTypeString(val) === '[object Map]';
|
|
25
22
|
const isFunction = (val) => typeof val === 'function';
|
|
@@ -56,10 +53,6 @@ const def = (obj, key, value) => {
|
|
|
56
53
|
value
|
|
57
54
|
});
|
|
58
55
|
};
|
|
59
|
-
const toNumber = (val) => {
|
|
60
|
-
const n = parseFloat(val);
|
|
61
|
-
return isNaN(n) ? val : n;
|
|
62
|
-
};
|
|
63
56
|
|
|
64
57
|
function warn(msg, ...args) {
|
|
65
58
|
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
@@ -72,7 +65,7 @@ class EffectScope {
|
|
|
72
65
|
/**
|
|
73
66
|
* @internal
|
|
74
67
|
*/
|
|
75
|
-
this.
|
|
68
|
+
this._active = true;
|
|
76
69
|
/**
|
|
77
70
|
* @internal
|
|
78
71
|
*/
|
|
@@ -87,8 +80,11 @@ class EffectScope {
|
|
|
87
80
|
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
88
81
|
}
|
|
89
82
|
}
|
|
83
|
+
get active() {
|
|
84
|
+
return this._active;
|
|
85
|
+
}
|
|
90
86
|
run(fn) {
|
|
91
|
-
if (this.
|
|
87
|
+
if (this._active) {
|
|
92
88
|
const currentEffectScope = activeEffectScope;
|
|
93
89
|
try {
|
|
94
90
|
activeEffectScope = this;
|
|
@@ -117,7 +113,7 @@ class EffectScope {
|
|
|
117
113
|
activeEffectScope = this.parent;
|
|
118
114
|
}
|
|
119
115
|
stop(fromParent) {
|
|
120
|
-
if (this.
|
|
116
|
+
if (this._active) {
|
|
121
117
|
let i, l;
|
|
122
118
|
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
123
119
|
this.effects[i].stop();
|
|
@@ -140,7 +136,7 @@ class EffectScope {
|
|
|
140
136
|
}
|
|
141
137
|
}
|
|
142
138
|
this.parent = undefined;
|
|
143
|
-
this.
|
|
139
|
+
this._active = false;
|
|
144
140
|
}
|
|
145
141
|
}
|
|
146
142
|
}
|
|
@@ -365,7 +361,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
365
361
|
deps = [...depsMap.values()];
|
|
366
362
|
}
|
|
367
363
|
else if (key === 'length' && isArray(target)) {
|
|
368
|
-
const newLength =
|
|
364
|
+
const newLength = Number(newValue);
|
|
369
365
|
depsMap.forEach((dep, key) => {
|
|
370
366
|
if (key === 'length' || key >= newLength) {
|
|
371
367
|
deps.push(dep);
|
|
@@ -454,6 +450,10 @@ function triggerEffect(effect, debuggerEventExtraInfo) {
|
|
|
454
450
|
}
|
|
455
451
|
}
|
|
456
452
|
}
|
|
453
|
+
function getDepFromReactive(object, key) {
|
|
454
|
+
var _a;
|
|
455
|
+
return (_a = targetMap.get(object)) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
456
|
+
}
|
|
457
457
|
|
|
458
458
|
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
459
459
|
const builtInSymbols = new Set(
|
|
@@ -465,7 +465,7 @@ Object.getOwnPropertyNames(Symbol)
|
|
|
465
465
|
.filter(key => key !== 'arguments' && key !== 'caller')
|
|
466
466
|
.map(key => Symbol[key])
|
|
467
467
|
.filter(isSymbol));
|
|
468
|
-
const get = /*#__PURE__*/ createGetter();
|
|
468
|
+
const get$1 = /*#__PURE__*/ createGetter();
|
|
469
469
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
470
470
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
471
471
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
@@ -499,6 +499,11 @@ function createArrayInstrumentations() {
|
|
|
499
499
|
});
|
|
500
500
|
return instrumentations;
|
|
501
501
|
}
|
|
502
|
+
function hasOwnProperty(key) {
|
|
503
|
+
const obj = toRaw(this);
|
|
504
|
+
track(obj, "has" /* TrackOpTypes.HAS */, key);
|
|
505
|
+
return obj.hasOwnProperty(key);
|
|
506
|
+
}
|
|
502
507
|
function createGetter(isReadonly = false, shallow = false) {
|
|
503
508
|
return function get(target, key, receiver) {
|
|
504
509
|
if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
|
|
@@ -522,8 +527,13 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
522
527
|
return target;
|
|
523
528
|
}
|
|
524
529
|
const targetIsArray = isArray(target);
|
|
525
|
-
if (!isReadonly
|
|
526
|
-
|
|
530
|
+
if (!isReadonly) {
|
|
531
|
+
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
532
|
+
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
533
|
+
}
|
|
534
|
+
if (key === 'hasOwnProperty') {
|
|
535
|
+
return hasOwnProperty;
|
|
536
|
+
}
|
|
527
537
|
}
|
|
528
538
|
const res = Reflect.get(target, key, receiver);
|
|
529
539
|
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
@@ -548,7 +558,7 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
548
558
|
return res;
|
|
549
559
|
};
|
|
550
560
|
}
|
|
551
|
-
const set = /*#__PURE__*/ createSetter();
|
|
561
|
+
const set$1 = /*#__PURE__*/ createSetter();
|
|
552
562
|
const shallowSet = /*#__PURE__*/ createSetter(true);
|
|
553
563
|
function createSetter(shallow = false) {
|
|
554
564
|
return function set(target, key, value, receiver) {
|
|
@@ -591,7 +601,7 @@ function deleteProperty(target, key) {
|
|
|
591
601
|
}
|
|
592
602
|
return result;
|
|
593
603
|
}
|
|
594
|
-
function has(target, key) {
|
|
604
|
+
function has$1(target, key) {
|
|
595
605
|
const result = Reflect.has(target, key);
|
|
596
606
|
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
597
607
|
track(target, "has" /* TrackOpTypes.HAS */, key);
|
|
@@ -603,10 +613,10 @@ function ownKeys(target) {
|
|
|
603
613
|
return Reflect.ownKeys(target);
|
|
604
614
|
}
|
|
605
615
|
const mutableHandlers = {
|
|
606
|
-
get,
|
|
607
|
-
set,
|
|
616
|
+
get: get$1,
|
|
617
|
+
set: set$1,
|
|
608
618
|
deleteProperty,
|
|
609
|
-
has,
|
|
619
|
+
has: has$1,
|
|
610
620
|
ownKeys
|
|
611
621
|
};
|
|
612
622
|
const readonlyHandlers = {
|
|
@@ -637,7 +647,7 @@ const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
|
|
|
637
647
|
|
|
638
648
|
const toShallow = (value) => value;
|
|
639
649
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
640
|
-
function get
|
|
650
|
+
function get(target, key, isReadonly = false, isShallow = false) {
|
|
641
651
|
// #1772: readonly(reactive(Map)) should return readonly + reactive version
|
|
642
652
|
// of the value
|
|
643
653
|
target = target["__v_raw" /* ReactiveFlags.RAW */];
|
|
@@ -663,7 +673,7 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
|
|
|
663
673
|
target.get(key);
|
|
664
674
|
}
|
|
665
675
|
}
|
|
666
|
-
function has
|
|
676
|
+
function has(key, isReadonly = false) {
|
|
667
677
|
const target = this["__v_raw" /* ReactiveFlags.RAW */];
|
|
668
678
|
const rawTarget = toRaw(target);
|
|
669
679
|
const rawKey = toRaw(key);
|
|
@@ -693,7 +703,7 @@ function add(value) {
|
|
|
693
703
|
}
|
|
694
704
|
return this;
|
|
695
705
|
}
|
|
696
|
-
function set
|
|
706
|
+
function set(key, value) {
|
|
697
707
|
value = toRaw(value);
|
|
698
708
|
const target = toRaw(this);
|
|
699
709
|
const { has, get } = getProto(target);
|
|
@@ -806,41 +816,41 @@ function createReadonlyMethod(type) {
|
|
|
806
816
|
function createInstrumentations() {
|
|
807
817
|
const mutableInstrumentations = {
|
|
808
818
|
get(key) {
|
|
809
|
-
return get
|
|
819
|
+
return get(this, key);
|
|
810
820
|
},
|
|
811
821
|
get size() {
|
|
812
822
|
return size(this);
|
|
813
823
|
},
|
|
814
|
-
has
|
|
824
|
+
has,
|
|
815
825
|
add,
|
|
816
|
-
set
|
|
826
|
+
set,
|
|
817
827
|
delete: deleteEntry,
|
|
818
828
|
clear,
|
|
819
829
|
forEach: createForEach(false, false)
|
|
820
830
|
};
|
|
821
831
|
const shallowInstrumentations = {
|
|
822
832
|
get(key) {
|
|
823
|
-
return get
|
|
833
|
+
return get(this, key, false, true);
|
|
824
834
|
},
|
|
825
835
|
get size() {
|
|
826
836
|
return size(this);
|
|
827
837
|
},
|
|
828
|
-
has
|
|
838
|
+
has,
|
|
829
839
|
add,
|
|
830
|
-
set
|
|
840
|
+
set,
|
|
831
841
|
delete: deleteEntry,
|
|
832
842
|
clear,
|
|
833
843
|
forEach: createForEach(false, true)
|
|
834
844
|
};
|
|
835
845
|
const readonlyInstrumentations = {
|
|
836
846
|
get(key) {
|
|
837
|
-
return get
|
|
847
|
+
return get(this, key, true);
|
|
838
848
|
},
|
|
839
849
|
get size() {
|
|
840
850
|
return size(this, true);
|
|
841
851
|
},
|
|
842
852
|
has(key) {
|
|
843
|
-
return has
|
|
853
|
+
return has.call(this, key, true);
|
|
844
854
|
},
|
|
845
855
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
846
856
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -850,13 +860,13 @@ function createInstrumentations() {
|
|
|
850
860
|
};
|
|
851
861
|
const shallowReadonlyInstrumentations = {
|
|
852
862
|
get(key) {
|
|
853
|
-
return get
|
|
863
|
+
return get(this, key, true, true);
|
|
854
864
|
},
|
|
855
865
|
get size() {
|
|
856
866
|
return size(this, true);
|
|
857
867
|
},
|
|
858
868
|
has(key) {
|
|
859
|
-
return has
|
|
869
|
+
return has.call(this, key, true);
|
|
860
870
|
},
|
|
861
871
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
862
872
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -1047,9 +1057,10 @@ function trackRefValue(ref) {
|
|
|
1047
1057
|
}
|
|
1048
1058
|
function triggerRefValue(ref, newVal) {
|
|
1049
1059
|
ref = toRaw(ref);
|
|
1050
|
-
|
|
1060
|
+
const dep = ref.dep;
|
|
1061
|
+
if (dep) {
|
|
1051
1062
|
{
|
|
1052
|
-
triggerEffects(
|
|
1063
|
+
triggerEffects(dep, {
|
|
1053
1064
|
target: ref,
|
|
1054
1065
|
type: "set" /* TriggerOpTypes.SET */,
|
|
1055
1066
|
key: 'value',
|
|
@@ -1161,6 +1172,9 @@ class ObjectRefImpl {
|
|
|
1161
1172
|
set value(newVal) {
|
|
1162
1173
|
this._object[this._key] = newVal;
|
|
1163
1174
|
}
|
|
1175
|
+
get dep() {
|
|
1176
|
+
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1177
|
+
}
|
|
1164
1178
|
}
|
|
1165
1179
|
function toRef(object, key, defaultValue) {
|
|
1166
1180
|
const val = object[key];
|
|
@@ -1169,13 +1183,13 @@ function toRef(object, key, defaultValue) {
|
|
|
1169
1183
|
: new ObjectRefImpl(object, key, defaultValue);
|
|
1170
1184
|
}
|
|
1171
1185
|
|
|
1172
|
-
var _a;
|
|
1186
|
+
var _a$1;
|
|
1173
1187
|
class ComputedRefImpl {
|
|
1174
1188
|
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1175
1189
|
this._setter = _setter;
|
|
1176
1190
|
this.dep = undefined;
|
|
1177
1191
|
this.__v_isRef = true;
|
|
1178
|
-
this[_a] = false;
|
|
1192
|
+
this[_a$1] = false;
|
|
1179
1193
|
this._dirty = true;
|
|
1180
1194
|
this.effect = new ReactiveEffect(getter, () => {
|
|
1181
1195
|
if (!this._dirty) {
|
|
@@ -1201,7 +1215,7 @@ class ComputedRefImpl {
|
|
|
1201
1215
|
this._setter(newValue);
|
|
1202
1216
|
}
|
|
1203
1217
|
}
|
|
1204
|
-
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1218
|
+
_a$1 = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1205
1219
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1206
1220
|
let getter;
|
|
1207
1221
|
let setter;
|
|
@@ -1225,7 +1239,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1225
1239
|
return cRef;
|
|
1226
1240
|
}
|
|
1227
1241
|
|
|
1228
|
-
var _a
|
|
1242
|
+
var _a;
|
|
1229
1243
|
const tick = /*#__PURE__*/ Promise.resolve();
|
|
1230
1244
|
const queue = [];
|
|
1231
1245
|
let queued = false;
|
|
@@ -1248,7 +1262,7 @@ class DeferredComputedRefImpl {
|
|
|
1248
1262
|
this.dep = undefined;
|
|
1249
1263
|
this._dirty = true;
|
|
1250
1264
|
this.__v_isRef = true;
|
|
1251
|
-
this[_a
|
|
1265
|
+
this[_a] = true;
|
|
1252
1266
|
let compareTarget;
|
|
1253
1267
|
let hasCompareTarget = false;
|
|
1254
1268
|
let scheduled = false;
|
|
@@ -1295,7 +1309,7 @@ class DeferredComputedRefImpl {
|
|
|
1295
1309
|
return toRaw(this)._get();
|
|
1296
1310
|
}
|
|
1297
1311
|
}
|
|
1298
|
-
_a
|
|
1312
|
+
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1299
1313
|
function deferredComputed(getter) {
|
|
1300
1314
|
return new DeferredComputedRefImpl(getter);
|
|
1301
1315
|
}
|
|
@@ -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]"===a(t),o=t=>"symbol"==typeof t,u=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,a=t=>h.call(t),l=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,f=(t,e)=>!Object.is(t,e);let _;class d{constructor(t=!1){this.detached=t,this.active=!0,this.effects=[],this.cleanups=[],this.parent=_,!t&&_&&(this.index=(_.scopes||(_.scopes=[])).push(this)-1)}run(t){if(this.active){const e=_;try{return _=this,t()}finally{_=e}}}on(){_=this}off(){_=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 p(t){return new d(t)}function v(t,e=_){e&&e.active&&e.effects.push(t)}function g(){return _}function y(t){_&&_.cleanups.push(t)}const w=t=>{const e=new Set(t);return e.w=0,e.n=0,e},b=t=>(t.w&k)>0,R=t=>(t.n&k)>0,m=new WeakMap;let S=0,k=1;let j;const O=Symbol(""),x=Symbol("");class E{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,v(this,n)}run(){if(!this.active)return this.fn();let t=j,e=W;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=j,j=this,W=!0,k=1<<++S,S<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=k})(this):P(this),this.fn()}finally{S<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];b(i)&&!R(i)?i.delete(t):e[n++]=i,i.w&=~k,i.n&=~k}e.length=n}})(this),k=1<<--S,j=this.parent,W=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){j===this?this.deferStop=!0:this.active&&(P(this),this.onStop&&this.onStop(),this.active=!1)}}function P(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}function M(t,e){t.effect&&(t=t.effect.fn);const s=new E(t);e&&(n(s,e),e.scope&&v(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i}function z(t){t.effect.stop()}let W=!0;const N=[];function V(){N.push(W),W=!1}function A(){N.push(W),W=!0}function I(){const t=N.pop();W=void 0===t||t}function K(t,e,n){if(W&&j){let e=m.get(t);e||m.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=w()),C(s)}}function C(t,e){let n=!1;S<=30?R(t)||(t.n|=k,n=!b(t)):n=!t.has(j),n&&(t.add(j),j.deps.push(t))}function F(t,e,n,s,i,o){const u=m.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===n&&r(t)){const t=(t=>{const e=parseFloat(t);return isNaN(e)?t:e})(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)?l(n)&&h.push(u.get("length")):(h.push(u.get(O)),c(t)&&h.push(u.get(x)));break;case"delete":r(t)||(h.push(u.get(O)),c(t)&&h.push(u.get(x)));break;case"set":c(t)&&h.push(u.get(O))}if(1===h.length)h[0]&&L(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);L(w(t))}}function L(t,e){const n=r(t)?t:[...t];for(const s of n)s.computed&&q(s);for(const s of n)s.computed||q(s)}function q(t,e){(t!==j||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const B=t("__proto__,__v_isRef,__isVue"),D=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(o)),G=X(),H=X(!1,!0),J=X(!0),Q=X(!0,!0),T=U();function U(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=Ct(this);for(let e=0,i=this.length;e<i;e++)K(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(Ct)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){V();const n=Ct(this)[e].apply(this,t);return I(),n}})),t}function X(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?xt:Ot:e?jt:kt).get(n))return n;const h=r(n);if(!t&&h&&i(T,s))return Reflect.get(T,s,c);const a=Reflect.get(n,s,c);return(o(s)?D.has(s):B(s))?a:(t||K(n,0,s),e?a:Gt(a)?h&&l(s)?a:a.value:u(a)?t?zt(a):Pt(a):a)}}function Y(t=!1){return function(e,n,s,c){let o=e[n];if(At(o)&&Gt(o)&&!Gt(s))return!1;if(!t&&(It(s)||At(s)||(o=Ct(o),s=Ct(s)),!r(e)&&Gt(o)&&!Gt(s)))return o.value=s,!0;const u=r(e)&&l(n)?Number(n)<e.length:i(e,n),h=Reflect.set(e,n,s,c);return e===Ct(c)&&(u?f(s,o)&&F(e,"set",n,s):F(e,"add",n,s)),h}}const Z={get:G,set:Y(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&F(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return o(e)&&D.has(e)||K(t,0,e),n},ownKeys:function(t){return K(t,0,r(t)?"length":O),Reflect.ownKeys(t)}},$={get:J,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},tt=n({},Z,{get:H,set:Y(!0)}),et=n({},$,{get:Q}),nt=t=>t,st=t=>Reflect.getPrototypeOf(t);function it(t,e,n=!1,s=!1){const i=Ct(t=t.__v_raw),r=Ct(e);n||(e!==r&&K(i,0,e),K(i,0,r));const{has:c}=st(i),o=s?nt:n?qt:Lt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function rt(t,e=!1){const n=this.__v_raw,s=Ct(n),i=Ct(t);return e||(t!==i&&K(s,0,t),K(s,0,i)),t===i?n.has(t):n.has(t)||n.has(i)}function ct(t,e=!1){return t=t.__v_raw,!e&&K(Ct(t),0,O),Reflect.get(t,"size",t)}function ot(t){t=Ct(t);const e=Ct(this);return st(e).has.call(e,t)||(e.add(t),F(e,"add",t,t)),this}function ut(t,e){e=Ct(e);const n=Ct(this),{has:s,get:i}=st(n);let r=s.call(n,t);r||(t=Ct(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?f(e,c)&&F(n,"set",t,e):F(n,"add",t,e),this}function ht(t){const e=Ct(this),{has:n,get:s}=st(e);let i=n.call(e,t);i||(t=Ct(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&F(e,"delete",t,void 0),r}function at(){const t=Ct(this),e=0!==t.size,n=t.clear();return e&&F(t,"clear",void 0,void 0),n}function lt(t,e){return function(n,s){const i=this,r=i.__v_raw,c=Ct(r),o=e?nt:t?qt:Lt;return!t&&K(c,0,O),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function ft(t,e,n){return function(...s){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](...s),l=n?nt:e?qt:Lt;return!e&&K(r,0,h?x:O),{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 _t(t){return function(...e){return"delete"!==t&&this}}function dt(){const t={get(t){return it(this,t)},get size(){return ct(this)},has:rt,add:ot,set:ut,delete:ht,clear:at,forEach:lt(!1,!1)},e={get(t){return it(this,t,!1,!0)},get size(){return ct(this)},has:rt,add:ot,set:ut,delete:ht,clear:at,forEach:lt(!1,!0)},n={get(t){return it(this,t,!0)},get size(){return ct(this,!0)},has(t){return rt.call(this,t,!0)},add:_t("add"),set:_t("set"),delete:_t("delete"),clear:_t("clear"),forEach:lt(!0,!1)},s={get(t){return it(this,t,!0,!0)},get size(){return ct(this,!0)},has(t){return rt.call(this,t,!0)},add:_t("add"),set:_t("set"),delete:_t("delete"),clear:_t("clear"),forEach:lt(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=ft(i,!1,!1),n[i]=ft(i,!0,!1),e[i]=ft(i,!1,!0),s[i]=ft(i,!0,!0)})),[t,n,e,s]}const[pt,vt,gt,yt]=dt();function wt(t,e){const n=e?t?yt:gt:t?vt:pt;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 bt={get:wt(!1,!1)},Rt={get:wt(!1,!0)},mt={get:wt(!0,!1)},St={get:wt(!0,!0)},kt=new WeakMap,jt=new WeakMap,Ot=new WeakMap,xt=new WeakMap;function Et(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=>a(t).slice(8,-1))(t))}function Pt(t){return At(t)?t:Nt(t,!1,Z,bt,kt)}function Mt(t){return Nt(t,!1,tt,Rt,jt)}function zt(t){return Nt(t,!0,$,mt,Ot)}function Wt(t){return Nt(t,!0,et,St,xt)}function Nt(t,e,n,s,i){if(!u(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=Et(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function Vt(t){return At(t)?Vt(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 Vt(t)||At(t)}function Ct(t){const e=t&&t.__v_raw;return e?Ct(e):t}function Ft(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Lt=t=>u(t)?Pt(t):t,qt=t=>u(t)?zt(t):t;function Bt(t){W&&j&&C((t=Ct(t)).dep||(t.dep=w()))}function Dt(t,e){(t=Ct(t)).dep&&L(t.dep)}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:Lt(t)}get value(){return Bt(this),this._value}set value(t){const e=this.__v_isShallow||It(t)||At(t);t=e?t:Ct(t),f(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Lt(t),Dt(this))}}function Ut(t){Dt(t)}function Xt(t){return Gt(t)?t.value:t}const Yt={get:(t,e,n)=>Xt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Gt(i)&&!Gt(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};function Zt(t){return Vt(t)?t:new Proxy(t,Yt)}class $t{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>Bt(this)),(()=>Dt(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function te(t){return new $t(t)}function ee(t){const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=se(t,n);return e}class ne{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}}function se(t,e,n){const s=t[e];return Gt(s)?s:new ne(t,e,n)}var ie,re;class ce{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this[ie]=!1,this._dirty=!0,this.effect=new E(t,(()=>{this._dirty||(this._dirty=!0,Dt(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=Ct(this);return Bt(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function oe(t,n,s=!1){let i,r;const c="function"==typeof t;c?(i=t,r=e):(i=t.get,r=t.set);return new ce(i,r,c||!r,s)}ie="__v_isReadonly";const ue=Promise.resolve(),he=[];let ae=!1;const le=()=>{for(let t=0;t<he.length;t++)he[t]();he.length=0,ae=!1};class fe{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this[re]=!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,he.push((()=>{this.effect.active&&this._get()!==t&&Dt(this),s=!1})),ae||(ae=!0,ue.then(le))}for(const t of this.dep)t.computed instanceof fe&&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 Bt(this),Ct(this)._get()}}function _e(t){return new fe(t)}re="__v_isReadonly";export{d as EffectScope,O as ITERATE_KEY,E as ReactiveEffect,oe as computed,te as customRef,_e as deferredComputed,M as effect,p as effectScope,A as enableTracking,g as getCurrentScope,Kt as isProxy,Vt as isReactive,At as isReadonly,Gt as isRef,It as isShallow,Ft as markRaw,y as onScopeDispose,V as pauseTracking,Zt as proxyRefs,Pt as reactive,zt as readonly,Ht as ref,I as resetTracking,Mt as shallowReactive,Wt as shallowReadonly,Jt as shallowRef,z as stop,Ct as toRaw,se as toRef,ee as toRefs,K as track,F as trigger,Ut as triggerRef,Xt as unref};
|
|
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]"===a(t),o=t=>"symbol"==typeof t,u=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,a=t=>h.call(t),l=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,f=(t,e)=>!Object.is(t,e);let _;class d{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=_,!t&&_&&(this.index=(_.scopes||(_.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=_;try{return _=this,t()}finally{_=e}}}on(){_=this}off(){_=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 p(t){return new d(t)}function v(t,e=_){e&&e.active&&e.effects.push(t)}function g(){return _}function y(t){_&&_.cleanups.push(t)}const w=t=>{const e=new Set(t);return e.w=0,e.n=0,e},b=t=>(t.w&k)>0,R=t=>(t.n&k)>0,m=new WeakMap;let S=0,k=1;let O;const j=Symbol(""),x=Symbol("");class P{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,v(this,n)}run(){if(!this.active)return this.fn();let t=O,e=W;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=O,O=this,W=!0,k=1<<++S,S<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=k})(this):E(this),this.fn()}finally{S<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];b(i)&&!R(i)?i.delete(t):e[n++]=i,i.w&=~k,i.n&=~k}e.length=n}})(this),k=1<<--S,O=this.parent,W=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){O===this?this.deferStop=!0:this.active&&(E(this),this.onStop&&this.onStop(),this.active=!1)}}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}}function M(t,e){t.effect&&(t=t.effect.fn);const s=new P(t);e&&(n(s,e),e.scope&&v(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i}function z(t){t.effect.stop()}let W=!0;const V=[];function N(){V.push(W),W=!1}function A(){V.push(W),W=!0}function I(){const t=V.pop();W=void 0===t||t}function K(t,e,n){if(W&&O){let e=m.get(t);e||m.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=w()),C(s)}}function C(t,e){let n=!1;S<=30?R(t)||(t.n|=k,n=!b(t)):n=!t.has(O),n&&(t.add(O),O.deps.push(t))}function L(t,e,n,s,i,o){const u=m.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)?l(n)&&h.push(u.get("length")):(h.push(u.get(j)),c(t)&&h.push(u.get(x)));break;case"delete":r(t)||(h.push(u.get(j)),c(t)&&h.push(u.get(x)));break;case"set":c(t)&&h.push(u.get(j))}if(1===h.length)h[0]&&q(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);q(w(t))}}function q(t,e){const n=r(t)?t:[...t];for(const s of n)s.computed&&B(s);for(const s of n)s.computed||B(s)}function B(t,e){(t!==O||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const D=t("__proto__,__v_isRef,__isVue"),F=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(o)),G=Y(),H=Y(!1,!0),J=Y(!0),Q=Y(!0,!0),T=U();function U(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=Lt(this);for(let e=0,i=this.length;e<i;e++)K(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(Lt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){N();const n=Lt(this)[e].apply(this,t);return I(),n}})),t}function X(t){const e=Lt(this);return K(e,0,t),e.hasOwnProperty(t)}function Y(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?Pt:xt:e?jt:Ot).get(n))return n;const h=r(n);if(!t){if(h&&i(T,s))return Reflect.get(T,s,c);if("hasOwnProperty"===s)return X}const a=Reflect.get(n,s,c);return(o(s)?F.has(s):D(s))?a:(t||K(n,0,s),e?a:Ht(a)?h&&l(s)?a:a.value:u(a)?t?Wt(a):Mt(a):a)}}function Z(t=!1){return function(e,n,s,c){let o=e[n];if(It(o)&&Ht(o)&&!Ht(s))return!1;if(!t&&(Kt(s)||It(s)||(o=Lt(o),s=Lt(s)),!r(e)&&Ht(o)&&!Ht(s)))return o.value=s,!0;const u=r(e)&&l(n)?Number(n)<e.length:i(e,n),h=Reflect.set(e,n,s,c);return e===Lt(c)&&(u?f(s,o)&&L(e,"set",n,s):L(e,"add",n,s)),h}}const $={get:G,set:Z(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&L(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return o(e)&&F.has(e)||K(t,0,e),n},ownKeys:function(t){return K(t,0,r(t)?"length":j),Reflect.ownKeys(t)}},tt={get:J,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},et=n({},$,{get:H,set:Z(!0)}),nt=n({},tt,{get:Q}),st=t=>t,it=t=>Reflect.getPrototypeOf(t);function rt(t,e,n=!1,s=!1){const i=Lt(t=t.__v_raw),r=Lt(e);n||(e!==r&&K(i,0,e),K(i,0,r));const{has:c}=it(i),o=s?st:n?Dt:Bt;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 n=this.__v_raw,s=Lt(n),i=Lt(t);return e||(t!==i&&K(s,0,t),K(s,0,i)),t===i?n.has(t):n.has(t)||n.has(i)}function ot(t,e=!1){return t=t.__v_raw,!e&&K(Lt(t),0,j),Reflect.get(t,"size",t)}function ut(t){t=Lt(t);const e=Lt(this);return it(e).has.call(e,t)||(e.add(t),L(e,"add",t,t)),this}function ht(t,e){e=Lt(e);const n=Lt(this),{has:s,get:i}=it(n);let r=s.call(n,t);r||(t=Lt(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?f(e,c)&&L(n,"set",t,e):L(n,"add",t,e),this}function at(t){const e=Lt(this),{has:n,get:s}=it(e);let i=n.call(e,t);i||(t=Lt(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&L(e,"delete",t,void 0),r}function lt(){const t=Lt(this),e=0!==t.size,n=t.clear();return e&&L(t,"clear",void 0,void 0),n}function ft(t,e){return function(n,s){const i=this,r=i.__v_raw,c=Lt(r),o=e?st:t?Dt:Bt;return!t&&K(c,0,j),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function _t(t,e,n){return function(...s){const i=this.__v_raw,r=Lt(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,a=i[t](...s),l=n?st:e?Dt:Bt;return!e&&K(r,0,h?x:j),{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)},n={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)},s={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),n[i]=_t(i,!0,!1),e[i]=_t(i,!1,!0),s[i]=_t(i,!0,!0)})),[t,n,e,s]}const[vt,gt,yt,wt]=pt();function bt(t,e){const n=e?t?wt:yt:t?gt:vt;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 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 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=>a(t).slice(8,-1))(t))}function Mt(t){return It(t)?t:Nt(t,!1,$,Rt,Ot)}function zt(t){return Nt(t,!1,et,mt,jt)}function Wt(t){return Nt(t,!0,tt,St,xt)}function Vt(t){return Nt(t,!0,nt,kt,Pt)}function Nt(t,e,n,s,i){if(!u(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=Et(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function At(t){return It(t)?At(t.__v_raw):!(!t||!t.__v_isReactive)}function It(t){return!(!t||!t.__v_isReadonly)}function Kt(t){return!(!t||!t.__v_isShallow)}function Ct(t){return At(t)||It(t)}function Lt(t){const e=t&&t.__v_raw;return e?Lt(e):t}function qt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const Bt=t=>u(t)?Mt(t):t,Dt=t=>u(t)?Wt(t):t;function Ft(t){W&&O&&C((t=Lt(t)).dep||(t.dep=w()))}function Gt(t,e){const n=(t=Lt(t)).dep;n&&q(n)}function Ht(t){return!(!t||!0!==t.__v_isRef)}function Jt(t){return Tt(t,!1)}function Qt(t){return Tt(t,!0)}function Tt(t,e){return Ht(t)?t:new Ut(t,e)}class Ut{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Lt(t),this._value=e?t:Bt(t)}get value(){return Ft(this),this._value}set value(t){const e=this.__v_isShallow||Kt(t)||It(t);t=e?t:Lt(t),f(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Bt(t),Gt(this))}}function Xt(t){Gt(t)}function Yt(t){return Ht(t)?t.value:t}const Zt={get:(t,e,n)=>Yt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Ht(i)&&!Ht(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};function $t(t){return At(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>Ft(this)),(()=>Gt(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function ne(t){const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=ie(t,n);return e}class se{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 function(t,e){var n;return null===(n=m.get(t))||void 0===n?void 0:n.get(e)}(Lt(this._object),this._key)}}function ie(t,e,n){const s=t[e];return Ht(s)?s:new se(t,e,n)}var re,ce;class oe{constructor(t,e,n,s){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this[re]=!1,this._dirty=!0,this.effect=new P(t,(()=>{this._dirty||(this._dirty=!0,Gt(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=n}get value(){const t=Lt(this);return Ft(t),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ue(t,n,s=!1){let i,r;const c="function"==typeof t;c?(i=t,r=e):(i=t.get,r=t.set);return new oe(i,r,c||!r,s)}re="__v_isReadonly";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[ce]=!0;let n=!1,s=!1;this.effect=new P(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,ae.push((()=>{this.effect.active&&this._get()!==t&&Gt(this),s=!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 Ft(this),Lt(this)._get()}}function de(t){return new _e(t)}ce="__v_isReadonly";export{d as EffectScope,j as ITERATE_KEY,P as ReactiveEffect,ue as computed,ee as customRef,de as deferredComputed,M as effect,p as effectScope,A as enableTracking,g as getCurrentScope,Ct as isProxy,At as isReactive,It as isReadonly,Ht as isRef,Kt as isShallow,qt as markRaw,y as onScopeDispose,N as pauseTracking,$t as proxyRefs,Mt as reactive,Wt as readonly,Jt as ref,I as resetTracking,zt as shallowReactive,Vt as shallowReadonly,Qt as shallowRef,z as stop,Lt as toRaw,ie as toRef,ne as toRefs,K as track,L as trigger,Xt as triggerRef,Yt as unref};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extend, isArray,
|
|
1
|
+
import { extend, isArray, isMap, isIntegerKey, hasOwn, isSymbol, isObject, hasChanged, 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);
|
|
@@ -11,7 +11,7 @@ class EffectScope {
|
|
|
11
11
|
/**
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
|
-
this.
|
|
14
|
+
this._active = true;
|
|
15
15
|
/**
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
@@ -26,8 +26,11 @@ class EffectScope {
|
|
|
26
26
|
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
get active() {
|
|
30
|
+
return this._active;
|
|
31
|
+
}
|
|
29
32
|
run(fn) {
|
|
30
|
-
if (this.
|
|
33
|
+
if (this._active) {
|
|
31
34
|
const currentEffectScope = activeEffectScope;
|
|
32
35
|
try {
|
|
33
36
|
activeEffectScope = this;
|
|
@@ -56,7 +59,7 @@ class EffectScope {
|
|
|
56
59
|
activeEffectScope = this.parent;
|
|
57
60
|
}
|
|
58
61
|
stop(fromParent) {
|
|
59
|
-
if (this.
|
|
62
|
+
if (this._active) {
|
|
60
63
|
let i, l;
|
|
61
64
|
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
62
65
|
this.effects[i].stop();
|
|
@@ -79,7 +82,7 @@ class EffectScope {
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
this.parent = undefined;
|
|
82
|
-
this.
|
|
85
|
+
this._active = false;
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
}
|
|
@@ -305,7 +308,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
305
308
|
deps = [...depsMap.values()];
|
|
306
309
|
}
|
|
307
310
|
else if (key === 'length' && isArray(target)) {
|
|
308
|
-
const newLength =
|
|
311
|
+
const newLength = Number(newValue);
|
|
309
312
|
depsMap.forEach((dep, key) => {
|
|
310
313
|
if (key === 'length' || key >= newLength) {
|
|
311
314
|
deps.push(dep);
|
|
@@ -401,6 +404,10 @@ function triggerEffect(effect, debuggerEventExtraInfo) {
|
|
|
401
404
|
}
|
|
402
405
|
}
|
|
403
406
|
}
|
|
407
|
+
function getDepFromReactive(object, key) {
|
|
408
|
+
var _a;
|
|
409
|
+
return (_a = targetMap.get(object)) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
410
|
+
}
|
|
404
411
|
|
|
405
412
|
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
406
413
|
const builtInSymbols = new Set(
|
|
@@ -412,7 +419,7 @@ Object.getOwnPropertyNames(Symbol)
|
|
|
412
419
|
.filter(key => key !== 'arguments' && key !== 'caller')
|
|
413
420
|
.map(key => Symbol[key])
|
|
414
421
|
.filter(isSymbol));
|
|
415
|
-
const get = /*#__PURE__*/ createGetter();
|
|
422
|
+
const get$1 = /*#__PURE__*/ createGetter();
|
|
416
423
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
417
424
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
418
425
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
@@ -446,6 +453,11 @@ function createArrayInstrumentations() {
|
|
|
446
453
|
});
|
|
447
454
|
return instrumentations;
|
|
448
455
|
}
|
|
456
|
+
function hasOwnProperty(key) {
|
|
457
|
+
const obj = toRaw(this);
|
|
458
|
+
track(obj, "has" /* TrackOpTypes.HAS */, key);
|
|
459
|
+
return obj.hasOwnProperty(key);
|
|
460
|
+
}
|
|
449
461
|
function createGetter(isReadonly = false, shallow = false) {
|
|
450
462
|
return function get(target, key, receiver) {
|
|
451
463
|
if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
|
|
@@ -469,8 +481,13 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
469
481
|
return target;
|
|
470
482
|
}
|
|
471
483
|
const targetIsArray = isArray(target);
|
|
472
|
-
if (!isReadonly
|
|
473
|
-
|
|
484
|
+
if (!isReadonly) {
|
|
485
|
+
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
486
|
+
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
487
|
+
}
|
|
488
|
+
if (key === 'hasOwnProperty') {
|
|
489
|
+
return hasOwnProperty;
|
|
490
|
+
}
|
|
474
491
|
}
|
|
475
492
|
const res = Reflect.get(target, key, receiver);
|
|
476
493
|
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
@@ -495,7 +512,7 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
495
512
|
return res;
|
|
496
513
|
};
|
|
497
514
|
}
|
|
498
|
-
const set = /*#__PURE__*/ createSetter();
|
|
515
|
+
const set$1 = /*#__PURE__*/ createSetter();
|
|
499
516
|
const shallowSet = /*#__PURE__*/ createSetter(true);
|
|
500
517
|
function createSetter(shallow = false) {
|
|
501
518
|
return function set(target, key, value, receiver) {
|
|
@@ -538,7 +555,7 @@ function deleteProperty(target, key) {
|
|
|
538
555
|
}
|
|
539
556
|
return result;
|
|
540
557
|
}
|
|
541
|
-
function has(target, key) {
|
|
558
|
+
function has$1(target, key) {
|
|
542
559
|
const result = Reflect.has(target, key);
|
|
543
560
|
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
544
561
|
track(target, "has" /* TrackOpTypes.HAS */, key);
|
|
@@ -550,10 +567,10 @@ function ownKeys(target) {
|
|
|
550
567
|
return Reflect.ownKeys(target);
|
|
551
568
|
}
|
|
552
569
|
const mutableHandlers = {
|
|
553
|
-
get,
|
|
554
|
-
set,
|
|
570
|
+
get: get$1,
|
|
571
|
+
set: set$1,
|
|
555
572
|
deleteProperty,
|
|
556
|
-
has,
|
|
573
|
+
has: has$1,
|
|
557
574
|
ownKeys
|
|
558
575
|
};
|
|
559
576
|
const readonlyHandlers = {
|
|
@@ -584,7 +601,7 @@ const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
|
|
|
584
601
|
|
|
585
602
|
const toShallow = (value) => value;
|
|
586
603
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
587
|
-
function get
|
|
604
|
+
function get(target, key, isReadonly = false, isShallow = false) {
|
|
588
605
|
// #1772: readonly(reactive(Map)) should return readonly + reactive version
|
|
589
606
|
// of the value
|
|
590
607
|
target = target["__v_raw" /* ReactiveFlags.RAW */];
|
|
@@ -610,7 +627,7 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
|
|
|
610
627
|
target.get(key);
|
|
611
628
|
}
|
|
612
629
|
}
|
|
613
|
-
function has
|
|
630
|
+
function has(key, isReadonly = false) {
|
|
614
631
|
const target = this["__v_raw" /* ReactiveFlags.RAW */];
|
|
615
632
|
const rawTarget = toRaw(target);
|
|
616
633
|
const rawKey = toRaw(key);
|
|
@@ -640,7 +657,7 @@ function add(value) {
|
|
|
640
657
|
}
|
|
641
658
|
return this;
|
|
642
659
|
}
|
|
643
|
-
function set
|
|
660
|
+
function set(key, value) {
|
|
644
661
|
value = toRaw(value);
|
|
645
662
|
const target = toRaw(this);
|
|
646
663
|
const { has, get } = getProto(target);
|
|
@@ -754,41 +771,41 @@ function createReadonlyMethod(type) {
|
|
|
754
771
|
function createInstrumentations() {
|
|
755
772
|
const mutableInstrumentations = {
|
|
756
773
|
get(key) {
|
|
757
|
-
return get
|
|
774
|
+
return get(this, key);
|
|
758
775
|
},
|
|
759
776
|
get size() {
|
|
760
777
|
return size(this);
|
|
761
778
|
},
|
|
762
|
-
has
|
|
779
|
+
has,
|
|
763
780
|
add,
|
|
764
|
-
set
|
|
781
|
+
set,
|
|
765
782
|
delete: deleteEntry,
|
|
766
783
|
clear,
|
|
767
784
|
forEach: createForEach(false, false)
|
|
768
785
|
};
|
|
769
786
|
const shallowInstrumentations = {
|
|
770
787
|
get(key) {
|
|
771
|
-
return get
|
|
788
|
+
return get(this, key, false, true);
|
|
772
789
|
},
|
|
773
790
|
get size() {
|
|
774
791
|
return size(this);
|
|
775
792
|
},
|
|
776
|
-
has
|
|
793
|
+
has,
|
|
777
794
|
add,
|
|
778
|
-
set
|
|
795
|
+
set,
|
|
779
796
|
delete: deleteEntry,
|
|
780
797
|
clear,
|
|
781
798
|
forEach: createForEach(false, true)
|
|
782
799
|
};
|
|
783
800
|
const readonlyInstrumentations = {
|
|
784
801
|
get(key) {
|
|
785
|
-
return get
|
|
802
|
+
return get(this, key, true);
|
|
786
803
|
},
|
|
787
804
|
get size() {
|
|
788
805
|
return size(this, true);
|
|
789
806
|
},
|
|
790
807
|
has(key) {
|
|
791
|
-
return has
|
|
808
|
+
return has.call(this, key, true);
|
|
792
809
|
},
|
|
793
810
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
794
811
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -798,13 +815,13 @@ function createInstrumentations() {
|
|
|
798
815
|
};
|
|
799
816
|
const shallowReadonlyInstrumentations = {
|
|
800
817
|
get(key) {
|
|
801
|
-
return get
|
|
818
|
+
return get(this, key, true, true);
|
|
802
819
|
},
|
|
803
820
|
get size() {
|
|
804
821
|
return size(this, true);
|
|
805
822
|
},
|
|
806
823
|
has(key) {
|
|
807
|
-
return has
|
|
824
|
+
return has.call(this, key, true);
|
|
808
825
|
},
|
|
809
826
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
810
827
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -998,9 +1015,10 @@ function trackRefValue(ref) {
|
|
|
998
1015
|
}
|
|
999
1016
|
function triggerRefValue(ref, newVal) {
|
|
1000
1017
|
ref = toRaw(ref);
|
|
1001
|
-
|
|
1018
|
+
const dep = ref.dep;
|
|
1019
|
+
if (dep) {
|
|
1002
1020
|
if ((process.env.NODE_ENV !== 'production')) {
|
|
1003
|
-
triggerEffects(
|
|
1021
|
+
triggerEffects(dep, {
|
|
1004
1022
|
target: ref,
|
|
1005
1023
|
type: "set" /* TriggerOpTypes.SET */,
|
|
1006
1024
|
key: 'value',
|
|
@@ -1008,7 +1026,7 @@ function triggerRefValue(ref, newVal) {
|
|
|
1008
1026
|
});
|
|
1009
1027
|
}
|
|
1010
1028
|
else {
|
|
1011
|
-
triggerEffects(
|
|
1029
|
+
triggerEffects(dep);
|
|
1012
1030
|
}
|
|
1013
1031
|
}
|
|
1014
1032
|
}
|
|
@@ -1115,6 +1133,9 @@ class ObjectRefImpl {
|
|
|
1115
1133
|
set value(newVal) {
|
|
1116
1134
|
this._object[this._key] = newVal;
|
|
1117
1135
|
}
|
|
1136
|
+
get dep() {
|
|
1137
|
+
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1138
|
+
}
|
|
1118
1139
|
}
|
|
1119
1140
|
function toRef(object, key, defaultValue) {
|
|
1120
1141
|
const val = object[key];
|
|
@@ -1123,13 +1144,13 @@ function toRef(object, key, defaultValue) {
|
|
|
1123
1144
|
: new ObjectRefImpl(object, key, defaultValue);
|
|
1124
1145
|
}
|
|
1125
1146
|
|
|
1126
|
-
var _a;
|
|
1147
|
+
var _a$1;
|
|
1127
1148
|
class ComputedRefImpl {
|
|
1128
1149
|
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1129
1150
|
this._setter = _setter;
|
|
1130
1151
|
this.dep = undefined;
|
|
1131
1152
|
this.__v_isRef = true;
|
|
1132
|
-
this[_a] = false;
|
|
1153
|
+
this[_a$1] = false;
|
|
1133
1154
|
this._dirty = true;
|
|
1134
1155
|
this.effect = new ReactiveEffect(getter, () => {
|
|
1135
1156
|
if (!this._dirty) {
|
|
@@ -1155,7 +1176,7 @@ class ComputedRefImpl {
|
|
|
1155
1176
|
this._setter(newValue);
|
|
1156
1177
|
}
|
|
1157
1178
|
}
|
|
1158
|
-
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1179
|
+
_a$1 = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1159
1180
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1160
1181
|
let getter;
|
|
1161
1182
|
let setter;
|
|
@@ -1180,7 +1201,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1180
1201
|
return cRef;
|
|
1181
1202
|
}
|
|
1182
1203
|
|
|
1183
|
-
var _a
|
|
1204
|
+
var _a;
|
|
1184
1205
|
const tick = /*#__PURE__*/ Promise.resolve();
|
|
1185
1206
|
const queue = [];
|
|
1186
1207
|
let queued = false;
|
|
@@ -1203,7 +1224,7 @@ class DeferredComputedRefImpl {
|
|
|
1203
1224
|
this.dep = undefined;
|
|
1204
1225
|
this._dirty = true;
|
|
1205
1226
|
this.__v_isRef = true;
|
|
1206
|
-
this[_a
|
|
1227
|
+
this[_a] = true;
|
|
1207
1228
|
let compareTarget;
|
|
1208
1229
|
let hasCompareTarget = false;
|
|
1209
1230
|
let scheduled = false;
|
|
@@ -1250,7 +1271,7 @@ class DeferredComputedRefImpl {
|
|
|
1250
1271
|
return toRaw(this)._get();
|
|
1251
1272
|
}
|
|
1252
1273
|
}
|
|
1253
|
-
_a
|
|
1274
|
+
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1254
1275
|
function deferredComputed(getter) {
|
|
1255
1276
|
return new DeferredComputedRefImpl(getter);
|
|
1256
1277
|
}
|