@vue/reactivity 3.5.0-alpha.1 → 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 +61 -52
- package/dist/reactivity.esm-browser.prod.js +2 -4
- package/dist/reactivity.esm-bundler.js +59 -51
- package/dist/reactivity.global.js +61 -52
- 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
|
**/
|
|
@@ -39,10 +39,11 @@ var VueReactivity = (function (exports) {
|
|
|
39
39
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
40
40
|
});
|
|
41
41
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
42
|
-
const def = (obj, key, value) => {
|
|
42
|
+
const def = (obj, key, value, writable = false) => {
|
|
43
43
|
Object.defineProperty(obj, key, {
|
|
44
44
|
configurable: true,
|
|
45
45
|
enumerable: false,
|
|
46
|
+
writable,
|
|
46
47
|
value
|
|
47
48
|
});
|
|
48
49
|
};
|
|
@@ -284,16 +285,14 @@ var VueReactivity = (function (exports) {
|
|
|
284
285
|
try {
|
|
285
286
|
e.trigger();
|
|
286
287
|
} catch (err) {
|
|
287
|
-
if (!error)
|
|
288
|
-
error = err;
|
|
288
|
+
if (!error) error = err;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
e = next;
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
batchDepth--;
|
|
295
|
-
if (error)
|
|
296
|
-
throw error;
|
|
295
|
+
if (error) throw error;
|
|
297
296
|
}
|
|
298
297
|
function prepareDeps(sub) {
|
|
299
298
|
for (let link = sub.deps; link; link = link.nextDep) {
|
|
@@ -307,8 +306,7 @@ var VueReactivity = (function (exports) {
|
|
|
307
306
|
let tail = sub.depsTail;
|
|
308
307
|
for (let link = tail; link; link = link.prevDep) {
|
|
309
308
|
if (link.version === -1) {
|
|
310
|
-
if (link === tail)
|
|
311
|
-
tail = link.prevDep;
|
|
309
|
+
if (link === tail) tail = link.prevDep;
|
|
312
310
|
removeSub(link);
|
|
313
311
|
removeDep(link);
|
|
314
312
|
} else {
|
|
@@ -572,8 +570,7 @@ var VueReactivity = (function (exports) {
|
|
|
572
570
|
const currentTail = link.dep.subs;
|
|
573
571
|
if (currentTail !== link) {
|
|
574
572
|
link.prevSub = currentTail;
|
|
575
|
-
if (currentTail)
|
|
576
|
-
currentTail.nextSub = link;
|
|
573
|
+
if (currentTail) currentTail.nextSub = link;
|
|
577
574
|
}
|
|
578
575
|
if (link.dep.subsHead === void 0) {
|
|
579
576
|
link.dep.subsHead = link;
|
|
@@ -679,8 +676,7 @@ var VueReactivity = (function (exports) {
|
|
|
679
676
|
|
|
680
677
|
function reactiveReadArray(array) {
|
|
681
678
|
const raw = toRaw(array);
|
|
682
|
-
if (raw === array)
|
|
683
|
-
return raw;
|
|
679
|
+
if (raw === array) return raw;
|
|
684
680
|
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
685
681
|
return isShallow(array) ? raw : raw.map(toReactive);
|
|
686
682
|
}
|
|
@@ -854,8 +850,7 @@ var VueReactivity = (function (exports) {
|
|
|
854
850
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
855
851
|
);
|
|
856
852
|
function hasOwnProperty(key) {
|
|
857
|
-
if (!isSymbol(key))
|
|
858
|
-
key = String(key);
|
|
853
|
+
if (!isSymbol(key)) key = String(key);
|
|
859
854
|
const obj = toRaw(this);
|
|
860
855
|
track(obj, "has", key);
|
|
861
856
|
return obj.hasOwnProperty(key);
|
|
@@ -1006,18 +1001,18 @@ var VueReactivity = (function (exports) {
|
|
|
1006
1001
|
|
|
1007
1002
|
const toShallow = (value) => value;
|
|
1008
1003
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1009
|
-
function get(target, key,
|
|
1004
|
+
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
1010
1005
|
target = target["__v_raw"];
|
|
1011
1006
|
const rawTarget = toRaw(target);
|
|
1012
1007
|
const rawKey = toRaw(key);
|
|
1013
|
-
if (!
|
|
1008
|
+
if (!isReadonly2) {
|
|
1014
1009
|
if (hasChanged(key, rawKey)) {
|
|
1015
1010
|
track(rawTarget, "get", key);
|
|
1016
1011
|
}
|
|
1017
1012
|
track(rawTarget, "get", rawKey);
|
|
1018
1013
|
}
|
|
1019
1014
|
const { has: has2 } = getProto(rawTarget);
|
|
1020
|
-
const wrap =
|
|
1015
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1021
1016
|
if (has2.call(rawTarget, key)) {
|
|
1022
1017
|
return wrap(target.get(key));
|
|
1023
1018
|
} else if (has2.call(rawTarget, rawKey)) {
|
|
@@ -1026,11 +1021,11 @@ var VueReactivity = (function (exports) {
|
|
|
1026
1021
|
target.get(key);
|
|
1027
1022
|
}
|
|
1028
1023
|
}
|
|
1029
|
-
function has(key,
|
|
1024
|
+
function has(key, isReadonly2 = false) {
|
|
1030
1025
|
const target = this["__v_raw"];
|
|
1031
1026
|
const rawTarget = toRaw(target);
|
|
1032
1027
|
const rawKey = toRaw(key);
|
|
1033
|
-
if (!
|
|
1028
|
+
if (!isReadonly2) {
|
|
1034
1029
|
if (hasChanged(key, rawKey)) {
|
|
1035
1030
|
track(rawTarget, "has", key);
|
|
1036
1031
|
}
|
|
@@ -1038,13 +1033,15 @@ var VueReactivity = (function (exports) {
|
|
|
1038
1033
|
}
|
|
1039
1034
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1040
1035
|
}
|
|
1041
|
-
function size(target,
|
|
1036
|
+
function size(target, isReadonly2 = false) {
|
|
1042
1037
|
target = target["__v_raw"];
|
|
1043
|
-
!
|
|
1038
|
+
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1044
1039
|
return Reflect.get(target, "size", target);
|
|
1045
1040
|
}
|
|
1046
|
-
function add(value) {
|
|
1047
|
-
value
|
|
1041
|
+
function add(value, _isShallow = false) {
|
|
1042
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1043
|
+
value = toRaw(value);
|
|
1044
|
+
}
|
|
1048
1045
|
const target = toRaw(this);
|
|
1049
1046
|
const proto = getProto(target);
|
|
1050
1047
|
const hadKey = proto.has.call(target, value);
|
|
@@ -1054,8 +1051,10 @@ var VueReactivity = (function (exports) {
|
|
|
1054
1051
|
}
|
|
1055
1052
|
return this;
|
|
1056
1053
|
}
|
|
1057
|
-
function set(key, value) {
|
|
1058
|
-
value
|
|
1054
|
+
function set(key, value, _isShallow = false) {
|
|
1055
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1056
|
+
value = toRaw(value);
|
|
1057
|
+
}
|
|
1059
1058
|
const target = toRaw(this);
|
|
1060
1059
|
const { has: has2, get: get2 } = getProto(target);
|
|
1061
1060
|
let hadKey = has2.call(target, key);
|
|
@@ -1101,19 +1100,19 @@ var VueReactivity = (function (exports) {
|
|
|
1101
1100
|
}
|
|
1102
1101
|
return result;
|
|
1103
1102
|
}
|
|
1104
|
-
function createForEach(
|
|
1103
|
+
function createForEach(isReadonly2, isShallow2) {
|
|
1105
1104
|
return function forEach(callback, thisArg) {
|
|
1106
1105
|
const observed = this;
|
|
1107
1106
|
const target = observed["__v_raw"];
|
|
1108
1107
|
const rawTarget = toRaw(target);
|
|
1109
|
-
const wrap =
|
|
1110
|
-
!
|
|
1108
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1109
|
+
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1111
1110
|
return target.forEach((value, key) => {
|
|
1112
1111
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1113
1112
|
});
|
|
1114
1113
|
};
|
|
1115
1114
|
}
|
|
1116
|
-
function createIterableMethod(method,
|
|
1115
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1117
1116
|
return function(...args) {
|
|
1118
1117
|
const target = this["__v_raw"];
|
|
1119
1118
|
const rawTarget = toRaw(target);
|
|
@@ -1121,8 +1120,8 @@ var VueReactivity = (function (exports) {
|
|
|
1121
1120
|
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
1122
1121
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
1123
1122
|
const innerIterator = target[method](...args);
|
|
1124
|
-
const wrap =
|
|
1125
|
-
!
|
|
1123
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1124
|
+
!isReadonly2 && track(
|
|
1126
1125
|
rawTarget,
|
|
1127
1126
|
"iterate",
|
|
1128
1127
|
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
@@ -1178,8 +1177,12 @@ var VueReactivity = (function (exports) {
|
|
|
1178
1177
|
return size(this);
|
|
1179
1178
|
},
|
|
1180
1179
|
has,
|
|
1181
|
-
add
|
|
1182
|
-
|
|
1180
|
+
add(value) {
|
|
1181
|
+
return add.call(this, value, true);
|
|
1182
|
+
},
|
|
1183
|
+
set(key, value) {
|
|
1184
|
+
return set.call(this, key, value, true);
|
|
1185
|
+
},
|
|
1183
1186
|
delete: deleteEntry,
|
|
1184
1187
|
clear,
|
|
1185
1188
|
forEach: createForEach(false, true)
|
|
@@ -1245,13 +1248,13 @@ var VueReactivity = (function (exports) {
|
|
|
1245
1248
|
shallowInstrumentations,
|
|
1246
1249
|
shallowReadonlyInstrumentations
|
|
1247
1250
|
] = /* @__PURE__ */ createInstrumentations();
|
|
1248
|
-
function createInstrumentationGetter(
|
|
1249
|
-
const instrumentations = shallow ?
|
|
1251
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1252
|
+
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
1250
1253
|
return (target, key, receiver) => {
|
|
1251
1254
|
if (key === "__v_isReactive") {
|
|
1252
|
-
return !
|
|
1255
|
+
return !isReadonly2;
|
|
1253
1256
|
} else if (key === "__v_isReadonly") {
|
|
1254
|
-
return
|
|
1257
|
+
return isReadonly2;
|
|
1255
1258
|
} else if (key === "__v_raw") {
|
|
1256
1259
|
return target;
|
|
1257
1260
|
}
|
|
@@ -1347,7 +1350,11 @@ var VueReactivity = (function (exports) {
|
|
|
1347
1350
|
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
1348
1351
|
if (!isObject(target)) {
|
|
1349
1352
|
{
|
|
1350
|
-
warn(
|
|
1353
|
+
warn(
|
|
1354
|
+
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
|
|
1355
|
+
target
|
|
1356
|
+
)}`
|
|
1357
|
+
);
|
|
1351
1358
|
}
|
|
1352
1359
|
return target;
|
|
1353
1360
|
}
|
|
@@ -1398,7 +1405,7 @@ var VueReactivity = (function (exports) {
|
|
|
1398
1405
|
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1399
1406
|
|
|
1400
1407
|
function isRef(r) {
|
|
1401
|
-
return r ? r
|
|
1408
|
+
return r ? r["__v_isRef"] === true : false;
|
|
1402
1409
|
}
|
|
1403
1410
|
function ref(value) {
|
|
1404
1411
|
return createRef(value, false);
|
|
@@ -1413,12 +1420,13 @@ var VueReactivity = (function (exports) {
|
|
|
1413
1420
|
return new RefImpl(rawValue, shallow);
|
|
1414
1421
|
}
|
|
1415
1422
|
class RefImpl {
|
|
1416
|
-
constructor(value,
|
|
1417
|
-
this.__v_isShallow = __v_isShallow;
|
|
1423
|
+
constructor(value, isShallow2) {
|
|
1418
1424
|
this.dep = new Dep();
|
|
1419
|
-
this
|
|
1420
|
-
this
|
|
1421
|
-
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;
|
|
1422
1430
|
}
|
|
1423
1431
|
get value() {
|
|
1424
1432
|
{
|
|
@@ -1432,7 +1440,7 @@ var VueReactivity = (function (exports) {
|
|
|
1432
1440
|
}
|
|
1433
1441
|
set value(newValue) {
|
|
1434
1442
|
const oldValue = this._rawValue;
|
|
1435
|
-
const useDirectValue = this
|
|
1443
|
+
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1436
1444
|
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
1437
1445
|
if (hasChanged(newValue, oldValue)) {
|
|
1438
1446
|
this._rawValue = newValue;
|
|
@@ -1482,7 +1490,7 @@ var VueReactivity = (function (exports) {
|
|
|
1482
1490
|
}
|
|
1483
1491
|
class CustomRefImpl {
|
|
1484
1492
|
constructor(factory) {
|
|
1485
|
-
this
|
|
1493
|
+
this["__v_isRef"] = true;
|
|
1486
1494
|
const dep = this.dep = new Dep();
|
|
1487
1495
|
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
|
|
1488
1496
|
this._get = get;
|
|
@@ -1513,7 +1521,7 @@ var VueReactivity = (function (exports) {
|
|
|
1513
1521
|
this._object = _object;
|
|
1514
1522
|
this._key = _key;
|
|
1515
1523
|
this._defaultValue = _defaultValue;
|
|
1516
|
-
this
|
|
1524
|
+
this["__v_isRef"] = true;
|
|
1517
1525
|
}
|
|
1518
1526
|
get value() {
|
|
1519
1527
|
const val = this._object[this._key];
|
|
@@ -1529,8 +1537,8 @@ var VueReactivity = (function (exports) {
|
|
|
1529
1537
|
class GetterRefImpl {
|
|
1530
1538
|
constructor(_getter) {
|
|
1531
1539
|
this._getter = _getter;
|
|
1532
|
-
this
|
|
1533
|
-
this
|
|
1540
|
+
this["__v_isRef"] = true;
|
|
1541
|
+
this["__v_isReadonly"] = true;
|
|
1534
1542
|
}
|
|
1535
1543
|
get value() {
|
|
1536
1544
|
return this._getter();
|
|
@@ -1567,7 +1575,7 @@ var VueReactivity = (function (exports) {
|
|
|
1567
1575
|
/**
|
|
1568
1576
|
* @internal
|
|
1569
1577
|
*/
|
|
1570
|
-
this
|
|
1578
|
+
this["__v_isRef"] = true;
|
|
1571
1579
|
// A computed is also a subscriber that tracks other deps
|
|
1572
1580
|
/**
|
|
1573
1581
|
* @internal
|
|
@@ -1587,7 +1595,7 @@ var VueReactivity = (function (exports) {
|
|
|
1587
1595
|
this.globalVersion = globalVersion - 1;
|
|
1588
1596
|
// for backwards compat
|
|
1589
1597
|
this.effect = this;
|
|
1590
|
-
this
|
|
1598
|
+
this["__v_isReadonly"] = !setter;
|
|
1591
1599
|
this.isSSR = isSSR;
|
|
1592
1600
|
}
|
|
1593
1601
|
/**
|
|
@@ -1652,7 +1660,8 @@ var VueReactivity = (function (exports) {
|
|
|
1652
1660
|
"IS_REACTIVE": "__v_isReactive",
|
|
1653
1661
|
"IS_READONLY": "__v_isReadonly",
|
|
1654
1662
|
"IS_SHALLOW": "__v_isShallow",
|
|
1655
|
-
"RAW": "__v_raw"
|
|
1663
|
+
"RAW": "__v_raw",
|
|
1664
|
+
"IS_REF": "__v_isRef"
|
|
1656
1665
|
};
|
|
1657
1666
|
|
|
1658
1667
|
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|