@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
  **/
@@ -48,25 +48,16 @@ function warn(msg, ...args) {
48
48
  }
49
49
  //#endregion
50
50
  //#region packages/reactivity/src/system.ts
51
- const ReactiveFlags$1 = {
52
- "None": 0,
53
- "0": "None",
54
- "Mutable": 1,
55
- "1": "Mutable",
56
- "Watching": 2,
57
- "2": "Watching",
58
- "RecursedCheck": 4,
59
- "4": "RecursedCheck",
60
- "Recursed": 8,
61
- "8": "Recursed",
62
- "Dirty": 16,
63
- "16": "Dirty",
64
- "Pending": 32,
65
- "32": "Pending"
66
- };
67
51
  const notifyBuffer = [];
68
52
  let batchDepth = 0;
69
53
  let activeSub = void 0;
54
+ let runDepth = 0;
55
+ function incRunDepth() {
56
+ ++runDepth;
57
+ }
58
+ function decRunDepth() {
59
+ --runDepth;
60
+ }
70
61
  let globalVersion = 0;
71
62
  let notifyIndex = 0;
72
63
  let notifyBufferLength = 0;
@@ -140,8 +131,10 @@ function propagate(link) {
140
131
  const sub = link.sub;
141
132
  let flags = sub.flags;
142
133
  if (flags & 3) {
143
- if (!(flags & 60)) sub.flags = flags | 32;
144
- else if (!(flags & 12)) flags = 0;
134
+ if (!(flags & 60)) {
135
+ sub.flags = flags | 32;
136
+ if (runDepth) sub.flags |= 8;
137
+ } else if (!(flags & 12)) flags = 0;
145
138
  else if (!(flags & 4)) sub.flags = flags & -9 | 32;
146
139
  else if (!(flags & 48) && isValidLink(link, sub)) {
147
140
  sub.flags = flags | 40;
@@ -193,13 +186,23 @@ function endTracking(sub, prevSub) {
193
186
  sub.flags &= -5;
194
187
  }
195
188
  function flush() {
189
+ let hasError = false;
190
+ let error;
196
191
  while (notifyIndex < notifyBufferLength) {
197
192
  const effect = notifyBuffer[notifyIndex];
198
193
  notifyBuffer[notifyIndex++] = void 0;
199
- effect.notify();
194
+ try {
195
+ effect.notify();
196
+ } catch (err) {
197
+ if (!hasError) {
198
+ hasError = true;
199
+ error = err;
200
+ }
201
+ }
200
202
  }
201
203
  notifyIndex = 0;
202
204
  notifyBufferLength = 0;
205
+ if (hasError) throw error;
203
206
  }
204
207
  function checkDirty(link, sub) {
205
208
  let stack;
@@ -210,13 +213,13 @@ function checkDirty(link, sub) {
210
213
  let dirty = false;
211
214
  if (sub.flags & 16) dirty = true;
212
215
  else if ((depFlags & 17) === 17) {
216
+ const subs = dep.subs;
213
217
  if (dep.update()) {
214
- const subs = dep.subs;
215
218
  if (subs.nextSub !== void 0) shallowPropagate(subs);
216
219
  dirty = true;
217
220
  }
218
221
  } else if ((depFlags & 33) === 33) {
219
- if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
222
+ stack = {
220
223
  value: link,
221
224
  prev: stack
222
225
  };
@@ -231,15 +234,12 @@ function checkDirty(link, sub) {
231
234
  }
232
235
  while (checkDepth) {
233
236
  --checkDepth;
234
- const firstSub = sub.subs;
235
- const hasMultipleSubs = firstSub.nextSub !== void 0;
236
- if (hasMultipleSubs) {
237
- link = stack.value;
238
- stack = stack.prev;
239
- } else link = firstSub;
237
+ link = stack.value;
238
+ stack = stack.prev;
240
239
  if (dirty) {
240
+ const subs = sub.subs;
241
241
  if (sub.update()) {
242
- if (hasMultipleSubs) shallowPropagate(firstSub);
242
+ if (subs.nextSub !== void 0) shallowPropagate(subs);
243
243
  sub = link.sub;
244
244
  continue;
245
245
  }
@@ -251,7 +251,7 @@ function checkDirty(link, sub) {
251
251
  }
252
252
  dirty = false;
253
253
  }
254
- return dirty;
254
+ return dirty && !!sub.flags;
255
255
  } while (true);
256
256
  }
257
257
  function shallowPropagate(link) {
@@ -286,9 +286,42 @@ var Dep = class {
286
286
  }
287
287
  set subs(value) {
288
288
  this._subs = value;
289
- if (value === void 0) this.map.delete(this.key);
289
+ if (value === void 0 && this.map) this.map.delete(this.key);
290
290
  }
291
291
  };
292
+ /**
293
+ * Tracks a dep its owner keys on its own, outside `targetMap`.
294
+ * @internal
295
+ */
296
+ function trackDep(dep, target = dep, key = "value") {
297
+ if (activeSub !== void 0) {
298
+ if (!!(process.env.NODE_ENV !== "production")) onTrack(activeSub, {
299
+ target,
300
+ type: "get",
301
+ key
302
+ });
303
+ link(dep, activeSub);
304
+ }
305
+ }
306
+ /**
307
+ * @internal
308
+ */
309
+ function triggerDep(dep, target = dep, key = "value", newValue, oldValue) {
310
+ const subs = dep.subs;
311
+ if (subs !== void 0) {
312
+ if (!!(process.env.NODE_ENV !== "production")) triggerEventInfos.push({
313
+ target,
314
+ type: "set",
315
+ key,
316
+ newValue,
317
+ oldValue
318
+ });
319
+ propagate(subs);
320
+ shallowPropagate(subs);
321
+ if (!batchDepth) flush();
322
+ if (!!(process.env.NODE_ENV !== "production")) triggerEventInfos.pop();
323
+ }
324
+ }
292
325
  const targetMap = /* @__PURE__ */ new WeakMap();
293
326
  const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
294
327
  const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
@@ -369,9 +402,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
369
402
  if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY));
370
403
  }
371
404
  break;
372
- case "set":
373
- if (isMap(target)) run(depsMap.get(ITERATE_KEY));
374
- break;
405
+ case "set": if (isMap(target)) run(depsMap.get(ITERATE_KEY));
375
406
  }
376
407
  }
377
408
  }
@@ -386,13 +417,17 @@ function getDepFromReactive(object, key) {
386
417
  /**
387
418
  * Track array iteration and return:
388
419
  * - if input is reactive: a cloned raw array with reactive values
389
- * - if input is non-reactive or shallowReactive: the original raw array
420
+ * - if input is readonly: a cloned raw array with readonly values, preserving
421
+ * reactivity
422
+ * - if input is raw or shallow: the original raw array
390
423
  */
391
424
  function reactiveReadArray(array) {
392
425
  const raw = /* @__PURE__ */ toRaw(array);
393
426
  if (raw === array) return raw;
394
427
  track(raw, "iterate", ARRAY_ITERATE_KEY);
395
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
428
+ if (/* @__PURE__ */ isShallow(array)) return raw;
429
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
430
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
396
431
  }
397
432
  /**
398
433
  * Track array iteration and return raw array
@@ -568,8 +603,8 @@ function noTracking(self, method, args = []) {
568
603
  }
569
604
  //#endregion
570
605
  //#region packages/reactivity/src/baseHandlers.ts
571
- const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
572
- const builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
606
+ const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
607
+ const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
573
608
  function hasOwnProperty(key) {
574
609
  if (!isSymbol(key)) key = String(key);
575
610
  const obj = /* @__PURE__ */ toRaw(this);
@@ -624,17 +659,19 @@ var MutableReactiveHandler = class extends BaseReactiveHandler {
624
659
  oldValue = /* @__PURE__ */ toRaw(oldValue);
625
660
  value = /* @__PURE__ */ toRaw(value);
626
661
  }
627
- if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) {
628
- if (!!(process.env.NODE_ENV !== "production")) warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
629
- return true;
630
- } else {
631
- oldValue.value = value;
632
- return true;
662
+ if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) {
663
+ if (isOldValueReadonly) {
664
+ if (!!(process.env.NODE_ENV !== "production")) warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
665
+ return true;
666
+ } else {
667
+ oldValue.value = value;
668
+ return true;
669
+ }
633
670
  }
634
671
  }
635
672
  const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
636
673
  const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
637
- if (target === /* @__PURE__ */ toRaw(receiver)) {
674
+ if (target === /* @__PURE__ */ toRaw(receiver) && result) {
638
675
  if (!hadKey) trigger(target, "add", key, value);
639
676
  else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
640
677
  }
@@ -670,10 +707,10 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
670
707
  return true;
671
708
  }
672
709
  };
673
- const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
674
- const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
675
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
676
- const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
710
+ const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
711
+ const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
712
+ const shallowReactiveHandlers = /*@__PURE__*/ new MutableReactiveHandler(true);
713
+ const shallowReadonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler(true);
677
714
  //#endregion
678
715
  //#region packages/reactivity/src/collectionHandlers.ts
679
716
  const toShallow = (value) => value;
@@ -824,10 +861,10 @@ function createInstrumentationGetter(isReadonly, shallow) {
824
861
  return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
825
862
  };
826
863
  }
827
- const mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) };
828
- const shallowCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, true) };
829
- const readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) };
830
- const shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) };
864
+ const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
865
+ const shallowCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, true) };
866
+ const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
867
+ const shallowReadonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, true) };
831
868
  function checkIdentityKeys(target, has, key) {
832
869
  const rawKey = /* @__PURE__ */ toRaw(key);
833
870
  if (rawKey !== key && has.call(target, rawKey)) {
@@ -852,10 +889,7 @@ function targetTypeMap(rawType) {
852
889
  default: return 0;
853
890
  }
854
891
  }
855
- function getTargetType(value) {
856
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
857
- }
858
- /* @__NO_SIDE_EFFECTS__ */
892
+ /*@__NO_SIDE_EFFECTS__*/
859
893
  function reactive(target) {
860
894
  if (/* @__PURE__ */ isReadonly(target)) return target;
861
895
  return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
@@ -890,7 +924,7 @@ function reactive(target) {
890
924
  * @param target - The source object.
891
925
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
892
926
  */
893
- /* @__NO_SIDE_EFFECTS__ */
927
+ /*@__NO_SIDE_EFFECTS__*/
894
928
  function shallowReactive(target) {
895
929
  return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
896
930
  }
@@ -923,7 +957,7 @@ function shallowReactive(target) {
923
957
  * @param target - The source object.
924
958
  * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
925
959
  */
926
- /* @__NO_SIDE_EFFECTS__ */
960
+ /*@__NO_SIDE_EFFECTS__*/
927
961
  function readonly(target) {
928
962
  return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
929
963
  }
@@ -957,7 +991,7 @@ function readonly(target) {
957
991
  * @param target - The source object.
958
992
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
959
993
  */
960
- /* @__NO_SIDE_EFFECTS__ */
994
+ /*@__NO_SIDE_EFFECTS__*/
961
995
  function shallowReadonly(target) {
962
996
  return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
963
997
  }
@@ -967,10 +1001,11 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
967
1001
  return target;
968
1002
  }
969
1003
  if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
970
- const targetType = getTargetType(target);
971
- if (targetType === 0) return target;
1004
+ if (target["__v_skip"] || !Object.isExtensible(target)) return target;
972
1005
  const existingProxy = proxyMap.get(target);
973
1006
  if (existingProxy) return existingProxy;
1007
+ const targetType = targetTypeMap(toRawType(target));
1008
+ if (targetType === 0) return target;
974
1009
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
975
1010
  proxyMap.set(target, proxy);
976
1011
  return proxy;
@@ -993,7 +1028,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
993
1028
  * @param value - The value to check.
994
1029
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
995
1030
  */
996
- /* @__NO_SIDE_EFFECTS__ */
1031
+ /*@__NO_SIDE_EFFECTS__*/
997
1032
  function isReactive(value) {
998
1033
  if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]);
999
1034
  return !!(value && value["__v_isReactive"]);
@@ -1009,11 +1044,11 @@ function isReactive(value) {
1009
1044
  * @param value - The value to check.
1010
1045
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
1011
1046
  */
1012
- /* @__NO_SIDE_EFFECTS__ */
1047
+ /*@__NO_SIDE_EFFECTS__*/
1013
1048
  function isReadonly(value) {
1014
1049
  return !!(value && value["__v_isReadonly"]);
1015
1050
  }
1016
- /* @__NO_SIDE_EFFECTS__ */
1051
+ /*@__NO_SIDE_EFFECTS__*/
1017
1052
  function isShallow(value) {
1018
1053
  return !!(value && value["__v_isShallow"]);
1019
1054
  }
@@ -1024,7 +1059,7 @@ function isShallow(value) {
1024
1059
  * @param value - The value to check.
1025
1060
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
1026
1061
  */
1027
- /* @__NO_SIDE_EFFECTS__ */
1062
+ /*@__NO_SIDE_EFFECTS__*/
1028
1063
  function isProxy(value) {
1029
1064
  return value ? !!value["__v_raw"] : false;
1030
1065
  }
@@ -1051,7 +1086,7 @@ function isProxy(value) {
1051
1086
  * @param observed - The object for which the "raw" value is requested.
1052
1087
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
1053
1088
  */
1054
- /* @__NO_SIDE_EFFECTS__ */
1089
+ /*@__NO_SIDE_EFFECTS__*/
1055
1090
  function toRaw(observed) {
1056
1091
  const raw = observed && observed["__v_raw"];
1057
1092
  return raw ? /* @__PURE__ */ toRaw(raw) : observed;
@@ -1100,15 +1135,15 @@ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value)
1100
1135
  const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1101
1136
  //#endregion
1102
1137
  //#region packages/reactivity/src/ref.ts
1103
- /* @__NO_SIDE_EFFECTS__ */
1138
+ /*@__NO_SIDE_EFFECTS__*/
1104
1139
  function isRef(r) {
1105
1140
  return r ? r["__v_isRef"] === true : false;
1106
1141
  }
1107
- /* @__NO_SIDE_EFFECTS__ */
1142
+ /*@__NO_SIDE_EFFECTS__*/
1108
1143
  function ref(value) {
1109
1144
  return createRef(value, toReactive);
1110
1145
  }
1111
- /* @__NO_SIDE_EFFECTS__ */
1146
+ /*@__NO_SIDE_EFFECTS__*/
1112
1147
  function shallowRef(value) {
1113
1148
  return createRef(value);
1114
1149
  }
@@ -1123,7 +1158,7 @@ var RefImpl = class {
1123
1158
  constructor(value, wrap) {
1124
1159
  this.subs = void 0;
1125
1160
  this.subsTail = void 0;
1126
- this.flags = ReactiveFlags$1.Mutable;
1161
+ this.flags = 1;
1127
1162
  this.__v_isRef = true;
1128
1163
  this.__v_isShallow = false;
1129
1164
  this._oldValue = this._rawValue = wrap ? /* @__PURE__ */ toRaw(value) : value;
@@ -1136,7 +1171,7 @@ var RefImpl = class {
1136
1171
  }
1137
1172
  get value() {
1138
1173
  trackRef(this);
1139
- if (this.flags & ReactiveFlags$1.Dirty && this.update()) {
1174
+ if (this.flags & 16 && this.update()) {
1140
1175
  const subs = this.subs;
1141
1176
  if (subs !== void 0) shallowPropagate(subs);
1142
1177
  }
@@ -1147,7 +1182,7 @@ var RefImpl = class {
1147
1182
  const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
1148
1183
  newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
1149
1184
  if (hasChanged(newValue, oldValue)) {
1150
- this.flags |= ReactiveFlags$1.Dirty;
1185
+ this.flags |= 16;
1151
1186
  this._rawValue = newValue;
1152
1187
  this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
1153
1188
  const subs = this.subs;
@@ -1166,7 +1201,7 @@ var RefImpl = class {
1166
1201
  }
1167
1202
  }
1168
1203
  update() {
1169
- this.flags &= ~ReactiveFlags$1.Dirty;
1204
+ this.flags &= -17;
1170
1205
  return hasChanged(this._oldValue, this._oldValue = this._rawValue);
1171
1206
  }
1172
1207
  };
@@ -1276,7 +1311,7 @@ var CustomRefImpl = class {
1276
1311
  constructor(factory) {
1277
1312
  this.subs = void 0;
1278
1313
  this.subsTail = void 0;
1279
- this.flags = ReactiveFlags$1.None;
1314
+ this.flags = 0;
1280
1315
  this["__v_isRef"] = true;
1281
1316
  this._value = void 0;
1282
1317
  const { get, set } = factory(() => trackRef(this), () => triggerRef(this));
@@ -1311,7 +1346,7 @@ function customRef(factory) {
1311
1346
  * @param object - Reactive object to be made into an object of linked refs.
1312
1347
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
1313
1348
  */
1314
- /* @__NO_SIDE_EFFECTS__ */
1349
+ /*@__NO_SIDE_EFFECTS__*/
1315
1350
  function toRefs(object) {
1316
1351
  const ret = isArray(object) ? new Array(object.length) : {};
1317
1352
  for (const key in object) ret[key] = propertyToRef(object, key);
@@ -1362,7 +1397,7 @@ var GetterRefImpl = class {
1362
1397
  return this._value = this._getter();
1363
1398
  }
1364
1399
  };
1365
- /* @__NO_SIDE_EFFECTS__ */
1400
+ /*@__NO_SIDE_EFFECTS__*/
1366
1401
  function toRef(source, key, defaultValue) {
1367
1402
  if (/* @__PURE__ */ isRef(source)) return source;
1368
1403
  else if (isFunction(source)) return new GetterRefImpl(source);
@@ -1411,9 +1446,11 @@ var ReactiveEffect = class {
1411
1446
  if (!this.active) return this.fn();
1412
1447
  cleanup(this);
1413
1448
  const prevSub = startTracking(this);
1449
+ incRunDepth();
1414
1450
  try {
1415
1451
  return this.fn();
1416
1452
  } finally {
1453
+ decRunDepth();
1417
1454
  endTracking(this, prevSub);
1418
1455
  const flags = this.flags;
1419
1456
  if ((flags & 136) === 136) {
@@ -1434,10 +1471,12 @@ var ReactiveEffect = class {
1434
1471
  get dirty() {
1435
1472
  const flags = this.flags;
1436
1473
  if (flags & 16) return true;
1437
- if (flags & 32) if (checkDirty(this.deps, this)) {
1438
- this.flags = flags | 16;
1439
- return true;
1440
- } else this.flags = flags & -33;
1474
+ if (flags & 32) {
1475
+ if (checkDirty(this.deps, this)) {
1476
+ this.flags = flags | 16;
1477
+ return true;
1478
+ } else this.flags = flags & -33;
1479
+ }
1441
1480
  return false;
1442
1481
  }
1443
1482
  };
@@ -1668,11 +1707,13 @@ var ComputedRefImpl = class {
1668
1707
  */
1669
1708
  get _dirty() {
1670
1709
  const flags = this.flags;
1671
- if (flags & ReactiveFlags$1.Dirty) return true;
1672
- if (flags & ReactiveFlags$1.Pending) if (checkDirty(this.deps, this)) {
1673
- this.flags = flags | ReactiveFlags$1.Dirty;
1674
- return true;
1675
- } else this.flags = flags & ~ReactiveFlags$1.Pending;
1710
+ if (flags & 16) return true;
1711
+ if (flags & 32) {
1712
+ if (checkDirty(this.deps, this)) {
1713
+ this.flags = flags | 16;
1714
+ return true;
1715
+ } else this.flags = flags & -33;
1716
+ }
1676
1717
  return false;
1677
1718
  }
1678
1719
  /**
@@ -1680,8 +1721,8 @@ var ComputedRefImpl = class {
1680
1721
  * for backwards compat
1681
1722
  */
1682
1723
  set _dirty(v) {
1683
- if (v) this.flags |= ReactiveFlags$1.Dirty;
1684
- else this.flags &= ~(ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending);
1724
+ if (v) this.flags |= 16;
1725
+ else this.flags &= -49;
1685
1726
  }
1686
1727
  constructor(fn, setter) {
1687
1728
  this.fn = fn;
@@ -1691,18 +1732,18 @@ var ComputedRefImpl = class {
1691
1732
  this.subsTail = void 0;
1692
1733
  this.deps = void 0;
1693
1734
  this.depsTail = void 0;
1694
- this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
1735
+ this.flags = 17;
1695
1736
  this.__v_isRef = true;
1696
1737
  this["__v_isReadonly"] = !setter;
1697
1738
  }
1698
1739
  get value() {
1699
1740
  const flags = this.flags;
1700
- if (flags & ReactiveFlags$1.Dirty || flags & ReactiveFlags$1.Pending && checkDirty(this.deps, this)) {
1741
+ if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
1701
1742
  if (this.update()) {
1702
1743
  const subs = this.subs;
1703
1744
  if (subs !== void 0) shallowPropagate(subs);
1704
1745
  }
1705
- } else if (flags & ReactiveFlags$1.Pending) this.flags = flags & ~ReactiveFlags$1.Pending;
1746
+ } else if (flags & 32) this.flags = flags & -33;
1706
1747
  if (activeSub !== void 0) {
1707
1748
  if (!!(process.env.NODE_ENV !== "production")) onTrack(activeSub, {
1708
1749
  target: this,
@@ -1733,7 +1774,7 @@ var ComputedRefImpl = class {
1733
1774
  }
1734
1775
  };
1735
1776
  if (!!(process.env.NODE_ENV !== "production")) setupOnTrigger(ComputedRefImpl);
1736
- /* @__NO_SIDE_EFFECTS__ */
1777
+ /*@__NO_SIDE_EFFECTS__*/
1737
1778
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1738
1779
  let getter;
1739
1780
  let setter;
@@ -1827,25 +1868,26 @@ var WatcherEffect = class extends ReactiveEffect {
1827
1868
  else if (isFunction(s)) return call ? call(s, 2) : s();
1828
1869
  else process.env.NODE_ENV !== "production" && warnInvalidSource(s, onWarn);
1829
1870
  });
1830
- } else if (isFunction(source)) if (cb) getter = call ? () => call(source, 2) : source;
1831
- else getter = () => {
1832
- if (this.cleanupsLength) {
1833
- const prevSub = setActiveSub();
1871
+ } else if (isFunction(source)) {
1872
+ if (cb) getter = call ? () => call(source, 2) : source;
1873
+ else getter = () => {
1874
+ if (this.cleanupsLength) {
1875
+ const prevSub = setActiveSub();
1876
+ try {
1877
+ cleanup(this);
1878
+ } finally {
1879
+ setActiveSub(prevSub);
1880
+ }
1881
+ }
1882
+ const currentEffect = activeWatcher;
1883
+ activeWatcher = this;
1834
1884
  try {
1835
- cleanup(this);
1885
+ return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
1836
1886
  } finally {
1837
- setActiveSub(prevSub);
1887
+ activeWatcher = currentEffect;
1838
1888
  }
1839
- }
1840
- const currentEffect = activeWatcher;
1841
- activeWatcher = this;
1842
- try {
1843
- return call ? call(source, 3, [this.boundCleanup]) : source(this.boundCleanup);
1844
- } finally {
1845
- activeWatcher = currentEffect;
1846
- }
1847
- };
1848
- else {
1889
+ };
1890
+ } else {
1849
1891
  getter = NOOP;
1850
1892
  process.env.NODE_ENV !== "production" && warnInvalidSource(source, onWarn);
1851
1893
  }
@@ -1863,8 +1905,9 @@ var WatcherEffect = class extends ReactiveEffect {
1863
1905
  if (once && cb) {
1864
1906
  const _cb = cb;
1865
1907
  cb = (...args) => {
1866
- _cb(...args);
1908
+ const res = _cb(...args);
1867
1909
  this.stop();
1910
+ return res;
1868
1911
  };
1869
1912
  }
1870
1913
  this.cb = cb;
@@ -1880,7 +1923,7 @@ var WatcherEffect = class extends ReactiveEffect {
1880
1923
  if (!this.cb) return;
1881
1924
  const { immediate, deep, call } = this.options;
1882
1925
  if (initialRun && !immediate) return;
1883
- if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1926
+ if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1884
1927
  cleanup(this);
1885
1928
  const currentWatcher = activeWatcher;
1886
1929
  activeWatcher = this;
@@ -1932,4 +1975,4 @@ function traverse(value, depth = Infinity, seen) {
1932
1975
  return value;
1933
1976
  }
1934
1977
  //#endregion
1935
- export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, WatcherEffect, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, setActiveSub, setCurrentScope, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, traverse, trigger, triggerRef, unref, watch };
1978
+ export { ARRAY_ITERATE_KEY, Dep, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, WatcherEffect, activeSub, computed, customRef, effect, effectScope, enableTracking, endBatch, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, setActiveSub, setCurrentScope, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, startBatch, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, trackDep, traverse, trigger, triggerDep, triggerRef, unref, watch };