@vue/reactivity 3.5.0-alpha.2 → 3.5.0-alpha.3
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 +59 -51
- package/dist/reactivity.cjs.prod.js +54 -50
- package/dist/reactivity.d.ts +16 -13
- package/dist/reactivity.esm-browser.js +59 -51
- package/dist/reactivity.esm-browser.prod.js +2 -4
- package/dist/reactivity.esm-bundler.js +59 -51
- package/dist/reactivity.global.js +59 -51
- package/dist/reactivity.global.prod.js +2 -4
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/reactivity v3.5.0-alpha.
|
|
2
|
+
* @vue/reactivity v3.5.0-alpha.3
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -242,16 +242,14 @@ function endBatch() {
|
|
|
242
242
|
try {
|
|
243
243
|
e.trigger();
|
|
244
244
|
} catch (err) {
|
|
245
|
-
if (!error)
|
|
246
|
-
error = err;
|
|
245
|
+
if (!error) error = err;
|
|
247
246
|
}
|
|
248
247
|
}
|
|
249
248
|
e = next;
|
|
250
249
|
}
|
|
251
250
|
}
|
|
252
251
|
batchDepth--;
|
|
253
|
-
if (error)
|
|
254
|
-
throw error;
|
|
252
|
+
if (error) throw error;
|
|
255
253
|
}
|
|
256
254
|
function prepareDeps(sub) {
|
|
257
255
|
for (let link = sub.deps; link; link = link.nextDep) {
|
|
@@ -265,8 +263,7 @@ function cleanupDeps(sub) {
|
|
|
265
263
|
let tail = sub.depsTail;
|
|
266
264
|
for (let link = tail; link; link = link.prevDep) {
|
|
267
265
|
if (link.version === -1) {
|
|
268
|
-
if (link === tail)
|
|
269
|
-
tail = link.prevDep;
|
|
266
|
+
if (link === tail) tail = link.prevDep;
|
|
270
267
|
removeSub(link);
|
|
271
268
|
removeDep(link);
|
|
272
269
|
} else {
|
|
@@ -530,8 +527,7 @@ function addSub(link) {
|
|
|
530
527
|
const currentTail = link.dep.subs;
|
|
531
528
|
if (currentTail !== link) {
|
|
532
529
|
link.prevSub = currentTail;
|
|
533
|
-
if (currentTail)
|
|
534
|
-
currentTail.nextSub = link;
|
|
530
|
+
if (currentTail) currentTail.nextSub = link;
|
|
535
531
|
}
|
|
536
532
|
if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) {
|
|
537
533
|
link.dep.subsHead = link;
|
|
@@ -641,8 +637,7 @@ function getDepFromReactive(object, key) {
|
|
|
641
637
|
|
|
642
638
|
function reactiveReadArray(array) {
|
|
643
639
|
const raw = toRaw(array);
|
|
644
|
-
if (raw === array)
|
|
645
|
-
return raw;
|
|
640
|
+
if (raw === array) return raw;
|
|
646
641
|
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
647
642
|
return isShallow(array) ? raw : raw.map(toReactive);
|
|
648
643
|
}
|
|
@@ -816,8 +811,7 @@ const builtInSymbols = new Set(
|
|
|
816
811
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
817
812
|
);
|
|
818
813
|
function hasOwnProperty(key) {
|
|
819
|
-
if (!isSymbol(key))
|
|
820
|
-
key = String(key);
|
|
814
|
+
if (!isSymbol(key)) key = String(key);
|
|
821
815
|
const obj = toRaw(this);
|
|
822
816
|
track(obj, "has", key);
|
|
823
817
|
return obj.hasOwnProperty(key);
|
|
@@ -968,18 +962,18 @@ const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true
|
|
|
968
962
|
|
|
969
963
|
const toShallow = (value) => value;
|
|
970
964
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
971
|
-
function get(target, key,
|
|
965
|
+
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
972
966
|
target = target["__v_raw"];
|
|
973
967
|
const rawTarget = toRaw(target);
|
|
974
968
|
const rawKey = toRaw(key);
|
|
975
|
-
if (!
|
|
969
|
+
if (!isReadonly2) {
|
|
976
970
|
if (hasChanged(key, rawKey)) {
|
|
977
971
|
track(rawTarget, "get", key);
|
|
978
972
|
}
|
|
979
973
|
track(rawTarget, "get", rawKey);
|
|
980
974
|
}
|
|
981
975
|
const { has: has2 } = getProto(rawTarget);
|
|
982
|
-
const wrap =
|
|
976
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
983
977
|
if (has2.call(rawTarget, key)) {
|
|
984
978
|
return wrap(target.get(key));
|
|
985
979
|
} else if (has2.call(rawTarget, rawKey)) {
|
|
@@ -988,11 +982,11 @@ function get(target, key, isReadonly = false, isShallow = false) {
|
|
|
988
982
|
target.get(key);
|
|
989
983
|
}
|
|
990
984
|
}
|
|
991
|
-
function has(key,
|
|
985
|
+
function has(key, isReadonly2 = false) {
|
|
992
986
|
const target = this["__v_raw"];
|
|
993
987
|
const rawTarget = toRaw(target);
|
|
994
988
|
const rawKey = toRaw(key);
|
|
995
|
-
if (!
|
|
989
|
+
if (!isReadonly2) {
|
|
996
990
|
if (hasChanged(key, rawKey)) {
|
|
997
991
|
track(rawTarget, "has", key);
|
|
998
992
|
}
|
|
@@ -1000,13 +994,15 @@ function has(key, isReadonly = false) {
|
|
|
1000
994
|
}
|
|
1001
995
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1002
996
|
}
|
|
1003
|
-
function size(target,
|
|
997
|
+
function size(target, isReadonly2 = false) {
|
|
1004
998
|
target = target["__v_raw"];
|
|
1005
|
-
!
|
|
999
|
+
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1006
1000
|
return Reflect.get(target, "size", target);
|
|
1007
1001
|
}
|
|
1008
|
-
function add(value) {
|
|
1009
|
-
value
|
|
1002
|
+
function add(value, _isShallow = false) {
|
|
1003
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1004
|
+
value = toRaw(value);
|
|
1005
|
+
}
|
|
1010
1006
|
const target = toRaw(this);
|
|
1011
1007
|
const proto = getProto(target);
|
|
1012
1008
|
const hadKey = proto.has.call(target, value);
|
|
@@ -1016,8 +1012,10 @@ function add(value) {
|
|
|
1016
1012
|
}
|
|
1017
1013
|
return this;
|
|
1018
1014
|
}
|
|
1019
|
-
function set(key, value) {
|
|
1020
|
-
value
|
|
1015
|
+
function set(key, value, _isShallow = false) {
|
|
1016
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1017
|
+
value = toRaw(value);
|
|
1018
|
+
}
|
|
1021
1019
|
const target = toRaw(this);
|
|
1022
1020
|
const { has: has2, get: get2 } = getProto(target);
|
|
1023
1021
|
let hadKey = has2.call(target, key);
|
|
@@ -1063,19 +1061,19 @@ function clear() {
|
|
|
1063
1061
|
}
|
|
1064
1062
|
return result;
|
|
1065
1063
|
}
|
|
1066
|
-
function createForEach(
|
|
1064
|
+
function createForEach(isReadonly2, isShallow2) {
|
|
1067
1065
|
return function forEach(callback, thisArg) {
|
|
1068
1066
|
const observed = this;
|
|
1069
1067
|
const target = observed["__v_raw"];
|
|
1070
1068
|
const rawTarget = toRaw(target);
|
|
1071
|
-
const wrap =
|
|
1072
|
-
!
|
|
1069
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1070
|
+
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1073
1071
|
return target.forEach((value, key) => {
|
|
1074
1072
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1075
1073
|
});
|
|
1076
1074
|
};
|
|
1077
1075
|
}
|
|
1078
|
-
function createIterableMethod(method,
|
|
1076
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1079
1077
|
return function(...args) {
|
|
1080
1078
|
const target = this["__v_raw"];
|
|
1081
1079
|
const rawTarget = toRaw(target);
|
|
@@ -1083,8 +1081,8 @@ function createIterableMethod(method, isReadonly, isShallow) {
|
|
|
1083
1081
|
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
1084
1082
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
1085
1083
|
const innerIterator = target[method](...args);
|
|
1086
|
-
const wrap =
|
|
1087
|
-
!
|
|
1084
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1085
|
+
!isReadonly2 && track(
|
|
1088
1086
|
rawTarget,
|
|
1089
1087
|
"iterate",
|
|
1090
1088
|
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
@@ -1140,8 +1138,12 @@ function createInstrumentations() {
|
|
|
1140
1138
|
return size(this);
|
|
1141
1139
|
},
|
|
1142
1140
|
has,
|
|
1143
|
-
add
|
|
1144
|
-
|
|
1141
|
+
add(value) {
|
|
1142
|
+
return add.call(this, value, true);
|
|
1143
|
+
},
|
|
1144
|
+
set(key, value) {
|
|
1145
|
+
return set.call(this, key, value, true);
|
|
1146
|
+
},
|
|
1145
1147
|
delete: deleteEntry,
|
|
1146
1148
|
clear,
|
|
1147
1149
|
forEach: createForEach(false, true)
|
|
@@ -1207,13 +1209,13 @@ const [
|
|
|
1207
1209
|
shallowInstrumentations,
|
|
1208
1210
|
shallowReadonlyInstrumentations
|
|
1209
1211
|
] = /* @__PURE__ */ createInstrumentations();
|
|
1210
|
-
function createInstrumentationGetter(
|
|
1211
|
-
const instrumentations = shallow ?
|
|
1212
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1213
|
+
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
1212
1214
|
return (target, key, receiver) => {
|
|
1213
1215
|
if (key === "__v_isReactive") {
|
|
1214
|
-
return !
|
|
1216
|
+
return !isReadonly2;
|
|
1215
1217
|
} else if (key === "__v_isReadonly") {
|
|
1216
|
-
return
|
|
1218
|
+
return isReadonly2;
|
|
1217
1219
|
} else if (key === "__v_raw") {
|
|
1218
1220
|
return target;
|
|
1219
1221
|
}
|
|
@@ -1309,7 +1311,11 @@ function shallowReadonly(target) {
|
|
|
1309
1311
|
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
1310
1312
|
if (!isObject(target)) {
|
|
1311
1313
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1312
|
-
warn(
|
|
1314
|
+
warn(
|
|
1315
|
+
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
|
|
1316
|
+
target
|
|
1317
|
+
)}`
|
|
1318
|
+
);
|
|
1313
1319
|
}
|
|
1314
1320
|
return target;
|
|
1315
1321
|
}
|
|
@@ -1360,7 +1366,7 @@ const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
|
1360
1366
|
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1361
1367
|
|
|
1362
1368
|
function isRef(r) {
|
|
1363
|
-
return r ? r
|
|
1369
|
+
return r ? r["__v_isRef"] === true : false;
|
|
1364
1370
|
}
|
|
1365
1371
|
function ref(value) {
|
|
1366
1372
|
return createRef(value, false);
|
|
@@ -1375,12 +1381,13 @@ function createRef(rawValue, shallow) {
|
|
|
1375
1381
|
return new RefImpl(rawValue, shallow);
|
|
1376
1382
|
}
|
|
1377
1383
|
class RefImpl {
|
|
1378
|
-
constructor(value,
|
|
1379
|
-
this.__v_isShallow = __v_isShallow;
|
|
1384
|
+
constructor(value, isShallow2) {
|
|
1380
1385
|
this.dep = new Dep();
|
|
1381
|
-
this
|
|
1382
|
-
this
|
|
1383
|
-
this.
|
|
1386
|
+
this["__v_isRef"] = true;
|
|
1387
|
+
this["__v_isShallow"] = false;
|
|
1388
|
+
this._rawValue = isShallow2 ? value : toRaw(value);
|
|
1389
|
+
this._value = isShallow2 ? value : toReactive(value);
|
|
1390
|
+
this["__v_isShallow"] = isShallow2;
|
|
1384
1391
|
}
|
|
1385
1392
|
get value() {
|
|
1386
1393
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
@@ -1396,7 +1403,7 @@ class RefImpl {
|
|
|
1396
1403
|
}
|
|
1397
1404
|
set value(newValue) {
|
|
1398
1405
|
const oldValue = this._rawValue;
|
|
1399
|
-
const useDirectValue = this
|
|
1406
|
+
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1400
1407
|
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
1401
1408
|
if (hasChanged(newValue, oldValue)) {
|
|
1402
1409
|
this._rawValue = newValue;
|
|
@@ -1450,7 +1457,7 @@ function proxyRefs(objectWithRefs) {
|
|
|
1450
1457
|
}
|
|
1451
1458
|
class CustomRefImpl {
|
|
1452
1459
|
constructor(factory) {
|
|
1453
|
-
this
|
|
1460
|
+
this["__v_isRef"] = true;
|
|
1454
1461
|
const dep = this.dep = new Dep();
|
|
1455
1462
|
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
|
|
1456
1463
|
this._get = get;
|
|
@@ -1481,7 +1488,7 @@ class ObjectRefImpl {
|
|
|
1481
1488
|
this._object = _object;
|
|
1482
1489
|
this._key = _key;
|
|
1483
1490
|
this._defaultValue = _defaultValue;
|
|
1484
|
-
this
|
|
1491
|
+
this["__v_isRef"] = true;
|
|
1485
1492
|
}
|
|
1486
1493
|
get value() {
|
|
1487
1494
|
const val = this._object[this._key];
|
|
@@ -1497,8 +1504,8 @@ class ObjectRefImpl {
|
|
|
1497
1504
|
class GetterRefImpl {
|
|
1498
1505
|
constructor(_getter) {
|
|
1499
1506
|
this._getter = _getter;
|
|
1500
|
-
this
|
|
1501
|
-
this
|
|
1507
|
+
this["__v_isRef"] = true;
|
|
1508
|
+
this["__v_isReadonly"] = true;
|
|
1502
1509
|
}
|
|
1503
1510
|
get value() {
|
|
1504
1511
|
return this._getter();
|
|
@@ -1535,7 +1542,7 @@ class ComputedRefImpl {
|
|
|
1535
1542
|
/**
|
|
1536
1543
|
* @internal
|
|
1537
1544
|
*/
|
|
1538
|
-
this
|
|
1545
|
+
this["__v_isRef"] = true;
|
|
1539
1546
|
// A computed is also a subscriber that tracks other deps
|
|
1540
1547
|
/**
|
|
1541
1548
|
* @internal
|
|
@@ -1555,7 +1562,7 @@ class ComputedRefImpl {
|
|
|
1555
1562
|
this.globalVersion = globalVersion - 1;
|
|
1556
1563
|
// for backwards compat
|
|
1557
1564
|
this.effect = this;
|
|
1558
|
-
this
|
|
1565
|
+
this["__v_isReadonly"] = !setter;
|
|
1559
1566
|
this.isSSR = isSSR;
|
|
1560
1567
|
}
|
|
1561
1568
|
/**
|
|
@@ -1620,7 +1627,8 @@ const ReactiveFlags = {
|
|
|
1620
1627
|
"IS_REACTIVE": "__v_isReactive",
|
|
1621
1628
|
"IS_READONLY": "__v_isReadonly",
|
|
1622
1629
|
"IS_SHALLOW": "__v_isShallow",
|
|
1623
|
-
"RAW": "__v_raw"
|
|
1630
|
+
"RAW": "__v_raw",
|
|
1631
|
+
"IS_REF": "__v_isRef"
|
|
1624
1632
|
};
|
|
1625
1633
|
|
|
1626
1634
|
export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, trigger, triggerRef, unref };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/reactivity v3.5.0-alpha.
|
|
2
|
+
* @vue/reactivity v3.5.0-alpha.3
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -285,16 +285,14 @@ var VueReactivity = (function (exports) {
|
|
|
285
285
|
try {
|
|
286
286
|
e.trigger();
|
|
287
287
|
} catch (err) {
|
|
288
|
-
if (!error)
|
|
289
|
-
error = err;
|
|
288
|
+
if (!error) error = err;
|
|
290
289
|
}
|
|
291
290
|
}
|
|
292
291
|
e = next;
|
|
293
292
|
}
|
|
294
293
|
}
|
|
295
294
|
batchDepth--;
|
|
296
|
-
if (error)
|
|
297
|
-
throw error;
|
|
295
|
+
if (error) throw error;
|
|
298
296
|
}
|
|
299
297
|
function prepareDeps(sub) {
|
|
300
298
|
for (let link = sub.deps; link; link = link.nextDep) {
|
|
@@ -308,8 +306,7 @@ var VueReactivity = (function (exports) {
|
|
|
308
306
|
let tail = sub.depsTail;
|
|
309
307
|
for (let link = tail; link; link = link.prevDep) {
|
|
310
308
|
if (link.version === -1) {
|
|
311
|
-
if (link === tail)
|
|
312
|
-
tail = link.prevDep;
|
|
309
|
+
if (link === tail) tail = link.prevDep;
|
|
313
310
|
removeSub(link);
|
|
314
311
|
removeDep(link);
|
|
315
312
|
} else {
|
|
@@ -573,8 +570,7 @@ var VueReactivity = (function (exports) {
|
|
|
573
570
|
const currentTail = link.dep.subs;
|
|
574
571
|
if (currentTail !== link) {
|
|
575
572
|
link.prevSub = currentTail;
|
|
576
|
-
if (currentTail)
|
|
577
|
-
currentTail.nextSub = link;
|
|
573
|
+
if (currentTail) currentTail.nextSub = link;
|
|
578
574
|
}
|
|
579
575
|
if (link.dep.subsHead === void 0) {
|
|
580
576
|
link.dep.subsHead = link;
|
|
@@ -680,8 +676,7 @@ var VueReactivity = (function (exports) {
|
|
|
680
676
|
|
|
681
677
|
function reactiveReadArray(array) {
|
|
682
678
|
const raw = toRaw(array);
|
|
683
|
-
if (raw === array)
|
|
684
|
-
return raw;
|
|
679
|
+
if (raw === array) return raw;
|
|
685
680
|
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
686
681
|
return isShallow(array) ? raw : raw.map(toReactive);
|
|
687
682
|
}
|
|
@@ -855,8 +850,7 @@ var VueReactivity = (function (exports) {
|
|
|
855
850
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
856
851
|
);
|
|
857
852
|
function hasOwnProperty(key) {
|
|
858
|
-
if (!isSymbol(key))
|
|
859
|
-
key = String(key);
|
|
853
|
+
if (!isSymbol(key)) key = String(key);
|
|
860
854
|
const obj = toRaw(this);
|
|
861
855
|
track(obj, "has", key);
|
|
862
856
|
return obj.hasOwnProperty(key);
|
|
@@ -1007,18 +1001,18 @@ var VueReactivity = (function (exports) {
|
|
|
1007
1001
|
|
|
1008
1002
|
const toShallow = (value) => value;
|
|
1009
1003
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1010
|
-
function get(target, key,
|
|
1004
|
+
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
1011
1005
|
target = target["__v_raw"];
|
|
1012
1006
|
const rawTarget = toRaw(target);
|
|
1013
1007
|
const rawKey = toRaw(key);
|
|
1014
|
-
if (!
|
|
1008
|
+
if (!isReadonly2) {
|
|
1015
1009
|
if (hasChanged(key, rawKey)) {
|
|
1016
1010
|
track(rawTarget, "get", key);
|
|
1017
1011
|
}
|
|
1018
1012
|
track(rawTarget, "get", rawKey);
|
|
1019
1013
|
}
|
|
1020
1014
|
const { has: has2 } = getProto(rawTarget);
|
|
1021
|
-
const wrap =
|
|
1015
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1022
1016
|
if (has2.call(rawTarget, key)) {
|
|
1023
1017
|
return wrap(target.get(key));
|
|
1024
1018
|
} else if (has2.call(rawTarget, rawKey)) {
|
|
@@ -1027,11 +1021,11 @@ var VueReactivity = (function (exports) {
|
|
|
1027
1021
|
target.get(key);
|
|
1028
1022
|
}
|
|
1029
1023
|
}
|
|
1030
|
-
function has(key,
|
|
1024
|
+
function has(key, isReadonly2 = false) {
|
|
1031
1025
|
const target = this["__v_raw"];
|
|
1032
1026
|
const rawTarget = toRaw(target);
|
|
1033
1027
|
const rawKey = toRaw(key);
|
|
1034
|
-
if (!
|
|
1028
|
+
if (!isReadonly2) {
|
|
1035
1029
|
if (hasChanged(key, rawKey)) {
|
|
1036
1030
|
track(rawTarget, "has", key);
|
|
1037
1031
|
}
|
|
@@ -1039,13 +1033,15 @@ var VueReactivity = (function (exports) {
|
|
|
1039
1033
|
}
|
|
1040
1034
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1041
1035
|
}
|
|
1042
|
-
function size(target,
|
|
1036
|
+
function size(target, isReadonly2 = false) {
|
|
1043
1037
|
target = target["__v_raw"];
|
|
1044
|
-
!
|
|
1038
|
+
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1045
1039
|
return Reflect.get(target, "size", target);
|
|
1046
1040
|
}
|
|
1047
|
-
function add(value) {
|
|
1048
|
-
value
|
|
1041
|
+
function add(value, _isShallow = false) {
|
|
1042
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1043
|
+
value = toRaw(value);
|
|
1044
|
+
}
|
|
1049
1045
|
const target = toRaw(this);
|
|
1050
1046
|
const proto = getProto(target);
|
|
1051
1047
|
const hadKey = proto.has.call(target, value);
|
|
@@ -1055,8 +1051,10 @@ var VueReactivity = (function (exports) {
|
|
|
1055
1051
|
}
|
|
1056
1052
|
return this;
|
|
1057
1053
|
}
|
|
1058
|
-
function set(key, value) {
|
|
1059
|
-
value
|
|
1054
|
+
function set(key, value, _isShallow = false) {
|
|
1055
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1056
|
+
value = toRaw(value);
|
|
1057
|
+
}
|
|
1060
1058
|
const target = toRaw(this);
|
|
1061
1059
|
const { has: has2, get: get2 } = getProto(target);
|
|
1062
1060
|
let hadKey = has2.call(target, key);
|
|
@@ -1102,19 +1100,19 @@ var VueReactivity = (function (exports) {
|
|
|
1102
1100
|
}
|
|
1103
1101
|
return result;
|
|
1104
1102
|
}
|
|
1105
|
-
function createForEach(
|
|
1103
|
+
function createForEach(isReadonly2, isShallow2) {
|
|
1106
1104
|
return function forEach(callback, thisArg) {
|
|
1107
1105
|
const observed = this;
|
|
1108
1106
|
const target = observed["__v_raw"];
|
|
1109
1107
|
const rawTarget = toRaw(target);
|
|
1110
|
-
const wrap =
|
|
1111
|
-
!
|
|
1108
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1109
|
+
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1112
1110
|
return target.forEach((value, key) => {
|
|
1113
1111
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1114
1112
|
});
|
|
1115
1113
|
};
|
|
1116
1114
|
}
|
|
1117
|
-
function createIterableMethod(method,
|
|
1115
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1118
1116
|
return function(...args) {
|
|
1119
1117
|
const target = this["__v_raw"];
|
|
1120
1118
|
const rawTarget = toRaw(target);
|
|
@@ -1122,8 +1120,8 @@ var VueReactivity = (function (exports) {
|
|
|
1122
1120
|
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
1123
1121
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
1124
1122
|
const innerIterator = target[method](...args);
|
|
1125
|
-
const wrap =
|
|
1126
|
-
!
|
|
1123
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1124
|
+
!isReadonly2 && track(
|
|
1127
1125
|
rawTarget,
|
|
1128
1126
|
"iterate",
|
|
1129
1127
|
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
@@ -1179,8 +1177,12 @@ var VueReactivity = (function (exports) {
|
|
|
1179
1177
|
return size(this);
|
|
1180
1178
|
},
|
|
1181
1179
|
has,
|
|
1182
|
-
add
|
|
1183
|
-
|
|
1180
|
+
add(value) {
|
|
1181
|
+
return add.call(this, value, true);
|
|
1182
|
+
},
|
|
1183
|
+
set(key, value) {
|
|
1184
|
+
return set.call(this, key, value, true);
|
|
1185
|
+
},
|
|
1184
1186
|
delete: deleteEntry,
|
|
1185
1187
|
clear,
|
|
1186
1188
|
forEach: createForEach(false, true)
|
|
@@ -1246,13 +1248,13 @@ var VueReactivity = (function (exports) {
|
|
|
1246
1248
|
shallowInstrumentations,
|
|
1247
1249
|
shallowReadonlyInstrumentations
|
|
1248
1250
|
] = /* @__PURE__ */ createInstrumentations();
|
|
1249
|
-
function createInstrumentationGetter(
|
|
1250
|
-
const instrumentations = shallow ?
|
|
1251
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1252
|
+
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
1251
1253
|
return (target, key, receiver) => {
|
|
1252
1254
|
if (key === "__v_isReactive") {
|
|
1253
|
-
return !
|
|
1255
|
+
return !isReadonly2;
|
|
1254
1256
|
} else if (key === "__v_isReadonly") {
|
|
1255
|
-
return
|
|
1257
|
+
return isReadonly2;
|
|
1256
1258
|
} else if (key === "__v_raw") {
|
|
1257
1259
|
return target;
|
|
1258
1260
|
}
|
|
@@ -1348,7 +1350,11 @@ var VueReactivity = (function (exports) {
|
|
|
1348
1350
|
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
1349
1351
|
if (!isObject(target)) {
|
|
1350
1352
|
{
|
|
1351
|
-
warn(
|
|
1353
|
+
warn(
|
|
1354
|
+
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
|
|
1355
|
+
target
|
|
1356
|
+
)}`
|
|
1357
|
+
);
|
|
1352
1358
|
}
|
|
1353
1359
|
return target;
|
|
1354
1360
|
}
|
|
@@ -1399,7 +1405,7 @@ var VueReactivity = (function (exports) {
|
|
|
1399
1405
|
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1400
1406
|
|
|
1401
1407
|
function isRef(r) {
|
|
1402
|
-
return r ? r
|
|
1408
|
+
return r ? r["__v_isRef"] === true : false;
|
|
1403
1409
|
}
|
|
1404
1410
|
function ref(value) {
|
|
1405
1411
|
return createRef(value, false);
|
|
@@ -1414,12 +1420,13 @@ var VueReactivity = (function (exports) {
|
|
|
1414
1420
|
return new RefImpl(rawValue, shallow);
|
|
1415
1421
|
}
|
|
1416
1422
|
class RefImpl {
|
|
1417
|
-
constructor(value,
|
|
1418
|
-
this.__v_isShallow = __v_isShallow;
|
|
1423
|
+
constructor(value, isShallow2) {
|
|
1419
1424
|
this.dep = new Dep();
|
|
1420
|
-
this
|
|
1421
|
-
this
|
|
1422
|
-
this.
|
|
1425
|
+
this["__v_isRef"] = true;
|
|
1426
|
+
this["__v_isShallow"] = false;
|
|
1427
|
+
this._rawValue = isShallow2 ? value : toRaw(value);
|
|
1428
|
+
this._value = isShallow2 ? value : toReactive(value);
|
|
1429
|
+
this["__v_isShallow"] = isShallow2;
|
|
1423
1430
|
}
|
|
1424
1431
|
get value() {
|
|
1425
1432
|
{
|
|
@@ -1433,7 +1440,7 @@ var VueReactivity = (function (exports) {
|
|
|
1433
1440
|
}
|
|
1434
1441
|
set value(newValue) {
|
|
1435
1442
|
const oldValue = this._rawValue;
|
|
1436
|
-
const useDirectValue = this
|
|
1443
|
+
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1437
1444
|
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
1438
1445
|
if (hasChanged(newValue, oldValue)) {
|
|
1439
1446
|
this._rawValue = newValue;
|
|
@@ -1483,7 +1490,7 @@ var VueReactivity = (function (exports) {
|
|
|
1483
1490
|
}
|
|
1484
1491
|
class CustomRefImpl {
|
|
1485
1492
|
constructor(factory) {
|
|
1486
|
-
this
|
|
1493
|
+
this["__v_isRef"] = true;
|
|
1487
1494
|
const dep = this.dep = new Dep();
|
|
1488
1495
|
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
|
|
1489
1496
|
this._get = get;
|
|
@@ -1514,7 +1521,7 @@ var VueReactivity = (function (exports) {
|
|
|
1514
1521
|
this._object = _object;
|
|
1515
1522
|
this._key = _key;
|
|
1516
1523
|
this._defaultValue = _defaultValue;
|
|
1517
|
-
this
|
|
1524
|
+
this["__v_isRef"] = true;
|
|
1518
1525
|
}
|
|
1519
1526
|
get value() {
|
|
1520
1527
|
const val = this._object[this._key];
|
|
@@ -1530,8 +1537,8 @@ var VueReactivity = (function (exports) {
|
|
|
1530
1537
|
class GetterRefImpl {
|
|
1531
1538
|
constructor(_getter) {
|
|
1532
1539
|
this._getter = _getter;
|
|
1533
|
-
this
|
|
1534
|
-
this
|
|
1540
|
+
this["__v_isRef"] = true;
|
|
1541
|
+
this["__v_isReadonly"] = true;
|
|
1535
1542
|
}
|
|
1536
1543
|
get value() {
|
|
1537
1544
|
return this._getter();
|
|
@@ -1568,7 +1575,7 @@ var VueReactivity = (function (exports) {
|
|
|
1568
1575
|
/**
|
|
1569
1576
|
* @internal
|
|
1570
1577
|
*/
|
|
1571
|
-
this
|
|
1578
|
+
this["__v_isRef"] = true;
|
|
1572
1579
|
// A computed is also a subscriber that tracks other deps
|
|
1573
1580
|
/**
|
|
1574
1581
|
* @internal
|
|
@@ -1588,7 +1595,7 @@ var VueReactivity = (function (exports) {
|
|
|
1588
1595
|
this.globalVersion = globalVersion - 1;
|
|
1589
1596
|
// for backwards compat
|
|
1590
1597
|
this.effect = this;
|
|
1591
|
-
this
|
|
1598
|
+
this["__v_isReadonly"] = !setter;
|
|
1592
1599
|
this.isSSR = isSSR;
|
|
1593
1600
|
}
|
|
1594
1601
|
/**
|
|
@@ -1653,7 +1660,8 @@ var VueReactivity = (function (exports) {
|
|
|
1653
1660
|
"IS_REACTIVE": "__v_isReactive",
|
|
1654
1661
|
"IS_READONLY": "__v_isReadonly",
|
|
1655
1662
|
"IS_SHALLOW": "__v_isShallow",
|
|
1656
|
-
"RAW": "__v_raw"
|
|
1663
|
+
"RAW": "__v_raw",
|
|
1664
|
+
"IS_REF": "__v_isRef"
|
|
1657
1665
|
};
|
|
1658
1666
|
|
|
1659
1667
|
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|