@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
package/dist/reactivity.cjs.js
CHANGED
|
@@ -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
|
**/
|
|
@@ -403,16 +403,16 @@ function removeSub(link, soft = false) {
|
|
|
403
403
|
nextSub.prevSub = prevSub;
|
|
404
404
|
link.nextSub = void 0;
|
|
405
405
|
}
|
|
406
|
-
if (dep.subs === link) {
|
|
407
|
-
dep.subs = prevSub;
|
|
408
|
-
}
|
|
409
406
|
if (dep.subsHead === link) {
|
|
410
407
|
dep.subsHead = nextSub;
|
|
411
408
|
}
|
|
412
|
-
if (
|
|
413
|
-
dep.
|
|
414
|
-
|
|
415
|
-
|
|
409
|
+
if (dep.subs === link) {
|
|
410
|
+
dep.subs = prevSub;
|
|
411
|
+
if (!prevSub && dep.computed) {
|
|
412
|
+
dep.computed.flags &= ~4;
|
|
413
|
+
for (let l = dep.computed.deps; l; l = l.nextDep) {
|
|
414
|
+
removeSub(l, true);
|
|
415
|
+
}
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
if (!soft && !--dep.sc && dep.map) {
|
|
@@ -685,7 +685,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
685
685
|
}
|
|
686
686
|
});
|
|
687
687
|
} else {
|
|
688
|
-
if (key !== void 0) {
|
|
688
|
+
if (key !== void 0 || depsMap.has(void 0)) {
|
|
689
689
|
run(depsMap.get(key));
|
|
690
690
|
}
|
|
691
691
|
if (isArrayIndex) {
|
|
@@ -1060,117 +1060,6 @@ const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true
|
|
|
1060
1060
|
|
|
1061
1061
|
const toShallow = (value) => value;
|
|
1062
1062
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1063
|
-
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
1064
|
-
target = target["__v_raw"];
|
|
1065
|
-
const rawTarget = toRaw(target);
|
|
1066
|
-
const rawKey = toRaw(key);
|
|
1067
|
-
if (!isReadonly2) {
|
|
1068
|
-
if (shared.hasChanged(key, rawKey)) {
|
|
1069
|
-
track(rawTarget, "get", key);
|
|
1070
|
-
}
|
|
1071
|
-
track(rawTarget, "get", rawKey);
|
|
1072
|
-
}
|
|
1073
|
-
const { has: has2 } = getProto(rawTarget);
|
|
1074
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1075
|
-
if (has2.call(rawTarget, key)) {
|
|
1076
|
-
return wrap(target.get(key));
|
|
1077
|
-
} else if (has2.call(rawTarget, rawKey)) {
|
|
1078
|
-
return wrap(target.get(rawKey));
|
|
1079
|
-
} else if (target !== rawTarget) {
|
|
1080
|
-
target.get(key);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
function has(key, isReadonly2 = false) {
|
|
1084
|
-
const target = this["__v_raw"];
|
|
1085
|
-
const rawTarget = toRaw(target);
|
|
1086
|
-
const rawKey = toRaw(key);
|
|
1087
|
-
if (!isReadonly2) {
|
|
1088
|
-
if (shared.hasChanged(key, rawKey)) {
|
|
1089
|
-
track(rawTarget, "has", key);
|
|
1090
|
-
}
|
|
1091
|
-
track(rawTarget, "has", rawKey);
|
|
1092
|
-
}
|
|
1093
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1094
|
-
}
|
|
1095
|
-
function size(target, isReadonly2 = false) {
|
|
1096
|
-
target = target["__v_raw"];
|
|
1097
|
-
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1098
|
-
return Reflect.get(target, "size", target);
|
|
1099
|
-
}
|
|
1100
|
-
function add(value, _isShallow = false) {
|
|
1101
|
-
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1102
|
-
value = toRaw(value);
|
|
1103
|
-
}
|
|
1104
|
-
const target = toRaw(this);
|
|
1105
|
-
const proto = getProto(target);
|
|
1106
|
-
const hadKey = proto.has.call(target, value);
|
|
1107
|
-
if (!hadKey) {
|
|
1108
|
-
target.add(value);
|
|
1109
|
-
trigger(target, "add", value, value);
|
|
1110
|
-
}
|
|
1111
|
-
return this;
|
|
1112
|
-
}
|
|
1113
|
-
function set(key, value, _isShallow = false) {
|
|
1114
|
-
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
1115
|
-
value = toRaw(value);
|
|
1116
|
-
}
|
|
1117
|
-
const target = toRaw(this);
|
|
1118
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
1119
|
-
let hadKey = has2.call(target, key);
|
|
1120
|
-
if (!hadKey) {
|
|
1121
|
-
key = toRaw(key);
|
|
1122
|
-
hadKey = has2.call(target, key);
|
|
1123
|
-
} else {
|
|
1124
|
-
checkIdentityKeys(target, has2, key);
|
|
1125
|
-
}
|
|
1126
|
-
const oldValue = get2.call(target, key);
|
|
1127
|
-
target.set(key, value);
|
|
1128
|
-
if (!hadKey) {
|
|
1129
|
-
trigger(target, "add", key, value);
|
|
1130
|
-
} else if (shared.hasChanged(value, oldValue)) {
|
|
1131
|
-
trigger(target, "set", key, value, oldValue);
|
|
1132
|
-
}
|
|
1133
|
-
return this;
|
|
1134
|
-
}
|
|
1135
|
-
function deleteEntry(key) {
|
|
1136
|
-
const target = toRaw(this);
|
|
1137
|
-
const { has: has2, get: get2 } = getProto(target);
|
|
1138
|
-
let hadKey = has2.call(target, key);
|
|
1139
|
-
if (!hadKey) {
|
|
1140
|
-
key = toRaw(key);
|
|
1141
|
-
hadKey = has2.call(target, key);
|
|
1142
|
-
} else {
|
|
1143
|
-
checkIdentityKeys(target, has2, key);
|
|
1144
|
-
}
|
|
1145
|
-
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
1146
|
-
const result = target.delete(key);
|
|
1147
|
-
if (hadKey) {
|
|
1148
|
-
trigger(target, "delete", key, void 0, oldValue);
|
|
1149
|
-
}
|
|
1150
|
-
return result;
|
|
1151
|
-
}
|
|
1152
|
-
function clear() {
|
|
1153
|
-
const target = toRaw(this);
|
|
1154
|
-
const hadItems = target.size !== 0;
|
|
1155
|
-
const oldTarget = shared.isMap(target) ? new Map(target) : new Set(target) ;
|
|
1156
|
-
const result = target.clear();
|
|
1157
|
-
if (hadItems) {
|
|
1158
|
-
trigger(target, "clear", void 0, void 0, oldTarget);
|
|
1159
|
-
}
|
|
1160
|
-
return result;
|
|
1161
|
-
}
|
|
1162
|
-
function createForEach(isReadonly2, isShallow2) {
|
|
1163
|
-
return function forEach(callback, thisArg) {
|
|
1164
|
-
const observed = this;
|
|
1165
|
-
const target = observed["__v_raw"];
|
|
1166
|
-
const rawTarget = toRaw(target);
|
|
1167
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1168
|
-
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1169
|
-
return target.forEach((value, key) => {
|
|
1170
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1171
|
-
});
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
1063
|
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1175
1064
|
return function(...args) {
|
|
1176
1065
|
const target = this["__v_raw"];
|
|
@@ -1213,71 +1102,134 @@ function createReadonlyMethod(type) {
|
|
|
1213
1102
|
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
1214
1103
|
};
|
|
1215
1104
|
}
|
|
1216
|
-
function createInstrumentations() {
|
|
1217
|
-
const
|
|
1218
|
-
get(key) {
|
|
1219
|
-
return get(this, key);
|
|
1220
|
-
},
|
|
1221
|
-
get size() {
|
|
1222
|
-
return size(this);
|
|
1223
|
-
},
|
|
1224
|
-
has,
|
|
1225
|
-
add,
|
|
1226
|
-
set,
|
|
1227
|
-
delete: deleteEntry,
|
|
1228
|
-
clear,
|
|
1229
|
-
forEach: createForEach(false, false)
|
|
1230
|
-
};
|
|
1231
|
-
const shallowInstrumentations2 = {
|
|
1232
|
-
get(key) {
|
|
1233
|
-
return get(this, key, false, true);
|
|
1234
|
-
},
|
|
1235
|
-
get size() {
|
|
1236
|
-
return size(this);
|
|
1237
|
-
},
|
|
1238
|
-
has,
|
|
1239
|
-
add(value) {
|
|
1240
|
-
return add.call(this, value, true);
|
|
1241
|
-
},
|
|
1242
|
-
set(key, value) {
|
|
1243
|
-
return set.call(this, key, value, true);
|
|
1244
|
-
},
|
|
1245
|
-
delete: deleteEntry,
|
|
1246
|
-
clear,
|
|
1247
|
-
forEach: createForEach(false, true)
|
|
1248
|
-
};
|
|
1249
|
-
const readonlyInstrumentations2 = {
|
|
1105
|
+
function createInstrumentations(readonly, shallow) {
|
|
1106
|
+
const instrumentations = {
|
|
1250
1107
|
get(key) {
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1108
|
+
const target = this["__v_raw"];
|
|
1109
|
+
const rawTarget = toRaw(target);
|
|
1110
|
+
const rawKey = toRaw(key);
|
|
1111
|
+
if (!readonly) {
|
|
1112
|
+
if (shared.hasChanged(key, rawKey)) {
|
|
1113
|
+
track(rawTarget, "get", key);
|
|
1114
|
+
}
|
|
1115
|
+
track(rawTarget, "get", rawKey);
|
|
1116
|
+
}
|
|
1117
|
+
const { has } = getProto(rawTarget);
|
|
1118
|
+
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1119
|
+
if (has.call(rawTarget, key)) {
|
|
1120
|
+
return wrap(target.get(key));
|
|
1121
|
+
} else if (has.call(rawTarget, rawKey)) {
|
|
1122
|
+
return wrap(target.get(rawKey));
|
|
1123
|
+
} else if (target !== rawTarget) {
|
|
1124
|
+
target.get(key);
|
|
1125
|
+
}
|
|
1268
1126
|
},
|
|
1269
1127
|
get size() {
|
|
1270
|
-
|
|
1128
|
+
const target = this["__v_raw"];
|
|
1129
|
+
!readonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1130
|
+
return Reflect.get(target, "size", target);
|
|
1271
1131
|
},
|
|
1272
1132
|
has(key) {
|
|
1273
|
-
|
|
1133
|
+
const target = this["__v_raw"];
|
|
1134
|
+
const rawTarget = toRaw(target);
|
|
1135
|
+
const rawKey = toRaw(key);
|
|
1136
|
+
if (!readonly) {
|
|
1137
|
+
if (shared.hasChanged(key, rawKey)) {
|
|
1138
|
+
track(rawTarget, "has", key);
|
|
1139
|
+
}
|
|
1140
|
+
track(rawTarget, "has", rawKey);
|
|
1141
|
+
}
|
|
1142
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1274
1143
|
},
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1144
|
+
forEach(callback, thisArg) {
|
|
1145
|
+
const observed = this;
|
|
1146
|
+
const target = observed["__v_raw"];
|
|
1147
|
+
const rawTarget = toRaw(target);
|
|
1148
|
+
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1149
|
+
!readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1150
|
+
return target.forEach((value, key) => {
|
|
1151
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1280
1154
|
};
|
|
1155
|
+
shared.extend(
|
|
1156
|
+
instrumentations,
|
|
1157
|
+
readonly ? {
|
|
1158
|
+
add: createReadonlyMethod("add"),
|
|
1159
|
+
set: createReadonlyMethod("set"),
|
|
1160
|
+
delete: createReadonlyMethod("delete"),
|
|
1161
|
+
clear: createReadonlyMethod("clear")
|
|
1162
|
+
} : {
|
|
1163
|
+
add(value) {
|
|
1164
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1165
|
+
value = toRaw(value);
|
|
1166
|
+
}
|
|
1167
|
+
const target = toRaw(this);
|
|
1168
|
+
const proto = getProto(target);
|
|
1169
|
+
const hadKey = proto.has.call(target, value);
|
|
1170
|
+
if (!hadKey) {
|
|
1171
|
+
target.add(value);
|
|
1172
|
+
trigger(target, "add", value, value);
|
|
1173
|
+
}
|
|
1174
|
+
return this;
|
|
1175
|
+
},
|
|
1176
|
+
set(key, value) {
|
|
1177
|
+
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1178
|
+
value = toRaw(value);
|
|
1179
|
+
}
|
|
1180
|
+
const target = toRaw(this);
|
|
1181
|
+
const { has, get } = getProto(target);
|
|
1182
|
+
let hadKey = has.call(target, key);
|
|
1183
|
+
if (!hadKey) {
|
|
1184
|
+
key = toRaw(key);
|
|
1185
|
+
hadKey = has.call(target, key);
|
|
1186
|
+
} else {
|
|
1187
|
+
checkIdentityKeys(target, has, key);
|
|
1188
|
+
}
|
|
1189
|
+
const oldValue = get.call(target, key);
|
|
1190
|
+
target.set(key, value);
|
|
1191
|
+
if (!hadKey) {
|
|
1192
|
+
trigger(target, "add", key, value);
|
|
1193
|
+
} else if (shared.hasChanged(value, oldValue)) {
|
|
1194
|
+
trigger(target, "set", key, value, oldValue);
|
|
1195
|
+
}
|
|
1196
|
+
return this;
|
|
1197
|
+
},
|
|
1198
|
+
delete(key) {
|
|
1199
|
+
const target = toRaw(this);
|
|
1200
|
+
const { has, get } = getProto(target);
|
|
1201
|
+
let hadKey = has.call(target, key);
|
|
1202
|
+
if (!hadKey) {
|
|
1203
|
+
key = toRaw(key);
|
|
1204
|
+
hadKey = has.call(target, key);
|
|
1205
|
+
} else {
|
|
1206
|
+
checkIdentityKeys(target, has, key);
|
|
1207
|
+
}
|
|
1208
|
+
const oldValue = get ? get.call(target, key) : void 0;
|
|
1209
|
+
const result = target.delete(key);
|
|
1210
|
+
if (hadKey) {
|
|
1211
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
1212
|
+
}
|
|
1213
|
+
return result;
|
|
1214
|
+
},
|
|
1215
|
+
clear() {
|
|
1216
|
+
const target = toRaw(this);
|
|
1217
|
+
const hadItems = target.size !== 0;
|
|
1218
|
+
const oldTarget = shared.isMap(target) ? new Map(target) : new Set(target) ;
|
|
1219
|
+
const result = target.clear();
|
|
1220
|
+
if (hadItems) {
|
|
1221
|
+
trigger(
|
|
1222
|
+
target,
|
|
1223
|
+
"clear",
|
|
1224
|
+
void 0,
|
|
1225
|
+
void 0,
|
|
1226
|
+
oldTarget
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
return result;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
);
|
|
1281
1233
|
const iteratorMethods = [
|
|
1282
1234
|
"keys",
|
|
1283
1235
|
"values",
|
|
@@ -1285,30 +1237,12 @@ function createInstrumentations() {
|
|
|
1285
1237
|
Symbol.iterator
|
|
1286
1238
|
];
|
|
1287
1239
|
iteratorMethods.forEach((method) => {
|
|
1288
|
-
|
|
1289
|
-
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
|
1290
|
-
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
|
1291
|
-
shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
|
1292
|
-
method,
|
|
1293
|
-
true,
|
|
1294
|
-
true
|
|
1295
|
-
);
|
|
1240
|
+
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
1296
1241
|
});
|
|
1297
|
-
return
|
|
1298
|
-
mutableInstrumentations2,
|
|
1299
|
-
readonlyInstrumentations2,
|
|
1300
|
-
shallowInstrumentations2,
|
|
1301
|
-
shallowReadonlyInstrumentations2
|
|
1302
|
-
];
|
|
1242
|
+
return instrumentations;
|
|
1303
1243
|
}
|
|
1304
|
-
const [
|
|
1305
|
-
mutableInstrumentations,
|
|
1306
|
-
readonlyInstrumentations,
|
|
1307
|
-
shallowInstrumentations,
|
|
1308
|
-
shallowReadonlyInstrumentations
|
|
1309
|
-
] = /* @__PURE__ */ createInstrumentations();
|
|
1310
1244
|
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1311
|
-
const instrumentations =
|
|
1245
|
+
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
1312
1246
|
return (target, key, receiver) => {
|
|
1313
1247
|
if (key === "__v_isReactive") {
|
|
1314
1248
|
return !isReadonly2;
|
|
@@ -1336,9 +1270,9 @@ const readonlyCollectionHandlers = {
|
|
|
1336
1270
|
const shallowReadonlyCollectionHandlers = {
|
|
1337
1271
|
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
1338
1272
|
};
|
|
1339
|
-
function checkIdentityKeys(target,
|
|
1273
|
+
function checkIdentityKeys(target, has, key) {
|
|
1340
1274
|
const rawKey = toRaw(key);
|
|
1341
|
-
if (rawKey !== key &&
|
|
1275
|
+
if (rawKey !== key && has.call(target, rawKey)) {
|
|
1342
1276
|
const type = shared.toRawType(target);
|
|
1343
1277
|
warn(
|
|
1344
1278
|
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
|