@vue-mini/core 1.2.8 → 1.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-mini.cjs.js +1008 -942
- package/dist/vue-mini.cjs.prod.js +2 -2
- package/dist/vue-mini.esm-bundler.js +152 -123
- package/package.json +3 -3
package/dist/vue-mini.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-mini v1.
|
|
2
|
+
* vue-mini v1.3.0-alpha.1
|
|
3
3
|
* https://github.com/vue-mini/vue-mini
|
|
4
4
|
* (c) 2019-present Yang Mingshan
|
|
5
5
|
* @license MIT
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @vue/shared v3.5
|
|
10
|
+
* @vue/shared v3.6.0-alpha.5
|
|
11
11
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
12
12
|
* @license MIT
|
|
13
13
|
**/
|
|
@@ -22,12 +22,6 @@ const EMPTY_OBJ$1 = Object.freeze({}) ;
|
|
|
22
22
|
const NOOP = () => {
|
|
23
23
|
};
|
|
24
24
|
const extend$1 = Object.assign;
|
|
25
|
-
const remove = (arr, el) => {
|
|
26
|
-
const i = arr.indexOf(el);
|
|
27
|
-
if (i > -1) {
|
|
28
|
-
arr.splice(i, 1);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
25
|
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
32
26
|
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
33
27
|
const isArray$1 = Array.isArray;
|
|
@@ -65,7 +59,7 @@ const def = (obj, key, value, writable = false) => {
|
|
|
65
59
|
};
|
|
66
60
|
|
|
67
61
|
/**
|
|
68
|
-
* @vue/reactivity v3.5
|
|
62
|
+
* @vue/reactivity v3.6.0-alpha.5
|
|
69
63
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
70
64
|
* @license MIT
|
|
71
65
|
**/
|
|
@@ -74,600 +68,338 @@ function warn(msg, ...args) {
|
|
|
74
68
|
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this._on = 0;
|
|
89
|
-
/**
|
|
90
|
-
* @internal
|
|
91
|
-
*/
|
|
92
|
-
this.effects = [];
|
|
93
|
-
/**
|
|
94
|
-
* @internal
|
|
95
|
-
*/
|
|
96
|
-
this.cleanups = [];
|
|
97
|
-
this._isPaused = false;
|
|
98
|
-
this.parent = activeEffectScope;
|
|
99
|
-
if (!detached && activeEffectScope) {
|
|
100
|
-
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
|
101
|
-
this
|
|
102
|
-
) - 1;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
get active() {
|
|
106
|
-
return this._active;
|
|
107
|
-
}
|
|
108
|
-
pause() {
|
|
109
|
-
if (this._active) {
|
|
110
|
-
this._isPaused = true;
|
|
111
|
-
let i, l;
|
|
112
|
-
if (this.scopes) {
|
|
113
|
-
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
114
|
-
this.scopes[i].pause();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
118
|
-
this.effects[i].pause();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Resumes the effect scope, including all child scopes and effects.
|
|
124
|
-
*/
|
|
125
|
-
resume() {
|
|
126
|
-
if (this._active) {
|
|
127
|
-
if (this._isPaused) {
|
|
128
|
-
this._isPaused = false;
|
|
129
|
-
let i, l;
|
|
130
|
-
if (this.scopes) {
|
|
131
|
-
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
132
|
-
this.scopes[i].resume();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
136
|
-
this.effects[i].resume();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
run(fn) {
|
|
142
|
-
if (this._active) {
|
|
143
|
-
const currentEffectScope = activeEffectScope;
|
|
144
|
-
try {
|
|
145
|
-
activeEffectScope = this;
|
|
146
|
-
return fn();
|
|
147
|
-
} finally {
|
|
148
|
-
activeEffectScope = currentEffectScope;
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
warn(`cannot run an inactive effect scope.`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* This should only be called on non-detached scopes
|
|
156
|
-
* @internal
|
|
157
|
-
*/
|
|
158
|
-
on() {
|
|
159
|
-
if (++this._on === 1) {
|
|
160
|
-
this.prevScope = activeEffectScope;
|
|
161
|
-
activeEffectScope = this;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* This should only be called on non-detached scopes
|
|
166
|
-
* @internal
|
|
167
|
-
*/
|
|
168
|
-
off() {
|
|
169
|
-
if (this._on > 0 && --this._on === 0) {
|
|
170
|
-
activeEffectScope = this.prevScope;
|
|
171
|
-
this.prevScope = void 0;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
stop(fromParent) {
|
|
175
|
-
if (this._active) {
|
|
176
|
-
this._active = false;
|
|
177
|
-
let i, l;
|
|
178
|
-
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
179
|
-
this.effects[i].stop();
|
|
180
|
-
}
|
|
181
|
-
this.effects.length = 0;
|
|
182
|
-
for (i = 0, l = this.cleanups.length; i < l; i++) {
|
|
183
|
-
this.cleanups[i]();
|
|
184
|
-
}
|
|
185
|
-
this.cleanups.length = 0;
|
|
186
|
-
if (this.scopes) {
|
|
187
|
-
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
188
|
-
this.scopes[i].stop(true);
|
|
189
|
-
}
|
|
190
|
-
this.scopes.length = 0;
|
|
191
|
-
}
|
|
192
|
-
if (!this.detached && this.parent && !fromParent) {
|
|
193
|
-
const last = this.parent.scopes.pop();
|
|
194
|
-
if (last && last !== this) {
|
|
195
|
-
this.parent.scopes[this.index] = last;
|
|
196
|
-
last.index = this.index;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
this.parent = void 0;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function effectScope(detached) {
|
|
204
|
-
return new EffectScope(detached);
|
|
205
|
-
}
|
|
206
|
-
function getCurrentScope() {
|
|
207
|
-
return activeEffectScope;
|
|
208
|
-
}
|
|
209
|
-
function onScopeDispose(fn, failSilently = false) {
|
|
210
|
-
if (activeEffectScope) {
|
|
211
|
-
activeEffectScope.cleanups.push(fn);
|
|
212
|
-
} else if (!failSilently) {
|
|
213
|
-
warn(
|
|
214
|
-
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
let activeSub;
|
|
220
|
-
const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
|
|
221
|
-
class ReactiveEffect {
|
|
222
|
-
constructor(fn) {
|
|
223
|
-
this.fn = fn;
|
|
224
|
-
/**
|
|
225
|
-
* @internal
|
|
226
|
-
*/
|
|
227
|
-
this.deps = void 0;
|
|
228
|
-
/**
|
|
229
|
-
* @internal
|
|
230
|
-
*/
|
|
231
|
-
this.depsTail = void 0;
|
|
232
|
-
/**
|
|
233
|
-
* @internal
|
|
234
|
-
*/
|
|
235
|
-
this.flags = 1 | 4;
|
|
236
|
-
/**
|
|
237
|
-
* @internal
|
|
238
|
-
*/
|
|
239
|
-
this.next = void 0;
|
|
240
|
-
/**
|
|
241
|
-
* @internal
|
|
242
|
-
*/
|
|
243
|
-
this.cleanup = void 0;
|
|
244
|
-
this.scheduler = void 0;
|
|
245
|
-
if (activeEffectScope && activeEffectScope.active) {
|
|
246
|
-
activeEffectScope.effects.push(this);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
pause() {
|
|
250
|
-
this.flags |= 64;
|
|
251
|
-
}
|
|
252
|
-
resume() {
|
|
253
|
-
if (this.flags & 64) {
|
|
254
|
-
this.flags &= -65;
|
|
255
|
-
if (pausedQueueEffects.has(this)) {
|
|
256
|
-
pausedQueueEffects.delete(this);
|
|
257
|
-
this.trigger();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* @internal
|
|
263
|
-
*/
|
|
264
|
-
notify() {
|
|
265
|
-
if (this.flags & 2 && !(this.flags & 32)) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
if (!(this.flags & 8)) {
|
|
269
|
-
batch(this);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
run() {
|
|
273
|
-
if (!(this.flags & 1)) {
|
|
274
|
-
return this.fn();
|
|
275
|
-
}
|
|
276
|
-
this.flags |= 2;
|
|
277
|
-
cleanupEffect(this);
|
|
278
|
-
prepareDeps(this);
|
|
279
|
-
const prevEffect = activeSub;
|
|
280
|
-
const prevShouldTrack = shouldTrack;
|
|
281
|
-
activeSub = this;
|
|
282
|
-
shouldTrack = true;
|
|
283
|
-
try {
|
|
284
|
-
return this.fn();
|
|
285
|
-
} finally {
|
|
286
|
-
if (activeSub !== this) {
|
|
287
|
-
warn(
|
|
288
|
-
"Active effect was not restored correctly - this is likely a Vue internal bug."
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
cleanupDeps(this);
|
|
292
|
-
activeSub = prevEffect;
|
|
293
|
-
shouldTrack = prevShouldTrack;
|
|
294
|
-
this.flags &= -3;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
stop() {
|
|
298
|
-
if (this.flags & 1) {
|
|
299
|
-
for (let link = this.deps; link; link = link.nextDep) {
|
|
300
|
-
removeSub(link);
|
|
301
|
-
}
|
|
302
|
-
this.deps = this.depsTail = void 0;
|
|
303
|
-
cleanupEffect(this);
|
|
304
|
-
this.onStop && this.onStop();
|
|
305
|
-
this.flags &= -2;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
trigger() {
|
|
309
|
-
if (this.flags & 64) {
|
|
310
|
-
pausedQueueEffects.add(this);
|
|
311
|
-
} else if (this.scheduler) {
|
|
312
|
-
this.scheduler();
|
|
313
|
-
} else {
|
|
314
|
-
this.runIfDirty();
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* @internal
|
|
319
|
-
*/
|
|
320
|
-
runIfDirty() {
|
|
321
|
-
if (isDirty(this)) {
|
|
322
|
-
this.run();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
get dirty() {
|
|
326
|
-
return isDirty(this);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
71
|
+
var ReactiveFlags$1 = /* @__PURE__ */ ((ReactiveFlags2) => {
|
|
72
|
+
ReactiveFlags2[ReactiveFlags2["None"] = 0] = "None";
|
|
73
|
+
ReactiveFlags2[ReactiveFlags2["Mutable"] = 1] = "Mutable";
|
|
74
|
+
ReactiveFlags2[ReactiveFlags2["Watching"] = 2] = "Watching";
|
|
75
|
+
ReactiveFlags2[ReactiveFlags2["RecursedCheck"] = 4] = "RecursedCheck";
|
|
76
|
+
ReactiveFlags2[ReactiveFlags2["Recursed"] = 8] = "Recursed";
|
|
77
|
+
ReactiveFlags2[ReactiveFlags2["Dirty"] = 16] = "Dirty";
|
|
78
|
+
ReactiveFlags2[ReactiveFlags2["Pending"] = 32] = "Pending";
|
|
79
|
+
return ReactiveFlags2;
|
|
80
|
+
})(ReactiveFlags$1 || {});
|
|
81
|
+
const notifyBuffer = [];
|
|
329
82
|
let batchDepth = 0;
|
|
330
|
-
let
|
|
331
|
-
let
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
83
|
+
let activeSub = void 0;
|
|
84
|
+
let globalVersion = 0;
|
|
85
|
+
let notifyIndex = 0;
|
|
86
|
+
let notifyBufferLength = 0;
|
|
87
|
+
function setActiveSub(sub) {
|
|
88
|
+
try {
|
|
89
|
+
return activeSub;
|
|
90
|
+
} finally {
|
|
91
|
+
activeSub = sub;
|
|
338
92
|
}
|
|
339
|
-
sub.next = batchedSub;
|
|
340
|
-
batchedSub = sub;
|
|
341
93
|
}
|
|
342
94
|
function startBatch() {
|
|
343
|
-
batchDepth
|
|
95
|
+
++batchDepth;
|
|
344
96
|
}
|
|
345
97
|
function endBatch() {
|
|
346
|
-
if (
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
if (batchedComputed) {
|
|
350
|
-
let e = batchedComputed;
|
|
351
|
-
batchedComputed = void 0;
|
|
352
|
-
while (e) {
|
|
353
|
-
const next = e.next;
|
|
354
|
-
e.next = void 0;
|
|
355
|
-
e.flags &= -9;
|
|
356
|
-
e = next;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
let error;
|
|
360
|
-
while (batchedSub) {
|
|
361
|
-
let e = batchedSub;
|
|
362
|
-
batchedSub = void 0;
|
|
363
|
-
while (e) {
|
|
364
|
-
const next = e.next;
|
|
365
|
-
e.next = void 0;
|
|
366
|
-
e.flags &= -9;
|
|
367
|
-
if (e.flags & 1) {
|
|
368
|
-
try {
|
|
369
|
-
;
|
|
370
|
-
e.trigger();
|
|
371
|
-
} catch (err) {
|
|
372
|
-
if (!error) error = err;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
e = next;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
if (error) throw error;
|
|
379
|
-
}
|
|
380
|
-
function prepareDeps(sub) {
|
|
381
|
-
for (let link = sub.deps; link; link = link.nextDep) {
|
|
382
|
-
link.version = -1;
|
|
383
|
-
link.prevActiveLink = link.dep.activeLink;
|
|
384
|
-
link.dep.activeLink = link;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
function cleanupDeps(sub) {
|
|
388
|
-
let head;
|
|
389
|
-
let tail = sub.depsTail;
|
|
390
|
-
let link = tail;
|
|
391
|
-
while (link) {
|
|
392
|
-
const prev = link.prevDep;
|
|
393
|
-
if (link.version === -1) {
|
|
394
|
-
if (link === tail) tail = prev;
|
|
395
|
-
removeSub(link);
|
|
396
|
-
removeDep(link);
|
|
397
|
-
} else {
|
|
398
|
-
head = link;
|
|
399
|
-
}
|
|
400
|
-
link.dep.activeLink = link.prevActiveLink;
|
|
401
|
-
link.prevActiveLink = void 0;
|
|
402
|
-
link = prev;
|
|
98
|
+
if (!--batchDepth && notifyBufferLength) {
|
|
99
|
+
flush();
|
|
403
100
|
}
|
|
404
|
-
sub.deps = head;
|
|
405
|
-
sub.depsTail = tail;
|
|
406
|
-
}
|
|
407
|
-
function isDirty(sub) {
|
|
408
|
-
for (let link = sub.deps; link; link = link.nextDep) {
|
|
409
|
-
if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
|
|
410
|
-
return true;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
if (sub._dirty) {
|
|
414
|
-
return true;
|
|
415
|
-
}
|
|
416
|
-
return false;
|
|
417
101
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
102
|
+
function link(dep, sub) {
|
|
103
|
+
const prevDep = sub.depsTail;
|
|
104
|
+
if (prevDep !== void 0 && prevDep.dep === dep) {
|
|
420
105
|
return;
|
|
421
106
|
}
|
|
422
|
-
|
|
423
|
-
if (
|
|
107
|
+
const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
|
|
108
|
+
if (nextDep !== void 0 && nextDep.dep === dep) {
|
|
109
|
+
nextDep.version = globalVersion;
|
|
110
|
+
sub.depsTail = nextDep;
|
|
424
111
|
return;
|
|
425
112
|
}
|
|
426
|
-
|
|
427
|
-
if (
|
|
113
|
+
const prevSub = dep.subsTail;
|
|
114
|
+
if (prevSub !== void 0 && prevSub.version === globalVersion && prevSub.sub === sub) {
|
|
428
115
|
return;
|
|
429
116
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
computed._value = value;
|
|
442
|
-
dep.version++;
|
|
443
|
-
}
|
|
444
|
-
} catch (err) {
|
|
445
|
-
dep.version++;
|
|
446
|
-
throw err;
|
|
447
|
-
} finally {
|
|
448
|
-
activeSub = prevSub;
|
|
449
|
-
shouldTrack = prevShouldTrack;
|
|
450
|
-
cleanupDeps(computed);
|
|
451
|
-
computed.flags &= -3;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
function removeSub(link, soft = false) {
|
|
455
|
-
const { dep, prevSub, nextSub } = link;
|
|
456
|
-
if (prevSub) {
|
|
457
|
-
prevSub.nextSub = nextSub;
|
|
458
|
-
link.prevSub = void 0;
|
|
459
|
-
}
|
|
460
|
-
if (nextSub) {
|
|
461
|
-
nextSub.prevSub = prevSub;
|
|
462
|
-
link.nextSub = void 0;
|
|
463
|
-
}
|
|
464
|
-
if (dep.subsHead === link) {
|
|
465
|
-
dep.subsHead = nextSub;
|
|
117
|
+
const newLink = sub.depsTail = dep.subsTail = {
|
|
118
|
+
version: globalVersion,
|
|
119
|
+
dep,
|
|
120
|
+
sub,
|
|
121
|
+
prevDep,
|
|
122
|
+
nextDep,
|
|
123
|
+
prevSub,
|
|
124
|
+
nextSub: void 0
|
|
125
|
+
};
|
|
126
|
+
if (nextDep !== void 0) {
|
|
127
|
+
nextDep.prevDep = newLink;
|
|
466
128
|
}
|
|
467
|
-
if (
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
for (let l = dep.computed.deps; l; l = l.nextDep) {
|
|
472
|
-
removeSub(l, true);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
129
|
+
if (prevDep !== void 0) {
|
|
130
|
+
prevDep.nextDep = newLink;
|
|
131
|
+
} else {
|
|
132
|
+
sub.deps = newLink;
|
|
475
133
|
}
|
|
476
|
-
if (
|
|
477
|
-
|
|
134
|
+
if (prevSub !== void 0) {
|
|
135
|
+
prevSub.nextSub = newLink;
|
|
136
|
+
} else {
|
|
137
|
+
dep.subs = newLink;
|
|
478
138
|
}
|
|
479
139
|
}
|
|
480
|
-
function
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (nextDep) {
|
|
140
|
+
function unlink(link2, sub = link2.sub) {
|
|
141
|
+
const dep = link2.dep;
|
|
142
|
+
const prevDep = link2.prevDep;
|
|
143
|
+
const nextDep = link2.nextDep;
|
|
144
|
+
const nextSub = link2.nextSub;
|
|
145
|
+
const prevSub = link2.prevSub;
|
|
146
|
+
if (nextDep !== void 0) {
|
|
487
147
|
nextDep.prevDep = prevDep;
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
function effect(fn, options) {
|
|
492
|
-
if (fn.effect instanceof ReactiveEffect) {
|
|
493
|
-
fn = fn.effect.fn;
|
|
494
|
-
}
|
|
495
|
-
const e = new ReactiveEffect(fn);
|
|
496
|
-
if (options) {
|
|
497
|
-
extend$1(e, options);
|
|
498
|
-
}
|
|
499
|
-
try {
|
|
500
|
-
e.run();
|
|
501
|
-
} catch (err) {
|
|
502
|
-
e.stop();
|
|
503
|
-
throw err;
|
|
504
|
-
}
|
|
505
|
-
const runner = e.run.bind(e);
|
|
506
|
-
runner.effect = e;
|
|
507
|
-
return runner;
|
|
508
|
-
}
|
|
509
|
-
function stop(runner) {
|
|
510
|
-
runner.effect.stop();
|
|
511
|
-
}
|
|
512
|
-
let shouldTrack = true;
|
|
513
|
-
const trackStack = [];
|
|
514
|
-
function pauseTracking() {
|
|
515
|
-
trackStack.push(shouldTrack);
|
|
516
|
-
shouldTrack = false;
|
|
517
|
-
}
|
|
518
|
-
function resetTracking() {
|
|
519
|
-
const last = trackStack.pop();
|
|
520
|
-
shouldTrack = last === void 0 ? true : last;
|
|
521
|
-
}
|
|
522
|
-
function cleanupEffect(e) {
|
|
523
|
-
const { cleanup } = e;
|
|
524
|
-
e.cleanup = void 0;
|
|
525
|
-
if (cleanup) {
|
|
526
|
-
const prevSub = activeSub;
|
|
527
|
-
activeSub = void 0;
|
|
528
|
-
try {
|
|
529
|
-
cleanup();
|
|
530
|
-
} finally {
|
|
531
|
-
activeSub = prevSub;
|
|
532
|
-
}
|
|
148
|
+
} else {
|
|
149
|
+
sub.depsTail = prevDep;
|
|
533
150
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
constructor(sub, dep) {
|
|
539
|
-
this.sub = sub;
|
|
540
|
-
this.dep = dep;
|
|
541
|
-
this.version = dep.version;
|
|
542
|
-
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
|
151
|
+
if (prevDep !== void 0) {
|
|
152
|
+
prevDep.nextDep = nextDep;
|
|
153
|
+
} else {
|
|
154
|
+
sub.deps = nextDep;
|
|
543
155
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
this.computed = computed;
|
|
549
|
-
this.version = 0;
|
|
550
|
-
/**
|
|
551
|
-
* Link between this dep and the current active effect
|
|
552
|
-
*/
|
|
553
|
-
this.activeLink = void 0;
|
|
554
|
-
/**
|
|
555
|
-
* Doubly linked list representing the subscribing effects (tail)
|
|
556
|
-
*/
|
|
557
|
-
this.subs = void 0;
|
|
558
|
-
/**
|
|
559
|
-
* For object property deps cleanup
|
|
560
|
-
*/
|
|
561
|
-
this.map = void 0;
|
|
562
|
-
this.key = void 0;
|
|
563
|
-
/**
|
|
564
|
-
* Subscriber counter
|
|
565
|
-
*/
|
|
566
|
-
this.sc = 0;
|
|
567
|
-
/**
|
|
568
|
-
* @internal
|
|
569
|
-
*/
|
|
570
|
-
this.__v_skip = true;
|
|
571
|
-
{
|
|
572
|
-
this.subsHead = void 0;
|
|
573
|
-
}
|
|
156
|
+
if (nextSub !== void 0) {
|
|
157
|
+
nextSub.prevSub = prevSub;
|
|
158
|
+
} else {
|
|
159
|
+
dep.subsTail = prevSub;
|
|
574
160
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
161
|
+
if (prevSub !== void 0) {
|
|
162
|
+
prevSub.nextSub = nextSub;
|
|
163
|
+
} else if ((dep.subs = nextSub) === void 0) {
|
|
164
|
+
let toRemove = dep.deps;
|
|
165
|
+
if (toRemove !== void 0) {
|
|
166
|
+
do {
|
|
167
|
+
toRemove = unlink(toRemove, dep);
|
|
168
|
+
} while (toRemove !== void 0);
|
|
169
|
+
dep.flags |= 16 /* Dirty */;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return nextDep;
|
|
173
|
+
}
|
|
174
|
+
function propagate(link2) {
|
|
175
|
+
let next = link2.nextSub;
|
|
176
|
+
let stack;
|
|
177
|
+
top: do {
|
|
178
|
+
const sub = link2.sub;
|
|
179
|
+
let flags = sub.flags;
|
|
180
|
+
if (flags & (1 /* Mutable */ | 2 /* Watching */)) {
|
|
181
|
+
if (!(flags & (4 /* RecursedCheck */ | 8 /* Recursed */ | 16 /* Dirty */ | 32 /* Pending */))) {
|
|
182
|
+
sub.flags = flags | 32 /* Pending */;
|
|
183
|
+
} else if (!(flags & (4 /* RecursedCheck */ | 8 /* Recursed */))) {
|
|
184
|
+
flags = 0 /* None */;
|
|
185
|
+
} else if (!(flags & 4 /* RecursedCheck */)) {
|
|
186
|
+
sub.flags = flags & -9 /* Recursed */ | 32 /* Pending */;
|
|
187
|
+
} else if (!(flags & (16 /* Dirty */ | 32 /* Pending */)) && isValidLink(link2, sub)) {
|
|
188
|
+
sub.flags = flags | 8 /* Recursed */ | 32 /* Pending */;
|
|
189
|
+
flags &= 1 /* Mutable */;
|
|
584
190
|
} else {
|
|
585
|
-
|
|
586
|
-
activeSub.depsTail.nextDep = link;
|
|
587
|
-
activeSub.depsTail = link;
|
|
191
|
+
flags = 0 /* None */;
|
|
588
192
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
if (
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
activeSub.depsTail = link;
|
|
602
|
-
if (activeSub.deps === link) {
|
|
603
|
-
activeSub.deps = next;
|
|
193
|
+
if (flags & 2 /* Watching */) {
|
|
194
|
+
notifyBuffer[notifyBufferLength++] = sub;
|
|
195
|
+
}
|
|
196
|
+
if (flags & 1 /* Mutable */) {
|
|
197
|
+
const subSubs = sub.subs;
|
|
198
|
+
if (subSubs !== void 0) {
|
|
199
|
+
link2 = subSubs;
|
|
200
|
+
if (subSubs.nextSub !== void 0) {
|
|
201
|
+
stack = { value: next, prev: stack };
|
|
202
|
+
next = link2.nextSub;
|
|
203
|
+
}
|
|
204
|
+
continue;
|
|
604
205
|
}
|
|
605
206
|
}
|
|
606
207
|
}
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
{
|
|
611
|
-
effect: activeSub
|
|
612
|
-
},
|
|
613
|
-
debugInfo
|
|
614
|
-
)
|
|
615
|
-
);
|
|
208
|
+
if ((link2 = next) !== void 0) {
|
|
209
|
+
next = link2.nextSub;
|
|
210
|
+
continue;
|
|
616
211
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
212
|
+
while (stack !== void 0) {
|
|
213
|
+
link2 = stack.value;
|
|
214
|
+
stack = stack.prev;
|
|
215
|
+
if (link2 !== void 0) {
|
|
216
|
+
next = link2.nextSub;
|
|
217
|
+
continue top;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
} while (true);
|
|
222
|
+
}
|
|
223
|
+
function startTracking(sub) {
|
|
224
|
+
++globalVersion;
|
|
225
|
+
sub.depsTail = void 0;
|
|
226
|
+
sub.flags = sub.flags & -57 | 4 /* RecursedCheck */;
|
|
227
|
+
return setActiveSub(sub);
|
|
228
|
+
}
|
|
229
|
+
function endTracking(sub, prevSub) {
|
|
230
|
+
if (activeSub !== sub) {
|
|
231
|
+
warn(
|
|
232
|
+
"Active effect was not restored correctly - this is likely a Vue internal bug."
|
|
233
|
+
);
|
|
623
234
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
235
|
+
activeSub = prevSub;
|
|
236
|
+
const depsTail = sub.depsTail;
|
|
237
|
+
let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
238
|
+
while (toRemove !== void 0) {
|
|
239
|
+
toRemove = unlink(toRemove, sub);
|
|
240
|
+
}
|
|
241
|
+
sub.flags &= -5 /* RecursedCheck */;
|
|
242
|
+
}
|
|
243
|
+
function flush() {
|
|
244
|
+
while (notifyIndex < notifyBufferLength) {
|
|
245
|
+
const effect = notifyBuffer[notifyIndex];
|
|
246
|
+
notifyBuffer[notifyIndex++] = void 0;
|
|
247
|
+
effect.notify();
|
|
248
|
+
}
|
|
249
|
+
notifyIndex = 0;
|
|
250
|
+
notifyBufferLength = 0;
|
|
251
|
+
}
|
|
252
|
+
function checkDirty(link2, sub) {
|
|
253
|
+
let stack;
|
|
254
|
+
let checkDepth = 0;
|
|
255
|
+
top: do {
|
|
256
|
+
const dep = link2.dep;
|
|
257
|
+
const depFlags = dep.flags;
|
|
258
|
+
let dirty = false;
|
|
259
|
+
if (sub.flags & 16 /* Dirty */) {
|
|
260
|
+
dirty = true;
|
|
261
|
+
} else if ((depFlags & (1 /* Mutable */ | 16 /* Dirty */)) === (1 /* Mutable */ | 16 /* Dirty */)) {
|
|
262
|
+
if (dep.update()) {
|
|
263
|
+
const subs = dep.subs;
|
|
264
|
+
if (subs.nextSub !== void 0) {
|
|
265
|
+
shallowPropagate(subs);
|
|
266
|
+
}
|
|
267
|
+
dirty = true;
|
|
268
|
+
}
|
|
269
|
+
} else if ((depFlags & (1 /* Mutable */ | 32 /* Pending */)) === (1 /* Mutable */ | 32 /* Pending */)) {
|
|
270
|
+
if (link2.nextSub !== void 0 || link2.prevSub !== void 0) {
|
|
271
|
+
stack = { value: link2, prev: stack };
|
|
272
|
+
}
|
|
273
|
+
link2 = dep.deps;
|
|
274
|
+
sub = dep;
|
|
275
|
+
++checkDepth;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (!dirty && link2.nextDep !== void 0) {
|
|
279
|
+
link2 = link2.nextDep;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
while (checkDepth) {
|
|
283
|
+
--checkDepth;
|
|
284
|
+
const firstSub = sub.subs;
|
|
285
|
+
const hasMultipleSubs = firstSub.nextSub !== void 0;
|
|
286
|
+
if (hasMultipleSubs) {
|
|
287
|
+
link2 = stack.value;
|
|
288
|
+
stack = stack.prev;
|
|
289
|
+
} else {
|
|
290
|
+
link2 = firstSub;
|
|
291
|
+
}
|
|
292
|
+
if (dirty) {
|
|
293
|
+
if (sub.update()) {
|
|
294
|
+
if (hasMultipleSubs) {
|
|
295
|
+
shallowPropagate(firstSub);
|
|
638
296
|
}
|
|
297
|
+
sub = link2.sub;
|
|
298
|
+
continue;
|
|
639
299
|
}
|
|
300
|
+
} else {
|
|
301
|
+
sub.flags &= -33 /* Pending */;
|
|
640
302
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
303
|
+
sub = link2.sub;
|
|
304
|
+
if (link2.nextDep !== void 0) {
|
|
305
|
+
link2 = link2.nextDep;
|
|
306
|
+
continue top;
|
|
646
307
|
}
|
|
647
|
-
|
|
648
|
-
|
|
308
|
+
dirty = false;
|
|
309
|
+
}
|
|
310
|
+
return dirty;
|
|
311
|
+
} while (true);
|
|
312
|
+
}
|
|
313
|
+
function shallowPropagate(link2) {
|
|
314
|
+
do {
|
|
315
|
+
const sub = link2.sub;
|
|
316
|
+
const nextSub = link2.nextSub;
|
|
317
|
+
const subFlags = sub.flags;
|
|
318
|
+
if ((subFlags & (32 /* Pending */ | 16 /* Dirty */)) === 32 /* Pending */) {
|
|
319
|
+
sub.flags = subFlags | 16 /* Dirty */;
|
|
320
|
+
}
|
|
321
|
+
link2 = nextSub;
|
|
322
|
+
} while (link2 !== void 0);
|
|
323
|
+
}
|
|
324
|
+
function isValidLink(checkLink, sub) {
|
|
325
|
+
let link2 = sub.depsTail;
|
|
326
|
+
while (link2 !== void 0) {
|
|
327
|
+
if (link2 === checkLink) {
|
|
328
|
+
return true;
|
|
649
329
|
}
|
|
330
|
+
link2 = link2.prevDep;
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const triggerEventInfos = [];
|
|
336
|
+
function onTrack(sub, debugInfo) {
|
|
337
|
+
if (sub.onTrack) {
|
|
338
|
+
sub.onTrack(
|
|
339
|
+
extend$1(
|
|
340
|
+
{
|
|
341
|
+
effect: sub
|
|
342
|
+
},
|
|
343
|
+
debugInfo
|
|
344
|
+
)
|
|
345
|
+
);
|
|
650
346
|
}
|
|
651
347
|
}
|
|
652
|
-
function
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
348
|
+
function onTrigger(sub) {
|
|
349
|
+
if (sub.onTrigger) {
|
|
350
|
+
const debugInfo = triggerEventInfos[triggerEventInfos.length - 1];
|
|
351
|
+
sub.onTrigger(
|
|
352
|
+
extend$1(
|
|
353
|
+
{
|
|
354
|
+
effect: sub
|
|
355
|
+
},
|
|
356
|
+
debugInfo
|
|
357
|
+
)
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function setupOnTrigger(target) {
|
|
362
|
+
Object.defineProperty(target.prototype, "onTrigger", {
|
|
363
|
+
get() {
|
|
364
|
+
return this._onTrigger;
|
|
365
|
+
},
|
|
366
|
+
set(val) {
|
|
367
|
+
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
368
|
+
this._onTrigger = val;
|
|
661
369
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function setupFlagsHandler(target) {
|
|
373
|
+
target._flags = target.flags;
|
|
374
|
+
Object.defineProperty(target, "flags", {
|
|
375
|
+
get() {
|
|
376
|
+
return target._flags;
|
|
377
|
+
},
|
|
378
|
+
set(value) {
|
|
379
|
+
if (!(target._flags & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending)) && !!(value & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending))) {
|
|
380
|
+
onTrigger(this);
|
|
381
|
+
}
|
|
382
|
+
target._flags = value;
|
|
666
383
|
}
|
|
667
|
-
|
|
668
|
-
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
class Dep {
|
|
388
|
+
constructor(map, key) {
|
|
389
|
+
this.map = map;
|
|
390
|
+
this.key = key;
|
|
391
|
+
this._subs = void 0;
|
|
392
|
+
this.subsTail = void 0;
|
|
393
|
+
this.flags = ReactiveFlags$1.None;
|
|
394
|
+
}
|
|
395
|
+
get subs() {
|
|
396
|
+
return this._subs;
|
|
397
|
+
}
|
|
398
|
+
set subs(value) {
|
|
399
|
+
this._subs = value;
|
|
400
|
+
if (value === void 0) {
|
|
401
|
+
this.map.delete(this.key);
|
|
669
402
|
}
|
|
670
|
-
link.dep.subs = link;
|
|
671
403
|
}
|
|
672
404
|
}
|
|
673
405
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -681,36 +413,34 @@ const ARRAY_ITERATE_KEY = Symbol(
|
|
|
681
413
|
"Array iterate"
|
|
682
414
|
);
|
|
683
415
|
function track(target, type, key) {
|
|
684
|
-
if (
|
|
416
|
+
if (activeSub !== void 0) {
|
|
685
417
|
let depsMap = targetMap.get(target);
|
|
686
418
|
if (!depsMap) {
|
|
687
419
|
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
688
420
|
}
|
|
689
421
|
let dep = depsMap.get(key);
|
|
690
422
|
if (!dep) {
|
|
691
|
-
depsMap.set(key, dep = new Dep());
|
|
692
|
-
dep.map = depsMap;
|
|
693
|
-
dep.key = key;
|
|
423
|
+
depsMap.set(key, dep = new Dep(depsMap, key));
|
|
694
424
|
}
|
|
695
425
|
{
|
|
696
|
-
|
|
426
|
+
onTrack(activeSub, {
|
|
697
427
|
target,
|
|
698
428
|
type,
|
|
699
429
|
key
|
|
700
430
|
});
|
|
701
431
|
}
|
|
432
|
+
link(dep, activeSub);
|
|
702
433
|
}
|
|
703
434
|
}
|
|
704
435
|
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
705
436
|
const depsMap = targetMap.get(target);
|
|
706
437
|
if (!depsMap) {
|
|
707
|
-
globalVersion++;
|
|
708
438
|
return;
|
|
709
439
|
}
|
|
710
440
|
const run = (dep) => {
|
|
711
|
-
if (dep) {
|
|
441
|
+
if (dep !== void 0 && dep.subs !== void 0) {
|
|
712
442
|
{
|
|
713
|
-
|
|
443
|
+
triggerEventInfos.push({
|
|
714
444
|
target,
|
|
715
445
|
type,
|
|
716
446
|
key,
|
|
@@ -719,6 +449,11 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
719
449
|
oldTarget
|
|
720
450
|
});
|
|
721
451
|
}
|
|
452
|
+
propagate(dep.subs);
|
|
453
|
+
shallowPropagate(dep.subs);
|
|
454
|
+
{
|
|
455
|
+
triggerEventInfos.pop();
|
|
456
|
+
}
|
|
722
457
|
}
|
|
723
458
|
};
|
|
724
459
|
startBatch();
|
|
@@ -970,11 +705,11 @@ function searchProxy(self, method, args) {
|
|
|
970
705
|
return res;
|
|
971
706
|
}
|
|
972
707
|
function noTracking(self, method, args = []) {
|
|
973
|
-
pauseTracking();
|
|
974
708
|
startBatch();
|
|
709
|
+
const prevSub = setActiveSub();
|
|
975
710
|
const res = toRaw(self)[method].apply(self, args);
|
|
711
|
+
setActiveSub(prevSub);
|
|
976
712
|
endBatch();
|
|
977
|
-
resetTracking();
|
|
978
713
|
return res;
|
|
979
714
|
}
|
|
980
715
|
|
|
@@ -1020,14 +755,18 @@ class BaseReactiveHandler {
|
|
|
1020
755
|
return hasOwnProperty;
|
|
1021
756
|
}
|
|
1022
757
|
}
|
|
758
|
+
const wasRef = isRef(target);
|
|
1023
759
|
const res = Reflect.get(
|
|
1024
760
|
target,
|
|
1025
761
|
key,
|
|
1026
762
|
// if this is a proxy wrapping a ref, return methods using the raw ref
|
|
1027
763
|
// as receiver so that we don't have to call `toRaw` on the ref in all
|
|
1028
764
|
// its class methods
|
|
1029
|
-
|
|
765
|
+
wasRef ? target : receiver
|
|
1030
766
|
);
|
|
767
|
+
if (wasRef && key !== "value") {
|
|
768
|
+
return res;
|
|
769
|
+
}
|
|
1031
770
|
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
1032
771
|
return res;
|
|
1033
772
|
}
|
|
@@ -1487,33 +1226,47 @@ function isRef(r) {
|
|
|
1487
1226
|
return r ? r["__v_isRef"] === true : false;
|
|
1488
1227
|
}
|
|
1489
1228
|
function ref(value) {
|
|
1490
|
-
return createRef(value,
|
|
1229
|
+
return createRef(value, toReactive);
|
|
1491
1230
|
}
|
|
1492
1231
|
function shallowRef(value) {
|
|
1493
|
-
return createRef(value
|
|
1232
|
+
return createRef(value);
|
|
1494
1233
|
}
|
|
1495
|
-
function createRef(rawValue,
|
|
1234
|
+
function createRef(rawValue, wrap) {
|
|
1496
1235
|
if (isRef(rawValue)) {
|
|
1497
1236
|
return rawValue;
|
|
1498
1237
|
}
|
|
1499
|
-
return new RefImpl(rawValue,
|
|
1238
|
+
return new RefImpl(rawValue, wrap);
|
|
1500
1239
|
}
|
|
1501
1240
|
class RefImpl {
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
this
|
|
1505
|
-
this
|
|
1506
|
-
this.
|
|
1507
|
-
|
|
1508
|
-
|
|
1241
|
+
// TODO isolatedDeclarations "__v_isShallow"
|
|
1242
|
+
constructor(value, wrap) {
|
|
1243
|
+
this.subs = void 0;
|
|
1244
|
+
this.subsTail = void 0;
|
|
1245
|
+
this.flags = ReactiveFlags$1.Mutable;
|
|
1246
|
+
/**
|
|
1247
|
+
* @internal
|
|
1248
|
+
*/
|
|
1249
|
+
this.__v_isRef = true;
|
|
1250
|
+
// TODO isolatedDeclarations "__v_isRef"
|
|
1251
|
+
/**
|
|
1252
|
+
* @internal
|
|
1253
|
+
*/
|
|
1254
|
+
this.__v_isShallow = false;
|
|
1255
|
+
this._oldValue = this._rawValue = wrap ? toRaw(value) : value;
|
|
1256
|
+
this._value = wrap ? wrap(value) : value;
|
|
1257
|
+
this._wrap = wrap;
|
|
1258
|
+
this["__v_isShallow"] = !wrap;
|
|
1259
|
+
}
|
|
1260
|
+
get dep() {
|
|
1261
|
+
return this;
|
|
1509
1262
|
}
|
|
1510
1263
|
get value() {
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
}
|
|
1264
|
+
trackRef(this);
|
|
1265
|
+
if (this.flags & ReactiveFlags$1.Dirty && this.update()) {
|
|
1266
|
+
const subs = this.subs;
|
|
1267
|
+
if (subs !== void 0) {
|
|
1268
|
+
shallowPropagate(subs);
|
|
1269
|
+
}
|
|
1517
1270
|
}
|
|
1518
1271
|
return this._value;
|
|
1519
1272
|
}
|
|
@@ -1522,30 +1275,55 @@ class RefImpl {
|
|
|
1522
1275
|
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1523
1276
|
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
1524
1277
|
if (hasChanged(newValue, oldValue)) {
|
|
1278
|
+
this.flags |= ReactiveFlags$1.Dirty;
|
|
1525
1279
|
this._rawValue = newValue;
|
|
1526
|
-
this._value = useDirectValue ? newValue :
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1280
|
+
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1281
|
+
const subs = this.subs;
|
|
1282
|
+
if (subs !== void 0) {
|
|
1283
|
+
{
|
|
1284
|
+
triggerEventInfos.push({
|
|
1285
|
+
target: this,
|
|
1286
|
+
type: "set",
|
|
1287
|
+
key: "value",
|
|
1288
|
+
newValue,
|
|
1289
|
+
oldValue
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
propagate(subs);
|
|
1293
|
+
if (!batchDepth) {
|
|
1294
|
+
flush();
|
|
1295
|
+
}
|
|
1296
|
+
{
|
|
1297
|
+
triggerEventInfos.pop();
|
|
1298
|
+
}
|
|
1535
1299
|
}
|
|
1536
1300
|
}
|
|
1537
1301
|
}
|
|
1302
|
+
update() {
|
|
1303
|
+
this.flags &= ~ReactiveFlags$1.Dirty;
|
|
1304
|
+
return hasChanged(this._oldValue, this._oldValue = this._rawValue);
|
|
1305
|
+
}
|
|
1538
1306
|
}
|
|
1539
1307
|
function triggerRef(ref2) {
|
|
1540
|
-
|
|
1308
|
+
const dep = ref2.dep;
|
|
1309
|
+
if (dep !== void 0 && dep.subs !== void 0) {
|
|
1310
|
+
propagate(dep.subs);
|
|
1311
|
+
shallowPropagate(dep.subs);
|
|
1312
|
+
if (!batchDepth) {
|
|
1313
|
+
flush();
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
function trackRef(dep) {
|
|
1318
|
+
if (activeSub !== void 0) {
|
|
1541
1319
|
{
|
|
1542
|
-
|
|
1543
|
-
target:
|
|
1544
|
-
type: "
|
|
1545
|
-
key: "value"
|
|
1546
|
-
newValue: ref2._value
|
|
1320
|
+
onTrack(activeSub, {
|
|
1321
|
+
target: dep,
|
|
1322
|
+
type: "get",
|
|
1323
|
+
key: "value"
|
|
1547
1324
|
});
|
|
1548
1325
|
}
|
|
1326
|
+
link(dep, activeSub);
|
|
1549
1327
|
}
|
|
1550
1328
|
}
|
|
1551
1329
|
function unref(ref2) {
|
|
@@ -1571,13 +1349,21 @@ function proxyRefs(objectWithRefs) {
|
|
|
1571
1349
|
}
|
|
1572
1350
|
class CustomRefImpl {
|
|
1573
1351
|
constructor(factory) {
|
|
1352
|
+
this.subs = void 0;
|
|
1353
|
+
this.subsTail = void 0;
|
|
1354
|
+
this.flags = ReactiveFlags$1.None;
|
|
1574
1355
|
this["__v_isRef"] = true;
|
|
1575
1356
|
this._value = void 0;
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1357
|
+
const { get, set } = factory(
|
|
1358
|
+
() => trackRef(this),
|
|
1359
|
+
() => triggerRef(this)
|
|
1360
|
+
);
|
|
1578
1361
|
this._get = get;
|
|
1579
1362
|
this._set = set;
|
|
1580
1363
|
}
|
|
1364
|
+
get dep() {
|
|
1365
|
+
return this;
|
|
1366
|
+
}
|
|
1581
1367
|
get value() {
|
|
1582
1368
|
return this._value = this._get();
|
|
1583
1369
|
}
|
|
@@ -1589,9 +1375,6 @@ function customRef(factory) {
|
|
|
1589
1375
|
return new CustomRefImpl(factory);
|
|
1590
1376
|
}
|
|
1591
1377
|
function toRefs(object) {
|
|
1592
|
-
if (!isProxy(object)) {
|
|
1593
|
-
warn(`toRefs() expects a reactive object but received a plain one.`);
|
|
1594
|
-
}
|
|
1595
1378
|
const ret = isArray$1(object) ? new Array(object.length) : {};
|
|
1596
1379
|
for (const key in object) {
|
|
1597
1380
|
ret[key] = propertyToRef(object, key);
|
|
@@ -1630,101 +1413,366 @@ class ObjectRefImpl {
|
|
|
1630
1413
|
return;
|
|
1631
1414
|
}
|
|
1632
1415
|
}
|
|
1633
|
-
this._object[this._key] = newVal;
|
|
1416
|
+
this._object[this._key] = newVal;
|
|
1417
|
+
}
|
|
1418
|
+
get dep() {
|
|
1419
|
+
return getDepFromReactive(this._raw, this._key);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
class GetterRefImpl {
|
|
1423
|
+
constructor(_getter) {
|
|
1424
|
+
this._getter = _getter;
|
|
1425
|
+
this["__v_isRef"] = true;
|
|
1426
|
+
this["__v_isReadonly"] = true;
|
|
1427
|
+
this._value = void 0;
|
|
1428
|
+
}
|
|
1429
|
+
get value() {
|
|
1430
|
+
return this._value = this._getter();
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
function toRef(source, key, defaultValue) {
|
|
1434
|
+
if (isRef(source)) {
|
|
1435
|
+
return source;
|
|
1436
|
+
} else if (isFunction$1(source)) {
|
|
1437
|
+
return new GetterRefImpl(source);
|
|
1438
|
+
} else if (isObject$1(source) && arguments.length > 1) {
|
|
1439
|
+
return propertyToRef(source, key, defaultValue);
|
|
1440
|
+
} else {
|
|
1441
|
+
return ref(source);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
function propertyToRef(source, key, defaultValue) {
|
|
1445
|
+
return new ObjectRefImpl(source, key, defaultValue);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
const EffectFlags = {
|
|
1449
|
+
"ALLOW_RECURSE": 128,
|
|
1450
|
+
"PAUSED": 256};
|
|
1451
|
+
class ReactiveEffect {
|
|
1452
|
+
constructor(fn) {
|
|
1453
|
+
this.deps = void 0;
|
|
1454
|
+
this.depsTail = void 0;
|
|
1455
|
+
this.subs = void 0;
|
|
1456
|
+
this.subsTail = void 0;
|
|
1457
|
+
this.flags = ReactiveFlags$1.Watching | ReactiveFlags$1.Dirty;
|
|
1458
|
+
/**
|
|
1459
|
+
* @internal
|
|
1460
|
+
*/
|
|
1461
|
+
this.cleanups = [];
|
|
1462
|
+
/**
|
|
1463
|
+
* @internal
|
|
1464
|
+
*/
|
|
1465
|
+
this.cleanupsLength = 0;
|
|
1466
|
+
if (fn !== void 0) {
|
|
1467
|
+
this.fn = fn;
|
|
1468
|
+
}
|
|
1469
|
+
if (activeEffectScope) {
|
|
1470
|
+
link(this, activeEffectScope);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
// @ts-expect-error
|
|
1474
|
+
fn() {
|
|
1475
|
+
}
|
|
1476
|
+
get active() {
|
|
1477
|
+
return !(this.flags & 1024);
|
|
1478
|
+
}
|
|
1479
|
+
pause() {
|
|
1480
|
+
this.flags |= 256;
|
|
1481
|
+
}
|
|
1482
|
+
resume() {
|
|
1483
|
+
const flags = this.flags &= -257;
|
|
1484
|
+
if (flags & (ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending)) {
|
|
1485
|
+
this.notify();
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
notify() {
|
|
1489
|
+
if (!(this.flags & 256) && this.dirty) {
|
|
1490
|
+
this.run();
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
run() {
|
|
1494
|
+
if (!this.active) {
|
|
1495
|
+
return this.fn();
|
|
1496
|
+
}
|
|
1497
|
+
cleanup(this);
|
|
1498
|
+
const prevSub = startTracking(this);
|
|
1499
|
+
try {
|
|
1500
|
+
return this.fn();
|
|
1501
|
+
} finally {
|
|
1502
|
+
endTracking(this, prevSub);
|
|
1503
|
+
const flags = this.flags;
|
|
1504
|
+
if ((flags & (ReactiveFlags$1.Recursed | 128)) === (ReactiveFlags$1.Recursed | 128)) {
|
|
1505
|
+
this.flags = flags & ~ReactiveFlags$1.Recursed;
|
|
1506
|
+
this.notify();
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
stop() {
|
|
1511
|
+
if (!this.active) {
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
this.flags = 1024;
|
|
1515
|
+
let dep = this.deps;
|
|
1516
|
+
while (dep !== void 0) {
|
|
1517
|
+
dep = unlink(dep, this);
|
|
1518
|
+
}
|
|
1519
|
+
const sub = this.subs;
|
|
1520
|
+
if (sub !== void 0) {
|
|
1521
|
+
unlink(sub);
|
|
1522
|
+
}
|
|
1523
|
+
cleanup(this);
|
|
1524
|
+
}
|
|
1525
|
+
get dirty() {
|
|
1526
|
+
const flags = this.flags;
|
|
1527
|
+
if (flags & ReactiveFlags$1.Dirty) {
|
|
1528
|
+
return true;
|
|
1529
|
+
}
|
|
1530
|
+
if (flags & ReactiveFlags$1.Pending) {
|
|
1531
|
+
if (checkDirty(this.deps, this)) {
|
|
1532
|
+
this.flags = flags | ReactiveFlags$1.Dirty;
|
|
1533
|
+
return true;
|
|
1534
|
+
} else {
|
|
1535
|
+
this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
return false;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
{
|
|
1542
|
+
setupOnTrigger(ReactiveEffect);
|
|
1543
|
+
}
|
|
1544
|
+
function effect(fn, options) {
|
|
1545
|
+
if (fn.effect instanceof ReactiveEffect) {
|
|
1546
|
+
fn = fn.effect.fn;
|
|
1547
|
+
}
|
|
1548
|
+
const e = new ReactiveEffect(fn);
|
|
1549
|
+
if (options) {
|
|
1550
|
+
const { onStop, scheduler } = options;
|
|
1551
|
+
if (onStop) {
|
|
1552
|
+
options.onStop = void 0;
|
|
1553
|
+
const stop2 = e.stop.bind(e);
|
|
1554
|
+
e.stop = () => {
|
|
1555
|
+
stop2();
|
|
1556
|
+
onStop();
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
if (scheduler) {
|
|
1560
|
+
options.scheduler = void 0;
|
|
1561
|
+
e.notify = () => {
|
|
1562
|
+
if (!(e.flags & 256)) {
|
|
1563
|
+
scheduler();
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
extend$1(e, options);
|
|
1568
|
+
}
|
|
1569
|
+
try {
|
|
1570
|
+
e.run();
|
|
1571
|
+
} catch (err) {
|
|
1572
|
+
e.stop();
|
|
1573
|
+
throw err;
|
|
1574
|
+
}
|
|
1575
|
+
const runner = e.run.bind(e);
|
|
1576
|
+
runner.effect = e;
|
|
1577
|
+
return runner;
|
|
1578
|
+
}
|
|
1579
|
+
function stop(runner) {
|
|
1580
|
+
runner.effect.stop();
|
|
1581
|
+
}
|
|
1582
|
+
function cleanup(sub) {
|
|
1583
|
+
const l = sub.cleanupsLength;
|
|
1584
|
+
if (l) {
|
|
1585
|
+
for (let i = 0; i < l; i++) {
|
|
1586
|
+
sub.cleanups[i]();
|
|
1587
|
+
}
|
|
1588
|
+
sub.cleanupsLength = 0;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
let activeEffectScope;
|
|
1593
|
+
class EffectScope {
|
|
1594
|
+
constructor(detached = false) {
|
|
1595
|
+
this.deps = void 0;
|
|
1596
|
+
this.depsTail = void 0;
|
|
1597
|
+
this.subs = void 0;
|
|
1598
|
+
this.subsTail = void 0;
|
|
1599
|
+
this.flags = 0;
|
|
1600
|
+
/**
|
|
1601
|
+
* @internal
|
|
1602
|
+
*/
|
|
1603
|
+
this.cleanups = [];
|
|
1604
|
+
/**
|
|
1605
|
+
* @internal
|
|
1606
|
+
*/
|
|
1607
|
+
this.cleanupsLength = 0;
|
|
1608
|
+
if (!detached && activeEffectScope) {
|
|
1609
|
+
link(this, activeEffectScope);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
get active() {
|
|
1613
|
+
return !(this.flags & 1024);
|
|
1614
|
+
}
|
|
1615
|
+
pause() {
|
|
1616
|
+
if (!(this.flags & 256)) {
|
|
1617
|
+
this.flags |= 256;
|
|
1618
|
+
for (let link2 = this.deps; link2 !== void 0; link2 = link2.nextDep) {
|
|
1619
|
+
const dep = link2.dep;
|
|
1620
|
+
if ("pause" in dep) {
|
|
1621
|
+
dep.pause();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Resumes the effect scope, including all child scopes and effects.
|
|
1628
|
+
*/
|
|
1629
|
+
resume() {
|
|
1630
|
+
const flags = this.flags;
|
|
1631
|
+
if (flags & 256) {
|
|
1632
|
+
this.flags = flags & -257;
|
|
1633
|
+
for (let link2 = this.deps; link2 !== void 0; link2 = link2.nextDep) {
|
|
1634
|
+
const dep = link2.dep;
|
|
1635
|
+
if ("resume" in dep) {
|
|
1636
|
+
dep.resume();
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
run(fn) {
|
|
1642
|
+
const prevScope = activeEffectScope;
|
|
1643
|
+
try {
|
|
1644
|
+
activeEffectScope = this;
|
|
1645
|
+
return fn();
|
|
1646
|
+
} finally {
|
|
1647
|
+
activeEffectScope = prevScope;
|
|
1648
|
+
}
|
|
1634
1649
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1650
|
+
stop() {
|
|
1651
|
+
if (!this.active) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
this.flags = 1024;
|
|
1655
|
+
let dep = this.deps;
|
|
1656
|
+
while (dep !== void 0) {
|
|
1657
|
+
const node = dep.dep;
|
|
1658
|
+
if ("stop" in node) {
|
|
1659
|
+
dep = dep.nextDep;
|
|
1660
|
+
node.stop();
|
|
1661
|
+
} else {
|
|
1662
|
+
dep = unlink(dep, this);
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
const sub = this.subs;
|
|
1666
|
+
if (sub !== void 0) {
|
|
1667
|
+
unlink(sub);
|
|
1668
|
+
}
|
|
1669
|
+
cleanup(this);
|
|
1637
1670
|
}
|
|
1638
1671
|
}
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
this._getter = _getter;
|
|
1642
|
-
this["__v_isRef"] = true;
|
|
1643
|
-
this["__v_isReadonly"] = true;
|
|
1644
|
-
this._value = void 0;
|
|
1645
|
-
}
|
|
1646
|
-
get value() {
|
|
1647
|
-
return this._value = this._getter();
|
|
1648
|
-
}
|
|
1672
|
+
function effectScope(detached) {
|
|
1673
|
+
return new EffectScope(detached);
|
|
1649
1674
|
}
|
|
1650
|
-
function
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
return ref(source);
|
|
1675
|
+
function getCurrentScope() {
|
|
1676
|
+
return activeEffectScope;
|
|
1677
|
+
}
|
|
1678
|
+
function setCurrentScope(scope) {
|
|
1679
|
+
try {
|
|
1680
|
+
return activeEffectScope;
|
|
1681
|
+
} finally {
|
|
1682
|
+
activeEffectScope = scope;
|
|
1659
1683
|
}
|
|
1660
1684
|
}
|
|
1661
|
-
function
|
|
1662
|
-
|
|
1685
|
+
function onScopeDispose(fn, failSilently = false) {
|
|
1686
|
+
if (activeEffectScope !== void 0) {
|
|
1687
|
+
activeEffectScope.cleanups[activeEffectScope.cleanupsLength++] = fn;
|
|
1688
|
+
} else if (!failSilently) {
|
|
1689
|
+
warn(
|
|
1690
|
+
`onScopeDispose() is called when there is no active effect scope to be associated with.`
|
|
1691
|
+
);
|
|
1692
|
+
}
|
|
1663
1693
|
}
|
|
1664
1694
|
|
|
1665
1695
|
class ComputedRefImpl {
|
|
1666
|
-
constructor(fn, setter
|
|
1696
|
+
constructor(fn, setter) {
|
|
1667
1697
|
this.fn = fn;
|
|
1668
1698
|
this.setter = setter;
|
|
1669
1699
|
/**
|
|
1670
1700
|
* @internal
|
|
1671
1701
|
*/
|
|
1672
1702
|
this._value = void 0;
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
*/
|
|
1676
|
-
this.dep = new Dep(this);
|
|
1677
|
-
/**
|
|
1678
|
-
* @internal
|
|
1679
|
-
*/
|
|
1680
|
-
this.__v_isRef = true;
|
|
1681
|
-
// TODO isolatedDeclarations "__v_isReadonly"
|
|
1682
|
-
// A computed is also a subscriber that tracks other deps
|
|
1683
|
-
/**
|
|
1684
|
-
* @internal
|
|
1685
|
-
*/
|
|
1703
|
+
this.subs = void 0;
|
|
1704
|
+
this.subsTail = void 0;
|
|
1686
1705
|
this.deps = void 0;
|
|
1687
|
-
/**
|
|
1688
|
-
* @internal
|
|
1689
|
-
*/
|
|
1690
1706
|
this.depsTail = void 0;
|
|
1707
|
+
this.flags = ReactiveFlags$1.Mutable | ReactiveFlags$1.Dirty;
|
|
1691
1708
|
/**
|
|
1692
1709
|
* @internal
|
|
1693
1710
|
*/
|
|
1694
|
-
this.
|
|
1695
|
-
/**
|
|
1696
|
-
* @internal
|
|
1697
|
-
*/
|
|
1698
|
-
this.globalVersion = globalVersion - 1;
|
|
1699
|
-
/**
|
|
1700
|
-
* @internal
|
|
1701
|
-
*/
|
|
1702
|
-
this.next = void 0;
|
|
1703
|
-
// for backwards compat
|
|
1704
|
-
this.effect = this;
|
|
1711
|
+
this.__v_isRef = true;
|
|
1705
1712
|
this["__v_isReadonly"] = !setter;
|
|
1706
|
-
|
|
1713
|
+
}
|
|
1714
|
+
// TODO isolatedDeclarations "__v_isReadonly"
|
|
1715
|
+
// for backwards compat
|
|
1716
|
+
get effect() {
|
|
1717
|
+
return this;
|
|
1718
|
+
}
|
|
1719
|
+
// for backwards compat
|
|
1720
|
+
get dep() {
|
|
1721
|
+
return this;
|
|
1707
1722
|
}
|
|
1708
1723
|
/**
|
|
1709
1724
|
* @internal
|
|
1725
|
+
* for backwards compat
|
|
1710
1726
|
*/
|
|
1711
|
-
|
|
1712
|
-
this.flags
|
|
1713
|
-
if (
|
|
1714
|
-
activeSub !== this) {
|
|
1715
|
-
batch(this, true);
|
|
1727
|
+
get _dirty() {
|
|
1728
|
+
const flags = this.flags;
|
|
1729
|
+
if (flags & ReactiveFlags$1.Dirty) {
|
|
1716
1730
|
return true;
|
|
1717
1731
|
}
|
|
1732
|
+
if (flags & ReactiveFlags$1.Pending) {
|
|
1733
|
+
if (checkDirty(this.deps, this)) {
|
|
1734
|
+
this.flags = flags | ReactiveFlags$1.Dirty;
|
|
1735
|
+
return true;
|
|
1736
|
+
} else {
|
|
1737
|
+
this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
return false;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* @internal
|
|
1744
|
+
* for backwards compat
|
|
1745
|
+
*/
|
|
1746
|
+
set _dirty(v) {
|
|
1747
|
+
if (v) {
|
|
1748
|
+
this.flags |= ReactiveFlags$1.Dirty;
|
|
1749
|
+
} else {
|
|
1750
|
+
this.flags &= ~(ReactiveFlags$1.Dirty | ReactiveFlags$1.Pending);
|
|
1751
|
+
}
|
|
1718
1752
|
}
|
|
1719
1753
|
get value() {
|
|
1720
|
-
const
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1754
|
+
const flags = this.flags;
|
|
1755
|
+
if (flags & ReactiveFlags$1.Dirty || flags & ReactiveFlags$1.Pending && checkDirty(this.deps, this)) {
|
|
1756
|
+
if (this.update()) {
|
|
1757
|
+
const subs = this.subs;
|
|
1758
|
+
if (subs !== void 0) {
|
|
1759
|
+
shallowPropagate(subs);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
} else if (flags & ReactiveFlags$1.Pending) {
|
|
1763
|
+
this.flags = flags & ~ReactiveFlags$1.Pending;
|
|
1764
|
+
}
|
|
1765
|
+
if (activeSub !== void 0) {
|
|
1766
|
+
{
|
|
1767
|
+
onTrack(activeSub, {
|
|
1768
|
+
target: this,
|
|
1769
|
+
type: "get",
|
|
1770
|
+
key: "value"
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
link(this, activeSub);
|
|
1774
|
+
} else if (activeEffectScope !== void 0) {
|
|
1775
|
+
link(this, activeEffectScope);
|
|
1728
1776
|
}
|
|
1729
1777
|
return this._value;
|
|
1730
1778
|
}
|
|
@@ -1735,6 +1783,23 @@ class ComputedRefImpl {
|
|
|
1735
1783
|
warn("Write operation failed: computed value is readonly");
|
|
1736
1784
|
}
|
|
1737
1785
|
}
|
|
1786
|
+
update() {
|
|
1787
|
+
const prevSub = startTracking(this);
|
|
1788
|
+
try {
|
|
1789
|
+
const oldValue = this._value;
|
|
1790
|
+
const newValue = this.fn(oldValue);
|
|
1791
|
+
if (hasChanged(oldValue, newValue)) {
|
|
1792
|
+
this._value = newValue;
|
|
1793
|
+
return true;
|
|
1794
|
+
}
|
|
1795
|
+
return false;
|
|
1796
|
+
} finally {
|
|
1797
|
+
endTracking(this, prevSub);
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
{
|
|
1802
|
+
setupOnTrigger(ComputedRefImpl);
|
|
1738
1803
|
}
|
|
1739
1804
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1740
1805
|
let getter;
|
|
@@ -1745,7 +1810,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1745
1810
|
getter = getterOrOptions.get;
|
|
1746
1811
|
setter = getterOrOptions.set;
|
|
1747
1812
|
}
|
|
1748
|
-
const cRef = new ComputedRefImpl(getter, setter
|
|
1813
|
+
const cRef = new ComputedRefImpl(getter, setter);
|
|
1749
1814
|
if (debugOptions && !isSSR) {
|
|
1750
1815
|
cRef.onTrack = debugOptions.onTrack;
|
|
1751
1816
|
cRef.onTrigger = debugOptions.onTrigger;
|
|
@@ -1765,177 +1830,146 @@ const TriggerOpTypes = {
|
|
|
1765
1830
|
"CLEAR": "clear"
|
|
1766
1831
|
};
|
|
1767
1832
|
const INITIAL_WATCHER_VALUE = {};
|
|
1768
|
-
const cleanupMap = /* @__PURE__ */ new WeakMap();
|
|
1769
1833
|
let activeWatcher = void 0;
|
|
1770
1834
|
function getCurrentWatcher() {
|
|
1771
1835
|
return activeWatcher;
|
|
1772
1836
|
}
|
|
1773
1837
|
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
1774
1838
|
if (owner) {
|
|
1775
|
-
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1839
|
+
const { call } = owner.options;
|
|
1840
|
+
if (call) {
|
|
1841
|
+
owner.cleanups[owner.cleanupsLength++] = () => call(cleanupFn, 4);
|
|
1842
|
+
} else {
|
|
1843
|
+
owner.cleanups[owner.cleanupsLength++] = cleanupFn;
|
|
1844
|
+
}
|
|
1778
1845
|
} else if (!failSilently) {
|
|
1779
1846
|
warn(
|
|
1780
1847
|
`onWatcherCleanup() was called when there was no active watcher to associate with.`
|
|
1781
1848
|
);
|
|
1782
1849
|
}
|
|
1783
1850
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1814
|
-
getter = () => source.map((s) => {
|
|
1815
|
-
if (isRef(s)) {
|
|
1816
|
-
return s.value;
|
|
1817
|
-
} else if (isReactive(s)) {
|
|
1818
|
-
return reactiveGetter(s);
|
|
1819
|
-
} else if (isFunction$1(s)) {
|
|
1820
|
-
return call ? call(s, 2) : s();
|
|
1851
|
+
class WatcherEffect extends ReactiveEffect {
|
|
1852
|
+
constructor(source, cb, options = EMPTY_OBJ$1) {
|
|
1853
|
+
const { deep, once, call, onWarn } = options;
|
|
1854
|
+
let getter;
|
|
1855
|
+
let forceTrigger = false;
|
|
1856
|
+
let isMultiSource = false;
|
|
1857
|
+
if (isRef(source)) {
|
|
1858
|
+
getter = () => source.value;
|
|
1859
|
+
forceTrigger = isShallow(source);
|
|
1860
|
+
} else if (isReactive(source)) {
|
|
1861
|
+
getter = () => reactiveGetter(source, deep);
|
|
1862
|
+
forceTrigger = true;
|
|
1863
|
+
} else if (isArray$1(source)) {
|
|
1864
|
+
isMultiSource = true;
|
|
1865
|
+
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
1866
|
+
getter = () => source.map((s) => {
|
|
1867
|
+
if (isRef(s)) {
|
|
1868
|
+
return s.value;
|
|
1869
|
+
} else if (isReactive(s)) {
|
|
1870
|
+
return reactiveGetter(s, deep);
|
|
1871
|
+
} else if (isFunction$1(s)) {
|
|
1872
|
+
return call ? call(s, 2) : s();
|
|
1873
|
+
} else {
|
|
1874
|
+
warnInvalidSource(s, onWarn);
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
} else if (isFunction$1(source)) {
|
|
1878
|
+
if (cb) {
|
|
1879
|
+
getter = call ? () => call(source, 2) : source;
|
|
1821
1880
|
} else {
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1881
|
+
getter = () => {
|
|
1882
|
+
if (this.cleanupsLength) {
|
|
1883
|
+
const prevSub = setActiveSub();
|
|
1884
|
+
try {
|
|
1885
|
+
cleanup(this);
|
|
1886
|
+
} finally {
|
|
1887
|
+
setActiveSub(prevSub);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
const currentEffect = activeWatcher;
|
|
1891
|
+
activeWatcher = this;
|
|
1832
1892
|
try {
|
|
1833
|
-
|
|
1893
|
+
return call ? call(source, 3, [
|
|
1894
|
+
this.boundCleanup
|
|
1895
|
+
]) : source(this.boundCleanup);
|
|
1834
1896
|
} finally {
|
|
1835
|
-
|
|
1897
|
+
activeWatcher = currentEffect;
|
|
1836
1898
|
}
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
} else {
|
|
1902
|
+
getter = NOOP;
|
|
1903
|
+
warnInvalidSource(source, onWarn);
|
|
1904
|
+
}
|
|
1905
|
+
if (cb && deep) {
|
|
1906
|
+
const baseGetter = getter;
|
|
1907
|
+
const depth = deep === true ? Infinity : deep;
|
|
1908
|
+
getter = () => traverse(baseGetter(), depth);
|
|
1909
|
+
}
|
|
1910
|
+
super(getter);
|
|
1911
|
+
this.cb = cb;
|
|
1912
|
+
this.options = options;
|
|
1913
|
+
this.boundCleanup = (fn) => onWatcherCleanup(fn, false, this);
|
|
1914
|
+
this.forceTrigger = forceTrigger;
|
|
1915
|
+
this.isMultiSource = isMultiSource;
|
|
1916
|
+
if (once && cb) {
|
|
1917
|
+
const _cb = cb;
|
|
1918
|
+
cb = (...args) => {
|
|
1919
|
+
_cb(...args);
|
|
1920
|
+
this.stop();
|
|
1845
1921
|
};
|
|
1846
1922
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
const baseGetter = getter;
|
|
1853
|
-
const depth = deep === true ? Infinity : deep;
|
|
1854
|
-
getter = () => traverse(baseGetter(), depth);
|
|
1855
|
-
}
|
|
1856
|
-
const scope = getCurrentScope();
|
|
1857
|
-
const watchHandle = () => {
|
|
1858
|
-
effect.stop();
|
|
1859
|
-
if (scope && scope.active) {
|
|
1860
|
-
remove(scope.effects, effect);
|
|
1923
|
+
this.cb = cb;
|
|
1924
|
+
this.oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
1925
|
+
{
|
|
1926
|
+
this.onTrack = options.onTrack;
|
|
1927
|
+
this.onTrigger = options.onTrigger;
|
|
1861
1928
|
}
|
|
1862
|
-
};
|
|
1863
|
-
if (once && cb) {
|
|
1864
|
-
const _cb = cb;
|
|
1865
|
-
cb = (...args) => {
|
|
1866
|
-
_cb(...args);
|
|
1867
|
-
watchHandle();
|
|
1868
|
-
};
|
|
1869
1929
|
}
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1930
|
+
run(initialRun = false) {
|
|
1931
|
+
const oldValue = this.oldValue;
|
|
1932
|
+
const newValue = this.oldValue = super.run();
|
|
1933
|
+
if (!this.cb) {
|
|
1873
1934
|
return;
|
|
1874
1935
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
if (cleanup) {
|
|
1879
|
-
cleanup();
|
|
1880
|
-
}
|
|
1881
|
-
const currentWatcher = activeWatcher;
|
|
1882
|
-
activeWatcher = effect;
|
|
1883
|
-
try {
|
|
1884
|
-
const args = [
|
|
1885
|
-
newValue,
|
|
1886
|
-
// pass undefined as the old value when it's changed for the first time
|
|
1887
|
-
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1888
|
-
boundCleanup
|
|
1889
|
-
];
|
|
1890
|
-
oldValue = newValue;
|
|
1891
|
-
call ? call(cb, 3, args) : (
|
|
1892
|
-
// @ts-expect-error
|
|
1893
|
-
cb(...args)
|
|
1894
|
-
);
|
|
1895
|
-
} finally {
|
|
1896
|
-
activeWatcher = currentWatcher;
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
} else {
|
|
1900
|
-
effect.run();
|
|
1936
|
+
const { immediate, deep, call } = this.options;
|
|
1937
|
+
if (initialRun && !immediate) {
|
|
1938
|
+
return;
|
|
1901
1939
|
}
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
call(
|
|
1914
|
-
|
|
1915
|
-
|
|
1940
|
+
if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
1941
|
+
cleanup(this);
|
|
1942
|
+
const currentWatcher = activeWatcher;
|
|
1943
|
+
activeWatcher = this;
|
|
1944
|
+
try {
|
|
1945
|
+
const args = [
|
|
1946
|
+
newValue,
|
|
1947
|
+
// pass undefined as the old value when it's changed for the first time
|
|
1948
|
+
oldValue === INITIAL_WATCHER_VALUE ? void 0 : this.isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
1949
|
+
this.boundCleanup
|
|
1950
|
+
];
|
|
1951
|
+
call ? call(this.cb, 3, args) : (
|
|
1952
|
+
// @ts-expect-error
|
|
1953
|
+
this.cb(...args)
|
|
1954
|
+
);
|
|
1955
|
+
} finally {
|
|
1956
|
+
activeWatcher = currentWatcher;
|
|
1916
1957
|
}
|
|
1917
|
-
cleanupMap.delete(effect);
|
|
1918
|
-
}
|
|
1919
|
-
};
|
|
1920
|
-
{
|
|
1921
|
-
effect.onTrack = options.onTrack;
|
|
1922
|
-
effect.onTrigger = options.onTrigger;
|
|
1923
|
-
}
|
|
1924
|
-
if (cb) {
|
|
1925
|
-
if (immediate) {
|
|
1926
|
-
job(true);
|
|
1927
|
-
} else {
|
|
1928
|
-
oldValue = effect.run();
|
|
1929
1958
|
}
|
|
1930
|
-
} else if (scheduler) {
|
|
1931
|
-
scheduler(job.bind(null, true), true);
|
|
1932
|
-
} else {
|
|
1933
|
-
effect.run();
|
|
1934
1959
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1960
|
+
}
|
|
1961
|
+
function reactiveGetter(source, deep) {
|
|
1962
|
+
if (deep) return source;
|
|
1963
|
+
if (isShallow(source) || deep === false || deep === 0)
|
|
1964
|
+
return traverse(source, 1);
|
|
1965
|
+
return traverse(source);
|
|
1966
|
+
}
|
|
1967
|
+
function warnInvalidSource(s, onWarn) {
|
|
1968
|
+
(onWarn || warn)(
|
|
1969
|
+
`Invalid watch source: `,
|
|
1970
|
+
s,
|
|
1971
|
+
`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
|
|
1972
|
+
);
|
|
1939
1973
|
}
|
|
1940
1974
|
function traverse(value, depth = Infinity, seen) {
|
|
1941
1975
|
if (depth <= 0 || !isObject$1(value) || value["__v_skip"]) {
|
|
@@ -1970,122 +2004,104 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1970
2004
|
return value;
|
|
1971
2005
|
}
|
|
1972
2006
|
|
|
1973
|
-
const EMPTY_OBJ = Object.freeze({}) ;
|
|
1974
|
-
const isArray = Array.isArray;
|
|
1975
|
-
const extend = Object.assign;
|
|
1976
|
-
function exclude(obj, keys) {
|
|
1977
|
-
const ret = {};
|
|
1978
|
-
Object.keys(obj).forEach((key) => {
|
|
1979
|
-
if (!keys.includes(key)) {
|
|
1980
|
-
ret[key] = obj[key];
|
|
1981
|
-
}
|
|
1982
|
-
});
|
|
1983
|
-
return ret;
|
|
1984
|
-
}
|
|
1985
|
-
function getType(x) {
|
|
1986
|
-
return Object.prototype.toString.call(x).slice(8, -1);
|
|
1987
|
-
}
|
|
1988
|
-
function isSimpleValue(x) {
|
|
1989
|
-
const simpleTypes = new Set(['undefined', 'boolean', 'number', 'string']);
|
|
1990
|
-
return x === null || simpleTypes.has(typeof x);
|
|
1991
|
-
}
|
|
1992
|
-
function isObject(x) {
|
|
1993
|
-
return x !== null && typeof x === 'object';
|
|
1994
|
-
}
|
|
1995
|
-
function isPlainObject(x) {
|
|
1996
|
-
return getType(x) === 'Object';
|
|
1997
|
-
}
|
|
1998
|
-
function isFunction(x) {
|
|
1999
|
-
return typeof x === 'function';
|
|
2000
|
-
}
|
|
2001
|
-
function toHiddenField(name) {
|
|
2002
|
-
return `__${name}__`;
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
2007
|
var SchedulerJobFlags;
|
|
2006
2008
|
(function (SchedulerJobFlags) {
|
|
2007
2009
|
SchedulerJobFlags[SchedulerJobFlags["QUEUED"] = 1] = "QUEUED";
|
|
2008
|
-
SchedulerJobFlags[SchedulerJobFlags["ALLOW_RECURSE"] =
|
|
2010
|
+
SchedulerJobFlags[SchedulerJobFlags["ALLOW_RECURSE"] = 2] = "ALLOW_RECURSE";
|
|
2009
2011
|
})(SchedulerJobFlags || (SchedulerJobFlags = {}));
|
|
2010
|
-
const
|
|
2011
|
-
let
|
|
2012
|
-
|
|
2013
|
-
let
|
|
2012
|
+
const jobs = [];
|
|
2013
|
+
let postJobs = [];
|
|
2014
|
+
let activePostJobs = null;
|
|
2015
|
+
let currentFlushPromise = null;
|
|
2016
|
+
let jobsLength = 0;
|
|
2017
|
+
let flushIndex = 0;
|
|
2014
2018
|
let postFlushIndex = 0;
|
|
2015
2019
|
const resolvedPromise = /*@__PURE__*/ Promise.resolve();
|
|
2016
|
-
let currentFlushPromise = null;
|
|
2017
2020
|
const RECURSION_LIMIT = 100;
|
|
2018
2021
|
function nextTick(fn) {
|
|
2019
2022
|
const p = currentFlushPromise || resolvedPromise;
|
|
2020
2023
|
return fn ? p.then(fn) : p;
|
|
2021
2024
|
}
|
|
2022
2025
|
function queueJob(job) {
|
|
2023
|
-
if (
|
|
2024
|
-
|
|
2025
|
-
job.flags |= SchedulerJobFlags.QUEUED;
|
|
2026
|
+
if (queueJobWorker(job, jobs, jobsLength)) {
|
|
2027
|
+
jobsLength++;
|
|
2026
2028
|
queueFlush();
|
|
2027
2029
|
}
|
|
2028
2030
|
}
|
|
2031
|
+
function queueJobWorker(job, queue, length) {
|
|
2032
|
+
const flags = job.flags;
|
|
2033
|
+
if (!(flags & SchedulerJobFlags.QUEUED)) {
|
|
2034
|
+
job.flags = flags | SchedulerJobFlags.QUEUED;
|
|
2035
|
+
queue[length] = job;
|
|
2036
|
+
return true;
|
|
2037
|
+
}
|
|
2038
|
+
return false;
|
|
2039
|
+
}
|
|
2029
2040
|
function queueFlush() {
|
|
2030
2041
|
if (!currentFlushPromise) {
|
|
2042
|
+
// We don't flush post jobs on flushJobs's finally block, so we don't need `doFlushJobs` here.
|
|
2031
2043
|
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
2032
2044
|
}
|
|
2033
2045
|
}
|
|
2034
|
-
function queuePostFlushCb(
|
|
2035
|
-
|
|
2036
|
-
pendingPostFlushCbs.push(cb);
|
|
2037
|
-
cb.flags |= SchedulerJobFlags.QUEUED;
|
|
2038
|
-
}
|
|
2046
|
+
function queuePostFlushCb(job) {
|
|
2047
|
+
queueJobWorker(job, postJobs, postJobs.length);
|
|
2039
2048
|
}
|
|
2040
2049
|
function flushPostFlushCbs() {
|
|
2041
|
-
if (
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
const cb =
|
|
2050
|
+
if (postJobs.length) {
|
|
2051
|
+
activePostJobs = postJobs;
|
|
2052
|
+
postJobs = [];
|
|
2053
|
+
while (postFlushIndex < activePostJobs.length) {
|
|
2054
|
+
const cb = activePostJobs[postFlushIndex++];
|
|
2046
2055
|
if (cb.flags & SchedulerJobFlags.ALLOW_RECURSE) {
|
|
2047
2056
|
cb.flags &= ~SchedulerJobFlags.QUEUED;
|
|
2048
2057
|
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2058
|
+
try {
|
|
2059
|
+
cb();
|
|
2060
|
+
}
|
|
2061
|
+
finally {
|
|
2062
|
+
cb.flags &= ~SchedulerJobFlags.QUEUED;
|
|
2063
|
+
}
|
|
2051
2064
|
}
|
|
2052
|
-
|
|
2065
|
+
activePostJobs = null;
|
|
2053
2066
|
postFlushIndex = 0;
|
|
2054
2067
|
}
|
|
2055
2068
|
}
|
|
2056
2069
|
function flushJobs() {
|
|
2057
2070
|
const seen = new Map() ;
|
|
2058
|
-
// Conditional usage of checkRecursiveUpdate must be determined out of
|
|
2059
|
-
// try ... catch block since Rollup by default de-optimizes treeshaking
|
|
2060
|
-
// inside try-catch. This can leave all warning code unshaked. Although
|
|
2061
|
-
// they would get eventually shaken by a minifier like terser, some minifiers
|
|
2062
|
-
// would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
|
|
2063
|
-
const check = (job) => checkRecursiveUpdates(seen, job)
|
|
2064
|
-
;
|
|
2065
2071
|
try {
|
|
2066
|
-
|
|
2067
|
-
const job =
|
|
2072
|
+
while (flushIndex < jobsLength) {
|
|
2073
|
+
const job = jobs[flushIndex];
|
|
2074
|
+
jobs[flushIndex++] = undefined;
|
|
2075
|
+
// Conditional usage of checkRecursiveUpdate must be determined out of
|
|
2076
|
+
// try ... catch block since Rollup by default de-optimizes treeshaking
|
|
2077
|
+
// inside try-catch. This can leave all warning code unshaked. Although
|
|
2078
|
+
// they would get eventually shaken by a minifier like terser, some minifiers
|
|
2079
|
+
// would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
|
|
2068
2080
|
/* istanbul ignore if -- @preserve */
|
|
2069
|
-
if (true &&
|
|
2081
|
+
if (true && checkRecursiveUpdates(seen, job)) {
|
|
2070
2082
|
continue;
|
|
2071
2083
|
}
|
|
2072
2084
|
if (job.flags & SchedulerJobFlags.ALLOW_RECURSE) {
|
|
2073
2085
|
job.flags &= ~SchedulerJobFlags.QUEUED;
|
|
2074
2086
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2087
|
+
try {
|
|
2088
|
+
job();
|
|
2089
|
+
}
|
|
2090
|
+
finally {
|
|
2091
|
+
if (!(job.flags & SchedulerJobFlags.ALLOW_RECURSE)) {
|
|
2092
|
+
job.flags &= ~SchedulerJobFlags.QUEUED;
|
|
2093
|
+
}
|
|
2078
2094
|
}
|
|
2079
2095
|
}
|
|
2080
2096
|
}
|
|
2081
2097
|
finally {
|
|
2082
2098
|
// If there was an error we still need to clear the QUEUED flags
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2099
|
+
while (flushIndex < jobsLength) {
|
|
2100
|
+
jobs[flushIndex].flags &= ~SchedulerJobFlags.QUEUED;
|
|
2101
|
+
jobs[flushIndex++] = undefined;
|
|
2086
2102
|
}
|
|
2087
|
-
flushIndex =
|
|
2088
|
-
|
|
2103
|
+
flushIndex = 0;
|
|
2104
|
+
jobsLength = 0;
|
|
2089
2105
|
currentFlushPromise = null;
|
|
2090
2106
|
}
|
|
2091
2107
|
}
|
|
@@ -2102,6 +2118,38 @@ function checkRecursiveUpdates(seen, fn) {
|
|
|
2102
2118
|
return false;
|
|
2103
2119
|
}
|
|
2104
2120
|
|
|
2121
|
+
const EMPTY_OBJ = Object.freeze({}) ;
|
|
2122
|
+
const isArray = Array.isArray;
|
|
2123
|
+
const extend = Object.assign;
|
|
2124
|
+
function exclude(obj, keys) {
|
|
2125
|
+
const ret = {};
|
|
2126
|
+
Object.keys(obj).forEach((key) => {
|
|
2127
|
+
if (!keys.includes(key)) {
|
|
2128
|
+
ret[key] = obj[key];
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
return ret;
|
|
2132
|
+
}
|
|
2133
|
+
function getType(x) {
|
|
2134
|
+
return Object.prototype.toString.call(x).slice(8, -1);
|
|
2135
|
+
}
|
|
2136
|
+
function isSimpleValue(x) {
|
|
2137
|
+
const simpleTypes = new Set(['undefined', 'boolean', 'number', 'string']);
|
|
2138
|
+
return x === null || simpleTypes.has(typeof x);
|
|
2139
|
+
}
|
|
2140
|
+
function isObject(x) {
|
|
2141
|
+
return x !== null && typeof x === 'object';
|
|
2142
|
+
}
|
|
2143
|
+
function isPlainObject(x) {
|
|
2144
|
+
return getType(x) === 'Object';
|
|
2145
|
+
}
|
|
2146
|
+
function isFunction(x) {
|
|
2147
|
+
return typeof x === 'function';
|
|
2148
|
+
}
|
|
2149
|
+
function toHiddenField(name) {
|
|
2150
|
+
return `__${name}__`;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2105
2153
|
// Simple effect.
|
|
2106
2154
|
function watchEffect(effect, options) {
|
|
2107
2155
|
return doWatch(effect, null, options);
|
|
@@ -2123,8 +2171,46 @@ function watch(source, cb, options) {
|
|
|
2123
2171
|
}
|
|
2124
2172
|
return doWatch(source, cb, options);
|
|
2125
2173
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2174
|
+
class RenderWatcherEffect extends WatcherEffect {
|
|
2175
|
+
constructor(
|
|
2176
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
2177
|
+
source, cb, options, flush) {
|
|
2178
|
+
super(source, cb, options);
|
|
2179
|
+
this.flush = flush;
|
|
2180
|
+
const job = () => {
|
|
2181
|
+
if (this.dirty) {
|
|
2182
|
+
this.run();
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
// Important: mark the job as a watcher callback so that scheduler knows
|
|
2186
|
+
// it is allowed to self-trigger (#1727)
|
|
2187
|
+
if (cb) {
|
|
2188
|
+
this.flags |= EffectFlags.ALLOW_RECURSE;
|
|
2189
|
+
job.flags |= SchedulerJobFlags.ALLOW_RECURSE;
|
|
2190
|
+
}
|
|
2191
|
+
this.job = job;
|
|
2192
|
+
}
|
|
2193
|
+
notify() {
|
|
2194
|
+
const flags = this.flags;
|
|
2195
|
+
if (!(flags & EffectFlags.PAUSED)) {
|
|
2196
|
+
const flush = this.flush;
|
|
2197
|
+
const job = this.job;
|
|
2198
|
+
if (flush === 'post') {
|
|
2199
|
+
queuePostFlushCb(job);
|
|
2200
|
+
}
|
|
2201
|
+
else if (flush === 'pre') {
|
|
2202
|
+
queueJob(job);
|
|
2203
|
+
}
|
|
2204
|
+
else {
|
|
2205
|
+
job();
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
function doWatch(
|
|
2211
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
2212
|
+
source, cb, options = EMPTY_OBJ) {
|
|
2213
|
+
const { immediate, deep, flush = 'pre', once } = options;
|
|
2128
2214
|
if (!cb) {
|
|
2129
2215
|
if (immediate !== undefined) {
|
|
2130
2216
|
console.warn(`watch() "immediate" option is only respected when using the ` +
|
|
@@ -2140,32 +2226,22 @@ function doWatch(source, cb, options = EMPTY_OBJ) {
|
|
|
2140
2226
|
}
|
|
2141
2227
|
}
|
|
2142
2228
|
const baseWatchOptions = extend({}, options);
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
};
|
|
2229
|
+
const effect = new RenderWatcherEffect(source, cb, baseWatchOptions, flush);
|
|
2230
|
+
// Initial run
|
|
2231
|
+
if (cb) {
|
|
2232
|
+
effect.run(true);
|
|
2148
2233
|
}
|
|
2149
|
-
else if (flush
|
|
2150
|
-
|
|
2151
|
-
if (isFirstRun) {
|
|
2152
|
-
job();
|
|
2153
|
-
}
|
|
2154
|
-
else {
|
|
2155
|
-
queueJob(job);
|
|
2156
|
-
}
|
|
2157
|
-
};
|
|
2234
|
+
else if (flush === 'post') {
|
|
2235
|
+
queuePostFlushCb(effect.job);
|
|
2158
2236
|
}
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
const watchHandle = watch$1(source, cb, baseWatchOptions);
|
|
2168
|
-
return watchHandle;
|
|
2237
|
+
else {
|
|
2238
|
+
effect.run(true);
|
|
2239
|
+
}
|
|
2240
|
+
const stop = effect.stop.bind(effect);
|
|
2241
|
+
stop.pause = effect.pause.bind(effect);
|
|
2242
|
+
stop.resume = effect.resume.bind(effect);
|
|
2243
|
+
stop.stop = stop;
|
|
2244
|
+
return stop;
|
|
2169
2245
|
}
|
|
2170
2246
|
|
|
2171
2247
|
const provides = Object.create(null);
|
|
@@ -2202,28 +2278,18 @@ function unsetCurrentApp() {
|
|
|
2202
2278
|
}
|
|
2203
2279
|
function setCurrentPage(page) {
|
|
2204
2280
|
currentPage = page;
|
|
2205
|
-
|
|
2206
|
-
page.__scope__.on();
|
|
2281
|
+
return setCurrentScope(page.__scope__);
|
|
2207
2282
|
}
|
|
2208
|
-
function unsetCurrentPage() {
|
|
2209
|
-
|
|
2210
|
-
if (currentPage) {
|
|
2211
|
-
// @ts-expect-error
|
|
2212
|
-
currentPage.__scope__.off();
|
|
2213
|
-
}
|
|
2283
|
+
function unsetCurrentPage(scope) {
|
|
2284
|
+
setCurrentScope(scope);
|
|
2214
2285
|
currentPage = null;
|
|
2215
2286
|
}
|
|
2216
2287
|
function setCurrentComponent(component) {
|
|
2217
2288
|
currentComponent = component;
|
|
2218
|
-
|
|
2219
|
-
component.__scope__.on();
|
|
2289
|
+
return setCurrentScope(component.__scope__);
|
|
2220
2290
|
}
|
|
2221
|
-
function unsetCurrentComponent() {
|
|
2222
|
-
|
|
2223
|
-
if (currentComponent) {
|
|
2224
|
-
// @ts-expect-error
|
|
2225
|
-
currentComponent.__scope__.off();
|
|
2226
|
-
}
|
|
2291
|
+
function unsetCurrentComponent(scope) {
|
|
2292
|
+
setCurrentScope(scope);
|
|
2227
2293
|
currentComponent = null;
|
|
2228
2294
|
}
|
|
2229
2295
|
|
|
@@ -2361,7 +2427,7 @@ function definePage(optionsOrSetup, config) {
|
|
|
2361
2427
|
const originOnLoad = options[PageLifecycle.ON_LOAD];
|
|
2362
2428
|
options[PageLifecycle.ON_LOAD] = function (query) {
|
|
2363
2429
|
this.__scope__ = new EffectScope();
|
|
2364
|
-
setCurrentPage(this);
|
|
2430
|
+
const scope = setCurrentPage(this);
|
|
2365
2431
|
const context = {
|
|
2366
2432
|
is: this.is,
|
|
2367
2433
|
route: this.route,
|
|
@@ -2405,7 +2471,7 @@ function definePage(optionsOrSetup, config) {
|
|
|
2405
2471
|
this.setData(data, flushPostFlushCbs);
|
|
2406
2472
|
}
|
|
2407
2473
|
}
|
|
2408
|
-
unsetCurrentPage();
|
|
2474
|
+
unsetCurrentPage(scope);
|
|
2409
2475
|
if (originOnLoad !== undefined) {
|
|
2410
2476
|
originOnLoad.call(this, query);
|
|
2411
2477
|
}
|
|
@@ -2534,7 +2600,7 @@ function defineComponent(optionsOrSetup, config) {
|
|
|
2534
2600
|
options[ComponentLifecycle.ATTACHED];
|
|
2535
2601
|
options.lifetimes[ComponentLifecycle.ATTACHED] = function () {
|
|
2536
2602
|
this.__scope__ = new EffectScope();
|
|
2537
|
-
setCurrentComponent(this);
|
|
2603
|
+
const scope = setCurrentComponent(this);
|
|
2538
2604
|
const rawProps = {};
|
|
2539
2605
|
if (properties) {
|
|
2540
2606
|
properties.forEach((property) => {
|
|
@@ -2589,7 +2655,7 @@ function defineComponent(optionsOrSetup, config) {
|
|
|
2589
2655
|
this.setData(data, flushPostFlushCbs);
|
|
2590
2656
|
}
|
|
2591
2657
|
}
|
|
2592
|
-
unsetCurrentComponent();
|
|
2658
|
+
unsetCurrentComponent(scope);
|
|
2593
2659
|
if (originAttached !== undefined) {
|
|
2594
2660
|
originAttached.call(this);
|
|
2595
2661
|
}
|