@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
  **/
@@ -11,7 +11,7 @@
11
11
  * \/\*#\_\_PURE\_\_\*\/
12
12
  * So that they can be tree-shaken if necessary.
13
13
  */
14
- /* @__NO_SIDE_EFFECTS__ */
14
+ /*@__NO_SIDE_EFFECTS__*/
15
15
  function makeMap(str) {
16
16
  const map = Object.create(null);
17
17
  for (const key of str.split(",")) map[key] = 1;
@@ -45,20 +45,12 @@ const cacheStringFunction = (fn) => {
45
45
  return cache[str] || (cache[str] = fn(str));
46
46
  });
47
47
  };
48
- const camelizeRE = /-(\w)/g;
49
- const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
50
- cacheStringFunction((str) => str.replace(camelizeRE, camelizeReplacer));
51
- const hyphenateRE = /\B([A-Z])/g;
52
- cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
53
48
  /**
54
49
  * @private
55
50
  */
56
51
  const capitalize = cacheStringFunction((str) => {
57
52
  return str.charAt(0).toUpperCase() + str.slice(1);
58
53
  });
59
- cacheStringFunction((str) => {
60
- return str ? `on${capitalize(str)}` : ``;
61
- });
62
54
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
63
55
  const def = (obj, key, value, writable = false) => {
64
56
  Object.defineProperty(obj, key, {
@@ -110,25 +102,16 @@ function warn(msg, ...args) {
110
102
  }
111
103
  //#endregion
112
104
  //#region packages/reactivity/src/system.ts
113
- const ReactiveFlags$1 = {
114
- "None": 0,
115
- "0": "None",
116
- "Mutable": 1,
117
- "1": "Mutable",
118
- "Watching": 2,
119
- "2": "Watching",
120
- "RecursedCheck": 4,
121
- "4": "RecursedCheck",
122
- "Recursed": 8,
123
- "8": "Recursed",
124
- "Dirty": 16,
125
- "16": "Dirty",
126
- "Pending": 32,
127
- "32": "Pending"
128
- };
129
105
  const notifyBuffer = [];
130
106
  let batchDepth = 0;
131
107
  let activeSub = void 0;
108
+ let runDepth = 0;
109
+ function incRunDepth() {
110
+ ++runDepth;
111
+ }
112
+ function decRunDepth() {
113
+ --runDepth;
114
+ }
132
115
  let globalVersion = 0;
133
116
  let notifyIndex = 0;
134
117
  let notifyBufferLength = 0;
@@ -202,8 +185,10 @@ function propagate(link) {
202
185
  const sub = link.sub;
203
186
  let flags = sub.flags;
204
187
  if (flags & 3) {
205
- if (!(flags & 60)) sub.flags = flags | 32;
206
- else if (!(flags & 12)) flags = 0;
188
+ if (!(flags & 60)) {
189
+ sub.flags = flags | 32;
190
+ if (runDepth) sub.flags |= 8;
191
+ } else if (!(flags & 12)) flags = 0;
207
192
  else if (!(flags & 4)) sub.flags = flags & -9 | 32;
208
193
  else if (!(flags & 48) && isValidLink(link, sub)) {
209
194
  sub.flags = flags | 40;
@@ -255,13 +240,23 @@ function endTracking(sub, prevSub) {
255
240
  sub.flags &= -5;
256
241
  }
257
242
  function flush() {
243
+ let hasError = false;
244
+ let error;
258
245
  while (notifyIndex < notifyBufferLength) {
259
246
  const effect = notifyBuffer[notifyIndex];
260
247
  notifyBuffer[notifyIndex++] = void 0;
261
- effect.notify();
248
+ try {
249
+ effect.notify();
250
+ } catch (err) {
251
+ if (!hasError) {
252
+ hasError = true;
253
+ error = err;
254
+ }
255
+ }
262
256
  }
263
257
  notifyIndex = 0;
264
258
  notifyBufferLength = 0;
259
+ if (hasError) throw error;
265
260
  }
266
261
  function checkDirty(link, sub) {
267
262
  let stack;
@@ -272,13 +267,13 @@ function checkDirty(link, sub) {
272
267
  let dirty = false;
273
268
  if (sub.flags & 16) dirty = true;
274
269
  else if ((depFlags & 17) === 17) {
270
+ const subs = dep.subs;
275
271
  if (dep.update()) {
276
- const subs = dep.subs;
277
272
  if (subs.nextSub !== void 0) shallowPropagate(subs);
278
273
  dirty = true;
279
274
  }
280
275
  } else if ((depFlags & 33) === 33) {
281
- if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
276
+ stack = {
282
277
  value: link,
283
278
  prev: stack
284
279
  };
@@ -293,15 +288,12 @@ function checkDirty(link, sub) {
293
288
  }
294
289
  while (checkDepth) {
295
290
  --checkDepth;
296
- const firstSub = sub.subs;
297
- const hasMultipleSubs = firstSub.nextSub !== void 0;
298
- if (hasMultipleSubs) {
299
- link = stack.value;
300
- stack = stack.prev;
301
- } else link = firstSub;
291
+ link = stack.value;
292
+ stack = stack.prev;
302
293
  if (dirty) {
294
+ const subs = sub.subs;
303
295
  if (sub.update()) {
304
- if (hasMultipleSubs) shallowPropagate(firstSub);
296
+ if (subs.nextSub !== void 0) shallowPropagate(subs);
305
297
  sub = link.sub;
306
298
  continue;
307
299
  }
@@ -313,7 +305,7 @@ function checkDirty(link, sub) {
313
305
  }
314
306
  dirty = false;
315
307
  }
316
- return dirty;
308
+ return dirty && !!sub.flags;
317
309
  } while (true);
318
310
  }
319
311
  function shallowPropagate(link) {
@@ -348,9 +340,42 @@ var Dep = class {
348
340
  }
349
341
  set subs(value) {
350
342
  this._subs = value;
351
- if (value === void 0) this.map.delete(this.key);
343
+ if (value === void 0 && this.map) this.map.delete(this.key);
352
344
  }
353
345
  };
346
+ /**
347
+ * Tracks a dep its owner keys on its own, outside `targetMap`.
348
+ * @internal
349
+ */
350
+ function trackDep(dep, target = dep, key = "value") {
351
+ if (activeSub !== void 0) {
352
+ onTrack(activeSub, {
353
+ target,
354
+ type: "get",
355
+ key
356
+ });
357
+ link(dep, activeSub);
358
+ }
359
+ }
360
+ /**
361
+ * @internal
362
+ */
363
+ function triggerDep(dep, target = dep, key = "value", newValue, oldValue) {
364
+ const subs = dep.subs;
365
+ if (subs !== void 0) {
366
+ triggerEventInfos.push({
367
+ target,
368
+ type: "set",
369
+ key,
370
+ newValue,
371
+ oldValue
372
+ });
373
+ propagate(subs);
374
+ shallowPropagate(subs);
375
+ if (!batchDepth) flush();
376
+ triggerEventInfos.pop();
377
+ }
378
+ }
354
379
  const targetMap = /* @__PURE__ */ new WeakMap();
355
380
  const ITERATE_KEY = Symbol("Object iterate");
356
381
  const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate");
@@ -431,9 +456,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
431
456
  if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
432
457
  }
433
458
  break;
434
- case "set":
435
- if (isMap(target)) run(depsMap.get(ITERATE_KEY));
436
- break;
459
+ case "set": if (isMap(target)) run(depsMap.get(ITERATE_KEY));
437
460
  }
438
461
  }
439
462
  }
@@ -448,13 +471,17 @@ function getDepFromReactive(object, key) {
448
471
  /**
449
472
  * Track array iteration and return:
450
473
  * - if input is reactive: a cloned raw array with reactive values
451
- * - if input is non-reactive or shallowReactive: the original raw array
474
+ * - if input is readonly: a cloned raw array with readonly values, preserving
475
+ * reactivity
476
+ * - if input is raw or shallow: the original raw array
452
477
  */
453
478
  function reactiveReadArray(array) {
454
479
  const raw = /* @__PURE__ */ toRaw(array);
455
480
  if (raw === array) return raw;
456
481
  track(raw, "iterate", ARRAY_ITERATE_KEY);
457
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
482
+ if (/* @__PURE__ */ isShallow(array)) return raw;
483
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
484
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
458
485
  }
459
486
  /**
460
487
  * Track array iteration and return raw array
@@ -630,8 +657,8 @@ function noTracking(self, method, args = []) {
630
657
  }
631
658
  //#endregion
632
659
  //#region packages/reactivity/src/baseHandlers.ts
633
- const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
634
- const builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
660
+ const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
661
+ const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
635
662
  function hasOwnProperty(key) {
636
663
  if (!isSymbol(key)) key = String(key);
637
664
  const obj = /* @__PURE__ */ toRaw(this);
@@ -686,17 +713,19 @@ var MutableReactiveHandler = class extends BaseReactiveHandler {
686
713
  oldValue = /* @__PURE__ */ toRaw(oldValue);
687
714
  value = /* @__PURE__ */ toRaw(value);
688
715
  }
689
- if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
690
- warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
691
- return true;
692
- } else {
693
- oldValue.value = value;
694
- return true;
716
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
717
+ if (isOldValueReadonly) {
718
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
719
+ return true;
720
+ } else {
721
+ oldValue.value = value;
722
+ return true;
723
+ }
695
724
  }
696
725
  }
697
726
  const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
698
727
  const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
699
- if (target === /* @__PURE__ */ toRaw(receiver)) {
728
+ if (target === /* @__PURE__ */ toRaw(receiver) && result) {
700
729
  if (!hadKey) trigger(target, "add", key, value);
701
730
  else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
702
731
  }
@@ -732,10 +761,10 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
732
761
  return true;
733
762
  }
734
763
  };
735
- const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
736
- const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
737
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
738
- const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
764
+ const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
765
+ const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
766
+ const shallowReactiveHandlers = /*@__PURE__*/ new MutableReactiveHandler(true);
767
+ const shallowReadonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler(true);
739
768
  //#endregion
740
769
  //#region packages/reactivity/src/collectionHandlers.ts
741
770
  const toShallow = (value) => value;
@@ -886,10 +915,10 @@ function createInstrumentationGetter(isReadonly, shallow) {
886
915
  return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
887
916
  };
888
917
  }
889
- const mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) };
890
- const shallowCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, true) };
891
- const readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) };
892
- const shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) };
918
+ const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
919
+ const shallowCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, true) };
920
+ const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
921
+ const shallowReadonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, true) };
893
922
  function checkIdentityKeys(target, has, key) {
894
923
  const rawKey = /* @__PURE__ */ toRaw(key);
895
924
  if (rawKey !== key && has.call(target, rawKey)) {
@@ -914,10 +943,7 @@ function targetTypeMap(rawType) {
914
943
  default: return 0;
915
944
  }
916
945
  }
917
- function getTargetType(value) {
918
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
919
- }
920
- /* @__NO_SIDE_EFFECTS__ */
946
+ /*@__NO_SIDE_EFFECTS__*/
921
947
  function reactive(target) {
922
948
  if (/* @__PURE__ */ isReadonly(target)) return target;
923
949
  return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
@@ -952,7 +978,7 @@ function reactive(target) {
952
978
  * @param target - The source object.
953
979
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
954
980
  */
955
- /* @__NO_SIDE_EFFECTS__ */
981
+ /*@__NO_SIDE_EFFECTS__*/
956
982
  function shallowReactive(target) {
957
983
  return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
958
984
  }
@@ -985,7 +1011,7 @@ function shallowReactive(target) {
985
1011
  * @param target - The source object.
986
1012
  * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
987
1013
  */
988
- /* @__NO_SIDE_EFFECTS__ */
1014
+ /*@__NO_SIDE_EFFECTS__*/
989
1015
  function readonly(target) {
990
1016
  return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
991
1017
  }
@@ -1019,7 +1045,7 @@ function readonly(target) {
1019
1045
  * @param target - The source object.
1020
1046
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
1021
1047
  */
1022
- /* @__NO_SIDE_EFFECTS__ */
1048
+ /*@__NO_SIDE_EFFECTS__*/
1023
1049
  function shallowReadonly(target) {
1024
1050
  return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1025
1051
  }
@@ -1029,10 +1055,11 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1029
1055
  return target;
1030
1056
  }
1031
1057
  if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
1032
- const targetType = getTargetType(target);
1033
- if (targetType === 0) return target;
1058
+ if (target["__v_skip"] || !Object.isExtensible(target)) return target;
1034
1059
  const existingProxy = proxyMap.get(target);
1035
1060
  if (existingProxy) return existingProxy;
1061
+ const targetType = targetTypeMap(toRawType(target));
1062
+ if (targetType === 0) return target;
1036
1063
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1037
1064
  proxyMap.set(target, proxy);
1038
1065
  return proxy;
@@ -1055,7 +1082,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1055
1082
  * @param value - The value to check.
1056
1083
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
1057
1084
  */
1058
- /* @__NO_SIDE_EFFECTS__ */
1085
+ /*@__NO_SIDE_EFFECTS__*/
1059
1086
  function isReactive(value) {
1060
1087
  if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
1061
1088
  return !!(value && value["__v_isReactive"]);
@@ -1071,11 +1098,11 @@ function isReactive(value) {
1071
1098
  * @param value - The value to check.
1072
1099
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
1073
1100
  */
1074
- /* @__NO_SIDE_EFFECTS__ */
1101
+ /*@__NO_SIDE_EFFECTS__*/
1075
1102
  function isReadonly(value) {
1076
1103
  return !!(value && value["__v_isReadonly"]);
1077
1104
  }
1078
- /* @__NO_SIDE_EFFECTS__ */
1105
+ /*@__NO_SIDE_EFFECTS__*/
1079
1106
  function isShallow(value) {
1080
1107
  return !!(value && value["__v_isShallow"]);
1081
1108
  }
@@ -1086,7 +1113,7 @@ function isShallow(value) {
1086
1113
  * @param value - The value to check.
1087
1114
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
1088
1115
  */
1089
- /* @__NO_SIDE_EFFECTS__ */
1116
+ /*@__NO_SIDE_EFFECTS__*/
1090
1117
  function isProxy(value) {
1091
1118
  return value ? !!value["__v_raw"] : false;
1092
1119
  }
@@ -1113,7 +1140,7 @@ function isProxy(value) {
1113
1140
  * @param observed - The object for which the "raw" value is requested.
1114
1141
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
1115
1142
  */
1116
- /* @__NO_SIDE_EFFECTS__ */
1143
+ /*@__NO_SIDE_EFFECTS__*/
1117
1144
  function toRaw(observed) {
1118
1145
  const raw = observed && observed["__v_raw"];
1119
1146
  return raw ? /* @__PURE__ */ toRaw(raw) : observed;
@@ -1162,15 +1189,15 @@ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value)
1162
1189
  const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1163
1190
  //#endregion
1164
1191
  //#region packages/reactivity/src/ref.ts
1165
- /* @__NO_SIDE_EFFECTS__ */
1192
+ /*@__NO_SIDE_EFFECTS__*/
1166
1193
  function isRef(r) {
1167
1194
  return r ? r["__v_isRef"] === true : false;
1168
1195
  }
1169
- /* @__NO_SIDE_EFFECTS__ */
1196
+ /*@__NO_SIDE_EFFECTS__*/
1170
1197
  function ref(value) {
1171
1198
  return createRef(value, toReactive);
1172
1199
  }
1173
- /* @__NO_SIDE_EFFECTS__ */
1200
+ /*@__NO_SIDE_EFFECTS__*/
1174
1201
  function shallowRef(value) {
1175
1202
  return createRef(value);
1176
1203
  }
@@ -1185,7 +1212,7 @@ var RefImpl = class {
1185
1212
  constructor(value, wrap) {
1186
1213
  this.subs = void 0;
1187
1214
  this.subsTail = void 0;
1188
- this.flags = ReactiveFlags$1.Mutable;
1215
+ this.flags = 1;
1189
1216
  this.__v_isRef = true;
1190
1217
  this.__v_isShallow = false;
1191
1218
  this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value;
@@ -1198,7 +1225,7 @@ var RefImpl = class {
1198
1225
  }
1199
1226
  get value() {
1200
1227
  trackRef(this);
1201
- if (this.flags & ReactiveFlags$1.Dirty && this.update()) {
1228
+ if (this.flags & 16 && this.update()) {
1202
1229
  const subs = this.subs;
1203
1230
  if (subs !== void 0) shallowPropagate(subs);
1204
1231
  }
@@ -1209,7 +1236,7 @@ var RefImpl = class {
1209
1236
  const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
1210
1237
  newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
1211
1238
  if (hasChanged(newValue, oldValue)) {
1212
- this.flags |= ReactiveFlags$1.Dirty;
1239
+ this.flags |= 16;
1213
1240
  this._rawValue = newValue;
1214
1241
  this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
1215
1242
  const subs = this.subs;
@@ -1228,7 +1255,7 @@ var RefImpl = class {
1228
1255
  }
1229
1256
  }
1230
1257
  update() {
1231
- this.flags &= ~ReactiveFlags$1.Dirty;
1258
+ this.flags &= -17;
1232
1259
  return hasChanged(this._oldValue, this._oldValue = this._rawValue);
1233
1260
  }
1234
1261
  };
@@ -1338,7 +1365,7 @@ var CustomRefImpl = class {
1338
1365
  constructor(factory) {
1339
1366
  this.subs = void 0;
1340
1367
  this.subsTail = void 0;
1341
- this.flags = ReactiveFlags$1.None;
1368
+ this.flags = 0;
1342
1369
  this["__v_isRef"] = true;
1343
1370
  this._value = void 0;
1344
1371
  const { get, set } = factory(() => trackRef(this), () => triggerRef(this));
@@ -1373,7 +1400,7 @@ function customRef(factory) {
1373
1400
  * @param object - Reactive object to be made into an object of linked refs.
1374
1401
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
1375
1402
  */
1376
- /* @__NO_SIDE_EFFECTS__ */
1403
+ /*@__NO_SIDE_EFFECTS__*/
1377
1404
  function toRefs(object) {
1378
1405
  const ret = isArray(object) ? new Array(object.length) : {};
1379
1406
  for (const key in object) ret[key] = propertyToRef(object, key);
@@ -1424,7 +1451,7 @@ var GetterRefImpl = class {
1424
1451
  return this._value = this._getter();
1425
1452
  }
1426
1453
  };
1427
- /* @__NO_SIDE_EFFECTS__ */
1454
+ /*@__NO_SIDE_EFFECTS__*/
1428
1455
  function toRef(source, key, defaultValue) {
1429
1456
  if (/* @__PURE__ */ isRef(source)) return source;
1430
1457
  else if (isFunction(source)) return new GetterRefImpl(source);
@@ -1473,9 +1500,11 @@ var ReactiveEffect = class {
1473
1500
  if (!this.active) return this.fn();
1474
1501
  cleanup(this);
1475
1502
  const prevSub = startTracking(this);
1503
+ incRunDepth();
1476
1504
  try {
1477
1505
  return this.fn();
1478
1506
  } finally {
1507
+ decRunDepth();
1479
1508
  endTracking(this, prevSub);
1480
1509
  const flags = this.flags;
1481
1510
  if ((flags & 136) === 136) {
@@ -1496,10 +1525,12 @@ var ReactiveEffect = class {
1496
1525
  get dirty() {
1497
1526
  const flags = this.flags;
1498
1527
  if (flags & 16) return true;
1499
- if (flags & 32) if (checkDirty(this.deps, this)) {
1500
- this.flags = flags | 16;
1501
- return true;
1502
- } else this.flags = flags & -33;
1528
+ if (flags & 32) {
1529
+ if (checkDirty(this.deps, this)) {
1530
+ this.flags = flags | 16;
1531
+ return true;
1532
+ } else this.flags = flags & -33;
1533
+ }
1503
1534
  return false;
1504
1535
  }
1505
1536
  };
@@ -1730,11 +1761,13 @@ var ComputedRefImpl = class {
1730
1761
  */
1731
1762
  get _dirty() {
1732
1763
  const flags = this.flags;
1733
- if (flags & ReactiveFlags$1.Dirty) return true;
1734
- if (flags & ReactiveFlags$1.Pending) if (checkDirty(this.deps, this)) {
1735
- this.flags = flags | ReactiveFlags$1.Dirty;
1736
- return true;
1737
- } else this.flags = flags & ~ReactiveFlags$1.Pending;
1764
+ if (flags & 16) return true;
1765
+ if (flags & 32) {
1766
+ if (checkDirty(this.deps, this)) {
1767
+ this.flags = flags | 16;
1768
+ return true;
1769
+ } else this.flags = flags & -33;
1770
+ }
1738
1771
  return false;
1739
1772
  }
1740
1773
  /**
@@ -1742,8 +1775,8 @@ var ComputedRefImpl = class {
1742
1775
  * for backwards compat
1743
1776
  */
1744
1777
  set _dirty(v) {
1745
- if (v) this.flags |= ReactiveFlags$1.Dirty;
1746
- else this.flags &= ~(ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending);
1778
+ if (v) this.flags |= 16;
1779
+ else this.flags &= -49;
1747
1780
  }
1748
1781
  constructor(fn, setter) {
1749
1782
  this.fn = fn;
@@ -1753,18 +1786,18 @@ var ComputedRefImpl = class {
1753
1786
  this.subsTail = void 0;
1754
1787
  this.deps = void 0;
1755
1788
  this.depsTail = void 0;
1756
- this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
1789
+ this.flags = 17;
1757
1790
  this.__v_isRef = true;
1758
1791
  this["__v_isReadonly"] = !setter;
1759
1792
  }
1760
1793
  get value() {
1761
1794
  const flags = this.flags;
1762
- if (flags & ReactiveFlags$1.Dirty || flags & ReactiveFlags$1.Pending && checkDirty(this.deps, this)) {
1795
+ if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
1763
1796
  if (this.update()) {
1764
1797
  const subs = this.subs;
1765
1798
  if (subs !== void 0) shallowPropagate(subs);
1766
1799
  }
1767
- } else if (flags & ReactiveFlags$1.Pending) this.flags = flags & ~ReactiveFlags$1.Pending;
1800
+ } else if (flags & 32) this.flags = flags & -33;
1768
1801
  if (activeSub !== void 0) {
1769
1802
  onTrack(activeSub, {
1770
1803
  target: this,
@@ -1795,7 +1828,7 @@ var ComputedRefImpl = class {
1795
1828
  }
1796
1829
  };
1797
1830
  setupOnTrigger(ComputedRefImpl);
1798
- /* @__NO_SIDE_EFFECTS__ */
1831
+ /*@__NO_SIDE_EFFECTS__*/
1799
1832
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1800
1833
  let getter;
1801
1834
  let setter;
@@ -1889,25 +1922,26 @@ var WatcherEffect = class extends ReactiveEffect {
1889
1922
  else if (isFunction(s)) return call ? call(s, 2) : s();
1890
1923
  else warnInvalidSource(s, onWarn);
1891
1924
  });
1892
- } else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
1893
- else getter = () => {
1894
- if (this.cleanupsLength) {
1895
- const prevSub = setActiveSub();
1925
+ } else if (isFunction(source)) {
1926
+ if (cb) getter = call ? () => call(source, 2) : source;
1927
+ else getter = () => {
1928
+ if (this.cleanupsLength) {
1929
+ const prevSub = setActiveSub();
1930
+ try {
1931
+ cleanup(this);
1932
+ } finally {
1933
+ setActiveSub(prevSub);
1934
+ }
1935
+ }
1936
+ const currentEffect = activeWatcher;
1937
+ activeWatcher = this;
1896
1938
  try {
1897
- cleanup(this);
1939
+ return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
1898
1940
  } finally {
1899
- setActiveSub(prevSub);
1941
+ activeWatcher = currentEffect;
1900
1942
  }
1901
- }
1902
- const currentEffect = activeWatcher;
1903
- activeWatcher = this;
1904
- try {
1905
- return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
1906
- } finally {
1907
- activeWatcher = currentEffect;
1908
- }
1909
- };
1910
- else {
1943
+ };
1944
+ } else {
1911
1945
  getter = NOOP;
1912
1946
  warnInvalidSource(source, onWarn);
1913
1947
  }
@@ -1925,8 +1959,9 @@ var WatcherEffect = class extends ReactiveEffect {
1925
1959
  if (once && cb) {
1926
1960
  const _cb = cb;
1927
1961
  cb = (...args) => {
1928
- _cb(...args);
1962
+ const res = _cb(...args);
1929
1963
  this.stop();
1964
+ return res;
1930
1965
  };
1931
1966
  }
1932
1967
  this.cb = cb;
@@ -1940,7 +1975,7 @@ var WatcherEffect = class extends ReactiveEffect {
1940
1975
  if (!this.cb) return;
1941
1976
  const { immediate, deep, call } = this.options;
1942
1977
  if (initialRun && !immediate) return;
1943
- if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1978
+ if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1944
1979
  cleanup(this);
1945
1980
  const currentWatcher = activeWatcher;
1946
1981
  activeWatcher = this;
@@ -1992,4 +2027,4 @@ function traverse(value, depth = Infinity, seen) {
1992
2027
  return value;
1993
2028
  }
1994
2029
  //#endregion
1995
- 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 };
2030
+ 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 };