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