@vue/reactivity 3.5.11 → 3.5.12
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 +135 -201
- package/dist/reactivity.cjs.prod.js +124 -192
- package/dist/reactivity.esm-browser.js +135 -201
- package/dist/reactivity.esm-browser.prod.js +2 -2
- package/dist/reactivity.esm-bundler.js +136 -202
- package/dist/reactivity.global.js +135 -201
- package/dist/reactivity.global.prod.js +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/reactivity v3.5.
|
|
2
|
+
* @vue/reactivity v3.5.12
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -390,11 +390,11 @@ function removeSub(link, soft = false) {
|
|
|
390
390
|
}
|
|
391
391
|
if (dep.subs === link) {
|
|
392
392
|
dep.subs = prevSub;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
393
|
+
if (!prevSub && dep.computed) {
|
|
394
|
+
dep.computed.flags &= ~4;
|
|
395
|
+
for (let l = dep.computed.deps; l; l = l.nextDep) {
|
|
396
|
+
removeSub(l, true);
|
|
397
|
+
}
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
if (!soft && !--dep.sc && dep.map) {
|
|
@@ -623,7 +623,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
623
623
|
}
|
|
624
624
|
});
|
|
625
625
|
} else {
|
|
626
|
-
if (key !== void 0) {
|
|
626
|
+
if (key !== void 0 || depsMap.has(void 0)) {
|
|
627
627
|
run(depsMap.get(key));
|
|
628
628
|
}
|
|
629
629
|
if (isArrayIndex) {
|
|
@@ -986,112 +986,6 @@ const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true
|
|
|
986
986
|
|
|
987
987
|
const toShallow = (value) => value;
|
|
988
988
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
989
|
-
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
990
|
-
target = target["__v_raw"];
|
|
991
|
-
const rawTarget = toRaw(target);
|
|
992
|
-
const rawKey = toRaw(key);
|
|
993
|
-
if (!isReadonly2) {
|
|
994
|
-
if (shared.hasChanged(key, rawKey)) {
|
|
995
|
-
track(rawTarget, "get", key);
|
|
996
|
-
}
|
|
997
|
-
track(rawTarget, "get", rawKey);
|
|
998
|
-
}
|
|
999
|
-
const { has: has2 } = getProto(rawTarget);
|
|
1000
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1001
|
-
if (has2.call(rawTarget, key)) {
|
|
1002
|
-
return wrap(target.get(key));
|
|
1003
|
-
} else if (has2.call(rawTarget, rawKey)) {
|
|
1004
|
-
return wrap(target.get(rawKey));
|
|
1005
|
-
} else if (target !== rawTarget) {
|
|
1006
|
-
target.get(key);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
function has(key, isReadonly2 = false) {
|
|
1010
|
-
const target = this["__v_raw"];
|
|
1011
|
-
const rawTarget = toRaw(target);
|
|
1012
|
-
const rawKey = toRaw(key);
|
|
1013
|
-
if (!isReadonly2) {
|
|
1014
|
-
if (shared.hasChanged(key, rawKey)) {
|
|
1015
|
-
track(rawTarget, "has", key);
|
|
1016
|
-
}
|
|
1017
|
-
track(rawTarget, "has", rawKey);
|
|
1018
|
-
}
|
|
1019
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1020
|
-
}
|
|
1021
|
-
function size(target, isReadonly2 = false) {
|
|
1022
|
-
target = target["__v_raw"];
|
|
1023
|
-
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1024
|
-
return Reflect.get(target, "size", target);
|
|
1025
|
-
}
|
|
1026
|
-
function add(value, _isShallow = false) {
|
|
1027
|
-
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1028
|
-
value = toRaw(value);
|
|
1029
|
-
}
|
|
1030
|
-
const target = toRaw(this);
|
|
1031
|
-
const proto = getProto(target);
|
|
1032
|
-
const hadKey = proto.has.call(target, value);
|
|
1033
|
-
if (!hadKey) {
|
|
1034
|
-
target.add(value);
|
|
1035
|
-
trigger(target, "add", value, value);
|
|
1036
|
-
}
|
|
1037
|
-
return this;
|
|
1038
|
-
}
|
|
1039
|
-
function set(key, value, _isShallow = false) {
|
|
1040
|
-
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1041
|
-
value = toRaw(value);
|
|
1042
|
-
}
|
|
1043
|
-
const target = toRaw(this);
|
|
1044
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
1045
|
-
let hadKey = has2.call(target, key);
|
|
1046
|
-
if (!hadKey) {
|
|
1047
|
-
key = toRaw(key);
|
|
1048
|
-
hadKey = has2.call(target, key);
|
|
1049
|
-
}
|
|
1050
|
-
const oldValue = get2.call(target, key);
|
|
1051
|
-
target.set(key, value);
|
|
1052
|
-
if (!hadKey) {
|
|
1053
|
-
trigger(target, "add", key, value);
|
|
1054
|
-
} else if (shared.hasChanged(value, oldValue)) {
|
|
1055
|
-
trigger(target, "set", key, value);
|
|
1056
|
-
}
|
|
1057
|
-
return this;
|
|
1058
|
-
}
|
|
1059
|
-
function deleteEntry(key) {
|
|
1060
|
-
const target = toRaw(this);
|
|
1061
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
1062
|
-
let hadKey = has2.call(target, key);
|
|
1063
|
-
if (!hadKey) {
|
|
1064
|
-
key = toRaw(key);
|
|
1065
|
-
hadKey = has2.call(target, key);
|
|
1066
|
-
}
|
|
1067
|
-
get2 ? get2.call(target, key) : void 0;
|
|
1068
|
-
const result = target.delete(key);
|
|
1069
|
-
if (hadKey) {
|
|
1070
|
-
trigger(target, "delete", key, void 0);
|
|
1071
|
-
}
|
|
1072
|
-
return result;
|
|
1073
|
-
}
|
|
1074
|
-
function clear() {
|
|
1075
|
-
const target = toRaw(this);
|
|
1076
|
-
const hadItems = target.size !== 0;
|
|
1077
|
-
const result = target.clear();
|
|
1078
|
-
if (hadItems) {
|
|
1079
|
-
trigger(target, "clear", void 0, void 0);
|
|
1080
|
-
}
|
|
1081
|
-
return result;
|
|
1082
|
-
}
|
|
1083
|
-
function createForEach(isReadonly2, isShallow2) {
|
|
1084
|
-
return function forEach(callback, thisArg) {
|
|
1085
|
-
const observed = this;
|
|
1086
|
-
const target = observed["__v_raw"];
|
|
1087
|
-
const rawTarget = toRaw(target);
|
|
1088
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1089
|
-
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1090
|
-
return target.forEach((value, key) => {
|
|
1091
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1092
|
-
});
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
989
|
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1096
990
|
return function(...args) {
|
|
1097
991
|
const target = this["__v_raw"];
|
|
@@ -1127,71 +1021,127 @@ function createReadonlyMethod(type) {
|
|
|
1127
1021
|
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
1128
1022
|
};
|
|
1129
1023
|
}
|
|
1130
|
-
function createInstrumentations() {
|
|
1131
|
-
const
|
|
1132
|
-
get(key) {
|
|
1133
|
-
return get(this, key);
|
|
1134
|
-
},
|
|
1135
|
-
get size() {
|
|
1136
|
-
return size(this);
|
|
1137
|
-
},
|
|
1138
|
-
has,
|
|
1139
|
-
add,
|
|
1140
|
-
set,
|
|
1141
|
-
delete: deleteEntry,
|
|
1142
|
-
clear,
|
|
1143
|
-
forEach: createForEach(false, false)
|
|
1144
|
-
};
|
|
1145
|
-
const shallowInstrumentations2 = {
|
|
1024
|
+
function createInstrumentations(readonly, shallow) {
|
|
1025
|
+
const instrumentations = {
|
|
1146
1026
|
get(key) {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
return get(this, key, true);
|
|
1166
|
-
},
|
|
1167
|
-
get size() {
|
|
1168
|
-
return size(this, true);
|
|
1169
|
-
},
|
|
1170
|
-
has(key) {
|
|
1171
|
-
return has.call(this, key, true);
|
|
1172
|
-
},
|
|
1173
|
-
add: createReadonlyMethod("add"),
|
|
1174
|
-
set: createReadonlyMethod("set"),
|
|
1175
|
-
delete: createReadonlyMethod("delete"),
|
|
1176
|
-
clear: createReadonlyMethod("clear"),
|
|
1177
|
-
forEach: createForEach(true, false)
|
|
1178
|
-
};
|
|
1179
|
-
const shallowReadonlyInstrumentations2 = {
|
|
1180
|
-
get(key) {
|
|
1181
|
-
return get(this, key, true, true);
|
|
1027
|
+
const target = this["__v_raw"];
|
|
1028
|
+
const rawTarget = toRaw(target);
|
|
1029
|
+
const rawKey = toRaw(key);
|
|
1030
|
+
if (!readonly) {
|
|
1031
|
+
if (shared.hasChanged(key, rawKey)) {
|
|
1032
|
+
track(rawTarget, "get", key);
|
|
1033
|
+
}
|
|
1034
|
+
track(rawTarget, "get", rawKey);
|
|
1035
|
+
}
|
|
1036
|
+
const { has } = getProto(rawTarget);
|
|
1037
|
+
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1038
|
+
if (has.call(rawTarget, key)) {
|
|
1039
|
+
return wrap(target.get(key));
|
|
1040
|
+
} else if (has.call(rawTarget, rawKey)) {
|
|
1041
|
+
return wrap(target.get(rawKey));
|
|
1042
|
+
} else if (target !== rawTarget) {
|
|
1043
|
+
target.get(key);
|
|
1044
|
+
}
|
|
1182
1045
|
},
|
|
1183
1046
|
get size() {
|
|
1184
|
-
|
|
1047
|
+
const target = this["__v_raw"];
|
|
1048
|
+
!readonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1049
|
+
return Reflect.get(target, "size", target);
|
|
1185
1050
|
},
|
|
1186
1051
|
has(key) {
|
|
1187
|
-
|
|
1052
|
+
const target = this["__v_raw"];
|
|
1053
|
+
const rawTarget = toRaw(target);
|
|
1054
|
+
const rawKey = toRaw(key);
|
|
1055
|
+
if (!readonly) {
|
|
1056
|
+
if (shared.hasChanged(key, rawKey)) {
|
|
1057
|
+
track(rawTarget, "has", key);
|
|
1058
|
+
}
|
|
1059
|
+
track(rawTarget, "has", rawKey);
|
|
1060
|
+
}
|
|
1061
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1188
1062
|
},
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1063
|
+
forEach(callback, thisArg) {
|
|
1064
|
+
const observed = this;
|
|
1065
|
+
const target = observed["__v_raw"];
|
|
1066
|
+
const rawTarget = toRaw(target);
|
|
1067
|
+
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1068
|
+
!readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1069
|
+
return target.forEach((value, key) => {
|
|
1070
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1194
1073
|
};
|
|
1074
|
+
shared.extend(
|
|
1075
|
+
instrumentations,
|
|
1076
|
+
readonly ? {
|
|
1077
|
+
add: createReadonlyMethod("add"),
|
|
1078
|
+
set: createReadonlyMethod("set"),
|
|
1079
|
+
delete: createReadonlyMethod("delete"),
|
|
1080
|
+
clear: createReadonlyMethod("clear")
|
|
1081
|
+
} : {
|
|
1082
|
+
add(value) {
|
|
1083
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1084
|
+
value = toRaw(value);
|
|
1085
|
+
}
|
|
1086
|
+
const target = toRaw(this);
|
|
1087
|
+
const proto = getProto(target);
|
|
1088
|
+
const hadKey = proto.has.call(target, value);
|
|
1089
|
+
if (!hadKey) {
|
|
1090
|
+
target.add(value);
|
|
1091
|
+
trigger(target, "add", value, value);
|
|
1092
|
+
}
|
|
1093
|
+
return this;
|
|
1094
|
+
},
|
|
1095
|
+
set(key, value) {
|
|
1096
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1097
|
+
value = toRaw(value);
|
|
1098
|
+
}
|
|
1099
|
+
const target = toRaw(this);
|
|
1100
|
+
const { has, get } = getProto(target);
|
|
1101
|
+
let hadKey = has.call(target, key);
|
|
1102
|
+
if (!hadKey) {
|
|
1103
|
+
key = toRaw(key);
|
|
1104
|
+
hadKey = has.call(target, key);
|
|
1105
|
+
}
|
|
1106
|
+
const oldValue = get.call(target, key);
|
|
1107
|
+
target.set(key, value);
|
|
1108
|
+
if (!hadKey) {
|
|
1109
|
+
trigger(target, "add", key, value);
|
|
1110
|
+
} else if (shared.hasChanged(value, oldValue)) {
|
|
1111
|
+
trigger(target, "set", key, value);
|
|
1112
|
+
}
|
|
1113
|
+
return this;
|
|
1114
|
+
},
|
|
1115
|
+
delete(key) {
|
|
1116
|
+
const target = toRaw(this);
|
|
1117
|
+
const { has, get } = getProto(target);
|
|
1118
|
+
let hadKey = has.call(target, key);
|
|
1119
|
+
if (!hadKey) {
|
|
1120
|
+
key = toRaw(key);
|
|
1121
|
+
hadKey = has.call(target, key);
|
|
1122
|
+
}
|
|
1123
|
+
get ? get.call(target, key) : void 0;
|
|
1124
|
+
const result = target.delete(key);
|
|
1125
|
+
if (hadKey) {
|
|
1126
|
+
trigger(target, "delete", key, void 0);
|
|
1127
|
+
}
|
|
1128
|
+
return result;
|
|
1129
|
+
},
|
|
1130
|
+
clear() {
|
|
1131
|
+
const target = toRaw(this);
|
|
1132
|
+
const hadItems = target.size !== 0;
|
|
1133
|
+
const result = target.clear();
|
|
1134
|
+
if (hadItems) {
|
|
1135
|
+
trigger(
|
|
1136
|
+
target,
|
|
1137
|
+
"clear",
|
|
1138
|
+
void 0,
|
|
1139
|
+
void 0);
|
|
1140
|
+
}
|
|
1141
|
+
return result;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
);
|
|
1195
1145
|
const iteratorMethods = [
|
|
1196
1146
|
"keys",
|
|
1197
1147
|
"values",
|
|
@@ -1199,30 +1149,12 @@ function createInstrumentations() {
|
|
|
1199
1149
|
Symbol.iterator
|
|
1200
1150
|
];
|
|
1201
1151
|
iteratorMethods.forEach((method) => {
|
|
1202
|
-
|
|
1203
|
-
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
|
1204
|
-
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
|
1205
|
-
shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
|
1206
|
-
method,
|
|
1207
|
-
true,
|
|
1208
|
-
true
|
|
1209
|
-
);
|
|
1152
|
+
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
1210
1153
|
});
|
|
1211
|
-
return
|
|
1212
|
-
mutableInstrumentations2,
|
|
1213
|
-
readonlyInstrumentations2,
|
|
1214
|
-
shallowInstrumentations2,
|
|
1215
|
-
shallowReadonlyInstrumentations2
|
|
1216
|
-
];
|
|
1154
|
+
return instrumentations;
|
|
1217
1155
|
}
|
|
1218
|
-
const [
|
|
1219
|
-
mutableInstrumentations,
|
|
1220
|
-
readonlyInstrumentations,
|
|
1221
|
-
shallowInstrumentations,
|
|
1222
|
-
shallowReadonlyInstrumentations
|
|
1223
|
-
] = /* @__PURE__ */ createInstrumentations();
|
|
1224
1156
|
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1225
|
-
const instrumentations =
|
|
1157
|
+
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
1226
1158
|
return (target, key, receiver) => {
|
|
1227
1159
|
if (key === "__v_isReactive") {
|
|
1228
1160
|
return !isReadonly2;
|