@vue/reactivity 3.2.45 → 3.2.47
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 -34
- package/dist/reactivity.cjs.prod.js +55 -34
- 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 -44
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
This package is inlined into Global & Browser ESM builds of user-facing renderers (e.g. `@vue/runtime-dom`), but also published as a package that can be used standalone. The standalone build should not be used alongside a pre-bundled build of a user-facing renderer, as they will have different internal storage for reactivity connections. A user-facing renderer should re-export all APIs from this package.
|
|
6
6
|
|
|
7
|
-
For full exposed APIs, see `src/index.ts`. You can also run `
|
|
7
|
+
For full exposed APIs, see `src/index.ts`. You can also run `pnpm build reactivity --types` from repo root, which will generate an API report at `temp/reactivity.api.md`.
|
|
8
8
|
|
|
9
9
|
## Credits
|
|
10
10
|
|
package/dist/reactivity.cjs.js
CHANGED
|
@@ -15,7 +15,7 @@ class EffectScope {
|
|
|
15
15
|
/**
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
|
-
this.
|
|
18
|
+
this._active = true;
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
@@ -30,8 +30,11 @@ class EffectScope {
|
|
|
30
30
|
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
get active() {
|
|
34
|
+
return this._active;
|
|
35
|
+
}
|
|
33
36
|
run(fn) {
|
|
34
|
-
if (this.
|
|
37
|
+
if (this._active) {
|
|
35
38
|
const currentEffectScope = activeEffectScope;
|
|
36
39
|
try {
|
|
37
40
|
activeEffectScope = this;
|
|
@@ -60,7 +63,7 @@ class EffectScope {
|
|
|
60
63
|
activeEffectScope = this.parent;
|
|
61
64
|
}
|
|
62
65
|
stop(fromParent) {
|
|
63
|
-
if (this.
|
|
66
|
+
if (this._active) {
|
|
64
67
|
let i, l;
|
|
65
68
|
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
66
69
|
this.effects[i].stop();
|
|
@@ -83,7 +86,7 @@ class EffectScope {
|
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
this.parent = undefined;
|
|
86
|
-
this.
|
|
89
|
+
this._active = false;
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
}
|
|
@@ -311,7 +314,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
311
314
|
deps = [...depsMap.values()];
|
|
312
315
|
}
|
|
313
316
|
else if (key === 'length' && shared.isArray(target)) {
|
|
314
|
-
const newLength =
|
|
317
|
+
const newLength = Number(newValue);
|
|
315
318
|
depsMap.forEach((dep, key) => {
|
|
316
319
|
if (key === 'length' || key >= newLength) {
|
|
317
320
|
deps.push(dep);
|
|
@@ -400,6 +403,10 @@ function triggerEffect(effect, debuggerEventExtraInfo) {
|
|
|
400
403
|
}
|
|
401
404
|
}
|
|
402
405
|
}
|
|
406
|
+
function getDepFromReactive(object, key) {
|
|
407
|
+
var _a;
|
|
408
|
+
return (_a = targetMap.get(object)) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
409
|
+
}
|
|
403
410
|
|
|
404
411
|
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
|
|
405
412
|
const builtInSymbols = new Set(
|
|
@@ -411,7 +418,7 @@ Object.getOwnPropertyNames(Symbol)
|
|
|
411
418
|
.filter(key => key !== 'arguments' && key !== 'caller')
|
|
412
419
|
.map(key => Symbol[key])
|
|
413
420
|
.filter(shared.isSymbol));
|
|
414
|
-
const get = /*#__PURE__*/ createGetter();
|
|
421
|
+
const get$1 = /*#__PURE__*/ createGetter();
|
|
415
422
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
416
423
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
417
424
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
@@ -445,6 +452,11 @@ function createArrayInstrumentations() {
|
|
|
445
452
|
});
|
|
446
453
|
return instrumentations;
|
|
447
454
|
}
|
|
455
|
+
function hasOwnProperty(key) {
|
|
456
|
+
const obj = toRaw(this);
|
|
457
|
+
track(obj, "has" /* TrackOpTypes.HAS */, key);
|
|
458
|
+
return obj.hasOwnProperty(key);
|
|
459
|
+
}
|
|
448
460
|
function createGetter(isReadonly = false, shallow = false) {
|
|
449
461
|
return function get(target, key, receiver) {
|
|
450
462
|
if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
|
|
@@ -468,8 +480,13 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
468
480
|
return target;
|
|
469
481
|
}
|
|
470
482
|
const targetIsArray = shared.isArray(target);
|
|
471
|
-
if (!isReadonly
|
|
472
|
-
|
|
483
|
+
if (!isReadonly) {
|
|
484
|
+
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
|
|
485
|
+
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
486
|
+
}
|
|
487
|
+
if (key === 'hasOwnProperty') {
|
|
488
|
+
return hasOwnProperty;
|
|
489
|
+
}
|
|
473
490
|
}
|
|
474
491
|
const res = Reflect.get(target, key, receiver);
|
|
475
492
|
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
@@ -494,7 +511,7 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
494
511
|
return res;
|
|
495
512
|
};
|
|
496
513
|
}
|
|
497
|
-
const set = /*#__PURE__*/ createSetter();
|
|
514
|
+
const set$1 = /*#__PURE__*/ createSetter();
|
|
498
515
|
const shallowSet = /*#__PURE__*/ createSetter(true);
|
|
499
516
|
function createSetter(shallow = false) {
|
|
500
517
|
return function set(target, key, value, receiver) {
|
|
@@ -537,7 +554,7 @@ function deleteProperty(target, key) {
|
|
|
537
554
|
}
|
|
538
555
|
return result;
|
|
539
556
|
}
|
|
540
|
-
function has(target, key) {
|
|
557
|
+
function has$1(target, key) {
|
|
541
558
|
const result = Reflect.has(target, key);
|
|
542
559
|
if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
|
|
543
560
|
track(target, "has" /* TrackOpTypes.HAS */, key);
|
|
@@ -549,10 +566,10 @@ function ownKeys(target) {
|
|
|
549
566
|
return Reflect.ownKeys(target);
|
|
550
567
|
}
|
|
551
568
|
const mutableHandlers = {
|
|
552
|
-
get,
|
|
553
|
-
set,
|
|
569
|
+
get: get$1,
|
|
570
|
+
set: set$1,
|
|
554
571
|
deleteProperty,
|
|
555
|
-
has,
|
|
572
|
+
has: has$1,
|
|
556
573
|
ownKeys
|
|
557
574
|
};
|
|
558
575
|
const readonlyHandlers = {
|
|
@@ -583,7 +600,7 @@ const shallowReadonlyHandlers = /*#__PURE__*/ shared.extend({}, readonlyHandlers
|
|
|
583
600
|
|
|
584
601
|
const toShallow = (value) => value;
|
|
585
602
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
586
|
-
function get
|
|
603
|
+
function get(target, key, isReadonly = false, isShallow = false) {
|
|
587
604
|
// #1772: readonly(reactive(Map)) should return readonly + reactive version
|
|
588
605
|
// of the value
|
|
589
606
|
target = target["__v_raw" /* ReactiveFlags.RAW */];
|
|
@@ -609,7 +626,7 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
|
|
|
609
626
|
target.get(key);
|
|
610
627
|
}
|
|
611
628
|
}
|
|
612
|
-
function has
|
|
629
|
+
function has(key, isReadonly = false) {
|
|
613
630
|
const target = this["__v_raw" /* ReactiveFlags.RAW */];
|
|
614
631
|
const rawTarget = toRaw(target);
|
|
615
632
|
const rawKey = toRaw(key);
|
|
@@ -639,7 +656,7 @@ function add(value) {
|
|
|
639
656
|
}
|
|
640
657
|
return this;
|
|
641
658
|
}
|
|
642
|
-
function set
|
|
659
|
+
function set(key, value) {
|
|
643
660
|
value = toRaw(value);
|
|
644
661
|
const target = toRaw(this);
|
|
645
662
|
const { has, get } = getProto(target);
|
|
@@ -752,41 +769,41 @@ function createReadonlyMethod(type) {
|
|
|
752
769
|
function createInstrumentations() {
|
|
753
770
|
const mutableInstrumentations = {
|
|
754
771
|
get(key) {
|
|
755
|
-
return get
|
|
772
|
+
return get(this, key);
|
|
756
773
|
},
|
|
757
774
|
get size() {
|
|
758
775
|
return size(this);
|
|
759
776
|
},
|
|
760
|
-
has
|
|
777
|
+
has,
|
|
761
778
|
add,
|
|
762
|
-
set
|
|
779
|
+
set,
|
|
763
780
|
delete: deleteEntry,
|
|
764
781
|
clear,
|
|
765
782
|
forEach: createForEach(false, false)
|
|
766
783
|
};
|
|
767
784
|
const shallowInstrumentations = {
|
|
768
785
|
get(key) {
|
|
769
|
-
return get
|
|
786
|
+
return get(this, key, false, true);
|
|
770
787
|
},
|
|
771
788
|
get size() {
|
|
772
789
|
return size(this);
|
|
773
790
|
},
|
|
774
|
-
has
|
|
791
|
+
has,
|
|
775
792
|
add,
|
|
776
|
-
set
|
|
793
|
+
set,
|
|
777
794
|
delete: deleteEntry,
|
|
778
795
|
clear,
|
|
779
796
|
forEach: createForEach(false, true)
|
|
780
797
|
};
|
|
781
798
|
const readonlyInstrumentations = {
|
|
782
799
|
get(key) {
|
|
783
|
-
return get
|
|
800
|
+
return get(this, key, true);
|
|
784
801
|
},
|
|
785
802
|
get size() {
|
|
786
803
|
return size(this, true);
|
|
787
804
|
},
|
|
788
805
|
has(key) {
|
|
789
|
-
return has
|
|
806
|
+
return has.call(this, key, true);
|
|
790
807
|
},
|
|
791
808
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
792
809
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -796,13 +813,13 @@ function createInstrumentations() {
|
|
|
796
813
|
};
|
|
797
814
|
const shallowReadonlyInstrumentations = {
|
|
798
815
|
get(key) {
|
|
799
|
-
return get
|
|
816
|
+
return get(this, key, true, true);
|
|
800
817
|
},
|
|
801
818
|
get size() {
|
|
802
819
|
return size(this, true);
|
|
803
820
|
},
|
|
804
821
|
has(key) {
|
|
805
|
-
return has
|
|
822
|
+
return has.call(this, key, true);
|
|
806
823
|
},
|
|
807
824
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
808
825
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -993,9 +1010,10 @@ function trackRefValue(ref) {
|
|
|
993
1010
|
}
|
|
994
1011
|
function triggerRefValue(ref, newVal) {
|
|
995
1012
|
ref = toRaw(ref);
|
|
996
|
-
|
|
1013
|
+
const dep = ref.dep;
|
|
1014
|
+
if (dep) {
|
|
997
1015
|
{
|
|
998
|
-
triggerEffects(
|
|
1016
|
+
triggerEffects(dep, {
|
|
999
1017
|
target: ref,
|
|
1000
1018
|
type: "set" /* TriggerOpTypes.SET */,
|
|
1001
1019
|
key: 'value',
|
|
@@ -1107,6 +1125,9 @@ class ObjectRefImpl {
|
|
|
1107
1125
|
set value(newVal) {
|
|
1108
1126
|
this._object[this._key] = newVal;
|
|
1109
1127
|
}
|
|
1128
|
+
get dep() {
|
|
1129
|
+
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1130
|
+
}
|
|
1110
1131
|
}
|
|
1111
1132
|
function toRef(object, key, defaultValue) {
|
|
1112
1133
|
const val = object[key];
|
|
@@ -1115,13 +1136,13 @@ function toRef(object, key, defaultValue) {
|
|
|
1115
1136
|
: new ObjectRefImpl(object, key, defaultValue);
|
|
1116
1137
|
}
|
|
1117
1138
|
|
|
1118
|
-
var _a;
|
|
1139
|
+
var _a$1;
|
|
1119
1140
|
class ComputedRefImpl {
|
|
1120
1141
|
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1121
1142
|
this._setter = _setter;
|
|
1122
1143
|
this.dep = undefined;
|
|
1123
1144
|
this.__v_isRef = true;
|
|
1124
|
-
this[_a] = false;
|
|
1145
|
+
this[_a$1] = false;
|
|
1125
1146
|
this._dirty = true;
|
|
1126
1147
|
this.effect = new ReactiveEffect(getter, () => {
|
|
1127
1148
|
if (!this._dirty) {
|
|
@@ -1147,7 +1168,7 @@ class ComputedRefImpl {
|
|
|
1147
1168
|
this._setter(newValue);
|
|
1148
1169
|
}
|
|
1149
1170
|
}
|
|
1150
|
-
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1171
|
+
_a$1 = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1151
1172
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1152
1173
|
let getter;
|
|
1153
1174
|
let setter;
|
|
@@ -1171,7 +1192,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1171
1192
|
return cRef;
|
|
1172
1193
|
}
|
|
1173
1194
|
|
|
1174
|
-
var _a
|
|
1195
|
+
var _a;
|
|
1175
1196
|
const tick = /*#__PURE__*/ Promise.resolve();
|
|
1176
1197
|
const queue = [];
|
|
1177
1198
|
let queued = false;
|
|
@@ -1194,7 +1215,7 @@ class DeferredComputedRefImpl {
|
|
|
1194
1215
|
this.dep = undefined;
|
|
1195
1216
|
this._dirty = true;
|
|
1196
1217
|
this.__v_isRef = true;
|
|
1197
|
-
this[_a
|
|
1218
|
+
this[_a] = true;
|
|
1198
1219
|
let compareTarget;
|
|
1199
1220
|
let hasCompareTarget = false;
|
|
1200
1221
|
let scheduled = false;
|
|
@@ -1241,7 +1262,7 @@ class DeferredComputedRefImpl {
|
|
|
1241
1262
|
return toRaw(this)._get();
|
|
1242
1263
|
}
|
|
1243
1264
|
}
|
|
1244
|
-
_a
|
|
1265
|
+
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1245
1266
|
function deferredComputed(getter) {
|
|
1246
1267
|
return new DeferredComputedRefImpl(getter);
|
|
1247
1268
|
}
|
|
@@ -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;
|
|
@@ -53,7 +56,7 @@ class EffectScope {
|
|
|
53
56
|
activeEffectScope = this.parent;
|
|
54
57
|
}
|
|
55
58
|
stop(fromParent) {
|
|
56
|
-
if (this.
|
|
59
|
+
if (this._active) {
|
|
57
60
|
let i, l;
|
|
58
61
|
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
59
62
|
this.effects[i].stop();
|
|
@@ -76,7 +79,7 @@ class EffectScope {
|
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
this.parent = undefined;
|
|
79
|
-
this.
|
|
82
|
+
this._active = false;
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -292,7 +295,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
292
295
|
deps = [...depsMap.values()];
|
|
293
296
|
}
|
|
294
297
|
else if (key === 'length' && shared.isArray(target)) {
|
|
295
|
-
const newLength =
|
|
298
|
+
const newLength = Number(newValue);
|
|
296
299
|
depsMap.forEach((dep, key) => {
|
|
297
300
|
if (key === 'length' || key >= newLength) {
|
|
298
301
|
deps.push(dep);
|
|
@@ -376,6 +379,10 @@ function triggerEffect(effect, debuggerEventExtraInfo) {
|
|
|
376
379
|
}
|
|
377
380
|
}
|
|
378
381
|
}
|
|
382
|
+
function getDepFromReactive(object, key) {
|
|
383
|
+
var _a;
|
|
384
|
+
return (_a = targetMap.get(object)) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
385
|
+
}
|
|
379
386
|
|
|
380
387
|
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
|
|
381
388
|
const builtInSymbols = new Set(
|
|
@@ -387,7 +394,7 @@ Object.getOwnPropertyNames(Symbol)
|
|
|
387
394
|
.filter(key => key !== 'arguments' && key !== 'caller')
|
|
388
395
|
.map(key => Symbol[key])
|
|
389
396
|
.filter(shared.isSymbol));
|
|
390
|
-
const get = /*#__PURE__*/ createGetter();
|
|
397
|
+
const get$1 = /*#__PURE__*/ createGetter();
|
|
391
398
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
392
399
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
393
400
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
@@ -421,6 +428,11 @@ function createArrayInstrumentations() {
|
|
|
421
428
|
});
|
|
422
429
|
return instrumentations;
|
|
423
430
|
}
|
|
431
|
+
function hasOwnProperty(key) {
|
|
432
|
+
const obj = toRaw(this);
|
|
433
|
+
track(obj, "has" /* TrackOpTypes.HAS */, key);
|
|
434
|
+
return obj.hasOwnProperty(key);
|
|
435
|
+
}
|
|
424
436
|
function createGetter(isReadonly = false, shallow = false) {
|
|
425
437
|
return function get(target, key, receiver) {
|
|
426
438
|
if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
|
|
@@ -444,8 +456,13 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
444
456
|
return target;
|
|
445
457
|
}
|
|
446
458
|
const targetIsArray = shared.isArray(target);
|
|
447
|
-
if (!isReadonly
|
|
448
|
-
|
|
459
|
+
if (!isReadonly) {
|
|
460
|
+
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
|
|
461
|
+
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
462
|
+
}
|
|
463
|
+
if (key === 'hasOwnProperty') {
|
|
464
|
+
return hasOwnProperty;
|
|
465
|
+
}
|
|
449
466
|
}
|
|
450
467
|
const res = Reflect.get(target, key, receiver);
|
|
451
468
|
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
@@ -470,7 +487,7 @@ function createGetter(isReadonly = false, shallow = false) {
|
|
|
470
487
|
return res;
|
|
471
488
|
};
|
|
472
489
|
}
|
|
473
|
-
const set = /*#__PURE__*/ createSetter();
|
|
490
|
+
const set$1 = /*#__PURE__*/ createSetter();
|
|
474
491
|
const shallowSet = /*#__PURE__*/ createSetter(true);
|
|
475
492
|
function createSetter(shallow = false) {
|
|
476
493
|
return function set(target, key, value, receiver) {
|
|
@@ -513,7 +530,7 @@ function deleteProperty(target, key) {
|
|
|
513
530
|
}
|
|
514
531
|
return result;
|
|
515
532
|
}
|
|
516
|
-
function has(target, key) {
|
|
533
|
+
function has$1(target, key) {
|
|
517
534
|
const result = Reflect.has(target, key);
|
|
518
535
|
if (!shared.isSymbol(key) || !builtInSymbols.has(key)) {
|
|
519
536
|
track(target, "has" /* TrackOpTypes.HAS */, key);
|
|
@@ -525,10 +542,10 @@ function ownKeys(target) {
|
|
|
525
542
|
return Reflect.ownKeys(target);
|
|
526
543
|
}
|
|
527
544
|
const mutableHandlers = {
|
|
528
|
-
get,
|
|
529
|
-
set,
|
|
545
|
+
get: get$1,
|
|
546
|
+
set: set$1,
|
|
530
547
|
deleteProperty,
|
|
531
|
-
has,
|
|
548
|
+
has: has$1,
|
|
532
549
|
ownKeys
|
|
533
550
|
};
|
|
534
551
|
const readonlyHandlers = {
|
|
@@ -553,7 +570,7 @@ const shallowReadonlyHandlers = /*#__PURE__*/ shared.extend({}, readonlyHandlers
|
|
|
553
570
|
|
|
554
571
|
const toShallow = (value) => value;
|
|
555
572
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
556
|
-
function get
|
|
573
|
+
function get(target, key, isReadonly = false, isShallow = false) {
|
|
557
574
|
// #1772: readonly(reactive(Map)) should return readonly + reactive version
|
|
558
575
|
// of the value
|
|
559
576
|
target = target["__v_raw" /* ReactiveFlags.RAW */];
|
|
@@ -579,7 +596,7 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
|
|
|
579
596
|
target.get(key);
|
|
580
597
|
}
|
|
581
598
|
}
|
|
582
|
-
function has
|
|
599
|
+
function has(key, isReadonly = false) {
|
|
583
600
|
const target = this["__v_raw" /* ReactiveFlags.RAW */];
|
|
584
601
|
const rawTarget = toRaw(target);
|
|
585
602
|
const rawKey = toRaw(key);
|
|
@@ -609,7 +626,7 @@ function add(value) {
|
|
|
609
626
|
}
|
|
610
627
|
return this;
|
|
611
628
|
}
|
|
612
|
-
function set
|
|
629
|
+
function set(key, value) {
|
|
613
630
|
value = toRaw(value);
|
|
614
631
|
const target = toRaw(this);
|
|
615
632
|
const { has, get } = getProto(target);
|
|
@@ -708,41 +725,41 @@ function createReadonlyMethod(type) {
|
|
|
708
725
|
function createInstrumentations() {
|
|
709
726
|
const mutableInstrumentations = {
|
|
710
727
|
get(key) {
|
|
711
|
-
return get
|
|
728
|
+
return get(this, key);
|
|
712
729
|
},
|
|
713
730
|
get size() {
|
|
714
731
|
return size(this);
|
|
715
732
|
},
|
|
716
|
-
has
|
|
733
|
+
has,
|
|
717
734
|
add,
|
|
718
|
-
set
|
|
735
|
+
set,
|
|
719
736
|
delete: deleteEntry,
|
|
720
737
|
clear,
|
|
721
738
|
forEach: createForEach(false, false)
|
|
722
739
|
};
|
|
723
740
|
const shallowInstrumentations = {
|
|
724
741
|
get(key) {
|
|
725
|
-
return get
|
|
742
|
+
return get(this, key, false, true);
|
|
726
743
|
},
|
|
727
744
|
get size() {
|
|
728
745
|
return size(this);
|
|
729
746
|
},
|
|
730
|
-
has
|
|
747
|
+
has,
|
|
731
748
|
add,
|
|
732
|
-
set
|
|
749
|
+
set,
|
|
733
750
|
delete: deleteEntry,
|
|
734
751
|
clear,
|
|
735
752
|
forEach: createForEach(false, true)
|
|
736
753
|
};
|
|
737
754
|
const readonlyInstrumentations = {
|
|
738
755
|
get(key) {
|
|
739
|
-
return get
|
|
756
|
+
return get(this, key, true);
|
|
740
757
|
},
|
|
741
758
|
get size() {
|
|
742
759
|
return size(this, true);
|
|
743
760
|
},
|
|
744
761
|
has(key) {
|
|
745
|
-
return has
|
|
762
|
+
return has.call(this, key, true);
|
|
746
763
|
},
|
|
747
764
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
748
765
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -752,13 +769,13 @@ function createInstrumentations() {
|
|
|
752
769
|
};
|
|
753
770
|
const shallowReadonlyInstrumentations = {
|
|
754
771
|
get(key) {
|
|
755
|
-
return get
|
|
772
|
+
return get(this, key, true, true);
|
|
756
773
|
},
|
|
757
774
|
get size() {
|
|
758
775
|
return size(this, true);
|
|
759
776
|
},
|
|
760
777
|
has(key) {
|
|
761
|
-
return has
|
|
778
|
+
return has.call(this, key, true);
|
|
762
779
|
},
|
|
763
780
|
add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
|
|
764
781
|
set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
|
|
@@ -931,9 +948,10 @@ function trackRefValue(ref) {
|
|
|
931
948
|
}
|
|
932
949
|
function triggerRefValue(ref, newVal) {
|
|
933
950
|
ref = toRaw(ref);
|
|
934
|
-
|
|
951
|
+
const dep = ref.dep;
|
|
952
|
+
if (dep) {
|
|
935
953
|
{
|
|
936
|
-
triggerEffects(
|
|
954
|
+
triggerEffects(dep);
|
|
937
955
|
}
|
|
938
956
|
}
|
|
939
957
|
}
|
|
@@ -1037,6 +1055,9 @@ class ObjectRefImpl {
|
|
|
1037
1055
|
set value(newVal) {
|
|
1038
1056
|
this._object[this._key] = newVal;
|
|
1039
1057
|
}
|
|
1058
|
+
get dep() {
|
|
1059
|
+
return getDepFromReactive(toRaw(this._object), this._key);
|
|
1060
|
+
}
|
|
1040
1061
|
}
|
|
1041
1062
|
function toRef(object, key, defaultValue) {
|
|
1042
1063
|
const val = object[key];
|
|
@@ -1045,13 +1066,13 @@ function toRef(object, key, defaultValue) {
|
|
|
1045
1066
|
: new ObjectRefImpl(object, key, defaultValue);
|
|
1046
1067
|
}
|
|
1047
1068
|
|
|
1048
|
-
var _a;
|
|
1069
|
+
var _a$1;
|
|
1049
1070
|
class ComputedRefImpl {
|
|
1050
1071
|
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1051
1072
|
this._setter = _setter;
|
|
1052
1073
|
this.dep = undefined;
|
|
1053
1074
|
this.__v_isRef = true;
|
|
1054
|
-
this[_a] = false;
|
|
1075
|
+
this[_a$1] = false;
|
|
1055
1076
|
this._dirty = true;
|
|
1056
1077
|
this.effect = new ReactiveEffect(getter, () => {
|
|
1057
1078
|
if (!this._dirty) {
|
|
@@ -1077,7 +1098,7 @@ class ComputedRefImpl {
|
|
|
1077
1098
|
this._setter(newValue);
|
|
1078
1099
|
}
|
|
1079
1100
|
}
|
|
1080
|
-
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1101
|
+
_a$1 = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1081
1102
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1082
1103
|
let getter;
|
|
1083
1104
|
let setter;
|
|
@@ -1094,7 +1115,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1094
1115
|
return cRef;
|
|
1095
1116
|
}
|
|
1096
1117
|
|
|
1097
|
-
var _a
|
|
1118
|
+
var _a;
|
|
1098
1119
|
const tick = /*#__PURE__*/ Promise.resolve();
|
|
1099
1120
|
const queue = [];
|
|
1100
1121
|
let queued = false;
|
|
@@ -1117,7 +1138,7 @@ class DeferredComputedRefImpl {
|
|
|
1117
1138
|
this.dep = undefined;
|
|
1118
1139
|
this._dirty = true;
|
|
1119
1140
|
this.__v_isRef = true;
|
|
1120
|
-
this[_a
|
|
1141
|
+
this[_a] = true;
|
|
1121
1142
|
let compareTarget;
|
|
1122
1143
|
let hasCompareTarget = false;
|
|
1123
1144
|
let scheduled = false;
|
|
@@ -1164,7 +1185,7 @@ class DeferredComputedRefImpl {
|
|
|
1164
1185
|
return toRaw(this)._get();
|
|
1165
1186
|
}
|
|
1166
1187
|
}
|
|
1167
|
-
_a
|
|
1188
|
+
_a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
|
|
1168
1189
|
function deferredComputed(getter) {
|
|
1169
1190
|
return new DeferredComputedRefImpl(getter);
|
|
1170
1191
|
}
|
package/dist/reactivity.d.ts
CHANGED
|
@@ -74,13 +74,14 @@ export declare type EffectScheduler = (...args: any[]) => any;
|
|
|
74
74
|
|
|
75
75
|
export declare class EffectScope {
|
|
76
76
|
detached: boolean;
|
|
77
|
-
/* Excluded from this release type:
|
|
77
|
+
/* Excluded from this release type: _active */
|
|
78
78
|
/* Excluded from this release type: effects */
|
|
79
79
|
/* Excluded from this release type: cleanups */
|
|
80
80
|
/* Excluded from this release type: parent */
|
|
81
81
|
/* Excluded from this release type: scopes */
|
|
82
82
|
/* Excluded from this release type: index */
|
|
83
83
|
constructor(detached?: boolean);
|
|
84
|
+
get active(): boolean;
|
|
84
85
|
run<T>(fn: () => T): T | undefined;
|
|
85
86
|
/* Excluded from this release type: on */
|
|
86
87
|
/* Excluded from this release type: off */
|