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