@vue/reactivity 3.4.30 → 3.4.32
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 +45 -55
- package/dist/reactivity.cjs.prod.js +45 -55
- package/dist/reactivity.d.ts +2 -2
- package/dist/reactivity.esm-browser.js +45 -55
- package/dist/reactivity.esm-browser.prod.js +2 -2
- package/dist/reactivity.esm-bundler.js +45 -55
- package/dist/reactivity.global.js +45 -55
- package/dist/reactivity.global.prod.js +2 -2
- package/package.json +2 -2
package/dist/reactivity.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/reactivity v3.4.
|
|
2
|
+
* @vue/reactivity v3.4.32
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -124,7 +124,7 @@ class ReactiveEffect {
|
|
|
124
124
|
/**
|
|
125
125
|
* @internal
|
|
126
126
|
*/
|
|
127
|
-
this._dirtyLevel =
|
|
127
|
+
this._dirtyLevel = 4;
|
|
128
128
|
/**
|
|
129
129
|
* @internal
|
|
130
130
|
*/
|
|
@@ -144,20 +144,14 @@ class ReactiveEffect {
|
|
|
144
144
|
recordEffectScope(this, scope);
|
|
145
145
|
}
|
|
146
146
|
get dirty() {
|
|
147
|
-
if (this._dirtyLevel === 2)
|
|
148
|
-
return false;
|
|
149
|
-
if (this._dirtyLevel === 3 || this._dirtyLevel === 4) {
|
|
147
|
+
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
|
150
148
|
this._dirtyLevel = 1;
|
|
151
149
|
pauseTracking();
|
|
152
150
|
for (let i = 0; i < this._depsLength; i++) {
|
|
153
151
|
const dep = this.deps[i];
|
|
154
152
|
if (dep.computed) {
|
|
155
|
-
if (dep.computed.effect._dirtyLevel === 2) {
|
|
156
|
-
resetTracking();
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
153
|
triggerComputed(dep.computed);
|
|
160
|
-
if (this._dirtyLevel >=
|
|
154
|
+
if (this._dirtyLevel >= 4) {
|
|
161
155
|
break;
|
|
162
156
|
}
|
|
163
157
|
}
|
|
@@ -167,10 +161,10 @@ class ReactiveEffect {
|
|
|
167
161
|
}
|
|
168
162
|
resetTracking();
|
|
169
163
|
}
|
|
170
|
-
return this._dirtyLevel >=
|
|
164
|
+
return this._dirtyLevel >= 4;
|
|
171
165
|
}
|
|
172
166
|
set dirty(v) {
|
|
173
|
-
this._dirtyLevel = v ?
|
|
167
|
+
this._dirtyLevel = v ? 4 : 0;
|
|
174
168
|
}
|
|
175
169
|
run() {
|
|
176
170
|
this._dirtyLevel = 0;
|
|
@@ -296,17 +290,8 @@ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
|
296
290
|
pauseScheduling();
|
|
297
291
|
for (const effect2 of dep.keys()) {
|
|
298
292
|
let tracking;
|
|
299
|
-
if (!dep.computed && effect2.computed) {
|
|
300
|
-
if (effect2._runnings > 0 && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
301
|
-
effect2._dirtyLevel = 2;
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
293
|
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
306
294
|
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
|
307
|
-
if (effect2.computed && effect2._dirtyLevel === 2) {
|
|
308
|
-
effect2._shouldSchedule = true;
|
|
309
|
-
}
|
|
310
295
|
effect2._dirtyLevel = dirtyLevel;
|
|
311
296
|
}
|
|
312
297
|
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
@@ -314,7 +299,7 @@ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
|
314
299
|
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, shared.extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
315
300
|
}
|
|
316
301
|
effect2.trigger();
|
|
317
|
-
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !==
|
|
302
|
+
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
|
318
303
|
effect2._shouldSchedule = false;
|
|
319
304
|
if (effect2.scheduler) {
|
|
320
305
|
queueEffectSchedulers.push(effect2.scheduler);
|
|
@@ -406,7 +391,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
406
391
|
if (dep) {
|
|
407
392
|
triggerEffects(
|
|
408
393
|
dep,
|
|
409
|
-
|
|
394
|
+
4,
|
|
410
395
|
{
|
|
411
396
|
target,
|
|
412
397
|
type,
|
|
@@ -602,18 +587,18 @@ const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true
|
|
|
602
587
|
|
|
603
588
|
const toShallow = (value) => value;
|
|
604
589
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
605
|
-
function get(target, key,
|
|
590
|
+
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
606
591
|
target = target["__v_raw"];
|
|
607
592
|
const rawTarget = toRaw(target);
|
|
608
593
|
const rawKey = toRaw(key);
|
|
609
|
-
if (!
|
|
594
|
+
if (!isReadonly2) {
|
|
610
595
|
if (shared.hasChanged(key, rawKey)) {
|
|
611
596
|
track(rawTarget, "get", key);
|
|
612
597
|
}
|
|
613
598
|
track(rawTarget, "get", rawKey);
|
|
614
599
|
}
|
|
615
600
|
const { has: has2 } = getProto(rawTarget);
|
|
616
|
-
const wrap =
|
|
601
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
617
602
|
if (has2.call(rawTarget, key)) {
|
|
618
603
|
return wrap(target.get(key));
|
|
619
604
|
} else if (has2.call(rawTarget, rawKey)) {
|
|
@@ -622,11 +607,11 @@ function get(target, key, isReadonly = false, isShallow = false) {
|
|
|
622
607
|
target.get(key);
|
|
623
608
|
}
|
|
624
609
|
}
|
|
625
|
-
function has(key,
|
|
610
|
+
function has(key, isReadonly2 = false) {
|
|
626
611
|
const target = this["__v_raw"];
|
|
627
612
|
const rawTarget = toRaw(target);
|
|
628
613
|
const rawKey = toRaw(key);
|
|
629
|
-
if (!
|
|
614
|
+
if (!isReadonly2) {
|
|
630
615
|
if (shared.hasChanged(key, rawKey)) {
|
|
631
616
|
track(rawTarget, "has", key);
|
|
632
617
|
}
|
|
@@ -634,13 +619,15 @@ function has(key, isReadonly = false) {
|
|
|
634
619
|
}
|
|
635
620
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
636
621
|
}
|
|
637
|
-
function size(target,
|
|
622
|
+
function size(target, isReadonly2 = false) {
|
|
638
623
|
target = target["__v_raw"];
|
|
639
|
-
!
|
|
624
|
+
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
640
625
|
return Reflect.get(target, "size", target);
|
|
641
626
|
}
|
|
642
|
-
function add(value) {
|
|
643
|
-
value
|
|
627
|
+
function add(value, _isShallow = false) {
|
|
628
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
629
|
+
value = toRaw(value);
|
|
630
|
+
}
|
|
644
631
|
const target = toRaw(this);
|
|
645
632
|
const proto = getProto(target);
|
|
646
633
|
const hadKey = proto.has.call(target, value);
|
|
@@ -650,8 +637,10 @@ function add(value) {
|
|
|
650
637
|
}
|
|
651
638
|
return this;
|
|
652
639
|
}
|
|
653
|
-
function set(key, value) {
|
|
654
|
-
value
|
|
640
|
+
function set(key, value, _isShallow = false) {
|
|
641
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
642
|
+
value = toRaw(value);
|
|
643
|
+
}
|
|
655
644
|
const target = toRaw(this);
|
|
656
645
|
const { has: has2, get: get2 } = getProto(target);
|
|
657
646
|
let hadKey = has2.call(target, key);
|
|
@@ -697,19 +686,19 @@ function clear() {
|
|
|
697
686
|
}
|
|
698
687
|
return result;
|
|
699
688
|
}
|
|
700
|
-
function createForEach(
|
|
689
|
+
function createForEach(isReadonly2, isShallow2) {
|
|
701
690
|
return function forEach(callback, thisArg) {
|
|
702
691
|
const observed = this;
|
|
703
692
|
const target = observed["__v_raw"];
|
|
704
693
|
const rawTarget = toRaw(target);
|
|
705
|
-
const wrap =
|
|
706
|
-
!
|
|
694
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
695
|
+
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
707
696
|
return target.forEach((value, key) => {
|
|
708
697
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
709
698
|
});
|
|
710
699
|
};
|
|
711
700
|
}
|
|
712
|
-
function createIterableMethod(method,
|
|
701
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
713
702
|
return function(...args) {
|
|
714
703
|
const target = this["__v_raw"];
|
|
715
704
|
const rawTarget = toRaw(target);
|
|
@@ -717,8 +706,8 @@ function createIterableMethod(method, isReadonly, isShallow) {
|
|
|
717
706
|
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
718
707
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
719
708
|
const innerIterator = target[method](...args);
|
|
720
|
-
const wrap =
|
|
721
|
-
!
|
|
709
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
710
|
+
!isReadonly2 && track(
|
|
722
711
|
rawTarget,
|
|
723
712
|
"iterate",
|
|
724
713
|
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
@@ -774,8 +763,12 @@ function createInstrumentations() {
|
|
|
774
763
|
return size(this);
|
|
775
764
|
},
|
|
776
765
|
has,
|
|
777
|
-
add
|
|
778
|
-
|
|
766
|
+
add(value) {
|
|
767
|
+
return add.call(this, value, true);
|
|
768
|
+
},
|
|
769
|
+
set(key, value) {
|
|
770
|
+
return set.call(this, key, value, true);
|
|
771
|
+
},
|
|
779
772
|
delete: deleteEntry,
|
|
780
773
|
clear,
|
|
781
774
|
forEach: createForEach(false, true)
|
|
@@ -841,13 +834,13 @@ const [
|
|
|
841
834
|
shallowInstrumentations,
|
|
842
835
|
shallowReadonlyInstrumentations
|
|
843
836
|
] = /* @__PURE__ */ createInstrumentations();
|
|
844
|
-
function createInstrumentationGetter(
|
|
845
|
-
const instrumentations = shallow ?
|
|
837
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
838
|
+
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
846
839
|
return (target, key, receiver) => {
|
|
847
840
|
if (key === "__v_isReactive") {
|
|
848
|
-
return !
|
|
841
|
+
return !isReadonly2;
|
|
849
842
|
} else if (key === "__v_isReadonly") {
|
|
850
|
-
return
|
|
843
|
+
return isReadonly2;
|
|
851
844
|
} else if (key === "__v_raw") {
|
|
852
845
|
return target;
|
|
853
846
|
}
|
|
@@ -1009,7 +1002,7 @@ class ComputedRefImpl {
|
|
|
1009
1002
|
() => getter(this._value),
|
|
1010
1003
|
() => triggerRefValue(
|
|
1011
1004
|
this,
|
|
1012
|
-
this.effect._dirtyLevel ===
|
|
1005
|
+
this.effect._dirtyLevel === 2 ? 2 : 3
|
|
1013
1006
|
)
|
|
1014
1007
|
);
|
|
1015
1008
|
this.effect.computed = this;
|
|
@@ -1018,11 +1011,8 @@ class ComputedRefImpl {
|
|
|
1018
1011
|
}
|
|
1019
1012
|
get value() {
|
|
1020
1013
|
const self = toRaw(this);
|
|
1021
|
-
const lastDirtyLevel = self.effect._dirtyLevel;
|
|
1022
1014
|
if ((!self._cacheable || self.effect.dirty) && shared.hasChanged(self._value, self._value = self.effect.run())) {
|
|
1023
|
-
|
|
1024
|
-
triggerRefValue(self, 5);
|
|
1025
|
-
}
|
|
1015
|
+
triggerRefValue(self, 4);
|
|
1026
1016
|
}
|
|
1027
1017
|
trackRefValue(self);
|
|
1028
1018
|
if (self.effect._dirtyLevel >= 2) {
|
|
@@ -1031,7 +1021,7 @@ class ComputedRefImpl {
|
|
|
1031
1021
|
|
|
1032
1022
|
getter: `, this.getter);
|
|
1033
1023
|
}
|
|
1034
|
-
triggerRefValue(self,
|
|
1024
|
+
triggerRefValue(self, 2);
|
|
1035
1025
|
}
|
|
1036
1026
|
return self._value;
|
|
1037
1027
|
}
|
|
@@ -1086,7 +1076,7 @@ function trackRefValue(ref2) {
|
|
|
1086
1076
|
);
|
|
1087
1077
|
}
|
|
1088
1078
|
}
|
|
1089
|
-
function triggerRefValue(ref2, dirtyLevel =
|
|
1079
|
+
function triggerRefValue(ref2, dirtyLevel = 4, newVal, oldVal) {
|
|
1090
1080
|
ref2 = toRaw(ref2);
|
|
1091
1081
|
const dep = ref2.dep;
|
|
1092
1082
|
if (dep) {
|
|
@@ -1137,12 +1127,12 @@ class RefImpl {
|
|
|
1137
1127
|
const oldVal = this._rawValue;
|
|
1138
1128
|
this._rawValue = newVal;
|
|
1139
1129
|
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
1140
|
-
triggerRefValue(this,
|
|
1130
|
+
triggerRefValue(this, 4, newVal, oldVal);
|
|
1141
1131
|
}
|
|
1142
1132
|
}
|
|
1143
1133
|
}
|
|
1144
1134
|
function triggerRef(ref2) {
|
|
1145
|
-
triggerRefValue(ref2,
|
|
1135
|
+
triggerRefValue(ref2, 4, ref2.value );
|
|
1146
1136
|
}
|
|
1147
1137
|
function unref(ref2) {
|
|
1148
1138
|
return isRef(ref2) ? ref2.value : ref2;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/reactivity v3.4.
|
|
2
|
+
* @vue/reactivity v3.4.32
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -114,7 +114,7 @@ class ReactiveEffect {
|
|
|
114
114
|
/**
|
|
115
115
|
* @internal
|
|
116
116
|
*/
|
|
117
|
-
this._dirtyLevel =
|
|
117
|
+
this._dirtyLevel = 4;
|
|
118
118
|
/**
|
|
119
119
|
* @internal
|
|
120
120
|
*/
|
|
@@ -134,20 +134,14 @@ class ReactiveEffect {
|
|
|
134
134
|
recordEffectScope(this, scope);
|
|
135
135
|
}
|
|
136
136
|
get dirty() {
|
|
137
|
-
if (this._dirtyLevel === 2)
|
|
138
|
-
return false;
|
|
139
|
-
if (this._dirtyLevel === 3 || this._dirtyLevel === 4) {
|
|
137
|
+
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
|
140
138
|
this._dirtyLevel = 1;
|
|
141
139
|
pauseTracking();
|
|
142
140
|
for (let i = 0; i < this._depsLength; i++) {
|
|
143
141
|
const dep = this.deps[i];
|
|
144
142
|
if (dep.computed) {
|
|
145
|
-
if (dep.computed.effect._dirtyLevel === 2) {
|
|
146
|
-
resetTracking();
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
143
|
triggerComputed(dep.computed);
|
|
150
|
-
if (this._dirtyLevel >=
|
|
144
|
+
if (this._dirtyLevel >= 4) {
|
|
151
145
|
break;
|
|
152
146
|
}
|
|
153
147
|
}
|
|
@@ -157,10 +151,10 @@ class ReactiveEffect {
|
|
|
157
151
|
}
|
|
158
152
|
resetTracking();
|
|
159
153
|
}
|
|
160
|
-
return this._dirtyLevel >=
|
|
154
|
+
return this._dirtyLevel >= 4;
|
|
161
155
|
}
|
|
162
156
|
set dirty(v) {
|
|
163
|
-
this._dirtyLevel = v ?
|
|
157
|
+
this._dirtyLevel = v ? 4 : 0;
|
|
164
158
|
}
|
|
165
159
|
run() {
|
|
166
160
|
this._dirtyLevel = 0;
|
|
@@ -281,22 +275,13 @@ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
|
281
275
|
pauseScheduling();
|
|
282
276
|
for (const effect2 of dep.keys()) {
|
|
283
277
|
let tracking;
|
|
284
|
-
if (!dep.computed && effect2.computed) {
|
|
285
|
-
if (effect2._runnings > 0 && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
286
|
-
effect2._dirtyLevel = 2;
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
278
|
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
291
279
|
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
|
292
|
-
if (effect2.computed && effect2._dirtyLevel === 2) {
|
|
293
|
-
effect2._shouldSchedule = true;
|
|
294
|
-
}
|
|
295
280
|
effect2._dirtyLevel = dirtyLevel;
|
|
296
281
|
}
|
|
297
282
|
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
298
283
|
effect2.trigger();
|
|
299
|
-
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !==
|
|
284
|
+
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
|
300
285
|
effect2._shouldSchedule = false;
|
|
301
286
|
if (effect2.scheduler) {
|
|
302
287
|
queueEffectSchedulers.push(effect2.scheduler);
|
|
@@ -382,7 +367,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
382
367
|
if (dep) {
|
|
383
368
|
triggerEffects(
|
|
384
369
|
dep,
|
|
385
|
-
|
|
370
|
+
4);
|
|
386
371
|
}
|
|
387
372
|
}
|
|
388
373
|
resetScheduling();
|
|
@@ -557,18 +542,18 @@ const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true
|
|
|
557
542
|
|
|
558
543
|
const toShallow = (value) => value;
|
|
559
544
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
560
|
-
function get(target, key,
|
|
545
|
+
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
561
546
|
target = target["__v_raw"];
|
|
562
547
|
const rawTarget = toRaw(target);
|
|
563
548
|
const rawKey = toRaw(key);
|
|
564
|
-
if (!
|
|
549
|
+
if (!isReadonly2) {
|
|
565
550
|
if (shared.hasChanged(key, rawKey)) {
|
|
566
551
|
track(rawTarget, "get", key);
|
|
567
552
|
}
|
|
568
553
|
track(rawTarget, "get", rawKey);
|
|
569
554
|
}
|
|
570
555
|
const { has: has2 } = getProto(rawTarget);
|
|
571
|
-
const wrap =
|
|
556
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
572
557
|
if (has2.call(rawTarget, key)) {
|
|
573
558
|
return wrap(target.get(key));
|
|
574
559
|
} else if (has2.call(rawTarget, rawKey)) {
|
|
@@ -577,11 +562,11 @@ function get(target, key, isReadonly = false, isShallow = false) {
|
|
|
577
562
|
target.get(key);
|
|
578
563
|
}
|
|
579
564
|
}
|
|
580
|
-
function has(key,
|
|
565
|
+
function has(key, isReadonly2 = false) {
|
|
581
566
|
const target = this["__v_raw"];
|
|
582
567
|
const rawTarget = toRaw(target);
|
|
583
568
|
const rawKey = toRaw(key);
|
|
584
|
-
if (!
|
|
569
|
+
if (!isReadonly2) {
|
|
585
570
|
if (shared.hasChanged(key, rawKey)) {
|
|
586
571
|
track(rawTarget, "has", key);
|
|
587
572
|
}
|
|
@@ -589,13 +574,15 @@ function has(key, isReadonly = false) {
|
|
|
589
574
|
}
|
|
590
575
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
591
576
|
}
|
|
592
|
-
function size(target,
|
|
577
|
+
function size(target, isReadonly2 = false) {
|
|
593
578
|
target = target["__v_raw"];
|
|
594
|
-
!
|
|
579
|
+
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
595
580
|
return Reflect.get(target, "size", target);
|
|
596
581
|
}
|
|
597
|
-
function add(value) {
|
|
598
|
-
value
|
|
582
|
+
function add(value, _isShallow = false) {
|
|
583
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
584
|
+
value = toRaw(value);
|
|
585
|
+
}
|
|
599
586
|
const target = toRaw(this);
|
|
600
587
|
const proto = getProto(target);
|
|
601
588
|
const hadKey = proto.has.call(target, value);
|
|
@@ -605,8 +592,10 @@ function add(value) {
|
|
|
605
592
|
}
|
|
606
593
|
return this;
|
|
607
594
|
}
|
|
608
|
-
function set(key, value) {
|
|
609
|
-
value
|
|
595
|
+
function set(key, value, _isShallow = false) {
|
|
596
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
597
|
+
value = toRaw(value);
|
|
598
|
+
}
|
|
610
599
|
const target = toRaw(this);
|
|
611
600
|
const { has: has2, get: get2 } = getProto(target);
|
|
612
601
|
let hadKey = has2.call(target, key);
|
|
@@ -647,19 +636,19 @@ function clear() {
|
|
|
647
636
|
}
|
|
648
637
|
return result;
|
|
649
638
|
}
|
|
650
|
-
function createForEach(
|
|
639
|
+
function createForEach(isReadonly2, isShallow2) {
|
|
651
640
|
return function forEach(callback, thisArg) {
|
|
652
641
|
const observed = this;
|
|
653
642
|
const target = observed["__v_raw"];
|
|
654
643
|
const rawTarget = toRaw(target);
|
|
655
|
-
const wrap =
|
|
656
|
-
!
|
|
644
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
645
|
+
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
657
646
|
return target.forEach((value, key) => {
|
|
658
647
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
659
648
|
});
|
|
660
649
|
};
|
|
661
650
|
}
|
|
662
|
-
function createIterableMethod(method,
|
|
651
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
663
652
|
return function(...args) {
|
|
664
653
|
const target = this["__v_raw"];
|
|
665
654
|
const rawTarget = toRaw(target);
|
|
@@ -667,8 +656,8 @@ function createIterableMethod(method, isReadonly, isShallow) {
|
|
|
667
656
|
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
668
657
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
669
658
|
const innerIterator = target[method](...args);
|
|
670
|
-
const wrap =
|
|
671
|
-
!
|
|
659
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
660
|
+
!isReadonly2 && track(
|
|
672
661
|
rawTarget,
|
|
673
662
|
"iterate",
|
|
674
663
|
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
@@ -717,8 +706,12 @@ function createInstrumentations() {
|
|
|
717
706
|
return size(this);
|
|
718
707
|
},
|
|
719
708
|
has,
|
|
720
|
-
add
|
|
721
|
-
|
|
709
|
+
add(value) {
|
|
710
|
+
return add.call(this, value, true);
|
|
711
|
+
},
|
|
712
|
+
set(key, value) {
|
|
713
|
+
return set.call(this, key, value, true);
|
|
714
|
+
},
|
|
722
715
|
delete: deleteEntry,
|
|
723
716
|
clear,
|
|
724
717
|
forEach: createForEach(false, true)
|
|
@@ -784,13 +777,13 @@ const [
|
|
|
784
777
|
shallowInstrumentations,
|
|
785
778
|
shallowReadonlyInstrumentations
|
|
786
779
|
] = /* @__PURE__ */ createInstrumentations();
|
|
787
|
-
function createInstrumentationGetter(
|
|
788
|
-
const instrumentations = shallow ?
|
|
780
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
781
|
+
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
789
782
|
return (target, key, receiver) => {
|
|
790
783
|
if (key === "__v_isReactive") {
|
|
791
|
-
return !
|
|
784
|
+
return !isReadonly2;
|
|
792
785
|
} else if (key === "__v_isReadonly") {
|
|
793
|
-
return
|
|
786
|
+
return isReadonly2;
|
|
794
787
|
} else if (key === "__v_raw") {
|
|
795
788
|
return target;
|
|
796
789
|
}
|
|
@@ -935,7 +928,7 @@ class ComputedRefImpl {
|
|
|
935
928
|
() => getter(this._value),
|
|
936
929
|
() => triggerRefValue(
|
|
937
930
|
this,
|
|
938
|
-
this.effect._dirtyLevel ===
|
|
931
|
+
this.effect._dirtyLevel === 2 ? 2 : 3
|
|
939
932
|
)
|
|
940
933
|
);
|
|
941
934
|
this.effect.computed = this;
|
|
@@ -944,15 +937,12 @@ class ComputedRefImpl {
|
|
|
944
937
|
}
|
|
945
938
|
get value() {
|
|
946
939
|
const self = toRaw(this);
|
|
947
|
-
const lastDirtyLevel = self.effect._dirtyLevel;
|
|
948
940
|
if ((!self._cacheable || self.effect.dirty) && shared.hasChanged(self._value, self._value = self.effect.run())) {
|
|
949
|
-
|
|
950
|
-
triggerRefValue(self, 5);
|
|
951
|
-
}
|
|
941
|
+
triggerRefValue(self, 4);
|
|
952
942
|
}
|
|
953
943
|
trackRefValue(self);
|
|
954
944
|
if (self.effect._dirtyLevel >= 2) {
|
|
955
|
-
triggerRefValue(self,
|
|
945
|
+
triggerRefValue(self, 2);
|
|
956
946
|
}
|
|
957
947
|
return self._value;
|
|
958
948
|
}
|
|
@@ -995,7 +985,7 @@ function trackRefValue(ref2) {
|
|
|
995
985
|
));
|
|
996
986
|
}
|
|
997
987
|
}
|
|
998
|
-
function triggerRefValue(ref2, dirtyLevel =
|
|
988
|
+
function triggerRefValue(ref2, dirtyLevel = 4, newVal, oldVal) {
|
|
999
989
|
ref2 = toRaw(ref2);
|
|
1000
990
|
const dep = ref2.dep;
|
|
1001
991
|
if (dep) {
|
|
@@ -1038,12 +1028,12 @@ class RefImpl {
|
|
|
1038
1028
|
this._rawValue;
|
|
1039
1029
|
this._rawValue = newVal;
|
|
1040
1030
|
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
1041
|
-
triggerRefValue(this,
|
|
1031
|
+
triggerRefValue(this, 4);
|
|
1042
1032
|
}
|
|
1043
1033
|
}
|
|
1044
1034
|
}
|
|
1045
1035
|
function triggerRef(ref2) {
|
|
1046
|
-
triggerRefValue(ref2,
|
|
1036
|
+
triggerRefValue(ref2, 4);
|
|
1047
1037
|
}
|
|
1048
1038
|
function unref(ref2) {
|
|
1049
1039
|
return isRef(ref2) ? ref2.value : ref2;
|
package/dist/reactivity.d.ts
CHANGED
|
@@ -507,7 +507,7 @@ export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
|
|
|
507
507
|
* @param ref - Ref or plain value to be converted into the plain value.
|
|
508
508
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
|
|
509
509
|
*/
|
|
510
|
-
export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
|
|
510
|
+
export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T> | ShallowRef<T>): T;
|
|
511
511
|
/**
|
|
512
512
|
* Normalizes values / refs / getters to values.
|
|
513
513
|
* This is similar to {@link unref()}, except that it also normalizes getters.
|
|
@@ -524,7 +524,7 @@ export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
|
|
|
524
524
|
* @param source - A getter, an existing ref, or a non-function value.
|
|
525
525
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
|
|
526
526
|
*/
|
|
527
|
-
export declare function toValue<T>(source: MaybeRefOrGetter<T> | ComputedRef<T>): T;
|
|
527
|
+
export declare function toValue<T>(source: MaybeRefOrGetter<T> | ComputedRef<T> | ShallowRef<T>): T;
|
|
528
528
|
/**
|
|
529
529
|
* Returns a reactive proxy for the given object.
|
|
530
530
|
*
|