@vue/reactivity 3.6.0-beta.9 → 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 +164 -110
- package/dist/reactivity.cjs.prod.js +147 -108
- package/dist/reactivity.d.ts +477 -477
- package/dist/reactivity.esm-browser.js +155 -120
- package/dist/reactivity.esm-browser.prod.js +2 -2
- package/dist/reactivity.esm-bundler.js +154 -111
- package/dist/reactivity.global.js +165 -119
- 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-
|
|
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
|
**/
|
|
@@ -49,25 +49,16 @@ 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;
|
|
55
|
+
let runDepth = 0;
|
|
56
|
+
function incRunDepth() {
|
|
57
|
+
++runDepth;
|
|
58
|
+
}
|
|
59
|
+
function decRunDepth() {
|
|
60
|
+
--runDepth;
|
|
61
|
+
}
|
|
71
62
|
let globalVersion = 0;
|
|
72
63
|
let notifyIndex = 0;
|
|
73
64
|
let notifyBufferLength = 0;
|
|
@@ -141,8 +132,10 @@ function propagate(link) {
|
|
|
141
132
|
const sub = link.sub;
|
|
142
133
|
let flags = sub.flags;
|
|
143
134
|
if (flags & 3) {
|
|
144
|
-
if (!(flags & 60))
|
|
145
|
-
|
|
135
|
+
if (!(flags & 60)) {
|
|
136
|
+
sub.flags = flags | 32;
|
|
137
|
+
if (runDepth) sub.flags |= 8;
|
|
138
|
+
} else if (!(flags & 12)) flags = 0;
|
|
146
139
|
else if (!(flags & 4)) sub.flags = flags & -9 | 32;
|
|
147
140
|
else if (!(flags & 48) && isValidLink(link, sub)) {
|
|
148
141
|
sub.flags = flags | 40;
|
|
@@ -194,13 +187,23 @@ function endTracking(sub, prevSub) {
|
|
|
194
187
|
sub.flags &= -5;
|
|
195
188
|
}
|
|
196
189
|
function flush() {
|
|
190
|
+
let hasError = false;
|
|
191
|
+
let error;
|
|
197
192
|
while (notifyIndex < notifyBufferLength) {
|
|
198
193
|
const effect = notifyBuffer[notifyIndex];
|
|
199
194
|
notifyBuffer[notifyIndex++] = void 0;
|
|
200
|
-
|
|
195
|
+
try {
|
|
196
|
+
effect.notify();
|
|
197
|
+
} catch (err) {
|
|
198
|
+
if (!hasError) {
|
|
199
|
+
hasError = true;
|
|
200
|
+
error = err;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
201
203
|
}
|
|
202
204
|
notifyIndex = 0;
|
|
203
205
|
notifyBufferLength = 0;
|
|
206
|
+
if (hasError) throw error;
|
|
204
207
|
}
|
|
205
208
|
function checkDirty(link, sub) {
|
|
206
209
|
let stack;
|
|
@@ -211,13 +214,13 @@ function checkDirty(link, sub) {
|
|
|
211
214
|
let dirty = false;
|
|
212
215
|
if (sub.flags & 16) dirty = true;
|
|
213
216
|
else if ((depFlags & 17) === 17) {
|
|
217
|
+
const subs = dep.subs;
|
|
214
218
|
if (dep.update()) {
|
|
215
|
-
const subs = dep.subs;
|
|
216
219
|
if (subs.nextSub !== void 0) shallowPropagate(subs);
|
|
217
220
|
dirty = true;
|
|
218
221
|
}
|
|
219
222
|
} else if ((depFlags & 33) === 33) {
|
|
220
|
-
|
|
223
|
+
stack = {
|
|
221
224
|
value: link,
|
|
222
225
|
prev: stack
|
|
223
226
|
};
|
|
@@ -232,15 +235,12 @@ function checkDirty(link, sub) {
|
|
|
232
235
|
}
|
|
233
236
|
while (checkDepth) {
|
|
234
237
|
--checkDepth;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (hasMultipleSubs) {
|
|
238
|
-
link = stack.value;
|
|
239
|
-
stack = stack.prev;
|
|
240
|
-
} else link = firstSub;
|
|
238
|
+
link = stack.value;
|
|
239
|
+
stack = stack.prev;
|
|
241
240
|
if (dirty) {
|
|
241
|
+
const subs = sub.subs;
|
|
242
242
|
if (sub.update()) {
|
|
243
|
-
if (
|
|
243
|
+
if (subs.nextSub !== void 0) shallowPropagate(subs);
|
|
244
244
|
sub = link.sub;
|
|
245
245
|
continue;
|
|
246
246
|
}
|
|
@@ -252,7 +252,7 @@ function checkDirty(link, sub) {
|
|
|
252
252
|
}
|
|
253
253
|
dirty = false;
|
|
254
254
|
}
|
|
255
|
-
return dirty;
|
|
255
|
+
return dirty && !!sub.flags;
|
|
256
256
|
} while (true);
|
|
257
257
|
}
|
|
258
258
|
function shallowPropagate(link) {
|
|
@@ -287,9 +287,42 @@ var Dep = class {
|
|
|
287
287
|
}
|
|
288
288
|
set subs(value) {
|
|
289
289
|
this._subs = value;
|
|
290
|
-
if (value === void 0) this.map.delete(this.key);
|
|
290
|
+
if (value === void 0 && this.map) this.map.delete(this.key);
|
|
291
291
|
}
|
|
292
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
|
+
}
|
|
293
326
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
294
327
|
const ITERATE_KEY = Symbol("Object iterate");
|
|
295
328
|
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
|
|
@@ -370,9 +403,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
370
403
|
if ((0, _vue_shared.isMap)(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
371
404
|
}
|
|
372
405
|
break;
|
|
373
|
-
case "set":
|
|
374
|
-
if ((0, _vue_shared.isMap)(target)) run(depsMap.get(ITERATE_KEY));
|
|
375
|
-
break;
|
|
406
|
+
case "set": if ((0, _vue_shared.isMap)(target)) run(depsMap.get(ITERATE_KEY));
|
|
376
407
|
}
|
|
377
408
|
}
|
|
378
409
|
}
|
|
@@ -387,13 +418,17 @@ function getDepFromReactive(object, key) {
|
|
|
387
418
|
/**
|
|
388
419
|
* Track array iteration and return:
|
|
389
420
|
* - if input is reactive: a cloned raw array with reactive values
|
|
390
|
-
* - 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
|
|
391
424
|
*/
|
|
392
425
|
function reactiveReadArray(array) {
|
|
393
426
|
const raw = /* @__PURE__ */ toRaw(array);
|
|
394
427
|
if (raw === array) return raw;
|
|
395
428
|
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
396
|
-
|
|
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);
|
|
397
432
|
}
|
|
398
433
|
/**
|
|
399
434
|
* Track array iteration and return raw array
|
|
@@ -569,8 +604,8 @@ function noTracking(self, method, args = []) {
|
|
|
569
604
|
}
|
|
570
605
|
//#endregion
|
|
571
606
|
//#region packages/reactivity/src/baseHandlers.ts
|
|
572
|
-
const isNonTrackableKeys =
|
|
573
|
-
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));
|
|
574
609
|
function hasOwnProperty(key) {
|
|
575
610
|
if (!(0, _vue_shared.isSymbol)(key)) key = String(key);
|
|
576
611
|
const obj = /* @__PURE__ */ toRaw(this);
|
|
@@ -625,17 +660,19 @@ var MutableReactiveHandler = class extends BaseReactiveHandler {
|
|
|
625
660
|
oldValue = /* @__PURE__ */ toRaw(oldValue);
|
|
626
661
|
value = /* @__PURE__ */ toRaw(value);
|
|
627
662
|
}
|
|
628
|
-
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value))
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
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
|
+
}
|
|
634
671
|
}
|
|
635
672
|
}
|
|
636
673
|
const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : (0, _vue_shared.hasOwn)(target, key);
|
|
637
674
|
const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
|
|
638
|
-
if (target === /* @__PURE__ */ toRaw(receiver)) {
|
|
675
|
+
if (target === /* @__PURE__ */ toRaw(receiver) && result) {
|
|
639
676
|
if (!hadKey) trigger(target, "add", key, value);
|
|
640
677
|
else if ((0, _vue_shared.hasChanged)(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
641
678
|
}
|
|
@@ -671,10 +708,10 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
671
708
|
return true;
|
|
672
709
|
}
|
|
673
710
|
};
|
|
674
|
-
const mutableHandlers =
|
|
675
|
-
const readonlyHandlers =
|
|
676
|
-
const shallowReactiveHandlers =
|
|
677
|
-
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);
|
|
678
715
|
//#endregion
|
|
679
716
|
//#region packages/reactivity/src/collectionHandlers.ts
|
|
680
717
|
const toShallow = (value) => value;
|
|
@@ -825,10 +862,10 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
825
862
|
return Reflect.get((0, _vue_shared.hasOwn)(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
826
863
|
};
|
|
827
864
|
}
|
|
828
|
-
const mutableCollectionHandlers = { get:
|
|
829
|
-
const shallowCollectionHandlers = { get:
|
|
830
|
-
const readonlyCollectionHandlers = { get:
|
|
831
|
-
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) };
|
|
832
869
|
function checkIdentityKeys(target, has, key) {
|
|
833
870
|
const rawKey = /* @__PURE__ */ toRaw(key);
|
|
834
871
|
if (rawKey !== key && has.call(target, rawKey)) {
|
|
@@ -853,10 +890,7 @@ function targetTypeMap(rawType) {
|
|
|
853
890
|
default: return 0;
|
|
854
891
|
}
|
|
855
892
|
}
|
|
856
|
-
|
|
857
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap((0, _vue_shared.toRawType)(value));
|
|
858
|
-
}
|
|
859
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
893
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
860
894
|
function reactive(target) {
|
|
861
895
|
if (/* @__PURE__ */ isReadonly(target)) return target;
|
|
862
896
|
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
@@ -891,7 +925,7 @@ function reactive(target) {
|
|
|
891
925
|
* @param target - The source object.
|
|
892
926
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
|
|
893
927
|
*/
|
|
894
|
-
|
|
928
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
895
929
|
function shallowReactive(target) {
|
|
896
930
|
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
|
897
931
|
}
|
|
@@ -924,7 +958,7 @@ function shallowReactive(target) {
|
|
|
924
958
|
* @param target - The source object.
|
|
925
959
|
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
926
960
|
*/
|
|
927
|
-
|
|
961
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
928
962
|
function readonly(target) {
|
|
929
963
|
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
930
964
|
}
|
|
@@ -958,7 +992,7 @@ function readonly(target) {
|
|
|
958
992
|
* @param target - The source object.
|
|
959
993
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
|
|
960
994
|
*/
|
|
961
|
-
|
|
995
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
962
996
|
function shallowReadonly(target) {
|
|
963
997
|
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
964
998
|
}
|
|
@@ -968,10 +1002,11 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
|
|
|
968
1002
|
return target;
|
|
969
1003
|
}
|
|
970
1004
|
if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
|
|
971
|
-
|
|
972
|
-
if (targetType === 0) return target;
|
|
1005
|
+
if (target["__v_skip"] || !Object.isExtensible(target)) return target;
|
|
973
1006
|
const existingProxy = proxyMap.get(target);
|
|
974
1007
|
if (existingProxy) return existingProxy;
|
|
1008
|
+
const targetType = targetTypeMap((0, _vue_shared.toRawType)(target));
|
|
1009
|
+
if (targetType === 0) return target;
|
|
975
1010
|
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
976
1011
|
proxyMap.set(target, proxy);
|
|
977
1012
|
return proxy;
|
|
@@ -994,7 +1029,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
|
|
|
994
1029
|
* @param value - The value to check.
|
|
995
1030
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
996
1031
|
*/
|
|
997
|
-
|
|
1032
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
998
1033
|
function isReactive(value) {
|
|
999
1034
|
if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
|
|
1000
1035
|
return !!(value && value["__v_isReactive"]);
|
|
@@ -1010,11 +1045,11 @@ function isReactive(value) {
|
|
|
1010
1045
|
* @param value - The value to check.
|
|
1011
1046
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
1012
1047
|
*/
|
|
1013
|
-
|
|
1048
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1014
1049
|
function isReadonly(value) {
|
|
1015
1050
|
return !!(value && value["__v_isReadonly"]);
|
|
1016
1051
|
}
|
|
1017
|
-
|
|
1052
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1018
1053
|
function isShallow(value) {
|
|
1019
1054
|
return !!(value && value["__v_isShallow"]);
|
|
1020
1055
|
}
|
|
@@ -1025,7 +1060,7 @@ function isShallow(value) {
|
|
|
1025
1060
|
* @param value - The value to check.
|
|
1026
1061
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
1027
1062
|
*/
|
|
1028
|
-
|
|
1063
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1029
1064
|
function isProxy(value) {
|
|
1030
1065
|
return value ? !!value["__v_raw"] : false;
|
|
1031
1066
|
}
|
|
@@ -1052,7 +1087,7 @@ function isProxy(value) {
|
|
|
1052
1087
|
* @param observed - The object for which the "raw" value is requested.
|
|
1053
1088
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
1054
1089
|
*/
|
|
1055
|
-
|
|
1090
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1056
1091
|
function toRaw(observed) {
|
|
1057
1092
|
const raw = observed && observed["__v_raw"];
|
|
1058
1093
|
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
@@ -1101,15 +1136,15 @@ const toReactive = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */
|
|
|
1101
1136
|
const toReadonly = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1102
1137
|
//#endregion
|
|
1103
1138
|
//#region packages/reactivity/src/ref.ts
|
|
1104
|
-
|
|
1139
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1105
1140
|
function isRef(r) {
|
|
1106
1141
|
return r ? r["__v_isRef"] === true : false;
|
|
1107
1142
|
}
|
|
1108
|
-
|
|
1143
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1109
1144
|
function ref(value) {
|
|
1110
1145
|
return createRef(value, toReactive);
|
|
1111
1146
|
}
|
|
1112
|
-
|
|
1147
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1113
1148
|
function shallowRef(value) {
|
|
1114
1149
|
return createRef(value);
|
|
1115
1150
|
}
|
|
@@ -1124,7 +1159,7 @@ var RefImpl = class {
|
|
|
1124
1159
|
constructor(value, wrap) {
|
|
1125
1160
|
this.subs = void 0;
|
|
1126
1161
|
this.subsTail = void 0;
|
|
1127
|
-
this.flags =
|
|
1162
|
+
this.flags = 1;
|
|
1128
1163
|
this.__v_isRef = true;
|
|
1129
1164
|
this.__v_isShallow = false;
|
|
1130
1165
|
this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value;
|
|
@@ -1137,7 +1172,7 @@ var RefImpl = class {
|
|
|
1137
1172
|
}
|
|
1138
1173
|
get value() {
|
|
1139
1174
|
trackRef(this);
|
|
1140
|
-
if (this.flags &
|
|
1175
|
+
if (this.flags & 16 && this.update()) {
|
|
1141
1176
|
const subs = this.subs;
|
|
1142
1177
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1143
1178
|
}
|
|
@@ -1148,7 +1183,7 @@ var RefImpl = class {
|
|
|
1148
1183
|
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
1149
1184
|
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
1150
1185
|
if ((0, _vue_shared.hasChanged)(newValue, oldValue)) {
|
|
1151
|
-
this.flags |=
|
|
1186
|
+
this.flags |= 16;
|
|
1152
1187
|
this._rawValue = newValue;
|
|
1153
1188
|
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1154
1189
|
const subs = this.subs;
|
|
@@ -1167,7 +1202,7 @@ var RefImpl = class {
|
|
|
1167
1202
|
}
|
|
1168
1203
|
}
|
|
1169
1204
|
update() {
|
|
1170
|
-
this.flags &=
|
|
1205
|
+
this.flags &= -17;
|
|
1171
1206
|
return (0, _vue_shared.hasChanged)(this._oldValue, this._oldValue = this._rawValue);
|
|
1172
1207
|
}
|
|
1173
1208
|
};
|
|
@@ -1277,7 +1312,7 @@ var CustomRefImpl = class {
|
|
|
1277
1312
|
constructor(factory) {
|
|
1278
1313
|
this.subs = void 0;
|
|
1279
1314
|
this.subsTail = void 0;
|
|
1280
|
-
this.flags =
|
|
1315
|
+
this.flags = 0;
|
|
1281
1316
|
this["__v_isRef"] = true;
|
|
1282
1317
|
this._value = void 0;
|
|
1283
1318
|
const { get, set } = factory(() => trackRef(this), () => triggerRef(this));
|
|
@@ -1312,7 +1347,7 @@ function customRef(factory) {
|
|
|
1312
1347
|
* @param object - Reactive object to be made into an object of linked refs.
|
|
1313
1348
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
|
|
1314
1349
|
*/
|
|
1315
|
-
|
|
1350
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1316
1351
|
function toRefs(object) {
|
|
1317
1352
|
const ret = (0, _vue_shared.isArray)(object) ? new Array(object.length) : {};
|
|
1318
1353
|
for (const key in object) ret[key] = propertyToRef(object, key);
|
|
@@ -1363,7 +1398,7 @@ var GetterRefImpl = class {
|
|
|
1363
1398
|
return this._value = this._getter();
|
|
1364
1399
|
}
|
|
1365
1400
|
};
|
|
1366
|
-
|
|
1401
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1367
1402
|
function toRef(source, key, defaultValue) {
|
|
1368
1403
|
if (/* @__PURE__ */ isRef(source)) return source;
|
|
1369
1404
|
else if ((0, _vue_shared.isFunction)(source)) return new GetterRefImpl(source);
|
|
@@ -1412,9 +1447,11 @@ var ReactiveEffect = class {
|
|
|
1412
1447
|
if (!this.active) return this.fn();
|
|
1413
1448
|
cleanup(this);
|
|
1414
1449
|
const prevSub = startTracking(this);
|
|
1450
|
+
incRunDepth();
|
|
1415
1451
|
try {
|
|
1416
1452
|
return this.fn();
|
|
1417
1453
|
} finally {
|
|
1454
|
+
decRunDepth();
|
|
1418
1455
|
endTracking(this, prevSub);
|
|
1419
1456
|
const flags = this.flags;
|
|
1420
1457
|
if ((flags & 136) === 136) {
|
|
@@ -1435,10 +1472,12 @@ var ReactiveEffect = class {
|
|
|
1435
1472
|
get dirty() {
|
|
1436
1473
|
const flags = this.flags;
|
|
1437
1474
|
if (flags & 16) return true;
|
|
1438
|
-
if (flags & 32)
|
|
1439
|
-
this.
|
|
1440
|
-
|
|
1441
|
-
|
|
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
|
+
}
|
|
1442
1481
|
return false;
|
|
1443
1482
|
}
|
|
1444
1483
|
};
|
|
@@ -1669,11 +1708,13 @@ var ComputedRefImpl = class {
|
|
|
1669
1708
|
*/
|
|
1670
1709
|
get _dirty() {
|
|
1671
1710
|
const flags = this.flags;
|
|
1672
|
-
if (flags &
|
|
1673
|
-
if (flags &
|
|
1674
|
-
this.
|
|
1675
|
-
|
|
1676
|
-
|
|
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
|
+
}
|
|
1677
1718
|
return false;
|
|
1678
1719
|
}
|
|
1679
1720
|
/**
|
|
@@ -1681,8 +1722,8 @@ var ComputedRefImpl = class {
|
|
|
1681
1722
|
* for backwards compat
|
|
1682
1723
|
*/
|
|
1683
1724
|
set _dirty(v) {
|
|
1684
|
-
if (v) this.flags |=
|
|
1685
|
-
else this.flags &=
|
|
1725
|
+
if (v) this.flags |= 16;
|
|
1726
|
+
else this.flags &= -49;
|
|
1686
1727
|
}
|
|
1687
1728
|
constructor(fn, setter) {
|
|
1688
1729
|
this.fn = fn;
|
|
@@ -1692,18 +1733,18 @@ var ComputedRefImpl = class {
|
|
|
1692
1733
|
this.subsTail = void 0;
|
|
1693
1734
|
this.deps = void 0;
|
|
1694
1735
|
this.depsTail = void 0;
|
|
1695
|
-
this.flags =
|
|
1736
|
+
this.flags = 17;
|
|
1696
1737
|
this.__v_isRef = true;
|
|
1697
1738
|
this["__v_isReadonly"] = !setter;
|
|
1698
1739
|
}
|
|
1699
1740
|
get value() {
|
|
1700
1741
|
const flags = this.flags;
|
|
1701
|
-
if (flags &
|
|
1742
|
+
if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
|
|
1702
1743
|
if (this.update()) {
|
|
1703
1744
|
const subs = this.subs;
|
|
1704
1745
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1705
1746
|
}
|
|
1706
|
-
} else if (flags &
|
|
1747
|
+
} else if (flags & 32) this.flags = flags & -33;
|
|
1707
1748
|
if (activeSub !== void 0) {
|
|
1708
1749
|
onTrack(activeSub, {
|
|
1709
1750
|
target: this,
|
|
@@ -1734,7 +1775,7 @@ var ComputedRefImpl = class {
|
|
|
1734
1775
|
}
|
|
1735
1776
|
};
|
|
1736
1777
|
setupOnTrigger(ComputedRefImpl);
|
|
1737
|
-
|
|
1778
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1738
1779
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1739
1780
|
let getter;
|
|
1740
1781
|
let setter;
|
|
@@ -1828,25 +1869,26 @@ var WatcherEffect = class extends ReactiveEffect {
|
|
|
1828
1869
|
else if ((0, _vue_shared.isFunction)(s)) return call ? call(s, 2) : s();
|
|
1829
1870
|
else warnInvalidSource(s, onWarn);
|
|
1830
1871
|
});
|
|
1831
|
-
} else if ((0, _vue_shared.isFunction)(source))
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
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;
|
|
1835
1885
|
try {
|
|
1836
|
-
|
|
1886
|
+
return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
|
|
1837
1887
|
} finally {
|
|
1838
|
-
|
|
1888
|
+
activeWatcher = currentEffect;
|
|
1839
1889
|
}
|
|
1840
|
-
}
|
|
1841
|
-
|
|
1842
|
-
activeWatcher = this;
|
|
1843
|
-
try {
|
|
1844
|
-
return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
|
|
1845
|
-
} finally {
|
|
1846
|
-
activeWatcher = currentEffect;
|
|
1847
|
-
}
|
|
1848
|
-
};
|
|
1849
|
-
else {
|
|
1890
|
+
};
|
|
1891
|
+
} else {
|
|
1850
1892
|
getter = _vue_shared.NOOP;
|
|
1851
1893
|
warnInvalidSource(source, onWarn);
|
|
1852
1894
|
}
|
|
@@ -1864,8 +1906,9 @@ var WatcherEffect = class extends ReactiveEffect {
|
|
|
1864
1906
|
if (once && cb) {
|
|
1865
1907
|
const _cb = cb;
|
|
1866
1908
|
cb = (...args) => {
|
|
1867
|
-
_cb(...args);
|
|
1909
|
+
const res = _cb(...args);
|
|
1868
1910
|
this.stop();
|
|
1911
|
+
return res;
|
|
1869
1912
|
};
|
|
1870
1913
|
}
|
|
1871
1914
|
this.cb = cb;
|
|
@@ -1879,7 +1922,7 @@ var WatcherEffect = class extends ReactiveEffect {
|
|
|
1879
1922
|
if (!this.cb) return;
|
|
1880
1923
|
const { immediate, deep, call } = this.options;
|
|
1881
1924
|
if (initialRun && !immediate) return;
|
|
1882
|
-
if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => (0, _vue_shared.hasChanged)(v, oldValue[i])) : (0, _vue_shared.hasChanged)(newValue, oldValue))) {
|
|
1925
|
+
if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => (0, _vue_shared.hasChanged)(v, oldValue[i])) : (0, _vue_shared.hasChanged)(newValue, oldValue))) {
|
|
1883
1926
|
cleanup(this);
|
|
1884
1927
|
const currentWatcher = activeWatcher;
|
|
1885
1928
|
activeWatcher = this;
|
|
@@ -1932,6 +1975,7 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1932
1975
|
}
|
|
1933
1976
|
//#endregion
|
|
1934
1977
|
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|
|
1978
|
+
exports.Dep = Dep;
|
|
1935
1979
|
exports.EffectFlags = EffectFlags;
|
|
1936
1980
|
exports.EffectScope = EffectScope;
|
|
1937
1981
|
exports.ITERATE_KEY = ITERATE_KEY;
|
|
@@ -1942,11 +1986,18 @@ exports.TrackOpTypes = TrackOpTypes;
|
|
|
1942
1986
|
exports.TriggerOpTypes = TriggerOpTypes;
|
|
1943
1987
|
exports.WatchErrorCodes = WatchErrorCodes;
|
|
1944
1988
|
exports.WatcherEffect = WatcherEffect;
|
|
1989
|
+
Object.defineProperty(exports, "activeSub", {
|
|
1990
|
+
enumerable: true,
|
|
1991
|
+
get: function() {
|
|
1992
|
+
return activeSub;
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1945
1995
|
exports.computed = computed;
|
|
1946
1996
|
exports.customRef = customRef;
|
|
1947
1997
|
exports.effect = effect;
|
|
1948
1998
|
exports.effectScope = effectScope;
|
|
1949
1999
|
exports.enableTracking = enableTracking;
|
|
2000
|
+
exports.endBatch = endBatch;
|
|
1950
2001
|
exports.getCurrentScope = getCurrentScope;
|
|
1951
2002
|
exports.getCurrentWatcher = getCurrentWatcher;
|
|
1952
2003
|
exports.isProxy = isProxy;
|
|
@@ -1971,6 +2022,7 @@ exports.shallowReactive = shallowReactive;
|
|
|
1971
2022
|
exports.shallowReadArray = shallowReadArray;
|
|
1972
2023
|
exports.shallowReadonly = shallowReadonly;
|
|
1973
2024
|
exports.shallowRef = shallowRef;
|
|
2025
|
+
exports.startBatch = startBatch;
|
|
1974
2026
|
exports.stop = stop;
|
|
1975
2027
|
exports.toRaw = toRaw;
|
|
1976
2028
|
exports.toReactive = toReactive;
|
|
@@ -1979,8 +2031,10 @@ exports.toRef = toRef;
|
|
|
1979
2031
|
exports.toRefs = toRefs;
|
|
1980
2032
|
exports.toValue = toValue;
|
|
1981
2033
|
exports.track = track;
|
|
2034
|
+
exports.trackDep = trackDep;
|
|
1982
2035
|
exports.traverse = traverse;
|
|
1983
2036
|
exports.trigger = trigger;
|
|
2037
|
+
exports.triggerDep = triggerDep;
|
|
1984
2038
|
exports.triggerRef = triggerRef;
|
|
1985
2039
|
exports.unref = unref;
|
|
1986
2040
|
exports.watch = watch;
|