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