@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
|
@@ -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
|
**/
|
|
@@ -9,25 +9,16 @@ Object.defineProperties(exports, {
|
|
|
9
9
|
});
|
|
10
10
|
let _vue_shared = require("@vue/shared");
|
|
11
11
|
//#region packages/reactivity/src/system.ts
|
|
12
|
-
const ReactiveFlags$1 = {
|
|
13
|
-
"None": 0,
|
|
14
|
-
"0": "None",
|
|
15
|
-
"Mutable": 1,
|
|
16
|
-
"1": "Mutable",
|
|
17
|
-
"Watching": 2,
|
|
18
|
-
"2": "Watching",
|
|
19
|
-
"RecursedCheck": 4,
|
|
20
|
-
"4": "RecursedCheck",
|
|
21
|
-
"Recursed": 8,
|
|
22
|
-
"8": "Recursed",
|
|
23
|
-
"Dirty": 16,
|
|
24
|
-
"16": "Dirty",
|
|
25
|
-
"Pending": 32,
|
|
26
|
-
"32": "Pending"
|
|
27
|
-
};
|
|
28
12
|
const notifyBuffer = [];
|
|
29
13
|
let batchDepth = 0;
|
|
30
14
|
let activeSub = void 0;
|
|
15
|
+
let runDepth = 0;
|
|
16
|
+
function incRunDepth() {
|
|
17
|
+
++runDepth;
|
|
18
|
+
}
|
|
19
|
+
function decRunDepth() {
|
|
20
|
+
--runDepth;
|
|
21
|
+
}
|
|
31
22
|
let globalVersion = 0;
|
|
32
23
|
let notifyIndex = 0;
|
|
33
24
|
let notifyBufferLength = 0;
|
|
@@ -101,8 +92,10 @@ function propagate(link) {
|
|
|
101
92
|
const sub = link.sub;
|
|
102
93
|
let flags = sub.flags;
|
|
103
94
|
if (flags & 3) {
|
|
104
|
-
if (!(flags & 60))
|
|
105
|
-
|
|
95
|
+
if (!(flags & 60)) {
|
|
96
|
+
sub.flags = flags | 32;
|
|
97
|
+
if (runDepth) sub.flags |= 8;
|
|
98
|
+
} else if (!(flags & 12)) flags = 0;
|
|
106
99
|
else if (!(flags & 4)) sub.flags = flags & -9 | 32;
|
|
107
100
|
else if (!(flags & 48) && isValidLink(link, sub)) {
|
|
108
101
|
sub.flags = flags | 40;
|
|
@@ -153,13 +146,23 @@ function endTracking(sub, prevSub) {
|
|
|
153
146
|
sub.flags &= -5;
|
|
154
147
|
}
|
|
155
148
|
function flush() {
|
|
149
|
+
let hasError = false;
|
|
150
|
+
let error;
|
|
156
151
|
while (notifyIndex < notifyBufferLength) {
|
|
157
152
|
const effect = notifyBuffer[notifyIndex];
|
|
158
153
|
notifyBuffer[notifyIndex++] = void 0;
|
|
159
|
-
|
|
154
|
+
try {
|
|
155
|
+
effect.notify();
|
|
156
|
+
} catch (err) {
|
|
157
|
+
if (!hasError) {
|
|
158
|
+
hasError = true;
|
|
159
|
+
error = err;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
160
162
|
}
|
|
161
163
|
notifyIndex = 0;
|
|
162
164
|
notifyBufferLength = 0;
|
|
165
|
+
if (hasError) throw error;
|
|
163
166
|
}
|
|
164
167
|
function checkDirty(link, sub) {
|
|
165
168
|
let stack;
|
|
@@ -170,13 +173,13 @@ function checkDirty(link, sub) {
|
|
|
170
173
|
let dirty = false;
|
|
171
174
|
if (sub.flags & 16) dirty = true;
|
|
172
175
|
else if ((depFlags & 17) === 17) {
|
|
176
|
+
const subs = dep.subs;
|
|
173
177
|
if (dep.update()) {
|
|
174
|
-
const subs = dep.subs;
|
|
175
178
|
if (subs.nextSub !== void 0) shallowPropagate(subs);
|
|
176
179
|
dirty = true;
|
|
177
180
|
}
|
|
178
181
|
} else if ((depFlags & 33) === 33) {
|
|
179
|
-
|
|
182
|
+
stack = {
|
|
180
183
|
value: link,
|
|
181
184
|
prev: stack
|
|
182
185
|
};
|
|
@@ -191,15 +194,12 @@ function checkDirty(link, sub) {
|
|
|
191
194
|
}
|
|
192
195
|
while (checkDepth) {
|
|
193
196
|
--checkDepth;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (hasMultipleSubs) {
|
|
197
|
-
link = stack.value;
|
|
198
|
-
stack = stack.prev;
|
|
199
|
-
} else link = firstSub;
|
|
197
|
+
link = stack.value;
|
|
198
|
+
stack = stack.prev;
|
|
200
199
|
if (dirty) {
|
|
200
|
+
const subs = sub.subs;
|
|
201
201
|
if (sub.update()) {
|
|
202
|
-
if (
|
|
202
|
+
if (subs.nextSub !== void 0) shallowPropagate(subs);
|
|
203
203
|
sub = link.sub;
|
|
204
204
|
continue;
|
|
205
205
|
}
|
|
@@ -211,7 +211,7 @@ function checkDirty(link, sub) {
|
|
|
211
211
|
}
|
|
212
212
|
dirty = false;
|
|
213
213
|
}
|
|
214
|
-
return dirty;
|
|
214
|
+
return dirty && !!sub.flags;
|
|
215
215
|
} while (true);
|
|
216
216
|
}
|
|
217
217
|
function shallowPropagate(link) {
|
|
@@ -246,9 +246,27 @@ var Dep = class {
|
|
|
246
246
|
}
|
|
247
247
|
set subs(value) {
|
|
248
248
|
this._subs = value;
|
|
249
|
-
if (value === void 0) this.map.delete(this.key);
|
|
249
|
+
if (value === void 0 && this.map) this.map.delete(this.key);
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
+
/**
|
|
253
|
+
* Tracks a dep its owner keys on its own, outside `targetMap`.
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
256
|
+
function trackDep(dep, target = dep, key = "value") {
|
|
257
|
+
if (activeSub !== void 0) link(dep, activeSub);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* @internal
|
|
261
|
+
*/
|
|
262
|
+
function triggerDep(dep, target = dep, key = "value", newValue, oldValue) {
|
|
263
|
+
const subs = dep.subs;
|
|
264
|
+
if (subs !== void 0) {
|
|
265
|
+
propagate(subs);
|
|
266
|
+
shallowPropagate(subs);
|
|
267
|
+
if (!batchDepth) flush();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
252
270
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
253
271
|
const ITERATE_KEY = Symbol("");
|
|
254
272
|
const MAP_KEY_ITERATE_KEY = Symbol("");
|
|
@@ -315,9 +333,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
315
333
|
if ((0, _vue_shared.isMap)(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
316
334
|
}
|
|
317
335
|
break;
|
|
318
|
-
case "set":
|
|
319
|
-
if ((0, _vue_shared.isMap)(target)) run(depsMap.get(ITERATE_KEY));
|
|
320
|
-
break;
|
|
336
|
+
case "set": if ((0, _vue_shared.isMap)(target)) run(depsMap.get(ITERATE_KEY));
|
|
321
337
|
}
|
|
322
338
|
}
|
|
323
339
|
}
|
|
@@ -332,13 +348,17 @@ function getDepFromReactive(object, key) {
|
|
|
332
348
|
/**
|
|
333
349
|
* Track array iteration and return:
|
|
334
350
|
* - if input is reactive: a cloned raw array with reactive values
|
|
335
|
-
* - if input is
|
|
351
|
+
* - if input is readonly: a cloned raw array with readonly values, preserving
|
|
352
|
+
* reactivity
|
|
353
|
+
* - if input is raw or shallow: the original raw array
|
|
336
354
|
*/
|
|
337
355
|
function reactiveReadArray(array) {
|
|
338
356
|
const raw = /* @__PURE__ */ toRaw(array);
|
|
339
357
|
if (raw === array) return raw;
|
|
340
358
|
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
341
|
-
|
|
359
|
+
if (/* @__PURE__ */ isShallow(array)) return raw;
|
|
360
|
+
if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
|
|
361
|
+
return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
|
|
342
362
|
}
|
|
343
363
|
/**
|
|
344
364
|
* Track array iteration and return raw array
|
|
@@ -514,8 +534,8 @@ function noTracking(self, method, args = []) {
|
|
|
514
534
|
}
|
|
515
535
|
//#endregion
|
|
516
536
|
//#region packages/reactivity/src/baseHandlers.ts
|
|
517
|
-
const isNonTrackableKeys =
|
|
518
|
-
const builtInSymbols = new Set(
|
|
537
|
+
const isNonTrackableKeys = /*@__PURE__*/ (0, _vue_shared.makeMap)(`__proto__,__v_isRef,__isVue`);
|
|
538
|
+
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(_vue_shared.isSymbol));
|
|
519
539
|
function hasOwnProperty(key) {
|
|
520
540
|
if (!(0, _vue_shared.isSymbol)(key)) key = String(key);
|
|
521
541
|
const obj = /* @__PURE__ */ toRaw(this);
|
|
@@ -570,15 +590,17 @@ var MutableReactiveHandler = class extends BaseReactiveHandler {
|
|
|
570
590
|
oldValue = /* @__PURE__ */ toRaw(oldValue);
|
|
571
591
|
value = /* @__PURE__ */ toRaw(value);
|
|
572
592
|
}
|
|
573
|
-
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value))
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
593
|
+
if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
|
|
594
|
+
if (isOldValueReadonly) return true;
|
|
595
|
+
else {
|
|
596
|
+
oldValue.value = value;
|
|
597
|
+
return true;
|
|
598
|
+
}
|
|
577
599
|
}
|
|
578
600
|
}
|
|
579
601
|
const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : (0, _vue_shared.hasOwn)(target, key);
|
|
580
602
|
const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
|
|
581
|
-
if (target === /* @__PURE__ */ toRaw(receiver)) {
|
|
603
|
+
if (target === /* @__PURE__ */ toRaw(receiver) && result) {
|
|
582
604
|
if (!hadKey) trigger(target, "add", key, value);
|
|
583
605
|
else if ((0, _vue_shared.hasChanged)(value, oldValue)) trigger(target, "set", key, value, oldValue);
|
|
584
606
|
}
|
|
@@ -612,10 +634,10 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
612
634
|
return true;
|
|
613
635
|
}
|
|
614
636
|
};
|
|
615
|
-
const mutableHandlers =
|
|
616
|
-
const readonlyHandlers =
|
|
617
|
-
const shallowReactiveHandlers =
|
|
618
|
-
const shallowReadonlyHandlers =
|
|
637
|
+
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
638
|
+
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
639
|
+
const shallowReactiveHandlers = /*@__PURE__*/ new MutableReactiveHandler(true);
|
|
640
|
+
const shallowReadonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler(true);
|
|
619
641
|
//#endregion
|
|
620
642
|
//#region packages/reactivity/src/collectionHandlers.ts
|
|
621
643
|
const toShallow = (value) => value;
|
|
@@ -762,10 +784,10 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
762
784
|
return Reflect.get((0, _vue_shared.hasOwn)(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
763
785
|
};
|
|
764
786
|
}
|
|
765
|
-
const mutableCollectionHandlers = { get:
|
|
766
|
-
const shallowCollectionHandlers = { get:
|
|
767
|
-
const readonlyCollectionHandlers = { get:
|
|
768
|
-
const shallowReadonlyCollectionHandlers = { get:
|
|
787
|
+
const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
|
|
788
|
+
const shallowCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, true) };
|
|
789
|
+
const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
|
|
790
|
+
const shallowReadonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, true) };
|
|
769
791
|
//#endregion
|
|
770
792
|
//#region packages/reactivity/src/reactive.ts
|
|
771
793
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -783,10 +805,7 @@ function targetTypeMap(rawType) {
|
|
|
783
805
|
default: return 0;
|
|
784
806
|
}
|
|
785
807
|
}
|
|
786
|
-
|
|
787
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap((0, _vue_shared.toRawType)(value));
|
|
788
|
-
}
|
|
789
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
808
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
790
809
|
function reactive(target) {
|
|
791
810
|
if (/* @__PURE__ */ isReadonly(target)) return target;
|
|
792
811
|
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
@@ -821,7 +840,7 @@ function reactive(target) {
|
|
|
821
840
|
* @param target - The source object.
|
|
822
841
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
|
|
823
842
|
*/
|
|
824
|
-
|
|
843
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
825
844
|
function shallowReactive(target) {
|
|
826
845
|
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
|
827
846
|
}
|
|
@@ -854,7 +873,7 @@ function shallowReactive(target) {
|
|
|
854
873
|
* @param target - The source object.
|
|
855
874
|
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
856
875
|
*/
|
|
857
|
-
|
|
876
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
858
877
|
function readonly(target) {
|
|
859
878
|
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
860
879
|
}
|
|
@@ -888,17 +907,18 @@ function readonly(target) {
|
|
|
888
907
|
* @param target - The source object.
|
|
889
908
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
|
|
890
909
|
*/
|
|
891
|
-
|
|
910
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
892
911
|
function shallowReadonly(target) {
|
|
893
912
|
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
894
913
|
}
|
|
895
914
|
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
|
|
896
915
|
if (!(0, _vue_shared.isObject)(target)) return target;
|
|
897
916
|
if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
|
|
898
|
-
|
|
899
|
-
if (targetType === 0) return target;
|
|
917
|
+
if (target["__v_skip"] || !Object.isExtensible(target)) return target;
|
|
900
918
|
const existingProxy = proxyMap.get(target);
|
|
901
919
|
if (existingProxy) return existingProxy;
|
|
920
|
+
const targetType = targetTypeMap((0, _vue_shared.toRawType)(target));
|
|
921
|
+
if (targetType === 0) return target;
|
|
902
922
|
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
903
923
|
proxyMap.set(target, proxy);
|
|
904
924
|
return proxy;
|
|
@@ -921,7 +941,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
|
|
|
921
941
|
* @param value - The value to check.
|
|
922
942
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
923
943
|
*/
|
|
924
|
-
|
|
944
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
925
945
|
function isReactive(value) {
|
|
926
946
|
if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
|
|
927
947
|
return !!(value && value["__v_isReactive"]);
|
|
@@ -937,11 +957,11 @@ function isReactive(value) {
|
|
|
937
957
|
* @param value - The value to check.
|
|
938
958
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
939
959
|
*/
|
|
940
|
-
|
|
960
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
941
961
|
function isReadonly(value) {
|
|
942
962
|
return !!(value && value["__v_isReadonly"]);
|
|
943
963
|
}
|
|
944
|
-
|
|
964
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
945
965
|
function isShallow(value) {
|
|
946
966
|
return !!(value && value["__v_isShallow"]);
|
|
947
967
|
}
|
|
@@ -952,7 +972,7 @@ function isShallow(value) {
|
|
|
952
972
|
* @param value - The value to check.
|
|
953
973
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
954
974
|
*/
|
|
955
|
-
|
|
975
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
956
976
|
function isProxy(value) {
|
|
957
977
|
return value ? !!value["__v_raw"] : false;
|
|
958
978
|
}
|
|
@@ -979,7 +999,7 @@ function isProxy(value) {
|
|
|
979
999
|
* @param observed - The object for which the "raw" value is requested.
|
|
980
1000
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
981
1001
|
*/
|
|
982
|
-
|
|
1002
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
983
1003
|
function toRaw(observed) {
|
|
984
1004
|
const raw = observed && observed["__v_raw"];
|
|
985
1005
|
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
@@ -1028,15 +1048,15 @@ const toReactive = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */
|
|
|
1028
1048
|
const toReadonly = (value) => (0, _vue_shared.isObject)(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1029
1049
|
//#endregion
|
|
1030
1050
|
//#region packages/reactivity/src/ref.ts
|
|
1031
|
-
|
|
1051
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1032
1052
|
function isRef(r) {
|
|
1033
1053
|
return r ? r["__v_isRef"] === true : false;
|
|
1034
1054
|
}
|
|
1035
|
-
|
|
1055
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1036
1056
|
function ref(value) {
|
|
1037
1057
|
return createRef(value, toReactive);
|
|
1038
1058
|
}
|
|
1039
|
-
|
|
1059
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1040
1060
|
function shallowRef(value) {
|
|
1041
1061
|
return createRef(value);
|
|
1042
1062
|
}
|
|
@@ -1051,7 +1071,7 @@ var RefImpl = class {
|
|
|
1051
1071
|
constructor(value, wrap) {
|
|
1052
1072
|
this.subs = void 0;
|
|
1053
1073
|
this.subsTail = void 0;
|
|
1054
|
-
this.flags =
|
|
1074
|
+
this.flags = 1;
|
|
1055
1075
|
this.__v_isRef = true;
|
|
1056
1076
|
this.__v_isShallow = false;
|
|
1057
1077
|
this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value;
|
|
@@ -1064,7 +1084,7 @@ var RefImpl = class {
|
|
|
1064
1084
|
}
|
|
1065
1085
|
get value() {
|
|
1066
1086
|
trackRef(this);
|
|
1067
|
-
if (this.flags &
|
|
1087
|
+
if (this.flags & 16 && this.update()) {
|
|
1068
1088
|
const subs = this.subs;
|
|
1069
1089
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1070
1090
|
}
|
|
@@ -1075,7 +1095,7 @@ var RefImpl = class {
|
|
|
1075
1095
|
const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
|
|
1076
1096
|
newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
|
|
1077
1097
|
if ((0, _vue_shared.hasChanged)(newValue, oldValue)) {
|
|
1078
|
-
this.flags |=
|
|
1098
|
+
this.flags |= 16;
|
|
1079
1099
|
this._rawValue = newValue;
|
|
1080
1100
|
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1081
1101
|
const subs = this.subs;
|
|
@@ -1086,7 +1106,7 @@ var RefImpl = class {
|
|
|
1086
1106
|
}
|
|
1087
1107
|
}
|
|
1088
1108
|
update() {
|
|
1089
|
-
this.flags &=
|
|
1109
|
+
this.flags &= -17;
|
|
1090
1110
|
return (0, _vue_shared.hasChanged)(this._oldValue, this._oldValue = this._rawValue);
|
|
1091
1111
|
}
|
|
1092
1112
|
};
|
|
@@ -1189,7 +1209,7 @@ var CustomRefImpl = class {
|
|
|
1189
1209
|
constructor(factory) {
|
|
1190
1210
|
this.subs = void 0;
|
|
1191
1211
|
this.subsTail = void 0;
|
|
1192
|
-
this.flags =
|
|
1212
|
+
this.flags = 0;
|
|
1193
1213
|
this["__v_isRef"] = true;
|
|
1194
1214
|
this._value = void 0;
|
|
1195
1215
|
const { get, set } = factory(() => trackRef(this), () => triggerRef(this));
|
|
@@ -1224,7 +1244,7 @@ function customRef(factory) {
|
|
|
1224
1244
|
* @param object - Reactive object to be made into an object of linked refs.
|
|
1225
1245
|
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
|
|
1226
1246
|
*/
|
|
1227
|
-
|
|
1247
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1228
1248
|
function toRefs(object) {
|
|
1229
1249
|
const ret = (0, _vue_shared.isArray)(object) ? new Array(object.length) : {};
|
|
1230
1250
|
for (const key in object) ret[key] = propertyToRef(object, key);
|
|
@@ -1275,7 +1295,7 @@ var GetterRefImpl = class {
|
|
|
1275
1295
|
return this._value = this._getter();
|
|
1276
1296
|
}
|
|
1277
1297
|
};
|
|
1278
|
-
|
|
1298
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1279
1299
|
function toRef(source, key, defaultValue) {
|
|
1280
1300
|
if (/* @__PURE__ */ isRef(source)) return source;
|
|
1281
1301
|
else if ((0, _vue_shared.isFunction)(source)) return new GetterRefImpl(source);
|
|
@@ -1324,9 +1344,11 @@ var ReactiveEffect = class {
|
|
|
1324
1344
|
if (!this.active) return this.fn();
|
|
1325
1345
|
cleanup(this);
|
|
1326
1346
|
const prevSub = startTracking(this);
|
|
1347
|
+
incRunDepth();
|
|
1327
1348
|
try {
|
|
1328
1349
|
return this.fn();
|
|
1329
1350
|
} finally {
|
|
1351
|
+
decRunDepth();
|
|
1330
1352
|
endTracking(this, prevSub);
|
|
1331
1353
|
const flags = this.flags;
|
|
1332
1354
|
if ((flags & 136) === 136) {
|
|
@@ -1347,10 +1369,12 @@ var ReactiveEffect = class {
|
|
|
1347
1369
|
get dirty() {
|
|
1348
1370
|
const flags = this.flags;
|
|
1349
1371
|
if (flags & 16) return true;
|
|
1350
|
-
if (flags & 32)
|
|
1351
|
-
this.
|
|
1352
|
-
|
|
1353
|
-
|
|
1372
|
+
if (flags & 32) {
|
|
1373
|
+
if (checkDirty(this.deps, this)) {
|
|
1374
|
+
this.flags = flags | 16;
|
|
1375
|
+
return true;
|
|
1376
|
+
} else this.flags = flags & -33;
|
|
1377
|
+
}
|
|
1354
1378
|
return false;
|
|
1355
1379
|
}
|
|
1356
1380
|
};
|
|
@@ -1577,11 +1601,13 @@ var ComputedRefImpl = class {
|
|
|
1577
1601
|
*/
|
|
1578
1602
|
get _dirty() {
|
|
1579
1603
|
const flags = this.flags;
|
|
1580
|
-
if (flags &
|
|
1581
|
-
if (flags &
|
|
1582
|
-
this.
|
|
1583
|
-
|
|
1584
|
-
|
|
1604
|
+
if (flags & 16) return true;
|
|
1605
|
+
if (flags & 32) {
|
|
1606
|
+
if (checkDirty(this.deps, this)) {
|
|
1607
|
+
this.flags = flags | 16;
|
|
1608
|
+
return true;
|
|
1609
|
+
} else this.flags = flags & -33;
|
|
1610
|
+
}
|
|
1585
1611
|
return false;
|
|
1586
1612
|
}
|
|
1587
1613
|
/**
|
|
@@ -1589,8 +1615,8 @@ var ComputedRefImpl = class {
|
|
|
1589
1615
|
* for backwards compat
|
|
1590
1616
|
*/
|
|
1591
1617
|
set _dirty(v) {
|
|
1592
|
-
if (v) this.flags |=
|
|
1593
|
-
else this.flags &=
|
|
1618
|
+
if (v) this.flags |= 16;
|
|
1619
|
+
else this.flags &= -49;
|
|
1594
1620
|
}
|
|
1595
1621
|
constructor(fn, setter) {
|
|
1596
1622
|
this.fn = fn;
|
|
@@ -1600,18 +1626,18 @@ var ComputedRefImpl = class {
|
|
|
1600
1626
|
this.subsTail = void 0;
|
|
1601
1627
|
this.deps = void 0;
|
|
1602
1628
|
this.depsTail = void 0;
|
|
1603
|
-
this.flags =
|
|
1629
|
+
this.flags = 17;
|
|
1604
1630
|
this.__v_isRef = true;
|
|
1605
1631
|
this["__v_isReadonly"] = !setter;
|
|
1606
1632
|
}
|
|
1607
1633
|
get value() {
|
|
1608
1634
|
const flags = this.flags;
|
|
1609
|
-
if (flags &
|
|
1635
|
+
if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
|
|
1610
1636
|
if (this.update()) {
|
|
1611
1637
|
const subs = this.subs;
|
|
1612
1638
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1613
1639
|
}
|
|
1614
|
-
} else if (flags &
|
|
1640
|
+
} else if (flags & 32) this.flags = flags & -33;
|
|
1615
1641
|
if (activeSub !== void 0) link(this, activeSub);
|
|
1616
1642
|
else if (activeEffectScope !== void 0) link(this, activeEffectScope);
|
|
1617
1643
|
return this._value;
|
|
@@ -1634,7 +1660,7 @@ var ComputedRefImpl = class {
|
|
|
1634
1660
|
}
|
|
1635
1661
|
}
|
|
1636
1662
|
};
|
|
1637
|
-
|
|
1663
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
1638
1664
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1639
1665
|
let getter;
|
|
1640
1666
|
let setter;
|
|
@@ -1722,25 +1748,26 @@ var WatcherEffect = class extends ReactiveEffect {
|
|
|
1722
1748
|
else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s, deep);
|
|
1723
1749
|
else if ((0, _vue_shared.isFunction)(s)) return call ? call(s, 2) : s();
|
|
1724
1750
|
});
|
|
1725
|
-
} else if ((0, _vue_shared.isFunction)(source))
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1751
|
+
} else if ((0, _vue_shared.isFunction)(source)) {
|
|
1752
|
+
if (cb) getter = call ? () => call(source, 2) : source;
|
|
1753
|
+
else getter = () => {
|
|
1754
|
+
if (this.cleanupsLength) {
|
|
1755
|
+
const prevSub = setActiveSub();
|
|
1756
|
+
try {
|
|
1757
|
+
cleanup(this);
|
|
1758
|
+
} finally {
|
|
1759
|
+
setActiveSub(prevSub);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
const currentEffect = activeWatcher;
|
|
1763
|
+
activeWatcher = this;
|
|
1729
1764
|
try {
|
|
1730
|
-
|
|
1765
|
+
return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
|
|
1731
1766
|
} finally {
|
|
1732
|
-
|
|
1767
|
+
activeWatcher = currentEffect;
|
|
1733
1768
|
}
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
activeWatcher = this;
|
|
1737
|
-
try {
|
|
1738
|
-
return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
|
|
1739
|
-
} finally {
|
|
1740
|
-
activeWatcher = currentEffect;
|
|
1741
|
-
}
|
|
1742
|
-
};
|
|
1743
|
-
else getter = _vue_shared.NOOP;
|
|
1769
|
+
};
|
|
1770
|
+
} else getter = _vue_shared.NOOP;
|
|
1744
1771
|
if (cb && deep) {
|
|
1745
1772
|
const baseGetter = getter;
|
|
1746
1773
|
const depth = deep === true ? Infinity : deep;
|
|
@@ -1755,8 +1782,9 @@ var WatcherEffect = class extends ReactiveEffect {
|
|
|
1755
1782
|
if (once && cb) {
|
|
1756
1783
|
const _cb = cb;
|
|
1757
1784
|
cb = (...args) => {
|
|
1758
|
-
_cb(...args);
|
|
1785
|
+
const res = _cb(...args);
|
|
1759
1786
|
this.stop();
|
|
1787
|
+
return res;
|
|
1760
1788
|
};
|
|
1761
1789
|
}
|
|
1762
1790
|
this.cb = cb;
|
|
@@ -1768,7 +1796,7 @@ var WatcherEffect = class extends ReactiveEffect {
|
|
|
1768
1796
|
if (!this.cb) return;
|
|
1769
1797
|
const { immediate, deep, call } = this.options;
|
|
1770
1798
|
if (initialRun && !immediate) return;
|
|
1771
|
-
if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => (0, _vue_shared.hasChanged)(v, oldValue[i])) : (0, _vue_shared.hasChanged)(newValue, oldValue))) {
|
|
1799
|
+
if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => (0, _vue_shared.hasChanged)(v, oldValue[i])) : (0, _vue_shared.hasChanged)(newValue, oldValue))) {
|
|
1772
1800
|
cleanup(this);
|
|
1773
1801
|
const currentWatcher = activeWatcher;
|
|
1774
1802
|
activeWatcher = this;
|
|
@@ -1818,6 +1846,7 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1818
1846
|
}
|
|
1819
1847
|
//#endregion
|
|
1820
1848
|
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
|
|
1849
|
+
exports.Dep = Dep;
|
|
1821
1850
|
exports.EffectFlags = EffectFlags;
|
|
1822
1851
|
exports.EffectScope = EffectScope;
|
|
1823
1852
|
exports.ITERATE_KEY = ITERATE_KEY;
|
|
@@ -1828,11 +1857,18 @@ exports.TrackOpTypes = TrackOpTypes;
|
|
|
1828
1857
|
exports.TriggerOpTypes = TriggerOpTypes;
|
|
1829
1858
|
exports.WatchErrorCodes = WatchErrorCodes;
|
|
1830
1859
|
exports.WatcherEffect = WatcherEffect;
|
|
1860
|
+
Object.defineProperty(exports, "activeSub", {
|
|
1861
|
+
enumerable: true,
|
|
1862
|
+
get: function() {
|
|
1863
|
+
return activeSub;
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1831
1866
|
exports.computed = computed;
|
|
1832
1867
|
exports.customRef = customRef;
|
|
1833
1868
|
exports.effect = effect;
|
|
1834
1869
|
exports.effectScope = effectScope;
|
|
1835
1870
|
exports.enableTracking = enableTracking;
|
|
1871
|
+
exports.endBatch = endBatch;
|
|
1836
1872
|
exports.getCurrentScope = getCurrentScope;
|
|
1837
1873
|
exports.getCurrentWatcher = getCurrentWatcher;
|
|
1838
1874
|
exports.isProxy = isProxy;
|
|
@@ -1857,6 +1893,7 @@ exports.shallowReactive = shallowReactive;
|
|
|
1857
1893
|
exports.shallowReadArray = shallowReadArray;
|
|
1858
1894
|
exports.shallowReadonly = shallowReadonly;
|
|
1859
1895
|
exports.shallowRef = shallowRef;
|
|
1896
|
+
exports.startBatch = startBatch;
|
|
1860
1897
|
exports.stop = stop;
|
|
1861
1898
|
exports.toRaw = toRaw;
|
|
1862
1899
|
exports.toReactive = toReactive;
|
|
@@ -1865,8 +1902,10 @@ exports.toRef = toRef;
|
|
|
1865
1902
|
exports.toRefs = toRefs;
|
|
1866
1903
|
exports.toValue = toValue;
|
|
1867
1904
|
exports.track = track;
|
|
1905
|
+
exports.trackDep = trackDep;
|
|
1868
1906
|
exports.traverse = traverse;
|
|
1869
1907
|
exports.trigger = trigger;
|
|
1908
|
+
exports.triggerDep = triggerDep;
|
|
1870
1909
|
exports.triggerRef = triggerRef;
|
|
1871
1910
|
exports.unref = unref;
|
|
1872
1911
|
exports.watch = watch;
|