@vue/reactivity 3.5.16 → 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.16
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,628 +55,346 @@ 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;
84
+ if (!--batchDepth && notifyBufferLength) {
85
+ flush();
353
86
  }
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
87
  }
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;
390
- }
391
- }
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
- constructor(computed) {
565
- this.computed = computed;
566
- this.version = 0;
567
- /**
568
- * Link between this dep and the current active effect
569
- */
570
- this.activeLink = void 0;
571
- /**
572
- * Doubly linked list representing the subscribing effects (tail)
573
- */
574
- this.subs = void 0;
575
- /**
576
- * For object property deps cleanup
577
- */
578
- this.map = void 0;
579
- this.key = void 0;
580
- /**
581
- * Subscriber counter
582
- */
583
- this.sc = 0;
584
- {
585
- this.subsHead = void 0;
586
- }
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
+ );
587
352
  }
588
- track(debugInfo) {
589
- if (!activeSub || !shouldTrack || activeSub === this.computed) {
590
- 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;
591
362
  }
592
- let link = this.activeLink;
593
- if (link === void 0 || link.sub !== activeSub) {
594
- link = this.activeLink = new Link(activeSub, this);
595
- if (!activeSub.deps) {
596
- activeSub.deps = activeSub.depsTail = link;
597
- } else {
598
- link.prevDep = activeSub.depsTail;
599
- activeSub.depsTail.nextDep = link;
600
- activeSub.depsTail = link;
601
- }
602
- addSub(link);
603
- } else if (link.version === -1) {
604
- link.version = this.version;
605
- if (link.nextDep) {
606
- const next = link.nextDep;
607
- next.prevDep = link.prevDep;
608
- if (link.prevDep) {
609
- link.prevDep.nextDep = next;
610
- }
611
- link.prevDep = activeSub.depsTail;
612
- link.nextDep = void 0;
613
- activeSub.depsTail.nextDep = link;
614
- activeSub.depsTail = link;
615
- if (activeSub.deps === link) {
616
- activeSub.deps = next;
617
- }
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);
618
374
  }
375
+ target._flags = value;
619
376
  }
620
- if (activeSub.onTrack) {
621
- activeSub.onTrack(
622
- extend(
623
- {
624
- effect: activeSub
625
- },
626
- debugInfo
627
- )
628
- );
629
- }
630
- return link;
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;
631
387
  }
632
- trigger(debugInfo) {
633
- this.version++;
634
- globalVersion++;
635
- this.notify(debugInfo);
388
+ get subs() {
389
+ return this._subs;
636
390
  }
637
- notify(debugInfo) {
638
- startBatch();
639
- try {
640
- if (true) {
641
- for (let head = this.subsHead; head; head = head.nextSub) {
642
- if (head.sub.onTrigger && !(head.sub.flags & 8)) {
643
- head.sub.onTrigger(
644
- extend(
645
- {
646
- effect: head.sub
647
- },
648
- debugInfo
649
- )
650
- );
651
- }
652
- }
653
- }
654
- for (let link = this.subs; link; link = link.prevSub) {
655
- if (link.sub.notify()) {
656
- ;
657
- link.sub.dep.notify();
658
- }
659
- }
660
- } finally {
661
- endBatch();
391
+ set subs(value) {
392
+ this._subs = value;
393
+ if (value === void 0) {
394
+ this.map.delete(this.key);
662
395
  }
663
396
  }
664
397
  }
665
- function addSub(link) {
666
- link.dep.sc++;
667
- if (link.sub.flags & 4) {
668
- const computed = link.dep.computed;
669
- if (computed && !link.dep.subs) {
670
- computed.flags |= 4 | 16;
671
- for (let l = computed.deps; l; l = l.nextDep) {
672
- addSub(l);
673
- }
674
- }
675
- const currentTail = link.dep.subs;
676
- if (currentTail !== link) {
677
- link.prevSub = currentTail;
678
- if (currentTail) currentTail.nextSub = link;
679
- }
680
- if (link.dep.subsHead === void 0) {
681
- link.dep.subsHead = link;
682
- }
683
- link.dep.subs = link;
684
- }
685
- }
686
398
  const targetMap = /* @__PURE__ */ new WeakMap();
687
399
  const ITERATE_KEY = Symbol(
688
400
  "Object iterate"
@@ -694,36 +406,34 @@ const ARRAY_ITERATE_KEY = Symbol(
694
406
  "Array iterate"
695
407
  );
696
408
  function track(target, type, key) {
697
- if (shouldTrack && activeSub) {
409
+ if (activeSub !== void 0) {
698
410
  let depsMap = targetMap.get(target);
699
411
  if (!depsMap) {
700
412
  targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
701
413
  }
702
414
  let dep = depsMap.get(key);
703
415
  if (!dep) {
704
- depsMap.set(key, dep = new Dep());
705
- dep.map = depsMap;
706
- dep.key = key;
416
+ depsMap.set(key, dep = new Dep(depsMap, key));
707
417
  }
708
418
  {
709
- dep.track({
419
+ onTrack(activeSub, {
710
420
  target,
711
421
  type,
712
422
  key
713
423
  });
714
424
  }
425
+ link(dep, activeSub);
715
426
  }
716
427
  }
717
428
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
718
429
  const depsMap = targetMap.get(target);
719
430
  if (!depsMap) {
720
- globalVersion++;
721
431
  return;
722
432
  }
723
433
  const run = (dep) => {
724
- if (dep) {
434
+ if (dep !== void 0 && dep.subs !== void 0) {
725
435
  {
726
- dep.trigger({
436
+ triggerEventInfos.push({
727
437
  target,
728
438
  type,
729
439
  key,
@@ -732,6 +442,11 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
732
442
  oldTarget
733
443
  });
734
444
  }
445
+ propagate(dep.subs);
446
+ shallowPropagate(dep.subs);
447
+ {
448
+ triggerEventInfos.pop();
449
+ }
735
450
  }
736
451
  };
737
452
  startBatch();
@@ -956,11 +671,11 @@ function searchProxy(self, method, args) {
956
671
  return res;
957
672
  }
958
673
  function noTracking(self, method, args = []) {
959
- pauseTracking();
960
674
  startBatch();
675
+ const prevSub = setActiveSub();
961
676
  const res = toRaw(self)[method].apply(self, args);
677
+ setActiveSub(prevSub);
962
678
  endBatch();
963
- resetTracking();
964
679
  return res;
965
680
  }
966
681
 
@@ -1006,14 +721,18 @@ class BaseReactiveHandler {
1006
721
  return hasOwnProperty;
1007
722
  }
1008
723
  }
724
+ const wasRef = isRef(target);
1009
725
  const res = Reflect.get(
1010
726
  target,
1011
727
  key,
1012
728
  // if this is a proxy wrapping a ref, return methods using the raw ref
1013
729
  // as receiver so that we don't have to call `toRaw` on the ref in all
1014
730
  // its class methods
1015
- isRef(target) ? target : receiver
731
+ wasRef ? target : receiver
1016
732
  );
733
+ if (wasRef && key !== "value") {
734
+ return res;
735
+ }
1017
736
  if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
1018
737
  return res;
1019
738
  }
@@ -1465,33 +1184,47 @@ function isRef(r) {
1465
1184
  return r ? r["__v_isRef"] === true : false;
1466
1185
  }
1467
1186
  function ref(value) {
1468
- return createRef(value, false);
1187
+ return createRef(value, toReactive);
1469
1188
  }
1470
1189
  function shallowRef(value) {
1471
- return createRef(value, true);
1190
+ return createRef(value);
1472
1191
  }
1473
- function createRef(rawValue, shallow) {
1192
+ function createRef(rawValue, wrap) {
1474
1193
  if (isRef(rawValue)) {
1475
1194
  return rawValue;
1476
1195
  }
1477
- return new RefImpl(rawValue, shallow);
1196
+ return new RefImpl(rawValue, wrap);
1478
1197
  }
1479
1198
  class RefImpl {
1480
- constructor(value, isShallow2) {
1481
- this.dep = new Dep();
1482
- this["__v_isRef"] = true;
1483
- this["__v_isShallow"] = false;
1484
- this._rawValue = isShallow2 ? value : toRaw(value);
1485
- this._value = isShallow2 ? value : toReactive(value);
1486
- 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;
1487
1220
  }
1488
1221
  get value() {
1489
- {
1490
- this.dep.track({
1491
- target: this,
1492
- type: "get",
1493
- key: "value"
1494
- });
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
+ }
1495
1228
  }
1496
1229
  return this._value;
1497
1230
  }
@@ -1500,191 +1233,541 @@ class RefImpl {
1500
1233
  const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
1501
1234
  newValue = useDirectValue ? newValue : toRaw(newValue);
1502
1235
  if (hasChanged(newValue, oldValue)) {
1236
+ this.flags |= ReactiveFlags$1.Dirty;
1503
1237
  this._rawValue = newValue;
1504
- this._value = useDirectValue ? newValue : toReactive(newValue);
1505
- {
1506
- this.dep.trigger({
1507
- target: this,
1508
- type: "set",
1509
- key: "value",
1510
- newValue,
1511
- oldValue
1512
- });
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
+ }
1513
1257
  }
1514
1258
  }
1515
1259
  }
1516
- }
1517
- function triggerRef(ref2) {
1518
- if (ref2.dep) {
1519
- {
1520
- ref2.dep.trigger({
1521
- target: ref2,
1522
- type: "set",
1523
- key: "value",
1524
- newValue: ref2._value
1525
- });
1526
- }
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;
1527
1519
  }
1520
+ const runner = e.run.bind(e);
1521
+ runner.effect = e;
1522
+ return runner;
1528
1523
  }
1529
- function unref(ref2) {
1530
- return isRef(ref2) ? ref2.value : ref2;
1524
+ function stop(runner) {
1525
+ runner.effect.stop();
1531
1526
  }
1532
- function toValue(source) {
1533
- return isFunction(source) ? source() : unref(source);
1527
+ const resetTrackingStack = [];
1528
+ function pauseTracking() {
1529
+ resetTrackingStack.push(activeSub);
1530
+ setActiveSub();
1534
1531
  }
1535
- const shallowUnwrapHandlers = {
1536
- get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
1537
- set: (target, key, value, receiver) => {
1538
- const oldValue = target[key];
1539
- if (isRef(oldValue) && !isRef(value)) {
1540
- oldValue.value = value;
1541
- return true;
1542
- } else {
1543
- 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
+ }
1544
1543
  }
1545
1544
  }
1546
- };
1547
- function proxyRefs(objectWithRefs) {
1548
- return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1549
1545
  }
1550
- class CustomRefImpl {
1551
- constructor(factory) {
1552
- this["__v_isRef"] = true;
1553
- this._value = void 0;
1554
- const dep = this.dep = new Dep();
1555
- const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1556
- this._get = get;
1557
- this._set = set;
1558
- }
1559
- get value() {
1560
- 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
+ );
1561
1551
  }
1562
- set value(newVal) {
1563
- this._set(newVal);
1552
+ if (resetTrackingStack.length) {
1553
+ setActiveSub(resetTrackingStack.pop());
1554
+ } else {
1555
+ setActiveSub();
1564
1556
  }
1565
1557
  }
1566
- function customRef(factory) {
1567
- 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
+ }
1568
1566
  }
1569
- function toRefs(object) {
1570
- if (!isProxy(object)) {
1571
- 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
+ );
1572
1574
  }
1573
- const ret = isArray(object) ? new Array(object.length) : {};
1574
- for (const key in object) {
1575
- ret[key] = propertyToRef(object, key);
1575
+ }
1576
+ function cleanupEffect(fn) {
1577
+ const prevSub = setActiveSub();
1578
+ try {
1579
+ fn();
1580
+ } finally {
1581
+ setActiveSub(prevSub);
1576
1582
  }
1577
- return ret;
1578
1583
  }
1579
- class ObjectRefImpl {
1580
- constructor(_object, _key, _defaultValue) {
1581
- this._object = _object;
1582
- this._key = _key;
1583
- this._defaultValue = _defaultValue;
1584
- this["__v_isRef"] = true;
1585
- 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
+ }
1586
1604
  }
1587
- get value() {
1588
- const val = this._object[this._key];
1589
- return this._value = val === void 0 ? this._defaultValue : val;
1605
+ get active() {
1606
+ return !(this.flags & 1024);
1590
1607
  }
1591
- set value(newVal) {
1592
- 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
+ }
1593
1618
  }
1594
- get dep() {
1595
- 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
+ }
1596
1633
  }
1597
- }
1598
- class GetterRefImpl {
1599
- constructor(_getter) {
1600
- this._getter = _getter;
1601
- this["__v_isRef"] = true;
1602
- this["__v_isReadonly"] = true;
1603
- 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
+ }
1604
1644
  }
1605
- get value() {
1606
- 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);
1607
1665
  }
1608
1666
  }
1609
- function toRef(source, key, defaultValue) {
1610
- if (isRef(source)) {
1611
- return source;
1612
- } else if (isFunction(source)) {
1613
- return new GetterRefImpl(source);
1614
- } else if (isObject(source) && arguments.length > 1) {
1615
- return propertyToRef(source, key, defaultValue);
1616
- } else {
1617
- 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;
1618
1678
  }
1619
1679
  }
1620
- function propertyToRef(source, key, defaultValue) {
1621
- const val = source[key];
1622
- 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
+ }
1623
1688
  }
1624
1689
 
1625
1690
  class ComputedRefImpl {
1626
- constructor(fn, setter, isSSR) {
1691
+ constructor(fn, setter) {
1627
1692
  this.fn = fn;
1628
1693
  this.setter = setter;
1629
1694
  /**
1630
1695
  * @internal
1631
1696
  */
1632
1697
  this._value = void 0;
1633
- /**
1634
- * @internal
1635
- */
1636
- this.dep = new Dep(this);
1637
- /**
1638
- * @internal
1639
- */
1640
- this.__v_isRef = true;
1641
- // TODO isolatedDeclarations "__v_isReadonly"
1642
- // A computed is also a subscriber that tracks other deps
1643
- /**
1644
- * @internal
1645
- */
1698
+ this.subs = void 0;
1699
+ this.subsTail = void 0;
1646
1700
  this.deps = void 0;
1647
- /**
1648
- * @internal
1649
- */
1650
1701
  this.depsTail = void 0;
1702
+ this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
1651
1703
  /**
1652
1704
  * @internal
1653
1705
  */
1654
- this.flags = 16;
1655
- /**
1656
- * @internal
1657
- */
1658
- this.globalVersion = globalVersion - 1;
1659
- /**
1660
- * @internal
1661
- */
1662
- this.next = void 0;
1663
- // for backwards compat
1664
- this.effect = this;
1706
+ this.__v_isRef = true;
1665
1707
  this["__v_isReadonly"] = !setter;
1666
- 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;
1667
1717
  }
1668
1718
  /**
1669
1719
  * @internal
1720
+ * for backwards compat
1670
1721
  */
1671
- notify() {
1672
- this.flags |= 16;
1673
- if (!(this.flags & 8) && // avoid infinite self recursion
1674
- activeSub !== this) {
1675
- batch(this, true);
1722
+ get _dirty() {
1723
+ const flags = this.flags;
1724
+ if (flags & ReactiveFlags$1.Dirty) {
1676
1725
  return true;
1677
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
+ }
1678
1747
  }
1679
1748
  get value() {
1680
- const link = this.dep.track({
1681
- target: this,
1682
- type: "get",
1683
- key: "value"
1684
- }) ;
1685
- refreshComputed(this);
1686
- if (link) {
1687
- 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);
1688
1771
  }
1689
1772
  return this._value;
1690
1773
  }
@@ -1695,6 +1778,23 @@ class ComputedRefImpl {
1695
1778
  warn("Write operation failed: computed value is readonly");
1696
1779
  }
1697
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);
1698
1798
  }
1699
1799
  function computed(getterOrOptions, debugOptions, isSSR = false) {
1700
1800
  let getter;
@@ -1705,7 +1805,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
1705
1805
  getter = getterOrOptions.get;
1706
1806
  setter = getterOrOptions.set;
1707
1807
  }
1708
- const cRef = new ComputedRefImpl(getter, setter, isSSR);
1808
+ const cRef = new ComputedRefImpl(getter, setter);
1709
1809
  if (debugOptions && !isSSR) {
1710
1810
  cRef.onTrack = debugOptions.onTrack;
1711
1811
  cRef.onTrigger = debugOptions.onTrigger;
@@ -1742,177 +1842,155 @@ const WatchErrorCodes = {
1742
1842
  "4": "WATCH_CLEANUP"
1743
1843
  };
1744
1844
  const INITIAL_WATCHER_VALUE = {};
1745
- const cleanupMap = /* @__PURE__ */ new WeakMap();
1746
1845
  let activeWatcher = void 0;
1747
1846
  function getCurrentWatcher() {
1748
1847
  return activeWatcher;
1749
1848
  }
1750
1849
  function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1751
1850
  if (owner) {
1752
- let cleanups = cleanupMap.get(owner);
1753
- if (!cleanups) cleanupMap.set(owner, cleanups = []);
1754
- 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
+ }
1755
1857
  } else if (!failSilently) {
1756
1858
  warn(
1757
1859
  `onWatcherCleanup() was called when there was no active watcher to associate with.`
1758
1860
  );
1759
1861
  }
1760
1862
  }
1761
- function watch(source, cb, options = EMPTY_OBJ) {
1762
- const { immediate, deep, once, scheduler, augmentJob, call } = options;
1763
- const warnInvalidSource = (s) => {
1764
- (options.onWarn || warn)(
1765
- `Invalid watch source: `,
1766
- s,
1767
- `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1768
- );
1769
- };
1770
- const reactiveGetter = (source2) => {
1771
- if (deep) return source2;
1772
- if (isShallow(source2) || deep === false || deep === 0)
1773
- return traverse(source2, 1);
1774
- return traverse(source2);
1775
- };
1776
- let effect;
1777
- let getter;
1778
- let cleanup;
1779
- let boundCleanup;
1780
- let forceTrigger = false;
1781
- let isMultiSource = false;
1782
- if (isRef(source)) {
1783
- getter = () => source.value;
1784
- forceTrigger = isShallow(source);
1785
- } else if (isReactive(source)) {
1786
- getter = () => reactiveGetter(source);
1787
- forceTrigger = true;
1788
- } else if (isArray(source)) {
1789
- isMultiSource = true;
1790
- forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1791
- getter = () => source.map((s) => {
1792
- if (isRef(s)) {
1793
- return s.value;
1794
- } else if (isReactive(s)) {
1795
- return reactiveGetter(s);
1796
- } else if (isFunction(s)) {
1797
- 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;
1798
1892
  } else {
1799
- warnInvalidSource(s);
1800
- }
1801
- });
1802
- } else if (isFunction(source)) {
1803
- if (cb) {
1804
- getter = call ? () => call(source, 2) : source;
1805
- } else {
1806
- getter = () => {
1807
- if (cleanup) {
1808
- 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;
1809
1904
  try {
1810
- cleanup();
1905
+ return call ? call(source, 3, [
1906
+ this.boundCleanup
1907
+ ]) : source(this.boundCleanup);
1811
1908
  } finally {
1812
- resetTracking();
1909
+ activeWatcher = currentEffect;
1813
1910
  }
1814
- }
1815
- const currentEffect = activeWatcher;
1816
- activeWatcher = effect;
1817
- try {
1818
- return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1819
- } finally {
1820
- activeWatcher = currentEffect;
1821
- }
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();
1822
1933
  };
1823
1934
  }
1824
- } else {
1825
- getter = NOOP;
1826
- warnInvalidSource(source);
1827
- }
1828
- if (cb && deep) {
1829
- const baseGetter = getter;
1830
- const depth = deep === true ? Infinity : deep;
1831
- getter = () => traverse(baseGetter(), depth);
1832
- }
1833
- const scope = getCurrentScope();
1834
- const watchHandle = () => {
1835
- effect.stop();
1836
- if (scope && scope.active) {
1837
- 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;
1838
1940
  }
1839
- };
1840
- if (once && cb) {
1841
- const _cb = cb;
1842
- cb = (...args) => {
1843
- _cb(...args);
1844
- watchHandle();
1845
- };
1846
1941
  }
1847
- let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1848
- const job = (immediateFirstRun) => {
1849
- 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) {
1850
1946
  return;
1851
1947
  }
1852
- if (cb) {
1853
- const newValue = effect.run();
1854
- if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1855
- if (cleanup) {
1856
- cleanup();
1857
- }
1858
- const currentWatcher = activeWatcher;
1859
- activeWatcher = effect;
1860
- try {
1861
- const args = [
1862
- newValue,
1863
- // pass undefined as the old value when it's changed for the first time
1864
- oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1865
- boundCleanup
1866
- ];
1867
- oldValue = newValue;
1868
- call ? call(cb, 3, args) : (
1869
- // @ts-expect-error
1870
- cb(...args)
1871
- );
1872
- } finally {
1873
- activeWatcher = currentWatcher;
1874
- }
1875
- }
1876
- } else {
1877
- effect.run();
1948
+ const { immediate, deep, call } = this.options;
1949
+ if (initialRun && !immediate) {
1950
+ return;
1878
1951
  }
1879
- };
1880
- if (augmentJob) {
1881
- augmentJob(job);
1882
- }
1883
- effect = new ReactiveEffect(getter);
1884
- effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1885
- boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1886
- cleanup = effect.onStop = () => {
1887
- const cleanups = cleanupMap.get(effect);
1888
- if (cleanups) {
1889
- if (call) {
1890
- call(cleanups, 4);
1891
- } else {
1892
- 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;
1893
1969
  }
1894
- cleanupMap.delete(effect);
1895
- }
1896
- };
1897
- {
1898
- effect.onTrack = options.onTrack;
1899
- effect.onTrigger = options.onTrigger;
1900
- }
1901
- if (cb) {
1902
- if (immediate) {
1903
- job(true);
1904
- } else {
1905
- oldValue = effect.run();
1906
1970
  }
1907
- } else if (scheduler) {
1908
- scheduler(job.bind(null, true), true);
1909
- } else {
1910
- effect.run();
1911
1971
  }
1912
- watchHandle.pause = effect.pause.bind(effect);
1913
- watchHandle.resume = effect.resume.bind(effect);
1914
- watchHandle.stop = watchHandle;
1915
- 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;
1916
1994
  }
1917
1995
  function traverse(value, depth = Infinity, seen) {
1918
1996
  if (depth <= 0 || !isObject(value) || value["__v_skip"]) {
@@ -1947,4 +2025,4 @@ function traverse(value, depth = Infinity, seen) {
1947
2025
  return value;
1948
2026
  }
1949
2027
 
1950
- 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 };