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