@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/reactivity v3.6.0-beta.9
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
  **/
@@ -13,7 +13,7 @@ var VueReactivity = (function(exports) {
13
13
  * \/\*#\_\_PURE\_\_\*\/
14
14
  * So that they can be tree-shaken if necessary.
15
15
  */
16
- /* @__NO_SIDE_EFFECTS__ */
16
+ /*@__NO_SIDE_EFFECTS__*/
17
17
  function makeMap(str) {
18
18
  const map = Object.create(null);
19
19
  for (const key of str.split(",")) map[key] = 1;
@@ -47,20 +47,12 @@ var VueReactivity = (function(exports) {
47
47
  return cache[str] || (cache[str] = fn(str));
48
48
  });
49
49
  };
50
- const camelizeRE = /-(\w)/g;
51
- const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
52
- cacheStringFunction((str) => str.replace(camelizeRE, camelizeReplacer));
53
- const hyphenateRE = /\B([A-Z])/g;
54
- cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
55
50
  /**
56
51
  * @private
57
52
  */
58
53
  const capitalize = cacheStringFunction((str) => {
59
54
  return str.charAt(0).toUpperCase() + str.slice(1);
60
55
  });
61
- cacheStringFunction((str) => {
62
- return str ? `on${capitalize(str)}` : ``;
63
- });
64
56
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
65
57
  const def = (obj, key, value, writable = false) => {
66
58
  Object.defineProperty(obj, key, {
@@ -112,25 +104,16 @@ var VueReactivity = (function(exports) {
112
104
  }
113
105
  //#endregion
114
106
  //#region packages/reactivity/src/system.ts
115
- const ReactiveFlags$1 = {
116
- "None": 0,
117
- "0": "None",
118
- "Mutable": 1,
119
- "1": "Mutable",
120
- "Watching": 2,
121
- "2": "Watching",
122
- "RecursedCheck": 4,
123
- "4": "RecursedCheck",
124
- "Recursed": 8,
125
- "8": "Recursed",
126
- "Dirty": 16,
127
- "16": "Dirty",
128
- "Pending": 32,
129
- "32": "Pending"
130
- };
131
107
  const notifyBuffer = [];
132
108
  let batchDepth = 0;
133
109
  let activeSub = void 0;
110
+ let runDepth = 0;
111
+ function incRunDepth() {
112
+ ++runDepth;
113
+ }
114
+ function decRunDepth() {
115
+ --runDepth;
116
+ }
134
117
  let globalVersion = 0;
135
118
  let notifyIndex = 0;
136
119
  let notifyBufferLength = 0;
@@ -204,8 +187,10 @@ var VueReactivity = (function(exports) {
204
187
  const sub = link.sub;
205
188
  let flags = sub.flags;
206
189
  if (flags & 3) {
207
- if (!(flags & 60)) sub.flags = flags | 32;
208
- else if (!(flags & 12)) flags = 0;
190
+ if (!(flags & 60)) {
191
+ sub.flags = flags | 32;
192
+ if (runDepth) sub.flags |= 8;
193
+ } else if (!(flags & 12)) flags = 0;
209
194
  else if (!(flags & 4)) sub.flags = flags & -9 | 32;
210
195
  else if (!(flags & 48) && isValidLink(link, sub)) {
211
196
  sub.flags = flags | 40;
@@ -257,13 +242,23 @@ var VueReactivity = (function(exports) {
257
242
  sub.flags &= -5;
258
243
  }
259
244
  function flush() {
245
+ let hasError = false;
246
+ let error;
260
247
  while (notifyIndex < notifyBufferLength) {
261
248
  const effect = notifyBuffer[notifyIndex];
262
249
  notifyBuffer[notifyIndex++] = void 0;
263
- effect.notify();
250
+ try {
251
+ effect.notify();
252
+ } catch (err) {
253
+ if (!hasError) {
254
+ hasError = true;
255
+ error = err;
256
+ }
257
+ }
264
258
  }
265
259
  notifyIndex = 0;
266
260
  notifyBufferLength = 0;
261
+ if (hasError) throw error;
267
262
  }
268
263
  function checkDirty(link, sub) {
269
264
  let stack;
@@ -274,13 +269,13 @@ var VueReactivity = (function(exports) {
274
269
  let dirty = false;
275
270
  if (sub.flags & 16) dirty = true;
276
271
  else if ((depFlags & 17) === 17) {
272
+ const subs = dep.subs;
277
273
  if (dep.update()) {
278
- const subs = dep.subs;
279
274
  if (subs.nextSub !== void 0) shallowPropagate(subs);
280
275
  dirty = true;
281
276
  }
282
277
  } else if ((depFlags & 33) === 33) {
283
- if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
278
+ stack = {
284
279
  value: link,
285
280
  prev: stack
286
281
  };
@@ -295,15 +290,12 @@ var VueReactivity = (function(exports) {
295
290
  }
296
291
  while (checkDepth) {
297
292
  --checkDepth;
298
- const firstSub = sub.subs;
299
- const hasMultipleSubs = firstSub.nextSub !== void 0;
300
- if (hasMultipleSubs) {
301
- link = stack.value;
302
- stack = stack.prev;
303
- } else link = firstSub;
293
+ link = stack.value;
294
+ stack = stack.prev;
304
295
  if (dirty) {
296
+ const subs = sub.subs;
305
297
  if (sub.update()) {
306
- if (hasMultipleSubs) shallowPropagate(firstSub);
298
+ if (subs.nextSub !== void 0) shallowPropagate(subs);
307
299
  sub = link.sub;
308
300
  continue;
309
301
  }
@@ -315,7 +307,7 @@ var VueReactivity = (function(exports) {
315
307
  }
316
308
  dirty = false;
317
309
  }
318
- return dirty;
310
+ return dirty && !!sub.flags;
319
311
  } while (true);
320
312
  }
321
313
  function shallowPropagate(link) {
@@ -350,9 +342,42 @@ var VueReactivity = (function(exports) {
350
342
  }
351
343
  set subs(value) {
352
344
  this._subs = value;
353
- if (value === void 0) this.map.delete(this.key);
345
+ if (value === void 0 && this.map) this.map.delete(this.key);
354
346
  }
355
347
  };
348
+ /**
349
+ * Tracks a dep its owner keys on its own, outside `targetMap`.
350
+ * @internal
351
+ */
352
+ function trackDep(dep, target = dep, key = "value") {
353
+ if (activeSub !== void 0) {
354
+ onTrack(activeSub, {
355
+ target,
356
+ type: "get",
357
+ key
358
+ });
359
+ link(dep, activeSub);
360
+ }
361
+ }
362
+ /**
363
+ * @internal
364
+ */
365
+ function triggerDep(dep, target = dep, key = "value", newValue, oldValue) {
366
+ const subs = dep.subs;
367
+ if (subs !== void 0) {
368
+ triggerEventInfos.push({
369
+ target,
370
+ type: "set",
371
+ key,
372
+ newValue,
373
+ oldValue
374
+ });
375
+ propagate(subs);
376
+ shallowPropagate(subs);
377
+ if (!batchDepth) flush();
378
+ triggerEventInfos.pop();
379
+ }
380
+ }
356
381
  const targetMap = /* @__PURE__ */ new WeakMap();
357
382
  const ITERATE_KEY = Symbol("Object iterate");
358
383
  const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
@@ -433,9 +458,7 @@ var VueReactivity = (function(exports) {
433
458
  if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
434
459
  }
435
460
  break;
436
- case "set":
437
- if (isMap(target)) run(depsMap.get(ITERATE_KEY));
438
- break;
461
+ case "set": if (isMap(target)) run(depsMap.get(ITERATE_KEY));
439
462
  }
440
463
  }
441
464
  }
@@ -450,13 +473,17 @@ var VueReactivity = (function(exports) {
450
473
  /**
451
474
  * Track array iteration and return:
452
475
  * - if input is reactive: a cloned raw array with reactive values
453
- * - if input is non-reactive or shallowReactive: the original raw array
476
+ * - if input is readonly: a cloned raw array with readonly values, preserving
477
+ * reactivity
478
+ * - if input is raw or shallow: the original raw array
454
479
  */
455
480
  function reactiveReadArray(array) {
456
481
  const raw = /* @__PURE__ */ toRaw(array);
457
482
  if (raw === array) return raw;
458
483
  track(raw, "iterate", ARRAY_ITERATE_KEY);
459
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
484
+ if (/* @__PURE__ */ isShallow(array)) return raw;
485
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
486
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
460
487
  }
461
488
  /**
462
489
  * Track array iteration and return raw array
@@ -632,8 +659,8 @@ var VueReactivity = (function(exports) {
632
659
  }
633
660
  //#endregion
634
661
  //#region packages/reactivity/src/baseHandlers.ts
635
- const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
636
- const builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
662
+ const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
663
+ const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
637
664
  function hasOwnProperty(key) {
638
665
  if (!isSymbol(key)) key = String(key);
639
666
  const obj = /* @__PURE__ */ toRaw(this);
@@ -688,17 +715,19 @@ var VueReactivity = (function(exports) {
688
715
  oldValue = /* @__PURE__ */ toRaw(oldValue);
689
716
  value = /* @__PURE__ */ toRaw(value);
690
717
  }
691
- if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
692
- warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
693
- return true;
694
- } else {
695
- oldValue.value = value;
696
- return true;
718
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
719
+ if (isOldValueReadonly) {
720
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
721
+ return true;
722
+ } else {
723
+ oldValue.value = value;
724
+ return true;
725
+ }
697
726
  }
698
727
  }
699
728
  const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
700
729
  const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
701
- if (target === /* @__PURE__ */ toRaw(receiver)) {
730
+ if (target === /* @__PURE__ */ toRaw(receiver) && result) {
702
731
  if (!hadKey) trigger(target, "add", key, value);
703
732
  else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
704
733
  }
@@ -734,10 +763,10 @@ var VueReactivity = (function(exports) {
734
763
  return true;
735
764
  }
736
765
  };
737
- const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
738
- const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
739
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
740
- const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
766
+ const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
767
+ const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
768
+ const shallowReactiveHandlers = /*@__PURE__*/ new MutableReactiveHandler(true);
769
+ const shallowReadonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler(true);
741
770
  //#endregion
742
771
  //#region packages/reactivity/src/collectionHandlers.ts
743
772
  const toShallow = (value) => value;
@@ -888,10 +917,10 @@ var VueReactivity = (function(exports) {
888
917
  return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
889
918
  };
890
919
  }
891
- const mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) };
892
- const shallowCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, true) };
893
- const readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) };
894
- const shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) };
920
+ const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
921
+ const shallowCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, true) };
922
+ const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
923
+ const shallowReadonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, true) };
895
924
  function checkIdentityKeys(target, has, key) {
896
925
  const rawKey = /* @__PURE__ */ toRaw(key);
897
926
  if (rawKey !== key && has.call(target, rawKey)) {
@@ -916,10 +945,7 @@ var VueReactivity = (function(exports) {
916
945
  default: return 0;
917
946
  }
918
947
  }
919
- function getTargetType(value) {
920
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
921
- }
922
- /* @__NO_SIDE_EFFECTS__ */
948
+ /*@__NO_SIDE_EFFECTS__*/
923
949
  function reactive(target) {
924
950
  if (/* @__PURE__ */ isReadonly(target)) return target;
925
951
  return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
@@ -954,7 +980,7 @@ var VueReactivity = (function(exports) {
954
980
  * @param target - The source object.
955
981
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
956
982
  */
957
- /* @__NO_SIDE_EFFECTS__ */
983
+ /*@__NO_SIDE_EFFECTS__*/
958
984
  function shallowReactive(target) {
959
985
  return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
960
986
  }
@@ -987,7 +1013,7 @@ var VueReactivity = (function(exports) {
987
1013
  * @param target - The source object.
988
1014
  * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
989
1015
  */
990
- /* @__NO_SIDE_EFFECTS__ */
1016
+ /*@__NO_SIDE_EFFECTS__*/
991
1017
  function readonly(target) {
992
1018
  return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
993
1019
  }
@@ -1021,7 +1047,7 @@ var VueReactivity = (function(exports) {
1021
1047
  * @param target - The source object.
1022
1048
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
1023
1049
  */
1024
- /* @__NO_SIDE_EFFECTS__ */
1050
+ /*@__NO_SIDE_EFFECTS__*/
1025
1051
  function shallowReadonly(target) {
1026
1052
  return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1027
1053
  }
@@ -1031,10 +1057,11 @@ var VueReactivity = (function(exports) {
1031
1057
  return target;
1032
1058
  }
1033
1059
  if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
1034
- const targetType = getTargetType(target);
1035
- if (targetType === 0) return target;
1060
+ if (target["__v_skip"] || !Object.isExtensible(target)) return target;
1036
1061
  const existingProxy = proxyMap.get(target);
1037
1062
  if (existingProxy) return existingProxy;
1063
+ const targetType = targetTypeMap(toRawType(target));
1064
+ if (targetType === 0) return target;
1038
1065
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1039
1066
  proxyMap.set(target, proxy);
1040
1067
  return proxy;
@@ -1057,7 +1084,7 @@ var VueReactivity = (function(exports) {
1057
1084
  * @param value - The value to check.
1058
1085
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
1059
1086
  */
1060
- /* @__NO_SIDE_EFFECTS__ */
1087
+ /*@__NO_SIDE_EFFECTS__*/
1061
1088
  function isReactive(value) {
1062
1089
  if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
1063
1090
  return !!(value && value["__v_isReactive"]);
@@ -1073,11 +1100,11 @@ var VueReactivity = (function(exports) {
1073
1100
  * @param value - The value to check.
1074
1101
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
1075
1102
  */
1076
- /* @__NO_SIDE_EFFECTS__ */
1103
+ /*@__NO_SIDE_EFFECTS__*/
1077
1104
  function isReadonly(value) {
1078
1105
  return !!(value && value["__v_isReadonly"]);
1079
1106
  }
1080
- /* @__NO_SIDE_EFFECTS__ */
1107
+ /*@__NO_SIDE_EFFECTS__*/
1081
1108
  function isShallow(value) {
1082
1109
  return !!(value && value["__v_isShallow"]);
1083
1110
  }
@@ -1088,7 +1115,7 @@ var VueReactivity = (function(exports) {
1088
1115
  * @param value - The value to check.
1089
1116
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
1090
1117
  */
1091
- /* @__NO_SIDE_EFFECTS__ */
1118
+ /*@__NO_SIDE_EFFECTS__*/
1092
1119
  function isProxy(value) {
1093
1120
  return value ? !!value["__v_raw"] : false;
1094
1121
  }
@@ -1115,7 +1142,7 @@ var VueReactivity = (function(exports) {
1115
1142
  * @param observed - The object for which the "raw" value is requested.
1116
1143
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
1117
1144
  */
1118
- /* @__NO_SIDE_EFFECTS__ */
1145
+ /*@__NO_SIDE_EFFECTS__*/
1119
1146
  function toRaw(observed) {
1120
1147
  const raw = observed && observed["__v_raw"];
1121
1148
  return raw ? /* @__PURE__ */ toRaw(raw) : observed;
@@ -1164,15 +1191,15 @@ var VueReactivity = (function(exports) {
1164
1191
  const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1165
1192
  //#endregion
1166
1193
  //#region packages/reactivity/src/ref.ts
1167
- /* @__NO_SIDE_EFFECTS__ */
1194
+ /*@__NO_SIDE_EFFECTS__*/
1168
1195
  function isRef(r) {
1169
1196
  return r ? r["__v_isRef"] === true : false;
1170
1197
  }
1171
- /* @__NO_SIDE_EFFECTS__ */
1198
+ /*@__NO_SIDE_EFFECTS__*/
1172
1199
  function ref(value) {
1173
1200
  return createRef(value, toReactive);
1174
1201
  }
1175
- /* @__NO_SIDE_EFFECTS__ */
1202
+ /*@__NO_SIDE_EFFECTS__*/
1176
1203
  function shallowRef(value) {
1177
1204
  return createRef(value);
1178
1205
  }
@@ -1187,7 +1214,7 @@ var VueReactivity = (function(exports) {
1187
1214
  constructor(value, wrap) {
1188
1215
  this.subs = void 0;
1189
1216
  this.subsTail = void 0;
1190
- this.flags = ReactiveFlags$1.Mutable;
1217
+ this.flags = 1;
1191
1218
  this.__v_isRef = true;
1192
1219
  this.__v_isShallow = false;
1193
1220
  this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value;
@@ -1200,7 +1227,7 @@ var VueReactivity = (function(exports) {
1200
1227
  }
1201
1228
  get value() {
1202
1229
  trackRef(this);
1203
- if (this.flags & ReactiveFlags$1.Dirty && this.update()) {
1230
+ if (this.flags & 16 && this.update()) {
1204
1231
  const subs = this.subs;
1205
1232
  if (subs !== void 0) shallowPropagate(subs);
1206
1233
  }
@@ -1211,7 +1238,7 @@ var VueReactivity = (function(exports) {
1211
1238
  const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
1212
1239
  newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
1213
1240
  if (hasChanged(newValue, oldValue)) {
1214
- this.flags |= ReactiveFlags$1.Dirty;
1241
+ this.flags |= 16;
1215
1242
  this._rawValue = newValue;
1216
1243
  this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
1217
1244
  const subs = this.subs;
@@ -1230,7 +1257,7 @@ var VueReactivity = (function(exports) {
1230
1257
  }
1231
1258
  }
1232
1259
  update() {
1233
- this.flags &= ~ReactiveFlags$1.Dirty;
1260
+ this.flags &= -17;
1234
1261
  return hasChanged(this._oldValue, this._oldValue = this._rawValue);
1235
1262
  }
1236
1263
  };
@@ -1340,7 +1367,7 @@ var VueReactivity = (function(exports) {
1340
1367
  constructor(factory) {
1341
1368
  this.subs = void 0;
1342
1369
  this.subsTail = void 0;
1343
- this.flags = ReactiveFlags$1.None;
1370
+ this.flags = 0;
1344
1371
  this["__v_isRef"] = true;
1345
1372
  this._value = void 0;
1346
1373
  const { get, set } = factory(() => trackRef(this), () => triggerRef(this));
@@ -1375,7 +1402,7 @@ var VueReactivity = (function(exports) {
1375
1402
  * @param object - Reactive object to be made into an object of linked refs.
1376
1403
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
1377
1404
  */
1378
- /* @__NO_SIDE_EFFECTS__ */
1405
+ /*@__NO_SIDE_EFFECTS__*/
1379
1406
  function toRefs(object) {
1380
1407
  const ret = isArray(object) ? new Array(object.length) : {};
1381
1408
  for (const key in object) ret[key] = propertyToRef(object, key);
@@ -1426,7 +1453,7 @@ var VueReactivity = (function(exports) {
1426
1453
  return this._value = this._getter();
1427
1454
  }
1428
1455
  };
1429
- /* @__NO_SIDE_EFFECTS__ */
1456
+ /*@__NO_SIDE_EFFECTS__*/
1430
1457
  function toRef(source, key, defaultValue) {
1431
1458
  if (/* @__PURE__ */ isRef(source)) return source;
1432
1459
  else if (isFunction(source)) return new GetterRefImpl(source);
@@ -1475,9 +1502,11 @@ var VueReactivity = (function(exports) {
1475
1502
  if (!this.active) return this.fn();
1476
1503
  cleanup(this);
1477
1504
  const prevSub = startTracking(this);
1505
+ incRunDepth();
1478
1506
  try {
1479
1507
  return this.fn();
1480
1508
  } finally {
1509
+ decRunDepth();
1481
1510
  endTracking(this, prevSub);
1482
1511
  const flags = this.flags;
1483
1512
  if ((flags & 136) === 136) {
@@ -1498,10 +1527,12 @@ var VueReactivity = (function(exports) {
1498
1527
  get dirty() {
1499
1528
  const flags = this.flags;
1500
1529
  if (flags & 16) return true;
1501
- if (flags & 32) if (checkDirty(this.deps, this)) {
1502
- this.flags = flags | 16;
1503
- return true;
1504
- } else this.flags = flags & -33;
1530
+ if (flags & 32) {
1531
+ if (checkDirty(this.deps, this)) {
1532
+ this.flags = flags | 16;
1533
+ return true;
1534
+ } else this.flags = flags & -33;
1535
+ }
1505
1536
  return false;
1506
1537
  }
1507
1538
  };
@@ -1732,11 +1763,13 @@ var VueReactivity = (function(exports) {
1732
1763
  */
1733
1764
  get _dirty() {
1734
1765
  const flags = this.flags;
1735
- if (flags & ReactiveFlags$1.Dirty) return true;
1736
- if (flags & ReactiveFlags$1.Pending) if (checkDirty(this.deps, this)) {
1737
- this.flags = flags | ReactiveFlags$1.Dirty;
1738
- return true;
1739
- } else this.flags = flags & ~ReactiveFlags$1.Pending;
1766
+ if (flags & 16) return true;
1767
+ if (flags & 32) {
1768
+ if (checkDirty(this.deps, this)) {
1769
+ this.flags = flags | 16;
1770
+ return true;
1771
+ } else this.flags = flags & -33;
1772
+ }
1740
1773
  return false;
1741
1774
  }
1742
1775
  /**
@@ -1744,8 +1777,8 @@ var VueReactivity = (function(exports) {
1744
1777
  * for backwards compat
1745
1778
  */
1746
1779
  set _dirty(v) {
1747
- if (v) this.flags |= ReactiveFlags$1.Dirty;
1748
- else this.flags &= ~(ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending);
1780
+ if (v) this.flags |= 16;
1781
+ else this.flags &= -49;
1749
1782
  }
1750
1783
  constructor(fn, setter) {
1751
1784
  this.fn = fn;
@@ -1755,18 +1788,18 @@ var VueReactivity = (function(exports) {
1755
1788
  this.subsTail = void 0;
1756
1789
  this.deps = void 0;
1757
1790
  this.depsTail = void 0;
1758
- this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
1791
+ this.flags = 17;
1759
1792
  this.__v_isRef = true;
1760
1793
  this["__v_isReadonly"] = !setter;
1761
1794
  }
1762
1795
  get value() {
1763
1796
  const flags = this.flags;
1764
- if (flags & ReactiveFlags$1.Dirty || flags & ReactiveFlags$1.Pending && checkDirty(this.deps, this)) {
1797
+ if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
1765
1798
  if (this.update()) {
1766
1799
  const subs = this.subs;
1767
1800
  if (subs !== void 0) shallowPropagate(subs);
1768
1801
  }
1769
- } else if (flags & ReactiveFlags$1.Pending) this.flags = flags & ~ReactiveFlags$1.Pending;
1802
+ } else if (flags & 32) this.flags = flags & -33;
1770
1803
  if (activeSub !== void 0) {
1771
1804
  onTrack(activeSub, {
1772
1805
  target: this,
@@ -1797,7 +1830,7 @@ var VueReactivity = (function(exports) {
1797
1830
  }
1798
1831
  };
1799
1832
  setupOnTrigger(ComputedRefImpl);
1800
- /* @__NO_SIDE_EFFECTS__ */
1833
+ /*@__NO_SIDE_EFFECTS__*/
1801
1834
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1802
1835
  let getter;
1803
1836
  let setter;
@@ -1891,25 +1924,26 @@ var VueReactivity = (function(exports) {
1891
1924
  else if (isFunction(s)) return call ? call(s, 2) : s();
1892
1925
  else warnInvalidSource(s, onWarn);
1893
1926
  });
1894
- } else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
1895
- else getter = () => {
1896
- if (this.cleanupsLength) {
1897
- const prevSub = setActiveSub();
1927
+ } else if (isFunction(source)) {
1928
+ if (cb) getter = call ? () => call(source, 2) : source;
1929
+ else getter = () => {
1930
+ if (this.cleanupsLength) {
1931
+ const prevSub = setActiveSub();
1932
+ try {
1933
+ cleanup(this);
1934
+ } finally {
1935
+ setActiveSub(prevSub);
1936
+ }
1937
+ }
1938
+ const currentEffect = activeWatcher;
1939
+ activeWatcher = this;
1898
1940
  try {
1899
- cleanup(this);
1941
+ return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
1900
1942
  } finally {
1901
- setActiveSub(prevSub);
1943
+ activeWatcher = currentEffect;
1902
1944
  }
1903
- }
1904
- const currentEffect = activeWatcher;
1905
- activeWatcher = this;
1906
- try {
1907
- return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
1908
- } finally {
1909
- activeWatcher = currentEffect;
1910
- }
1911
- };
1912
- else {
1945
+ };
1946
+ } else {
1913
1947
  getter = NOOP;
1914
1948
  warnInvalidSource(source, onWarn);
1915
1949
  }
@@ -1927,8 +1961,9 @@ var VueReactivity = (function(exports) {
1927
1961
  if (once && cb) {
1928
1962
  const _cb = cb;
1929
1963
  cb = (...args) => {
1930
- _cb(...args);
1964
+ const res = _cb(...args);
1931
1965
  this.stop();
1966
+ return res;
1932
1967
  };
1933
1968
  }
1934
1969
  this.cb = cb;
@@ -1942,7 +1977,7 @@ var VueReactivity = (function(exports) {
1942
1977
  if (!this.cb) return;
1943
1978
  const { immediate, deep, call } = this.options;
1944
1979
  if (initialRun && !immediate) return;
1945
- if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1980
+ if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1946
1981
  cleanup(this);
1947
1982
  const currentWatcher = activeWatcher;
1948
1983
  activeWatcher = this;
@@ -1995,6 +2030,7 @@ var VueReactivity = (function(exports) {
1995
2030
  }
1996
2031
  //#endregion
1997
2032
  exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
2033
+ exports.Dep = Dep;
1998
2034
  exports.EffectFlags = EffectFlags;
1999
2035
  exports.EffectScope = EffectScope;
2000
2036
  exports.ITERATE_KEY = ITERATE_KEY;
@@ -2005,11 +2041,18 @@ var VueReactivity = (function(exports) {
2005
2041
  exports.TriggerOpTypes = TriggerOpTypes;
2006
2042
  exports.WatchErrorCodes = WatchErrorCodes;
2007
2043
  exports.WatcherEffect = WatcherEffect;
2044
+ Object.defineProperty(exports, "activeSub", {
2045
+ enumerable: true,
2046
+ get: function() {
2047
+ return activeSub;
2048
+ }
2049
+ });
2008
2050
  exports.computed = computed;
2009
2051
  exports.customRef = customRef;
2010
2052
  exports.effect = effect;
2011
2053
  exports.effectScope = effectScope;
2012
2054
  exports.enableTracking = enableTracking;
2055
+ exports.endBatch = endBatch;
2013
2056
  exports.getCurrentScope = getCurrentScope;
2014
2057
  exports.getCurrentWatcher = getCurrentWatcher;
2015
2058
  exports.isProxy = isProxy;
@@ -2034,6 +2077,7 @@ var VueReactivity = (function(exports) {
2034
2077
  exports.shallowReadArray = shallowReadArray;
2035
2078
  exports.shallowReadonly = shallowReadonly;
2036
2079
  exports.shallowRef = shallowRef;
2080
+ exports.startBatch = startBatch;
2037
2081
  exports.stop = stop;
2038
2082
  exports.toRaw = toRaw;
2039
2083
  exports.toReactive = toReactive;
@@ -2042,8 +2086,10 @@ var VueReactivity = (function(exports) {
2042
2086
  exports.toRefs = toRefs;
2043
2087
  exports.toValue = toValue;
2044
2088
  exports.track = track;
2089
+ exports.trackDep = trackDep;
2045
2090
  exports.traverse = traverse;
2046
2091
  exports.trigger = trigger;
2092
+ exports.triggerDep = triggerDep;
2047
2093
  exports.triggerRef = triggerRef;
2048
2094
  exports.unref = unref;
2049
2095
  exports.watch = watch;