@vue/reactivity 3.5.17 → 3.6.0-alpha.1

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.5.17
2
+ * @vue/reactivity v3.6.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -15,12 +15,6 @@ const EMPTY_OBJ = Object.freeze({}) ;
15
15
  const NOOP = () => {
16
16
  };
17
17
  const extend = Object.assign;
18
- const remove = (arr, el) => {
19
- const i = arr.indexOf(el);
20
- if (i > -1) {
21
- arr.splice(i, 1);
22
- }
23
- };
24
18
  const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
25
19
  const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
26
20
  const isArray = Array.isArray;
@@ -61,631 +55,344 @@ function warn(msg, ...args) {
61
55
  console.warn(`[Vue warn] ${msg}`, ...args);
62
56
  }
63
57
 
64
- let activeEffectScope;
65
- class EffectScope {
66
- constructor(detached = false) {
67
- this.detached = detached;
68
- /**
69
- * @internal
70
- */
71
- this._active = true;
72
- /**
73
- * @internal track `on` calls, allow `on` call multiple times
74
- */
75
- this._on = 0;
76
- /**
77
- * @internal
78
- */
79
- this.effects = [];
80
- /**
81
- * @internal
82
- */
83
- this.cleanups = [];
84
- this._isPaused = false;
85
- this.parent = activeEffectScope;
86
- if (!detached && activeEffectScope) {
87
- this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
88
- this
89
- ) - 1;
90
- }
91
- }
92
- get active() {
93
- return this._active;
94
- }
95
- pause() {
96
- if (this._active) {
97
- this._isPaused = true;
98
- let i, l;
99
- if (this.scopes) {
100
- for (i = 0, l = this.scopes.length; i < l; i++) {
101
- this.scopes[i].pause();
102
- }
103
- }
104
- for (i = 0, l = this.effects.length; i < l; i++) {
105
- this.effects[i].pause();
106
- }
107
- }
108
- }
109
- /**
110
- * Resumes the effect scope, including all child scopes and effects.
111
- */
112
- resume() {
113
- if (this._active) {
114
- if (this._isPaused) {
115
- this._isPaused = false;
116
- let i, l;
117
- if (this.scopes) {
118
- for (i = 0, l = this.scopes.length; i < l; i++) {
119
- this.scopes[i].resume();
120
- }
121
- }
122
- for (i = 0, l = this.effects.length; i < l; i++) {
123
- this.effects[i].resume();
124
- }
125
- }
126
- }
127
- }
128
- run(fn) {
129
- if (this._active) {
130
- const currentEffectScope = activeEffectScope;
131
- try {
132
- activeEffectScope = this;
133
- return fn();
134
- } finally {
135
- activeEffectScope = currentEffectScope;
136
- }
137
- } else {
138
- warn(`cannot run an inactive effect scope.`);
139
- }
140
- }
141
- /**
142
- * This should only be called on non-detached scopes
143
- * @internal
144
- */
145
- on() {
146
- if (++this._on === 1) {
147
- this.prevScope = activeEffectScope;
148
- activeEffectScope = this;
149
- }
150
- }
151
- /**
152
- * This should only be called on non-detached scopes
153
- * @internal
154
- */
155
- off() {
156
- if (this._on > 0 && --this._on === 0) {
157
- activeEffectScope = this.prevScope;
158
- this.prevScope = void 0;
159
- }
160
- }
161
- stop(fromParent) {
162
- if (this._active) {
163
- this._active = false;
164
- let i, l;
165
- for (i = 0, l = this.effects.length; i < l; i++) {
166
- this.effects[i].stop();
167
- }
168
- this.effects.length = 0;
169
- for (i = 0, l = this.cleanups.length; i < l; i++) {
170
- this.cleanups[i]();
171
- }
172
- this.cleanups.length = 0;
173
- if (this.scopes) {
174
- for (i = 0, l = this.scopes.length; i < l; i++) {
175
- this.scopes[i].stop(true);
176
- }
177
- this.scopes.length = 0;
178
- }
179
- if (!this.detached && this.parent && !fromParent) {
180
- const last = this.parent.scopes.pop();
181
- if (last && last !== this) {
182
- this.parent.scopes[this.index] = last;
183
- last.index = this.index;
184
- }
185
- }
186
- this.parent = void 0;
187
- }
188
- }
189
- }
190
- function effectScope(detached) {
191
- return new EffectScope(detached);
192
- }
193
- function getCurrentScope() {
194
- return activeEffectScope;
195
- }
196
- function onScopeDispose(fn, failSilently = false) {
197
- if (activeEffectScope) {
198
- activeEffectScope.cleanups.push(fn);
199
- } else if (!failSilently) {
200
- warn(
201
- `onScopeDispose() is called when there is no active effect scope to be associated with.`
202
- );
203
- }
204
- }
205
-
206
- let activeSub;
207
- const EffectFlags = {
208
- "ACTIVE": 1,
209
- "1": "ACTIVE",
210
- "RUNNING": 2,
211
- "2": "RUNNING",
212
- "TRACKING": 4,
213
- "4": "TRACKING",
214
- "NOTIFIED": 8,
215
- "8": "NOTIFIED",
216
- "DIRTY": 16,
217
- "16": "DIRTY",
218
- "ALLOW_RECURSE": 32,
219
- "32": "ALLOW_RECURSE",
220
- "PAUSED": 64,
221
- "64": "PAUSED",
222
- "EVALUATED": 128,
223
- "128": "EVALUATED"
224
- };
225
- const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
226
- class ReactiveEffect {
227
- constructor(fn) {
228
- this.fn = fn;
229
- /**
230
- * @internal
231
- */
232
- this.deps = void 0;
233
- /**
234
- * @internal
235
- */
236
- this.depsTail = void 0;
237
- /**
238
- * @internal
239
- */
240
- this.flags = 1 | 4;
241
- /**
242
- * @internal
243
- */
244
- this.next = void 0;
245
- /**
246
- * @internal
247
- */
248
- this.cleanup = void 0;
249
- this.scheduler = void 0;
250
- if (activeEffectScope && activeEffectScope.active) {
251
- activeEffectScope.effects.push(this);
252
- }
253
- }
254
- pause() {
255
- this.flags |= 64;
256
- }
257
- resume() {
258
- if (this.flags & 64) {
259
- this.flags &= -65;
260
- if (pausedQueueEffects.has(this)) {
261
- pausedQueueEffects.delete(this);
262
- this.trigger();
263
- }
264
- }
265
- }
266
- /**
267
- * @internal
268
- */
269
- notify() {
270
- if (this.flags & 2 && !(this.flags & 32)) {
271
- return;
272
- }
273
- if (!(this.flags & 8)) {
274
- batch(this);
275
- }
276
- }
277
- run() {
278
- if (!(this.flags & 1)) {
279
- return this.fn();
280
- }
281
- this.flags |= 2;
282
- cleanupEffect(this);
283
- prepareDeps(this);
284
- const prevEffect = activeSub;
285
- const prevShouldTrack = shouldTrack;
286
- activeSub = this;
287
- shouldTrack = true;
288
- try {
289
- return this.fn();
290
- } finally {
291
- if (activeSub !== this) {
292
- warn(
293
- "Active effect was not restored correctly - this is likely a Vue internal bug."
294
- );
295
- }
296
- cleanupDeps(this);
297
- activeSub = prevEffect;
298
- shouldTrack = prevShouldTrack;
299
- this.flags &= -3;
300
- }
301
- }
302
- stop() {
303
- if (this.flags & 1) {
304
- for (let link = this.deps; link; link = link.nextDep) {
305
- removeSub(link);
306
- }
307
- this.deps = this.depsTail = void 0;
308
- cleanupEffect(this);
309
- this.onStop && this.onStop();
310
- this.flags &= -2;
311
- }
312
- }
313
- trigger() {
314
- if (this.flags & 64) {
315
- pausedQueueEffects.add(this);
316
- } else if (this.scheduler) {
317
- this.scheduler();
318
- } else {
319
- this.runIfDirty();
320
- }
321
- }
322
- /**
323
- * @internal
324
- */
325
- runIfDirty() {
326
- if (isDirty(this)) {
327
- this.run();
328
- }
329
- }
330
- get dirty() {
331
- return isDirty(this);
332
- }
333
- }
58
+ var ReactiveFlags$1 = /* @__PURE__ */ ((ReactiveFlags2) => {
59
+ ReactiveFlags2[ReactiveFlags2["None"] = 0] = "None";
60
+ ReactiveFlags2[ReactiveFlags2["Mutable"] = 1] = "Mutable";
61
+ ReactiveFlags2[ReactiveFlags2["Watching"] = 2] = "Watching";
62
+ ReactiveFlags2[ReactiveFlags2["RecursedCheck"] = 4] = "RecursedCheck";
63
+ ReactiveFlags2[ReactiveFlags2["Recursed"] = 8] = "Recursed";
64
+ ReactiveFlags2[ReactiveFlags2["Dirty"] = 16] = "Dirty";
65
+ ReactiveFlags2[ReactiveFlags2["Pending"] = 32] = "Pending";
66
+ return ReactiveFlags2;
67
+ })(ReactiveFlags$1 || {});
68
+ const notifyBuffer = [];
334
69
  let batchDepth = 0;
335
- let batchedSub;
336
- let batchedComputed;
337
- function batch(sub, isComputed = false) {
338
- sub.flags |= 8;
339
- if (isComputed) {
340
- sub.next = batchedComputed;
341
- batchedComputed = sub;
342
- return;
70
+ let activeSub = void 0;
71
+ let notifyIndex = 0;
72
+ let notifyBufferLength = 0;
73
+ function setActiveSub(sub) {
74
+ try {
75
+ return activeSub;
76
+ } finally {
77
+ activeSub = sub;
343
78
  }
344
- sub.next = batchedSub;
345
- batchedSub = sub;
346
79
  }
347
80
  function startBatch() {
348
- batchDepth++;
81
+ ++batchDepth;
349
82
  }
350
83
  function endBatch() {
351
- if (--batchDepth > 0) {
352
- return;
353
- }
354
- if (batchedComputed) {
355
- let e = batchedComputed;
356
- batchedComputed = void 0;
357
- while (e) {
358
- const next = e.next;
359
- e.next = void 0;
360
- e.flags &= -9;
361
- e = next;
362
- }
363
- }
364
- let error;
365
- while (batchedSub) {
366
- let e = batchedSub;
367
- batchedSub = void 0;
368
- while (e) {
369
- const next = e.next;
370
- e.next = void 0;
371
- e.flags &= -9;
372
- if (e.flags & 1) {
373
- try {
374
- ;
375
- e.trigger();
376
- } catch (err) {
377
- if (!error) error = err;
378
- }
379
- }
380
- e = next;
381
- }
382
- }
383
- if (error) throw error;
384
- }
385
- function prepareDeps(sub) {
386
- for (let link = sub.deps; link; link = link.nextDep) {
387
- link.version = -1;
388
- link.prevActiveLink = link.dep.activeLink;
389
- link.dep.activeLink = link;
84
+ if (!--batchDepth && notifyBufferLength) {
85
+ flush();
390
86
  }
391
87
  }
392
- function cleanupDeps(sub) {
393
- let head;
394
- let tail = sub.depsTail;
395
- let link = tail;
396
- while (link) {
397
- const prev = link.prevDep;
398
- if (link.version === -1) {
399
- if (link === tail) tail = prev;
400
- removeSub(link);
401
- removeDep(link);
402
- } else {
403
- head = link;
404
- }
405
- link.dep.activeLink = link.prevActiveLink;
406
- link.prevActiveLink = void 0;
407
- link = prev;
88
+ function link(dep, sub) {
89
+ const prevDep = sub.depsTail;
90
+ if (prevDep !== void 0 && prevDep.dep === dep) {
91
+ return;
408
92
  }
409
- sub.deps = head;
410
- sub.depsTail = tail;
411
- }
412
- function isDirty(sub) {
413
- for (let link = sub.deps; link; link = link.nextDep) {
414
- if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
415
- return true;
93
+ let nextDep = void 0;
94
+ const recursedCheck = sub.flags & 4 /* RecursedCheck */;
95
+ if (recursedCheck) {
96
+ nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
97
+ if (nextDep !== void 0 && nextDep.dep === dep) {
98
+ sub.depsTail = nextDep;
99
+ return;
416
100
  }
417
101
  }
418
- if (sub._dirty) {
419
- return true;
420
- }
421
- return false;
422
- }
423
- function refreshComputed(computed) {
424
- if (computed.flags & 4 && !(computed.flags & 16)) {
102
+ const prevSub = dep.subsTail;
103
+ if (prevSub !== void 0 && prevSub.sub === sub && (!recursedCheck || isValidLink(prevSub, sub))) {
425
104
  return;
426
105
  }
427
- computed.flags &= -17;
428
- if (computed.globalVersion === globalVersion) {
429
- return;
106
+ const newLink = sub.depsTail = dep.subsTail = {
107
+ dep,
108
+ sub,
109
+ prevDep,
110
+ nextDep,
111
+ prevSub,
112
+ nextSub: void 0
113
+ };
114
+ if (nextDep !== void 0) {
115
+ nextDep.prevDep = newLink;
430
116
  }
431
- computed.globalVersion = globalVersion;
432
- if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) {
433
- return;
117
+ if (prevDep !== void 0) {
118
+ prevDep.nextDep = newLink;
119
+ } else {
120
+ sub.deps = newLink;
434
121
  }
435
- computed.flags |= 2;
436
- const dep = computed.dep;
437
- const prevSub = activeSub;
438
- const prevShouldTrack = shouldTrack;
439
- activeSub = computed;
440
- shouldTrack = true;
441
- try {
442
- prepareDeps(computed);
443
- const value = computed.fn(computed._value);
444
- if (dep.version === 0 || hasChanged(value, computed._value)) {
445
- computed.flags |= 128;
446
- computed._value = value;
447
- dep.version++;
448
- }
449
- } catch (err) {
450
- dep.version++;
451
- throw err;
452
- } finally {
453
- activeSub = prevSub;
454
- shouldTrack = prevShouldTrack;
455
- cleanupDeps(computed);
456
- computed.flags &= -3;
122
+ if (prevSub !== void 0) {
123
+ prevSub.nextSub = newLink;
124
+ } else {
125
+ dep.subs = newLink;
457
126
  }
458
127
  }
459
- function removeSub(link, soft = false) {
460
- const { dep, prevSub, nextSub } = link;
461
- if (prevSub) {
462
- prevSub.nextSub = nextSub;
463
- link.prevSub = void 0;
128
+ function unlink(link2, sub = link2.sub) {
129
+ const dep = link2.dep;
130
+ const prevDep = link2.prevDep;
131
+ const nextDep = link2.nextDep;
132
+ const nextSub = link2.nextSub;
133
+ const prevSub = link2.prevSub;
134
+ if (nextDep !== void 0) {
135
+ nextDep.prevDep = prevDep;
136
+ } else {
137
+ sub.depsTail = prevDep;
464
138
  }
465
- if (nextSub) {
466
- nextSub.prevSub = prevSub;
467
- link.nextSub = void 0;
139
+ if (prevDep !== void 0) {
140
+ prevDep.nextDep = nextDep;
141
+ } else {
142
+ sub.deps = nextDep;
468
143
  }
469
- if (dep.subsHead === link) {
470
- dep.subsHead = nextSub;
144
+ if (nextSub !== void 0) {
145
+ nextSub.prevSub = prevSub;
146
+ } else {
147
+ dep.subsTail = prevSub;
471
148
  }
472
- if (dep.subs === link) {
473
- dep.subs = prevSub;
474
- if (!prevSub && dep.computed) {
475
- dep.computed.flags &= -5;
476
- for (let l = dep.computed.deps; l; l = l.nextDep) {
477
- removeSub(l, true);
149
+ if (prevSub !== void 0) {
150
+ prevSub.nextSub = nextSub;
151
+ } else if ((dep.subs = nextSub) === void 0) {
152
+ let toRemove = dep.deps;
153
+ if (toRemove !== void 0) {
154
+ do {
155
+ toRemove = unlink(toRemove, dep);
156
+ } while (toRemove !== void 0);
157
+ dep.flags |= 16 /* Dirty */;
158
+ }
159
+ }
160
+ return nextDep;
161
+ }
162
+ function propagate(link2) {
163
+ let next = link2.nextSub;
164
+ let stack;
165
+ top: do {
166
+ const sub = link2.sub;
167
+ let flags = sub.flags;
168
+ if (flags & (1 /* Mutable */ | 2 /* Watching */)) {
169
+ if (!(flags & (4 /* RecursedCheck */ | 8 /* Recursed */ | 16 /* Dirty */ | 32 /* Pending */))) {
170
+ sub.flags = flags | 32 /* Pending */;
171
+ } else if (!(flags & (4 /* RecursedCheck */ | 8 /* Recursed */))) {
172
+ flags = 0 /* None */;
173
+ } else if (!(flags & 4 /* RecursedCheck */)) {
174
+ sub.flags = flags & -9 /* Recursed */ | 32 /* Pending */;
175
+ } else if (!(flags & (16 /* Dirty */ | 32 /* Pending */)) && isValidLink(link2, sub)) {
176
+ sub.flags = flags | 8 /* Recursed */ | 32 /* Pending */;
177
+ flags &= 1 /* Mutable */;
178
+ } else {
179
+ flags = 0 /* None */;
180
+ }
181
+ if (flags & 2 /* Watching */) {
182
+ notifyBuffer[notifyBufferLength++] = sub;
183
+ }
184
+ if (flags & 1 /* Mutable */) {
185
+ const subSubs = sub.subs;
186
+ if (subSubs !== void 0) {
187
+ link2 = subSubs;
188
+ if (subSubs.nextSub !== void 0) {
189
+ stack = { value: next, prev: stack };
190
+ next = link2.nextSub;
191
+ }
192
+ continue;
193
+ }
478
194
  }
479
195
  }
480
- }
481
- if (!soft && !--dep.sc && dep.map) {
482
- dep.map.delete(dep.key);
483
- }
484
- }
485
- function removeDep(link) {
486
- const { prevDep, nextDep } = link;
487
- if (prevDep) {
488
- prevDep.nextDep = nextDep;
489
- link.prevDep = void 0;
490
- }
491
- if (nextDep) {
492
- nextDep.prevDep = prevDep;
493
- link.nextDep = void 0;
494
- }
495
- }
496
- function effect(fn, options) {
497
- if (fn.effect instanceof ReactiveEffect) {
498
- fn = fn.effect.fn;
499
- }
500
- const e = new ReactiveEffect(fn);
501
- if (options) {
502
- extend(e, options);
503
- }
504
- try {
505
- e.run();
506
- } catch (err) {
507
- e.stop();
508
- throw err;
509
- }
510
- const runner = e.run.bind(e);
511
- runner.effect = e;
512
- return runner;
513
- }
514
- function stop(runner) {
515
- runner.effect.stop();
516
- }
517
- let shouldTrack = true;
518
- const trackStack = [];
519
- function pauseTracking() {
520
- trackStack.push(shouldTrack);
521
- shouldTrack = false;
522
- }
523
- function enableTracking() {
524
- trackStack.push(shouldTrack);
525
- shouldTrack = true;
196
+ if ((link2 = next) !== void 0) {
197
+ next = link2.nextSub;
198
+ continue;
199
+ }
200
+ while (stack !== void 0) {
201
+ link2 = stack.value;
202
+ stack = stack.prev;
203
+ if (link2 !== void 0) {
204
+ next = link2.nextSub;
205
+ continue top;
206
+ }
207
+ }
208
+ break;
209
+ } while (true);
526
210
  }
527
- function resetTracking() {
528
- const last = trackStack.pop();
529
- shouldTrack = last === void 0 ? true : last;
211
+ function startTracking(sub) {
212
+ sub.depsTail = void 0;
213
+ sub.flags = sub.flags & -57 | 4 /* RecursedCheck */;
214
+ return setActiveSub(sub);
530
215
  }
531
- function onEffectCleanup(fn, failSilently = false) {
532
- if (activeSub instanceof ReactiveEffect) {
533
- activeSub.cleanup = fn;
534
- } else if (!failSilently) {
216
+ function endTracking(sub, prevSub) {
217
+ if (activeSub !== sub) {
535
218
  warn(
536
- `onEffectCleanup() was called when there was no active effect to associate with.`
219
+ "Active effect was not restored correctly - this is likely a Vue internal bug."
537
220
  );
538
221
  }
539
- }
540
- function cleanupEffect(e) {
541
- const { cleanup } = e;
542
- e.cleanup = void 0;
543
- if (cleanup) {
544
- const prevSub = activeSub;
545
- activeSub = void 0;
546
- try {
547
- cleanup();
548
- } finally {
549
- activeSub = prevSub;
550
- }
222
+ activeSub = prevSub;
223
+ const depsTail = sub.depsTail;
224
+ let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
225
+ while (toRemove !== void 0) {
226
+ toRemove = unlink(toRemove, sub);
227
+ }
228
+ sub.flags &= -5 /* RecursedCheck */;
229
+ }
230
+ function flush() {
231
+ while (notifyIndex < notifyBufferLength) {
232
+ const effect = notifyBuffer[notifyIndex];
233
+ notifyBuffer[notifyIndex++] = void 0;
234
+ effect.notify();
235
+ }
236
+ notifyIndex = 0;
237
+ notifyBufferLength = 0;
238
+ }
239
+ function checkDirty(link2, sub) {
240
+ let stack;
241
+ let checkDepth = 0;
242
+ top: do {
243
+ const dep = link2.dep;
244
+ const depFlags = dep.flags;
245
+ let dirty = false;
246
+ if (sub.flags & 16 /* Dirty */) {
247
+ dirty = true;
248
+ } else if ((depFlags & (1 /* Mutable */ | 16 /* Dirty */)) === (1 /* Mutable */ | 16 /* Dirty */)) {
249
+ if (dep.update()) {
250
+ const subs = dep.subs;
251
+ if (subs.nextSub !== void 0) {
252
+ shallowPropagate(subs);
253
+ }
254
+ dirty = true;
255
+ }
256
+ } else if ((depFlags & (1 /* Mutable */ | 32 /* Pending */)) === (1 /* Mutable */ | 32 /* Pending */)) {
257
+ if (link2.nextSub !== void 0 || link2.prevSub !== void 0) {
258
+ stack = { value: link2, prev: stack };
259
+ }
260
+ link2 = dep.deps;
261
+ sub = dep;
262
+ ++checkDepth;
263
+ continue;
264
+ }
265
+ if (!dirty && link2.nextDep !== void 0) {
266
+ link2 = link2.nextDep;
267
+ continue;
268
+ }
269
+ while (checkDepth) {
270
+ --checkDepth;
271
+ const firstSub = sub.subs;
272
+ const hasMultipleSubs = firstSub.nextSub !== void 0;
273
+ if (hasMultipleSubs) {
274
+ link2 = stack.value;
275
+ stack = stack.prev;
276
+ } else {
277
+ link2 = firstSub;
278
+ }
279
+ if (dirty) {
280
+ if (sub.update()) {
281
+ if (hasMultipleSubs) {
282
+ shallowPropagate(firstSub);
283
+ }
284
+ sub = link2.sub;
285
+ continue;
286
+ }
287
+ } else {
288
+ sub.flags &= -33 /* Pending */;
289
+ }
290
+ sub = link2.sub;
291
+ if (link2.nextDep !== void 0) {
292
+ link2 = link2.nextDep;
293
+ continue top;
294
+ }
295
+ dirty = false;
296
+ }
297
+ return dirty;
298
+ } while (true);
299
+ }
300
+ function shallowPropagate(link2) {
301
+ do {
302
+ const sub = link2.sub;
303
+ const nextSub = link2.nextSub;
304
+ const subFlags = sub.flags;
305
+ if ((subFlags & (32 /* Pending */ | 16 /* Dirty */)) === 32 /* Pending */) {
306
+ sub.flags = subFlags | 16 /* Dirty */;
307
+ }
308
+ link2 = nextSub;
309
+ } while (link2 !== void 0);
310
+ }
311
+ function isValidLink(checkLink, sub) {
312
+ const depsTail = sub.depsTail;
313
+ if (depsTail !== void 0) {
314
+ let link2 = sub.deps;
315
+ do {
316
+ if (link2 === checkLink) {
317
+ return true;
318
+ }
319
+ if (link2 === depsTail) {
320
+ break;
321
+ }
322
+ link2 = link2.nextDep;
323
+ } while (link2 !== void 0);
551
324
  }
325
+ return false;
552
326
  }
553
327
 
554
- let globalVersion = 0;
555
- class Link {
556
- constructor(sub, dep) {
557
- this.sub = sub;
558
- this.dep = dep;
559
- this.version = dep.version;
560
- this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
328
+ const triggerEventInfos = [];
329
+ function onTrack(sub, debugInfo) {
330
+ if (sub.onTrack) {
331
+ sub.onTrack(
332
+ extend(
333
+ {
334
+ effect: sub
335
+ },
336
+ debugInfo
337
+ )
338
+ );
561
339
  }
562
340
  }
563
- class Dep {
564
- // TODO isolatedDeclarations "__v_skip"
565
- constructor(computed) {
566
- this.computed = computed;
567
- this.version = 0;
568
- /**
569
- * Link between this dep and the current active effect
570
- */
571
- this.activeLink = void 0;
572
- /**
573
- * Doubly linked list representing the subscribing effects (tail)
574
- */
575
- this.subs = void 0;
576
- /**
577
- * For object property deps cleanup
578
- */
579
- this.map = void 0;
580
- this.key = void 0;
581
- /**
582
- * Subscriber counter
583
- */
584
- this.sc = 0;
585
- /**
586
- * @internal
587
- */
588
- this.__v_skip = true;
589
- {
590
- this.subsHead = void 0;
591
- }
341
+ function onTrigger(sub) {
342
+ if (sub.onTrigger) {
343
+ const debugInfo = triggerEventInfos[triggerEventInfos.length - 1];
344
+ sub.onTrigger(
345
+ extend(
346
+ {
347
+ effect: sub
348
+ },
349
+ debugInfo
350
+ )
351
+ );
592
352
  }
593
- track(debugInfo) {
594
- if (!activeSub || !shouldTrack || activeSub === this.computed) {
595
- return;
353
+ }
354
+ function setupOnTrigger(target) {
355
+ Object.defineProperty(target.prototype, "onTrigger", {
356
+ get() {
357
+ return this._onTrigger;
358
+ },
359
+ set(val) {
360
+ if (val && !this._onTrigger) setupFlagsHandler(this);
361
+ this._onTrigger = val;
596
362
  }
597
- let link = this.activeLink;
598
- if (link === void 0 || link.sub !== activeSub) {
599
- link = this.activeLink = new Link(activeSub, this);
600
- if (!activeSub.deps) {
601
- activeSub.deps = activeSub.depsTail = link;
602
- } else {
603
- link.prevDep = activeSub.depsTail;
604
- activeSub.depsTail.nextDep = link;
605
- activeSub.depsTail = link;
606
- }
607
- addSub(link);
608
- } else if (link.version === -1) {
609
- link.version = this.version;
610
- if (link.nextDep) {
611
- const next = link.nextDep;
612
- next.prevDep = link.prevDep;
613
- if (link.prevDep) {
614
- link.prevDep.nextDep = next;
615
- }
616
- link.prevDep = activeSub.depsTail;
617
- link.nextDep = void 0;
618
- activeSub.depsTail.nextDep = link;
619
- activeSub.depsTail = link;
620
- if (activeSub.deps === link) {
621
- activeSub.deps = next;
622
- }
363
+ });
364
+ }
365
+ function setupFlagsHandler(target) {
366
+ target._flags = target.flags;
367
+ Object.defineProperty(target, "flags", {
368
+ get() {
369
+ return target._flags;
370
+ },
371
+ set(value) {
372
+ if (!(target._flags & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending)) && !!(value & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending))) {
373
+ onTrigger(this);
623
374
  }
375
+ target._flags = value;
624
376
  }
625
- if (activeSub.onTrack) {
626
- activeSub.onTrack(
627
- extend(
628
- {
629
- effect: activeSub
630
- },
631
- debugInfo
632
- )
633
- );
634
- }
635
- return link;
636
- }
637
- trigger(debugInfo) {
638
- this.version++;
639
- globalVersion++;
640
- this.notify(debugInfo);
377
+ });
378
+ }
379
+
380
+ class Dep {
381
+ constructor(map, key) {
382
+ this.map = map;
383
+ this.key = key;
384
+ this._subs = void 0;
385
+ this.subsTail = void 0;
386
+ this.flags = ReactiveFlags$1.None;
641
387
  }
642
- notify(debugInfo) {
643
- startBatch();
644
- try {
645
- if (true) {
646
- for (let head = this.subsHead; head; head = head.nextSub) {
647
- if (head.sub.onTrigger && !(head.sub.flags & 8)) {
648
- head.sub.onTrigger(
649
- extend(
650
- {
651
- effect: head.sub
652
- },
653
- debugInfo
654
- )
655
- );
656
- }
657
- }
658
- }
659
- for (let link = this.subs; link; link = link.prevSub) {
660
- if (link.sub.notify()) {
661
- ;
662
- link.sub.dep.notify();
663
- }
664
- }
665
- } finally {
666
- endBatch();
667
- }
388
+ get subs() {
389
+ return this._subs;
668
390
  }
669
- }
670
- function addSub(link) {
671
- link.dep.sc++;
672
- if (link.sub.flags & 4) {
673
- const computed = link.dep.computed;
674
- if (computed && !link.dep.subs) {
675
- computed.flags |= 4 | 16;
676
- for (let l = computed.deps; l; l = l.nextDep) {
677
- addSub(l);
678
- }
679
- }
680
- const currentTail = link.dep.subs;
681
- if (currentTail !== link) {
682
- link.prevSub = currentTail;
683
- if (currentTail) currentTail.nextSub = link;
684
- }
685
- if (link.dep.subsHead === void 0) {
686
- link.dep.subsHead = link;
391
+ set subs(value) {
392
+ this._subs = value;
393
+ if (value === void 0) {
394
+ this.map.delete(this.key);
687
395
  }
688
- link.dep.subs = link;
689
396
  }
690
397
  }
691
398
  const targetMap = /* @__PURE__ */ new WeakMap();
@@ -699,36 +406,34 @@ const ARRAY_ITERATE_KEY = Symbol(
699
406
  "Array iterate"
700
407
  );
701
408
  function track(target, type, key) {
702
- if (shouldTrack && activeSub) {
409
+ if (activeSub !== void 0) {
703
410
  let depsMap = targetMap.get(target);
704
411
  if (!depsMap) {
705
412
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
706
413
  }
707
414
  let dep = depsMap.get(key);
708
415
  if (!dep) {
709
- depsMap.set(key, dep = new Dep());
710
- dep.map = depsMap;
711
- dep.key = key;
416
+ depsMap.set(key, dep = new Dep(depsMap, key));
712
417
  }
713
418
  {
714
- dep.track({
419
+ onTrack(activeSub, {
715
420
  target,
716
421
  type,
717
422
  key
718
423
  });
719
424
  }
425
+ link(dep, activeSub);
720
426
  }
721
427
  }
722
428
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
723
429
  const depsMap = targetMap.get(target);
724
430
  if (!depsMap) {
725
- globalVersion++;
726
431
  return;
727
432
  }
728
433
  const run = (dep) => {
729
- if (dep) {
434
+ if (dep !== void 0 && dep.subs !== void 0) {
730
435
  {
731
- dep.trigger({
436
+ triggerEventInfos.push({
732
437
  target,
733
438
  type,
734
439
  key,
@@ -737,6 +442,11 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
737
442
  oldTarget
738
443
  });
739
444
  }
445
+ propagate(dep.subs);
446
+ shallowPropagate(dep.subs);
447
+ {
448
+ triggerEventInfos.pop();
449
+ }
740
450
  }
741
451
  };
742
452
  startBatch();
@@ -961,11 +671,11 @@ function searchProxy(self, method, args) {
961
671
  return res;
962
672
  }
963
673
  function noTracking(self, method, args = []) {
964
- pauseTracking();
965
674
  startBatch();
675
+ const prevSub = setActiveSub();
966
676
  const res = toRaw(self)[method].apply(self, args);
677
+ setActiveSub(prevSub);
967
678
  endBatch();
968
- resetTracking();
969
679
  return res;
970
680
  }
971
681
 
@@ -1011,14 +721,18 @@ class BaseReactiveHandler {
1011
721
  return hasOwnProperty;
1012
722
  }
1013
723
  }
724
+ const wasRef = isRef(target);
1014
725
  const res = Reflect.get(
1015
726
  target,
1016
727
  key,
1017
728
  // if this is a proxy wrapping a ref, return methods using the raw ref
1018
729
  // as receiver so that we don't have to call `toRaw` on the ref in all
1019
730
  // its class methods
1020
- isRef(target) ? target : receiver
731
+ wasRef ? target : receiver
1021
732
  );
733
+ if (wasRef && key !== "value") {
734
+ return res;
735
+ }
1022
736
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
1023
737
  return res;
1024
738
  }
@@ -1470,33 +1184,47 @@ function isRef(r) {
1470
1184
  return r ? r["__v_isRef"] === true : false;
1471
1185
  }
1472
1186
  function ref(value) {
1473
- return createRef(value, false);
1187
+ return createRef(value, toReactive);
1474
1188
  }
1475
1189
  function shallowRef(value) {
1476
- return createRef(value, true);
1190
+ return createRef(value);
1477
1191
  }
1478
- function createRef(rawValue, shallow) {
1192
+ function createRef(rawValue, wrap) {
1479
1193
  if (isRef(rawValue)) {
1480
1194
  return rawValue;
1481
1195
  }
1482
- return new RefImpl(rawValue, shallow);
1196
+ return new RefImpl(rawValue, wrap);
1483
1197
  }
1484
1198
  class RefImpl {
1485
- constructor(value, isShallow2) {
1486
- this.dep = new Dep();
1487
- this["__v_isRef"] = true;
1488
- this["__v_isShallow"] = false;
1489
- this._rawValue = isShallow2 ? value : toRaw(value);
1490
- this._value = isShallow2 ? value : toReactive(value);
1491
- this["__v_isShallow"] = isShallow2;
1199
+ // TODO isolatedDeclarations "__v_isShallow"
1200
+ constructor(value, wrap) {
1201
+ this.subs = void 0;
1202
+ this.subsTail = void 0;
1203
+ this.flags = ReactiveFlags$1.Mutable;
1204
+ /**
1205
+ * @internal
1206
+ */
1207
+ this.__v_isRef = true;
1208
+ // TODO isolatedDeclarations "__v_isRef"
1209
+ /**
1210
+ * @internal
1211
+ */
1212
+ this.__v_isShallow = false;
1213
+ this._oldValue = this._rawValue = wrap ? toRaw(value) : value;
1214
+ this._value = wrap ? wrap(value) : value;
1215
+ this._wrap = wrap;
1216
+ this["__v_isShallow"] = !wrap;
1217
+ }
1218
+ get dep() {
1219
+ return this;
1492
1220
  }
1493
1221
  get value() {
1494
- {
1495
- this.dep.track({
1496
- target: this,
1497
- type: "get",
1498
- key: "value"
1499
- });
1222
+ trackRef(this);
1223
+ if (this.flags & ReactiveFlags$1.Dirty && this.update()) {
1224
+ const subs = this.subs;
1225
+ if (subs !== void 0) {
1226
+ shallowPropagate(subs);
1227
+ }
1500
1228
  }
1501
1229
  return this._value;
1502
1230
  }
@@ -1505,191 +1233,541 @@ class RefImpl {
1505
1233
  const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
1506
1234
  newValue = useDirectValue ? newValue : toRaw(newValue);
1507
1235
  if (hasChanged(newValue, oldValue)) {
1236
+ this.flags |= ReactiveFlags$1.Dirty;
1508
1237
  this._rawValue = newValue;
1509
- this._value = useDirectValue ? newValue : toReactive(newValue);
1510
- {
1511
- this.dep.trigger({
1512
- target: this,
1513
- type: "set",
1514
- key: "value",
1515
- newValue,
1516
- oldValue
1517
- });
1238
+ this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
1239
+ const subs = this.subs;
1240
+ if (subs !== void 0) {
1241
+ {
1242
+ triggerEventInfos.push({
1243
+ target: this,
1244
+ type: "set",
1245
+ key: "value",
1246
+ newValue,
1247
+ oldValue
1248
+ });
1249
+ }
1250
+ propagate(subs);
1251
+ if (!batchDepth) {
1252
+ flush();
1253
+ }
1254
+ {
1255
+ triggerEventInfos.pop();
1256
+ }
1518
1257
  }
1519
1258
  }
1520
1259
  }
1521
- }
1522
- function triggerRef(ref2) {
1523
- if (ref2.dep) {
1524
- {
1525
- ref2.dep.trigger({
1526
- target: ref2,
1527
- type: "set",
1528
- key: "value",
1529
- newValue: ref2._value
1530
- });
1531
- }
1260
+ update() {
1261
+ this.flags &= ~ReactiveFlags$1.Dirty;
1262
+ return hasChanged(this._oldValue, this._oldValue = this._rawValue);
1263
+ }
1264
+ }
1265
+ function triggerRef(ref2) {
1266
+ const dep = ref2.dep;
1267
+ if (dep !== void 0 && dep.subs !== void 0) {
1268
+ propagate(dep.subs);
1269
+ shallowPropagate(dep.subs);
1270
+ if (!batchDepth) {
1271
+ flush();
1272
+ }
1273
+ }
1274
+ }
1275
+ function trackRef(dep) {
1276
+ if (activeSub !== void 0) {
1277
+ {
1278
+ onTrack(activeSub, {
1279
+ target: dep,
1280
+ type: "get",
1281
+ key: "value"
1282
+ });
1283
+ }
1284
+ link(dep, activeSub);
1285
+ }
1286
+ }
1287
+ function unref(ref2) {
1288
+ return isRef(ref2) ? ref2.value : ref2;
1289
+ }
1290
+ function toValue(source) {
1291
+ return isFunction(source) ? source() : unref(source);
1292
+ }
1293
+ const shallowUnwrapHandlers = {
1294
+ get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
1295
+ set: (target, key, value, receiver) => {
1296
+ const oldValue = target[key];
1297
+ if (isRef(oldValue) && !isRef(value)) {
1298
+ oldValue.value = value;
1299
+ return true;
1300
+ } else {
1301
+ return Reflect.set(target, key, value, receiver);
1302
+ }
1303
+ }
1304
+ };
1305
+ function proxyRefs(objectWithRefs) {
1306
+ return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1307
+ }
1308
+ class CustomRefImpl {
1309
+ constructor(factory) {
1310
+ this.subs = void 0;
1311
+ this.subsTail = void 0;
1312
+ this.flags = ReactiveFlags$1.None;
1313
+ this["__v_isRef"] = true;
1314
+ this._value = void 0;
1315
+ const { get, set } = factory(
1316
+ () => trackRef(this),
1317
+ () => triggerRef(this)
1318
+ );
1319
+ this._get = get;
1320
+ this._set = set;
1321
+ }
1322
+ get dep() {
1323
+ return this;
1324
+ }
1325
+ get value() {
1326
+ return this._value = this._get();
1327
+ }
1328
+ set value(newVal) {
1329
+ this._set(newVal);
1330
+ }
1331
+ }
1332
+ function customRef(factory) {
1333
+ return new CustomRefImpl(factory);
1334
+ }
1335
+ function toRefs(object) {
1336
+ const ret = isArray(object) ? new Array(object.length) : {};
1337
+ for (const key in object) {
1338
+ ret[key] = propertyToRef(object, key);
1339
+ }
1340
+ return ret;
1341
+ }
1342
+ class ObjectRefImpl {
1343
+ constructor(_object, _key, _defaultValue) {
1344
+ this._object = _object;
1345
+ this._key = _key;
1346
+ this._defaultValue = _defaultValue;
1347
+ this["__v_isRef"] = true;
1348
+ this._value = void 0;
1349
+ }
1350
+ get value() {
1351
+ const val = this._object[this._key];
1352
+ return this._value = val === void 0 ? this._defaultValue : val;
1353
+ }
1354
+ set value(newVal) {
1355
+ this._object[this._key] = newVal;
1356
+ }
1357
+ get dep() {
1358
+ return getDepFromReactive(toRaw(this._object), this._key);
1359
+ }
1360
+ }
1361
+ class GetterRefImpl {
1362
+ constructor(_getter) {
1363
+ this._getter = _getter;
1364
+ this["__v_isRef"] = true;
1365
+ this["__v_isReadonly"] = true;
1366
+ this._value = void 0;
1367
+ }
1368
+ get value() {
1369
+ return this._value = this._getter();
1370
+ }
1371
+ }
1372
+ function toRef(source, key, defaultValue) {
1373
+ if (isRef(source)) {
1374
+ return source;
1375
+ } else if (isFunction(source)) {
1376
+ return new GetterRefImpl(source);
1377
+ } else if (isObject(source) && arguments.length > 1) {
1378
+ return propertyToRef(source, key, defaultValue);
1379
+ } else {
1380
+ return ref(source);
1381
+ }
1382
+ }
1383
+ function propertyToRef(source, key, defaultValue) {
1384
+ const val = source[key];
1385
+ return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1386
+ }
1387
+
1388
+ const EffectFlags = {
1389
+ "ALLOW_RECURSE": 128,
1390
+ "128": "ALLOW_RECURSE",
1391
+ "PAUSED": 256,
1392
+ "256": "PAUSED",
1393
+ "STOP": 1024,
1394
+ "1024": "STOP"
1395
+ };
1396
+ class ReactiveEffect {
1397
+ constructor(fn) {
1398
+ this.deps = void 0;
1399
+ this.depsTail = void 0;
1400
+ this.subs = void 0;
1401
+ this.subsTail = void 0;
1402
+ this.flags = ReactiveFlags$1.Watching | ReactiveFlags$1.Dirty;
1403
+ /**
1404
+ * @internal
1405
+ */
1406
+ this.cleanups = [];
1407
+ /**
1408
+ * @internal
1409
+ */
1410
+ this.cleanupsLength = 0;
1411
+ if (fn !== void 0) {
1412
+ this.fn = fn;
1413
+ }
1414
+ if (activeEffectScope) {
1415
+ link(this, activeEffectScope);
1416
+ }
1417
+ }
1418
+ // @ts-expect-error
1419
+ fn() {
1420
+ }
1421
+ get active() {
1422
+ return !(this.flags & 1024);
1423
+ }
1424
+ pause() {
1425
+ this.flags |= 256;
1426
+ }
1427
+ resume() {
1428
+ const flags = this.flags &= -257;
1429
+ if (flags & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending)) {
1430
+ this.notify();
1431
+ }
1432
+ }
1433
+ notify() {
1434
+ if (!(this.flags & 256) && this.dirty) {
1435
+ this.run();
1436
+ }
1437
+ }
1438
+ run() {
1439
+ if (!this.active) {
1440
+ return this.fn();
1441
+ }
1442
+ cleanup(this);
1443
+ const prevSub = startTracking(this);
1444
+ try {
1445
+ return this.fn();
1446
+ } finally {
1447
+ endTracking(this, prevSub);
1448
+ const flags = this.flags;
1449
+ if ((flags & (ReactiveFlags$1.Recursed | 128)) === (ReactiveFlags$1.Recursed | 128)) {
1450
+ this.flags = flags & ~ReactiveFlags$1.Recursed;
1451
+ this.notify();
1452
+ }
1453
+ }
1454
+ }
1455
+ stop() {
1456
+ if (!this.active) {
1457
+ return;
1458
+ }
1459
+ this.flags = 1024;
1460
+ let dep = this.deps;
1461
+ while (dep !== void 0) {
1462
+ dep = unlink(dep, this);
1463
+ }
1464
+ const sub = this.subs;
1465
+ if (sub !== void 0) {
1466
+ unlink(sub);
1467
+ }
1468
+ cleanup(this);
1469
+ }
1470
+ get dirty() {
1471
+ const flags = this.flags;
1472
+ if (flags & ReactiveFlags$1.Dirty) {
1473
+ return true;
1474
+ }
1475
+ if (flags & ReactiveFlags$1.Pending) {
1476
+ if (checkDirty(this.deps, this)) {
1477
+ this.flags = flags | ReactiveFlags$1.Dirty;
1478
+ return true;
1479
+ } else {
1480
+ this.flags = flags & ~ReactiveFlags$1.Pending;
1481
+ }
1482
+ }
1483
+ return false;
1484
+ }
1485
+ }
1486
+ {
1487
+ setupOnTrigger(ReactiveEffect);
1488
+ }
1489
+ function effect(fn, options) {
1490
+ if (fn.effect instanceof ReactiveEffect) {
1491
+ fn = fn.effect.fn;
1492
+ }
1493
+ const e = new ReactiveEffect(fn);
1494
+ if (options) {
1495
+ const { onStop, scheduler } = options;
1496
+ if (onStop) {
1497
+ options.onStop = void 0;
1498
+ const stop2 = e.stop.bind(e);
1499
+ e.stop = () => {
1500
+ stop2();
1501
+ onStop();
1502
+ };
1503
+ }
1504
+ if (scheduler) {
1505
+ options.scheduler = void 0;
1506
+ e.notify = () => {
1507
+ if (!(e.flags & 256)) {
1508
+ scheduler();
1509
+ }
1510
+ };
1511
+ }
1512
+ extend(e, options);
1513
+ }
1514
+ try {
1515
+ e.run();
1516
+ } catch (err) {
1517
+ e.stop();
1518
+ throw err;
1532
1519
  }
1520
+ const runner = e.run.bind(e);
1521
+ runner.effect = e;
1522
+ return runner;
1533
1523
  }
1534
- function unref(ref2) {
1535
- return isRef(ref2) ? ref2.value : ref2;
1524
+ function stop(runner) {
1525
+ runner.effect.stop();
1536
1526
  }
1537
- function toValue(source) {
1538
- return isFunction(source) ? source() : unref(source);
1527
+ const resetTrackingStack = [];
1528
+ function pauseTracking() {
1529
+ resetTrackingStack.push(activeSub);
1530
+ setActiveSub();
1539
1531
  }
1540
- const shallowUnwrapHandlers = {
1541
- get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
1542
- set: (target, key, value, receiver) => {
1543
- const oldValue = target[key];
1544
- if (isRef(oldValue) && !isRef(value)) {
1545
- oldValue.value = value;
1546
- return true;
1547
- } else {
1548
- return Reflect.set(target, key, value, receiver);
1532
+ function enableTracking() {
1533
+ const isPaused = activeSub === void 0;
1534
+ if (!isPaused) {
1535
+ resetTrackingStack.push(activeSub);
1536
+ } else {
1537
+ resetTrackingStack.push(void 0);
1538
+ for (let i = resetTrackingStack.length - 1; i >= 0; i--) {
1539
+ if (resetTrackingStack[i] !== void 0) {
1540
+ setActiveSub(resetTrackingStack[i]);
1541
+ break;
1542
+ }
1549
1543
  }
1550
1544
  }
1551
- };
1552
- function proxyRefs(objectWithRefs) {
1553
- return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1554
1545
  }
1555
- class CustomRefImpl {
1556
- constructor(factory) {
1557
- this["__v_isRef"] = true;
1558
- this._value = void 0;
1559
- const dep = this.dep = new Dep();
1560
- const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1561
- this._get = get;
1562
- this._set = set;
1563
- }
1564
- get value() {
1565
- return this._value = this._get();
1546
+ function resetTracking() {
1547
+ if (resetTrackingStack.length === 0) {
1548
+ warn(
1549
+ `resetTracking() was called when there was no active tracking to reset.`
1550
+ );
1566
1551
  }
1567
- set value(newVal) {
1568
- this._set(newVal);
1552
+ if (resetTrackingStack.length) {
1553
+ setActiveSub(resetTrackingStack.pop());
1554
+ } else {
1555
+ setActiveSub();
1569
1556
  }
1570
1557
  }
1571
- function customRef(factory) {
1572
- return new CustomRefImpl(factory);
1558
+ function cleanup(sub) {
1559
+ const l = sub.cleanupsLength;
1560
+ if (l) {
1561
+ for (let i = 0; i < l; i++) {
1562
+ sub.cleanups[i]();
1563
+ }
1564
+ sub.cleanupsLength = 0;
1565
+ }
1573
1566
  }
1574
- function toRefs(object) {
1575
- if (!isProxy(object)) {
1576
- warn(`toRefs() expects a reactive object but received a plain one.`);
1567
+ function onEffectCleanup(fn, failSilently = false) {
1568
+ if (activeSub instanceof ReactiveEffect) {
1569
+ activeSub.cleanups[activeSub.cleanupsLength++] = () => cleanupEffect(fn);
1570
+ } else if (!failSilently) {
1571
+ warn(
1572
+ `onEffectCleanup() was called when there was no active effect to associate with.`
1573
+ );
1577
1574
  }
1578
- const ret = isArray(object) ? new Array(object.length) : {};
1579
- for (const key in object) {
1580
- ret[key] = propertyToRef(object, key);
1575
+ }
1576
+ function cleanupEffect(fn) {
1577
+ const prevSub = setActiveSub();
1578
+ try {
1579
+ fn();
1580
+ } finally {
1581
+ setActiveSub(prevSub);
1581
1582
  }
1582
- return ret;
1583
1583
  }
1584
- class ObjectRefImpl {
1585
- constructor(_object, _key, _defaultValue) {
1586
- this._object = _object;
1587
- this._key = _key;
1588
- this._defaultValue = _defaultValue;
1589
- this["__v_isRef"] = true;
1590
- this._value = void 0;
1584
+
1585
+ let activeEffectScope;
1586
+ class EffectScope {
1587
+ constructor(detached = false) {
1588
+ this.deps = void 0;
1589
+ this.depsTail = void 0;
1590
+ this.subs = void 0;
1591
+ this.subsTail = void 0;
1592
+ this.flags = 0;
1593
+ /**
1594
+ * @internal
1595
+ */
1596
+ this.cleanups = [];
1597
+ /**
1598
+ * @internal
1599
+ */
1600
+ this.cleanupsLength = 0;
1601
+ if (!detached && activeEffectScope) {
1602
+ link(this, activeEffectScope);
1603
+ }
1591
1604
  }
1592
- get value() {
1593
- const val = this._object[this._key];
1594
- return this._value = val === void 0 ? this._defaultValue : val;
1605
+ get active() {
1606
+ return !(this.flags & 1024);
1595
1607
  }
1596
- set value(newVal) {
1597
- this._object[this._key] = newVal;
1608
+ pause() {
1609
+ if (!(this.flags & 256)) {
1610
+ this.flags |= 256;
1611
+ for (let link2 = this.deps; link2 !== void 0; link2 = link2.nextDep) {
1612
+ const dep = link2.dep;
1613
+ if ("pause" in dep) {
1614
+ dep.pause();
1615
+ }
1616
+ }
1617
+ }
1598
1618
  }
1599
- get dep() {
1600
- return getDepFromReactive(toRaw(this._object), this._key);
1619
+ /**
1620
+ * Resumes the effect scope, including all child scopes and effects.
1621
+ */
1622
+ resume() {
1623
+ const flags = this.flags;
1624
+ if (flags & 256) {
1625
+ this.flags = flags & -257;
1626
+ for (let link2 = this.deps; link2 !== void 0; link2 = link2.nextDep) {
1627
+ const dep = link2.dep;
1628
+ if ("resume" in dep) {
1629
+ dep.resume();
1630
+ }
1631
+ }
1632
+ }
1601
1633
  }
1602
- }
1603
- class GetterRefImpl {
1604
- constructor(_getter) {
1605
- this._getter = _getter;
1606
- this["__v_isRef"] = true;
1607
- this["__v_isReadonly"] = true;
1608
- this._value = void 0;
1634
+ run(fn) {
1635
+ const prevSub = setActiveSub();
1636
+ const prevScope = activeEffectScope;
1637
+ try {
1638
+ activeEffectScope = this;
1639
+ return fn();
1640
+ } finally {
1641
+ activeEffectScope = prevScope;
1642
+ setActiveSub(prevSub);
1643
+ }
1609
1644
  }
1610
- get value() {
1611
- return this._value = this._getter();
1645
+ stop() {
1646
+ if (!this.active) {
1647
+ return;
1648
+ }
1649
+ this.flags = 1024;
1650
+ let dep = this.deps;
1651
+ while (dep !== void 0) {
1652
+ const node = dep.dep;
1653
+ if ("stop" in node) {
1654
+ dep = dep.nextDep;
1655
+ node.stop();
1656
+ } else {
1657
+ dep = unlink(dep, this);
1658
+ }
1659
+ }
1660
+ const sub = this.subs;
1661
+ if (sub !== void 0) {
1662
+ unlink(sub);
1663
+ }
1664
+ cleanup(this);
1612
1665
  }
1613
1666
  }
1614
- function toRef(source, key, defaultValue) {
1615
- if (isRef(source)) {
1616
- return source;
1617
- } else if (isFunction(source)) {
1618
- return new GetterRefImpl(source);
1619
- } else if (isObject(source) && arguments.length > 1) {
1620
- return propertyToRef(source, key, defaultValue);
1621
- } else {
1622
- return ref(source);
1667
+ function effectScope(detached) {
1668
+ return new EffectScope(detached);
1669
+ }
1670
+ function getCurrentScope() {
1671
+ return activeEffectScope;
1672
+ }
1673
+ function setCurrentScope(scope) {
1674
+ try {
1675
+ return activeEffectScope;
1676
+ } finally {
1677
+ activeEffectScope = scope;
1623
1678
  }
1624
1679
  }
1625
- function propertyToRef(source, key, defaultValue) {
1626
- const val = source[key];
1627
- return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1680
+ function onScopeDispose(fn, failSilently = false) {
1681
+ if (activeEffectScope !== void 0) {
1682
+ activeEffectScope.cleanups[activeEffectScope.cleanupsLength++] = fn;
1683
+ } else if (!failSilently) {
1684
+ warn(
1685
+ `onScopeDispose() is called when there is no active effect scope to be associated with.`
1686
+ );
1687
+ }
1628
1688
  }
1629
1689
 
1630
1690
  class ComputedRefImpl {
1631
- constructor(fn, setter, isSSR) {
1691
+ constructor(fn, setter) {
1632
1692
  this.fn = fn;
1633
1693
  this.setter = setter;
1634
1694
  /**
1635
1695
  * @internal
1636
1696
  */
1637
1697
  this._value = void 0;
1638
- /**
1639
- * @internal
1640
- */
1641
- this.dep = new Dep(this);
1642
- /**
1643
- * @internal
1644
- */
1645
- this.__v_isRef = true;
1646
- // TODO isolatedDeclarations "__v_isReadonly"
1647
- // A computed is also a subscriber that tracks other deps
1648
- /**
1649
- * @internal
1650
- */
1698
+ this.subs = void 0;
1699
+ this.subsTail = void 0;
1651
1700
  this.deps = void 0;
1652
- /**
1653
- * @internal
1654
- */
1655
1701
  this.depsTail = void 0;
1702
+ this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
1656
1703
  /**
1657
1704
  * @internal
1658
1705
  */
1659
- this.flags = 16;
1660
- /**
1661
- * @internal
1662
- */
1663
- this.globalVersion = globalVersion - 1;
1664
- /**
1665
- * @internal
1666
- */
1667
- this.next = void 0;
1668
- // for backwards compat
1669
- this.effect = this;
1706
+ this.__v_isRef = true;
1670
1707
  this["__v_isReadonly"] = !setter;
1671
- this.isSSR = isSSR;
1708
+ }
1709
+ // TODO isolatedDeclarations "__v_isReadonly"
1710
+ // for backwards compat
1711
+ get effect() {
1712
+ return this;
1713
+ }
1714
+ // for backwards compat
1715
+ get dep() {
1716
+ return this;
1672
1717
  }
1673
1718
  /**
1674
1719
  * @internal
1720
+ * for backwards compat
1675
1721
  */
1676
- notify() {
1677
- this.flags |= 16;
1678
- if (!(this.flags & 8) && // avoid infinite self recursion
1679
- activeSub !== this) {
1680
- batch(this, true);
1722
+ get _dirty() {
1723
+ const flags = this.flags;
1724
+ if (flags & ReactiveFlags$1.Dirty) {
1681
1725
  return true;
1682
1726
  }
1727
+ if (flags & ReactiveFlags$1.Pending) {
1728
+ if (checkDirty(this.deps, this)) {
1729
+ this.flags = flags | ReactiveFlags$1.Dirty;
1730
+ return true;
1731
+ } else {
1732
+ this.flags = flags & ~ReactiveFlags$1.Pending;
1733
+ }
1734
+ }
1735
+ return false;
1736
+ }
1737
+ /**
1738
+ * @internal
1739
+ * for backwards compat
1740
+ */
1741
+ set _dirty(v) {
1742
+ if (v) {
1743
+ this.flags |= ReactiveFlags$1.Dirty;
1744
+ } else {
1745
+ this.flags &= ~(ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending);
1746
+ }
1683
1747
  }
1684
1748
  get value() {
1685
- const link = this.dep.track({
1686
- target: this,
1687
- type: "get",
1688
- key: "value"
1689
- }) ;
1690
- refreshComputed(this);
1691
- if (link) {
1692
- link.version = this.dep.version;
1749
+ const flags = this.flags;
1750
+ if (flags & ReactiveFlags$1.Dirty || flags & ReactiveFlags$1.Pending && checkDirty(this.deps, this)) {
1751
+ if (this.update()) {
1752
+ const subs = this.subs;
1753
+ if (subs !== void 0) {
1754
+ shallowPropagate(subs);
1755
+ }
1756
+ }
1757
+ } else if (flags & ReactiveFlags$1.Pending) {
1758
+ this.flags = flags & ~ReactiveFlags$1.Pending;
1759
+ }
1760
+ if (activeSub !== void 0) {
1761
+ {
1762
+ onTrack(activeSub, {
1763
+ target: this,
1764
+ type: "get",
1765
+ key: "value"
1766
+ });
1767
+ }
1768
+ link(this, activeSub);
1769
+ } else if (activeEffectScope !== void 0) {
1770
+ link(this, activeEffectScope);
1693
1771
  }
1694
1772
  return this._value;
1695
1773
  }
@@ -1700,6 +1778,23 @@ class ComputedRefImpl {
1700
1778
  warn("Write operation failed: computed value is readonly");
1701
1779
  }
1702
1780
  }
1781
+ update() {
1782
+ const prevSub = startTracking(this);
1783
+ try {
1784
+ const oldValue = this._value;
1785
+ const newValue = this.fn(oldValue);
1786
+ if (hasChanged(oldValue, newValue)) {
1787
+ this._value = newValue;
1788
+ return true;
1789
+ }
1790
+ return false;
1791
+ } finally {
1792
+ endTracking(this, prevSub);
1793
+ }
1794
+ }
1795
+ }
1796
+ {
1797
+ setupOnTrigger(ComputedRefImpl);
1703
1798
  }
1704
1799
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1705
1800
  let getter;
@@ -1710,7 +1805,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
1710
1805
  getter = getterOrOptions.get;
1711
1806
  setter = getterOrOptions.set;
1712
1807
  }
1713
- const cRef = new ComputedRefImpl(getter, setter, isSSR);
1808
+ const cRef = new ComputedRefImpl(getter, setter);
1714
1809
  if (debugOptions && !isSSR) {
1715
1810
  cRef.onTrack = debugOptions.onTrack;
1716
1811
  cRef.onTrigger = debugOptions.onTrigger;
@@ -1747,177 +1842,155 @@ const WatchErrorCodes = {
1747
1842
  "4": "WATCH_CLEANUP"
1748
1843
  };
1749
1844
  const INITIAL_WATCHER_VALUE = {};
1750
- const cleanupMap = /* @__PURE__ */ new WeakMap();
1751
1845
  let activeWatcher = void 0;
1752
1846
  function getCurrentWatcher() {
1753
1847
  return activeWatcher;
1754
1848
  }
1755
1849
  function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1756
1850
  if (owner) {
1757
- let cleanups = cleanupMap.get(owner);
1758
- if (!cleanups) cleanupMap.set(owner, cleanups = []);
1759
- cleanups.push(cleanupFn);
1851
+ const { call } = owner.options;
1852
+ if (call) {
1853
+ owner.cleanups[owner.cleanupsLength++] = () => call(cleanupFn, 4);
1854
+ } else {
1855
+ owner.cleanups[owner.cleanupsLength++] = cleanupFn;
1856
+ }
1760
1857
  } else if (!failSilently) {
1761
1858
  warn(
1762
1859
  `onWatcherCleanup() was called when there was no active watcher to associate with.`
1763
1860
  );
1764
1861
  }
1765
1862
  }
1766
- function watch(source, cb, options = EMPTY_OBJ) {
1767
- const { immediate, deep, once, scheduler, augmentJob, call } = options;
1768
- const warnInvalidSource = (s) => {
1769
- (options.onWarn || warn)(
1770
- `Invalid watch source: `,
1771
- s,
1772
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1773
- );
1774
- };
1775
- const reactiveGetter = (source2) => {
1776
- if (deep) return source2;
1777
- if (isShallow(source2) || deep === false || deep === 0)
1778
- return traverse(source2, 1);
1779
- return traverse(source2);
1780
- };
1781
- let effect;
1782
- let getter;
1783
- let cleanup;
1784
- let boundCleanup;
1785
- let forceTrigger = false;
1786
- let isMultiSource = false;
1787
- if (isRef(source)) {
1788
- getter = () => source.value;
1789
- forceTrigger = isShallow(source);
1790
- } else if (isReactive(source)) {
1791
- getter = () => reactiveGetter(source);
1792
- forceTrigger = true;
1793
- } else if (isArray(source)) {
1794
- isMultiSource = true;
1795
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1796
- getter = () => source.map((s) => {
1797
- if (isRef(s)) {
1798
- return s.value;
1799
- } else if (isReactive(s)) {
1800
- return reactiveGetter(s);
1801
- } else if (isFunction(s)) {
1802
- return call ? call(s, 2) : s();
1863
+ class WatcherEffect extends ReactiveEffect {
1864
+ constructor(source, cb, options = EMPTY_OBJ) {
1865
+ const { deep, once, call, onWarn } = options;
1866
+ let getter;
1867
+ let forceTrigger = false;
1868
+ let isMultiSource = false;
1869
+ if (isRef(source)) {
1870
+ getter = () => source.value;
1871
+ forceTrigger = isShallow(source);
1872
+ } else if (isReactive(source)) {
1873
+ getter = () => reactiveGetter(source, deep);
1874
+ forceTrigger = true;
1875
+ } else if (isArray(source)) {
1876
+ isMultiSource = true;
1877
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1878
+ getter = () => source.map((s) => {
1879
+ if (isRef(s)) {
1880
+ return s.value;
1881
+ } else if (isReactive(s)) {
1882
+ return reactiveGetter(s, deep);
1883
+ } else if (isFunction(s)) {
1884
+ return call ? call(s, 2) : s();
1885
+ } else {
1886
+ warnInvalidSource(s, onWarn);
1887
+ }
1888
+ });
1889
+ } else if (isFunction(source)) {
1890
+ if (cb) {
1891
+ getter = call ? () => call(source, 2) : source;
1803
1892
  } else {
1804
- warnInvalidSource(s);
1805
- }
1806
- });
1807
- } else if (isFunction(source)) {
1808
- if (cb) {
1809
- getter = call ? () => call(source, 2) : source;
1810
- } else {
1811
- getter = () => {
1812
- if (cleanup) {
1813
- pauseTracking();
1893
+ getter = () => {
1894
+ if (this.cleanupsLength) {
1895
+ const prevSub = setActiveSub();
1896
+ try {
1897
+ cleanup(this);
1898
+ } finally {
1899
+ setActiveSub(prevSub);
1900
+ }
1901
+ }
1902
+ const currentEffect = activeWatcher;
1903
+ activeWatcher = this;
1814
1904
  try {
1815
- cleanup();
1905
+ return call ? call(source, 3, [
1906
+ this.boundCleanup
1907
+ ]) : source(this.boundCleanup);
1816
1908
  } finally {
1817
- resetTracking();
1909
+ activeWatcher = currentEffect;
1818
1910
  }
1819
- }
1820
- const currentEffect = activeWatcher;
1821
- activeWatcher = effect;
1822
- try {
1823
- return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1824
- } finally {
1825
- activeWatcher = currentEffect;
1826
- }
1911
+ };
1912
+ }
1913
+ } else {
1914
+ getter = NOOP;
1915
+ warnInvalidSource(source, onWarn);
1916
+ }
1917
+ if (cb && deep) {
1918
+ const baseGetter = getter;
1919
+ const depth = deep === true ? Infinity : deep;
1920
+ getter = () => traverse(baseGetter(), depth);
1921
+ }
1922
+ super(getter);
1923
+ this.cb = cb;
1924
+ this.options = options;
1925
+ this.boundCleanup = (fn) => onWatcherCleanup(fn, false, this);
1926
+ this.forceTrigger = forceTrigger;
1927
+ this.isMultiSource = isMultiSource;
1928
+ if (once && cb) {
1929
+ const _cb = cb;
1930
+ cb = (...args) => {
1931
+ _cb(...args);
1932
+ this.stop();
1827
1933
  };
1828
1934
  }
1829
- } else {
1830
- getter = NOOP;
1831
- warnInvalidSource(source);
1832
- }
1833
- if (cb && deep) {
1834
- const baseGetter = getter;
1835
- const depth = deep === true ? Infinity : deep;
1836
- getter = () => traverse(baseGetter(), depth);
1837
- }
1838
- const scope = getCurrentScope();
1839
- const watchHandle = () => {
1840
- effect.stop();
1841
- if (scope && scope.active) {
1842
- remove(scope.effects, effect);
1935
+ this.cb = cb;
1936
+ this.oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1937
+ {
1938
+ this.onTrack = options.onTrack;
1939
+ this.onTrigger = options.onTrigger;
1843
1940
  }
1844
- };
1845
- if (once && cb) {
1846
- const _cb = cb;
1847
- cb = (...args) => {
1848
- _cb(...args);
1849
- watchHandle();
1850
- };
1851
1941
  }
1852
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1853
- const job = (immediateFirstRun) => {
1854
- if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
1942
+ run(initialRun = false) {
1943
+ const oldValue = this.oldValue;
1944
+ const newValue = this.oldValue = super.run();
1945
+ if (!this.cb) {
1855
1946
  return;
1856
1947
  }
1857
- if (cb) {
1858
- const newValue = effect.run();
1859
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1860
- if (cleanup) {
1861
- cleanup();
1862
- }
1863
- const currentWatcher = activeWatcher;
1864
- activeWatcher = effect;
1865
- try {
1866
- const args = [
1867
- newValue,
1868
- // pass undefined as the old value when it's changed for the first time
1869
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1870
- boundCleanup
1871
- ];
1872
- oldValue = newValue;
1873
- call ? call(cb, 3, args) : (
1874
- // @ts-expect-error
1875
- cb(...args)
1876
- );
1877
- } finally {
1878
- activeWatcher = currentWatcher;
1879
- }
1880
- }
1881
- } else {
1882
- effect.run();
1948
+ const { immediate, deep, call } = this.options;
1949
+ if (initialRun && !immediate) {
1950
+ return;
1883
1951
  }
1884
- };
1885
- if (augmentJob) {
1886
- augmentJob(job);
1887
- }
1888
- effect = new ReactiveEffect(getter);
1889
- effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1890
- boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1891
- cleanup = effect.onStop = () => {
1892
- const cleanups = cleanupMap.get(effect);
1893
- if (cleanups) {
1894
- if (call) {
1895
- call(cleanups, 4);
1896
- } else {
1897
- for (const cleanup2 of cleanups) cleanup2();
1952
+ if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1953
+ cleanup(this);
1954
+ const currentWatcher = activeWatcher;
1955
+ activeWatcher = this;
1956
+ try {
1957
+ const args = [
1958
+ newValue,
1959
+ // pass undefined as the old value when it's changed for the first time
1960
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : this.isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1961
+ this.boundCleanup
1962
+ ];
1963
+ call ? call(this.cb, 3, args) : (
1964
+ // @ts-expect-error
1965
+ this.cb(...args)
1966
+ );
1967
+ } finally {
1968
+ activeWatcher = currentWatcher;
1898
1969
  }
1899
- cleanupMap.delete(effect);
1900
- }
1901
- };
1902
- {
1903
- effect.onTrack = options.onTrack;
1904
- effect.onTrigger = options.onTrigger;
1905
- }
1906
- if (cb) {
1907
- if (immediate) {
1908
- job(true);
1909
- } else {
1910
- oldValue = effect.run();
1911
1970
  }
1912
- } else if (scheduler) {
1913
- scheduler(job.bind(null, true), true);
1914
- } else {
1915
- effect.run();
1916
1971
  }
1917
- watchHandle.pause = effect.pause.bind(effect);
1918
- watchHandle.resume = effect.resume.bind(effect);
1919
- watchHandle.stop = watchHandle;
1920
- return watchHandle;
1972
+ }
1973
+ function reactiveGetter(source, deep) {
1974
+ if (deep) return source;
1975
+ if (isShallow(source) || deep === false || deep === 0)
1976
+ return traverse(source, 1);
1977
+ return traverse(source);
1978
+ }
1979
+ function warnInvalidSource(s, onWarn) {
1980
+ (onWarn || warn)(
1981
+ `Invalid watch source: `,
1982
+ s,
1983
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1984
+ );
1985
+ }
1986
+ function watch(source, cb, options = EMPTY_OBJ) {
1987
+ const effect = new WatcherEffect(source, cb, options);
1988
+ effect.run(true);
1989
+ const stop = effect.stop.bind(effect);
1990
+ stop.pause = effect.pause.bind(effect);
1991
+ stop.resume = effect.resume.bind(effect);
1992
+ stop.stop = stop;
1993
+ return stop;
1921
1994
  }
1922
1995
  function traverse(value, depth = Infinity, seen) {
1923
1996
  if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
@@ -1952,4 +2025,4 @@ function traverse(value, depth = Infinity, seen) {
1952
2025
  return value;
1953
2026
  }
1954
2027
 
1955
- export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, WatchErrorCodes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, onWatcherCleanup, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, traverse, trigger, triggerRef, unref, watch };
2028
+ 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 };