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