@vue/reactivity 3.6.0-rc.1 → 3.6.0-rc.11
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 +137 -90
- package/dist/reactivity.cjs.prod.js +120 -88
- package/dist/reactivity.d.ts +468 -467
- package/dist/reactivity.esm-browser.js +128 -92
- package/dist/reactivity.esm-browser.prod.js +2 -2
- package/dist/reactivity.esm-bundler.js +127 -91
- package/dist/reactivity.global.js +138 -91
- 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.6.0-rc.
|
|
2
|
+
* @vue/reactivity v3.6.0-rc.11
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -49,22 +49,6 @@ function warn(msg, ...args) {
|
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region packages/reactivity/src/system.ts
|
|
52
|
-
const ReactiveFlags$1 = {
|
|
53
|
-
"None": 0,
|
|
54
|
-
"0": "None",
|
|
55
|
-
"Mutable": 1,
|
|
56
|
-
"1": "Mutable",
|
|
57
|
-
"Watching": 2,
|
|
58
|
-
"2": "Watching",
|
|
59
|
-
"RecursedCheck": 4,
|
|
60
|
-
"4": "RecursedCheck",
|
|
61
|
-
"Recursed": 8,
|
|
62
|
-
"8": "Recursed",
|
|
63
|
-
"Dirty": 16,
|
|
64
|
-
"16": "Dirty",
|
|
65
|
-
"Pending": 32,
|
|
66
|
-
"32": "Pending"
|
|
67
|
-
};
|
|
68
52
|
const notifyBuffer = [];
|
|
69
53
|
let batchDepth = 0;
|
|
70
54
|
let activeSub = void 0;
|
|
@@ -203,13 +187,23 @@ function endTracking(sub, prevSub) {
|
|
|
203
187
|
sub.flags &= -5;
|
|
204
188
|
}
|
|
205
189
|
function flush() {
|
|
190
|
+
let hasError = false;
|
|
191
|
+
let error;
|
|
206
192
|
while (notifyIndex < notifyBufferLength) {
|
|
207
193
|
const effect = notifyBuffer[notifyIndex];
|
|
208
194
|
notifyBuffer[notifyIndex++] = void 0;
|
|
209
|
-
|
|
195
|
+
try {
|
|
196
|
+
effect.notify();
|
|
197
|
+
} catch (err) {
|
|
198
|
+
if (!hasError) {
|
|
199
|
+
hasError = true;
|
|
200
|
+
error = err;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
210
203
|
}
|
|
211
204
|
notifyIndex = 0;
|
|
212
205
|
notifyBufferLength = 0;
|
|
206
|
+
if (hasError) throw error;
|
|
213
207
|
}
|
|
214
208
|
function checkDirty(link, sub) {
|
|
215
209
|
let stack;
|
|
@@ -293,9 +287,42 @@ var Dep = class {
|
|
|
293
287
|
}
|
|
294
288
|
set subs(value) {
|
|
295
289
|
this._subs = value;
|
|
296
|
-
if (value === void 0) this.map.delete(this.key);
|
|
290
|
+
if (value === void 0 && this.map) this.map.delete(this.key);
|
|
297
291
|
}
|
|
298
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* Tracks a dep its owner keys on its own, outside `targetMap`.
|
|
295
|
+
* @internal
|
|
296
|
+
*/
|
|
297
|
+
function trackDep(dep, target = dep, key = "value") {
|
|
298
|
+
if (activeSub !== void 0) {
|
|
299
|
+
onTrack(activeSub, {
|
|
300
|
+
target,
|
|
301
|
+
type: "get",
|
|
302
|
+
key
|
|
303
|
+
});
|
|
304
|
+
link(dep, activeSub);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
function triggerDep(dep, target = dep, key = "value", newValue, oldValue) {
|
|
311
|
+
const subs = dep.subs;
|
|
312
|
+
if (subs !== void 0) {
|
|
313
|
+
triggerEventInfos.push({
|
|
314
|
+
target,
|
|
315
|
+
type: "set",
|
|
316
|
+
key,
|
|
317
|
+
newValue,
|
|
318
|
+
oldValue
|
|
319
|
+
});
|
|
320
|
+
propagate(subs);
|
|
321
|
+
shallowPropagate(subs);
|
|
322
|
+
if (!batchDepth) flush();
|
|
323
|
+
triggerEventInfos.pop();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
299
326
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
300
327
|
const ITERATE_KEY = Symbol("Object iterate");
|
|
301
328
|
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
|
|
@@ -376,9 +403,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
376
403
|
if ((0, _vue_shared.isMap)(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
377
404
|
}
|
|
378
405
|
break;
|
|
379
|
-
case "set":
|
|
380
|
-
if ((0, _vue_shared.isMap)(target)) run(depsMap.get(ITERATE_KEY));
|
|
381
|
-
break;
|
|
406
|
+
case "set": if ((0, _vue_shared.isMap)(target)) run(depsMap.get(ITERATE_KEY));
|
|
382
407
|
}
|
|
383
408
|
}
|
|
384
409
|
}
|
|
@@ -393,13 +418,17 @@ function getDepFromReactive(object, key) {
|
|
|
393
418
|
/**
|
|
394
419
|
* Track array iteration and return:
|
|
395
420
|
* - if input is reactive: a cloned raw array with reactive values
|
|
396
|
-
* - if input is
|
|
421
|
+
* - if input is readonly: a cloned raw array with readonly values, preserving
|
|
422
|
+
* reactivity
|
|
423
|
+
* - if input is raw or shallow: the original raw array
|
|
397
424
|
*/
|
|
398
425
|
function reactiveReadArray(array) {
|
|
399
426
|
const raw = /* @__PURE__ */ toRaw(array);
|
|
400
427
|
if (raw === array) return raw;
|
|
401
428
|
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
402
|
-
|
|
429
|
+
if (/* @__PURE__ */ isShallow(array)) return raw;
|
|
430
|
+
if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
|
|
431
|
+
return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
|
|
403
432
|
}
|
|
404
433
|
/**
|
|
405
434
|
* Track array iteration and return raw array
|
|
@@ -575,8 +604,8 @@ function noTracking(self, method, args = []) {
|
|
|
575
604
|
}
|
|
576
605
|
//#endregion
|
|
577
606
|
//#region packages/reactivity/src/baseHandlers.ts
|
|
578
|
-
const isNonTrackableKeys =
|
|
579
|
-
const builtInSymbols = new Set(
|
|
607
|
+
const isNonTrackableKeys = /*@__PURE__*/ (0, _vue_shared.makeMap)(`__proto__,__v_isRef,__isVue`);
|
|
608
|
+
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(_vue_shared.isSymbol));
|
|
580
609
|
function hasOwnProperty(key) {
|
|
581
610
|
if (!(0, _vue_shared.isSymbol)(key)) key = String(key);
|
|
582
611
|
const obj = /* @__PURE__ */ toRaw(this);
|
|
@@ -631,12 +660,14 @@ var MutableReactiveHandler = class extends BaseReactiveHandler {
|
|
|
631
660
|
oldValue = /* @__PURE__ */ toRaw(oldValue);
|
|
632
661
|
value = /* @__PURE__ */ toRaw(value);
|
|
633
662
|
}
|
|
634
|
-
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value))
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
663
|
+
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
|
|
664
|
+
if (isOldValueReadonly) {
|
|
665
|
+
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
|
|
666
|
+
return true;
|
|
667
|
+
} else {
|
|
668
|
+
oldValue.value = value;
|
|
669
|
+
return true;
|
|
670
|
+
}
|
|
640
671
|
}
|
|
641
672
|
}
|
|
642
673
|
const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : (0, _vue_shared.hasOwn)(target, key);
|
|
@@ -677,10 +708,10 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
677
708
|
return true;
|
|
678
709
|
}
|
|
679
710
|
};
|
|
680
|
-
const mutableHandlers =
|
|
681
|
-
const readonlyHandlers =
|
|
682
|
-
const shallowReactiveHandlers =
|
|
683
|
-
const shallowReadonlyHandlers =
|
|
711
|
+
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
712
|
+
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
713
|
+
const shallowReactiveHandlers = /*@__PURE__*/ new MutableReactiveHandler(true);
|
|
714
|
+
const shallowReadonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler(true);
|
|
684
715
|
//#endregion
|
|
685
716
|
//#region packages/reactivity/src/collectionHandlers.ts
|
|
686
717
|
const toShallow = (value) => value;
|
|
@@ -831,10 +862,10 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
831
862
|
return Reflect.get((0, _vue_shared.hasOwn)(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
832
863
|
};
|
|
833
864
|
}
|
|
834
|
-
const mutableCollectionHandlers = { get:
|
|
835
|
-
const shallowCollectionHandlers = { get:
|
|
836
|
-
const readonlyCollectionHandlers = { get:
|
|
837
|
-
const shallowReadonlyCollectionHandlers = { get:
|
|
865
|
+
const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
|
|
866
|
+
const shallowCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, true) };
|
|
867
|
+
const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
|
|
868
|
+
const shallowReadonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, true) };
|
|
838
869
|
function checkIdentityKeys(target, has, key) {
|
|
839
870
|
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
840
871
|
if (rawKey !== key && has.call(target, rawKey)) {
|
|
@@ -859,7 +890,7 @@ function targetTypeMap(rawType) {
|
|
|
859
890
|
default: return 0;
|
|
860
891
|
}
|
|
861
892
|
}
|
|
862
|
-
|
|
893
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
863
894
|
function reactive(target) {
|
|
864
895
|
if (/* @__PURE__ */ isReadonly(target)) return target;
|
|
865
896
|
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
@@ -894,7 +925,7 @@ function reactive(target) {
|
|
|
894
925
|
* @param target - The source object.
|
|
895
926
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
|
|
896
927
|
*/
|
|
897
|
-
|
|
928
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
898
929
|
function shallowReactive(target) {
|
|
899
930
|
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
|
900
931
|
}
|
|
@@ -927,7 +958,7 @@ function shallowReactive(target) {
|
|
|
927
958
|
* @param target - The source object.
|
|
928
959
|
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
929
960
|
*/
|
|
930
|
-
|
|
961
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
931
962
|
function readonly(target) {
|
|
932
963
|
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
933
964
|
}
|
|
@@ -961,7 +992,7 @@ function readonly(target) {
|
|
|
961
992
|
* @param target - The source object.
|
|
962
993
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
|
|
963
994
|
*/
|
|
964
|
-
|
|
995
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
965
996
|
function shallowReadonly(target) {
|
|
966
997
|
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
967
998
|
}
|
|
@@ -998,7 +1029,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
|
|
|
998
1029
|
* @param value - The value to check.
|
|
999
1030
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
1000
1031
|
*/
|
|
1001
|
-
|
|
1032
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1002
1033
|
function isReactive(value) {
|
|
1003
1034
|
if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
|
|
1004
1035
|
return !!(value && value["__v_isReactive"]);
|
|
@@ -1014,11 +1045,11 @@ function isReactive(value) {
|
|
|
1014
1045
|
* @param value - The value to check.
|
|
1015
1046
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
1016
1047
|
*/
|
|
1017
|
-
|
|
1048
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1018
1049
|
function isReadonly(value) {
|
|
1019
1050
|
return !!(value && value["__v_isReadonly"]);
|
|
1020
1051
|
}
|
|
1021
|
-
|
|
1052
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1022
1053
|
function isShallow(value) {
|
|
1023
1054
|
return !!(value && value["__v_isShallow"]);
|
|
1024
1055
|
}
|
|
@@ -1029,7 +1060,7 @@ function isShallow(value) {
|
|
|
1029
1060
|
* @param value - The value to check.
|
|
1030
1061
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
1031
1062
|
*/
|
|
1032
|
-
|
|
1063
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1033
1064
|
function isProxy(value) {
|
|
1034
1065
|
return value ? !!value["__v_raw"] : false;
|
|
1035
1066
|
}
|
|
@@ -1056,7 +1087,7 @@ function isProxy(value) {
|
|
|
1056
1087
|
* @param observed - The object for which the "raw" value is requested.
|
|
1057
1088
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
1058
1089
|
*/
|
|
1059
|
-
|
|
1090
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1060
1091
|
function toRaw(observed) {
|
|
1061
1092
|
const raw = observed && observed["__v_raw"];
|
|
1062
1093
|
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
@@ -1105,15 +1136,15 @@ const toReactive = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */
|
|
|
1105
1136
|
const toReadonly = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1106
1137
|
//#endregion
|
|
1107
1138
|
//#region packages/reactivity/src/ref.ts
|
|
1108
|
-
|
|
1139
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1109
1140
|
function isRef(r) {
|
|
1110
1141
|
return r ? r["__v_isRef"] === true : false;
|
|
1111
1142
|
}
|
|
1112
|
-
|
|
1143
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1113
1144
|
function ref(value) {
|
|
1114
1145
|
return createRef(value, toReactive);
|
|
1115
1146
|
}
|
|
1116
|
-
|
|
1147
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1117
1148
|
function shallowRef(value) {
|
|
1118
1149
|
return createRef(value);
|
|
1119
1150
|
}
|
|
@@ -1128,7 +1159,7 @@ var RefImpl = class {
|
|
|
1128
1159
|
constructor(value, wrap) {
|
|
1129
1160
|
this.subs = void 0;
|
|
1130
1161
|
this.subsTail = void 0;
|
|
1131
|
-
this.flags =
|
|
1162
|
+
this.flags = 1;
|
|
1132
1163
|
this.__v_isRef = true;
|
|
1133
1164
|
this.__v_isShallow = false;
|
|
1134
1165
|
this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value;
|
|
@@ -1141,7 +1172,7 @@ var RefImpl = class {
|
|
|
1141
1172
|
}
|
|
1142
1173
|
get value() {
|
|
1143
1174
|
trackRef(this);
|
|
1144
|
-
if (this.flags &
|
|
1175
|
+
if (this.flags & 16 && this.update()) {
|
|
1145
1176
|
const subs = this.subs;
|
|
1146
1177
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1147
1178
|
}
|
|
@@ -1152,7 +1183,7 @@ var RefImpl = class {
|
|
|
1152
1183
|
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
1153
1184
|
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
1154
1185
|
if ((0, _vue_shared.hasChanged)(newValue, oldValue)) {
|
|
1155
|
-
this.flags |=
|
|
1186
|
+
this.flags |= 16;
|
|
1156
1187
|
this._rawValue = newValue;
|
|
1157
1188
|
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1158
1189
|
const subs = this.subs;
|
|
@@ -1171,7 +1202,7 @@ var RefImpl = class {
|
|
|
1171
1202
|
}
|
|
1172
1203
|
}
|
|
1173
1204
|
update() {
|
|
1174
|
-
this.flags &=
|
|
1205
|
+
this.flags &= -17;
|
|
1175
1206
|
return (0, _vue_shared.hasChanged)(this._oldValue, this._oldValue = this._rawValue);
|
|
1176
1207
|
}
|
|
1177
1208
|
};
|
|
@@ -1281,7 +1312,7 @@ var CustomRefImpl = class {
|
|
|
1281
1312
|
constructor(factory) {
|
|
1282
1313
|
this.subs = void 0;
|
|
1283
1314
|
this.subsTail = void 0;
|
|
1284
|
-
this.flags =
|
|
1315
|
+
this.flags = 0;
|
|
1285
1316
|
this["__v_isRef"] = true;
|
|
1286
1317
|
this._value = void 0;
|
|
1287
1318
|
const { get, set } = factory(() => trackRef(this), () => triggerRef(this));
|
|
@@ -1316,7 +1347,7 @@ function customRef(factory) {
|
|
|
1316
1347
|
* @param object - Reactive object to be made into an object of linked refs.
|
|
1317
1348
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
|
|
1318
1349
|
*/
|
|
1319
|
-
|
|
1350
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1320
1351
|
function toRefs(object) {
|
|
1321
1352
|
const ret = (0, _vue_shared.isArray)(object) ? new Array(object.length) : {};
|
|
1322
1353
|
for (const key in object) ret[key] = propertyToRef(object, key);
|
|
@@ -1367,7 +1398,7 @@ var GetterRefImpl = class {
|
|
|
1367
1398
|
return this._value = this._getter();
|
|
1368
1399
|
}
|
|
1369
1400
|
};
|
|
1370
|
-
|
|
1401
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1371
1402
|
function toRef(source, key, defaultValue) {
|
|
1372
1403
|
if (/* @__PURE__ */ isRef(source)) return source;
|
|
1373
1404
|
else if ((0, _vue_shared.isFunction)(source)) return new GetterRefImpl(source);
|
|
@@ -1441,10 +1472,12 @@ var ReactiveEffect = class {
|
|
|
1441
1472
|
get dirty() {
|
|
1442
1473
|
const flags = this.flags;
|
|
1443
1474
|
if (flags & 16) return true;
|
|
1444
|
-
if (flags & 32)
|
|
1445
|
-
this.
|
|
1446
|
-
|
|
1447
|
-
|
|
1475
|
+
if (flags & 32) {
|
|
1476
|
+
if (checkDirty(this.deps, this)) {
|
|
1477
|
+
this.flags = flags | 16;
|
|
1478
|
+
return true;
|
|
1479
|
+
} else this.flags = flags & -33;
|
|
1480
|
+
}
|
|
1448
1481
|
return false;
|
|
1449
1482
|
}
|
|
1450
1483
|
};
|
|
@@ -1675,11 +1708,13 @@ var ComputedRefImpl = class {
|
|
|
1675
1708
|
*/
|
|
1676
1709
|
get _dirty() {
|
|
1677
1710
|
const flags = this.flags;
|
|
1678
|
-
if (flags &
|
|
1679
|
-
if (flags &
|
|
1680
|
-
this.
|
|
1681
|
-
|
|
1682
|
-
|
|
1711
|
+
if (flags & 16) return true;
|
|
1712
|
+
if (flags & 32) {
|
|
1713
|
+
if (checkDirty(this.deps, this)) {
|
|
1714
|
+
this.flags = flags | 16;
|
|
1715
|
+
return true;
|
|
1716
|
+
} else this.flags = flags & -33;
|
|
1717
|
+
}
|
|
1683
1718
|
return false;
|
|
1684
1719
|
}
|
|
1685
1720
|
/**
|
|
@@ -1687,8 +1722,8 @@ var ComputedRefImpl = class {
|
|
|
1687
1722
|
* for backwards compat
|
|
1688
1723
|
*/
|
|
1689
1724
|
set _dirty(v) {
|
|
1690
|
-
if (v) this.flags |=
|
|
1691
|
-
else this.flags &=
|
|
1725
|
+
if (v) this.flags |= 16;
|
|
1726
|
+
else this.flags &= -49;
|
|
1692
1727
|
}
|
|
1693
1728
|
constructor(fn, setter) {
|
|
1694
1729
|
this.fn = fn;
|
|
@@ -1698,18 +1733,18 @@ var ComputedRefImpl = class {
|
|
|
1698
1733
|
this.subsTail = void 0;
|
|
1699
1734
|
this.deps = void 0;
|
|
1700
1735
|
this.depsTail = void 0;
|
|
1701
|
-
this.flags =
|
|
1736
|
+
this.flags = 17;
|
|
1702
1737
|
this.__v_isRef = true;
|
|
1703
1738
|
this["__v_isReadonly"] = !setter;
|
|
1704
1739
|
}
|
|
1705
1740
|
get value() {
|
|
1706
1741
|
const flags = this.flags;
|
|
1707
|
-
if (flags &
|
|
1742
|
+
if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
|
|
1708
1743
|
if (this.update()) {
|
|
1709
1744
|
const subs = this.subs;
|
|
1710
1745
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1711
1746
|
}
|
|
1712
|
-
} else if (flags &
|
|
1747
|
+
} else if (flags & 32) this.flags = flags & -33;
|
|
1713
1748
|
if (activeSub !== void 0) {
|
|
1714
1749
|
onTrack(activeSub, {
|
|
1715
1750
|
target: this,
|
|
@@ -1740,7 +1775,7 @@ var ComputedRefImpl = class {
|
|
|
1740
1775
|
}
|
|
1741
1776
|
};
|
|
1742
1777
|
setupOnTrigger(ComputedRefImpl);
|
|
1743
|
-
|
|
1778
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1744
1779
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1745
1780
|
let getter;
|
|
1746
1781
|
let setter;
|
|
@@ -1834,25 +1869,26 @@ var WatcherEffect = class extends ReactiveEffect {
|
|
|
1834
1869
|
else if ((0, _vue_shared.isFunction)(s)) return call ? call(s, 2) : s();
|
|
1835
1870
|
else warnInvalidSource(s, onWarn);
|
|
1836
1871
|
});
|
|
1837
|
-
} else if ((0, _vue_shared.isFunction)(source))
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1872
|
+
} else if ((0, _vue_shared.isFunction)(source)) {
|
|
1873
|
+
if (cb) getter = call ? () => call(source, 2) : source;
|
|
1874
|
+
else getter = () => {
|
|
1875
|
+
if (this.cleanupsLength) {
|
|
1876
|
+
const prevSub = setActiveSub();
|
|
1877
|
+
try {
|
|
1878
|
+
cleanup(this);
|
|
1879
|
+
} finally {
|
|
1880
|
+
setActiveSub(prevSub);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
const currentEffect = activeWatcher;
|
|
1884
|
+
activeWatcher = this;
|
|
1841
1885
|
try {
|
|
1842
|
-
|
|
1886
|
+
return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
|
|
1843
1887
|
} finally {
|
|
1844
|
-
|
|
1888
|
+
activeWatcher = currentEffect;
|
|
1845
1889
|
}
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
activeWatcher = this;
|
|
1849
|
-
try {
|
|
1850
|
-
return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
|
|
1851
|
-
} finally {
|
|
1852
|
-
activeWatcher = currentEffect;
|
|
1853
|
-
}
|
|
1854
|
-
};
|
|
1855
|
-
else {
|
|
1890
|
+
};
|
|
1891
|
+
} else {
|
|
1856
1892
|
getter = _vue_shared.NOOP;
|
|
1857
1893
|
warnInvalidSource(source, onWarn);
|
|
1858
1894
|
}
|
|
@@ -1939,6 +1975,7 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1939
1975
|
}
|
|
1940
1976
|
//#endregion
|
|
1941
1977
|
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|
|
1978
|
+
exports.Dep = Dep;
|
|
1942
1979
|
exports.EffectFlags = EffectFlags;
|
|
1943
1980
|
exports.EffectScope = EffectScope;
|
|
1944
1981
|
exports.ITERATE_KEY = ITERATE_KEY;
|
|
@@ -1949,11 +1986,18 @@ exports.TrackOpTypes = TrackOpTypes;
|
|
|
1949
1986
|
exports.TriggerOpTypes = TriggerOpTypes;
|
|
1950
1987
|
exports.WatchErrorCodes = WatchErrorCodes;
|
|
1951
1988
|
exports.WatcherEffect = WatcherEffect;
|
|
1989
|
+
Object.defineProperty(exports, "activeSub", {
|
|
1990
|
+
enumerable: true,
|
|
1991
|
+
get: function() {
|
|
1992
|
+
return activeSub;
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1952
1995
|
exports.computed = computed;
|
|
1953
1996
|
exports.customRef = customRef;
|
|
1954
1997
|
exports.effect = effect;
|
|
1955
1998
|
exports.effectScope = effectScope;
|
|
1956
1999
|
exports.enableTracking = enableTracking;
|
|
2000
|
+
exports.endBatch = endBatch;
|
|
1957
2001
|
exports.getCurrentScope = getCurrentScope;
|
|
1958
2002
|
exports.getCurrentWatcher = getCurrentWatcher;
|
|
1959
2003
|
exports.isProxy = isProxy;
|
|
@@ -1978,6 +2022,7 @@ exports.shallowReactive = shallowReactive;
|
|
|
1978
2022
|
exports.shallowReadArray = shallowReadArray;
|
|
1979
2023
|
exports.shallowReadonly = shallowReadonly;
|
|
1980
2024
|
exports.shallowRef = shallowRef;
|
|
2025
|
+
exports.startBatch = startBatch;
|
|
1981
2026
|
exports.stop = stop;
|
|
1982
2027
|
exports.toRaw = toRaw;
|
|
1983
2028
|
exports.toReactive = toReactive;
|
|
@@ -1986,8 +2031,10 @@ exports.toRef = toRef;
|
|
|
1986
2031
|
exports.toRefs = toRefs;
|
|
1987
2032
|
exports.toValue = toValue;
|
|
1988
2033
|
exports.track = track;
|
|
2034
|
+
exports.trackDep = trackDep;
|
|
1989
2035
|
exports.traverse = traverse;
|
|
1990
2036
|
exports.trigger = trigger;
|
|
2037
|
+
exports.triggerDep = triggerDep;
|
|
1991
2038
|
exports.triggerRef = triggerRef;
|
|
1992
2039
|
exports.unref = unref;
|
|
1993
2040
|
exports.watch = watch;
|