@vue/reactivity 3.6.0-rc.13 → 3.6.0-rc.15
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 +204 -108
- package/dist/reactivity.cjs.prod.js +128 -57
- package/dist/reactivity.esm-browser.js +215 -111
- package/dist/reactivity.esm-browser.prod.js +2 -2
- package/dist/reactivity.esm-bundler.js +210 -110
- package/dist/reactivity.global.js +215 -111
- package/dist/reactivity.global.prod.js +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/reactivity v3.6.0-rc.
|
|
2
|
+
* @vue/reactivity v3.6.0-rc.15
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -41,16 +41,24 @@ var VueReactivity = (function(exports) {
|
|
|
41
41
|
};
|
|
42
42
|
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
43
43
|
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
44
|
+
const STRING_CACHE_MAX_SIZE = 1e4;
|
|
44
45
|
const cacheStringFunction = (fn) => {
|
|
45
|
-
|
|
46
|
+
let cache = Object.create(null);
|
|
47
|
+
let size = 0;
|
|
46
48
|
return ((str) => {
|
|
47
|
-
|
|
49
|
+
const hit = cache[str];
|
|
50
|
+
if (hit !== void 0) return hit;
|
|
51
|
+
if (++size > STRING_CACHE_MAX_SIZE) {
|
|
52
|
+
cache = Object.create(null);
|
|
53
|
+
size = 1;
|
|
54
|
+
}
|
|
55
|
+
return cache[str] = fn(str);
|
|
48
56
|
});
|
|
49
57
|
};
|
|
50
58
|
/**
|
|
51
59
|
* @private
|
|
52
60
|
*/
|
|
53
|
-
const capitalize = cacheStringFunction((str) => {
|
|
61
|
+
const capitalize = /*@__PURE__*/ cacheStringFunction((str) => {
|
|
54
62
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
55
63
|
});
|
|
56
64
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
@@ -63,41 +71,6 @@ var VueReactivity = (function(exports) {
|
|
|
63
71
|
});
|
|
64
72
|
};
|
|
65
73
|
//#endregion
|
|
66
|
-
//#region packages/reactivity/src/debug.ts
|
|
67
|
-
const triggerEventInfos = [];
|
|
68
|
-
function onTrack(sub, debugInfo) {
|
|
69
|
-
if (sub.onTrack) sub.onTrack(extend({ effect: sub }, debugInfo));
|
|
70
|
-
}
|
|
71
|
-
function onTrigger(sub) {
|
|
72
|
-
if (sub.onTrigger) {
|
|
73
|
-
const debugInfo = triggerEventInfos[triggerEventInfos.length - 1];
|
|
74
|
-
sub.onTrigger(extend({ effect: sub }, debugInfo));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function setupOnTrigger(target) {
|
|
78
|
-
Object.defineProperty(target.prototype, "onTrigger", {
|
|
79
|
-
get() {
|
|
80
|
-
return this._onTrigger;
|
|
81
|
-
},
|
|
82
|
-
set(val) {
|
|
83
|
-
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
84
|
-
this._onTrigger = val;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
function setupFlagsHandler(target) {
|
|
89
|
-
target._flags = target.flags;
|
|
90
|
-
Object.defineProperty(target, "flags", {
|
|
91
|
-
get() {
|
|
92
|
-
return target._flags;
|
|
93
|
-
},
|
|
94
|
-
set(value) {
|
|
95
|
-
if (!(target._flags & 48) && !!(value & 48)) onTrigger(this);
|
|
96
|
-
target._flags = value;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
74
|
//#region packages/reactivity/src/warning.ts
|
|
102
75
|
function warn(msg, ...args) {
|
|
103
76
|
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
@@ -107,13 +80,7 @@ var VueReactivity = (function(exports) {
|
|
|
107
80
|
const notifyBuffer = [];
|
|
108
81
|
let batchDepth = 0;
|
|
109
82
|
let activeSub = void 0;
|
|
110
|
-
|
|
111
|
-
function incRunDepth() {
|
|
112
|
-
++runDepth;
|
|
113
|
-
}
|
|
114
|
-
function decRunDepth() {
|
|
115
|
-
--runDepth;
|
|
116
|
-
}
|
|
83
|
+
const CHECKING = 512;
|
|
117
84
|
let globalVersion = 0;
|
|
118
85
|
let notifyIndex = 0;
|
|
119
86
|
let notifyBufferLength = 0;
|
|
@@ -162,6 +129,7 @@ var VueReactivity = (function(exports) {
|
|
|
162
129
|
const nextDep = link.nextDep;
|
|
163
130
|
const nextSub = link.nextSub;
|
|
164
131
|
const prevSub = link.prevSub;
|
|
132
|
+
link.prevDep = link.nextDep = link.prevSub = link.nextSub = void 0;
|
|
165
133
|
if (nextDep !== void 0) nextDep.prevDep = prevDep;
|
|
166
134
|
else sub.depsTail = prevDep;
|
|
167
135
|
if (prevDep !== void 0) prevDep.nextDep = nextDep;
|
|
@@ -169,7 +137,7 @@ var VueReactivity = (function(exports) {
|
|
|
169
137
|
if (nextSub !== void 0) nextSub.prevSub = prevSub;
|
|
170
138
|
else dep.subsTail = prevSub;
|
|
171
139
|
if (prevSub !== void 0) prevSub.nextSub = nextSub;
|
|
172
|
-
else if ((dep.subs = nextSub) === void 0) {
|
|
140
|
+
else if ((dep.subs = nextSub) === void 0 && dep.flags & 1) {
|
|
173
141
|
let toRemove = dep.deps;
|
|
174
142
|
if (toRemove !== void 0) {
|
|
175
143
|
do
|
|
@@ -187,14 +155,12 @@ var VueReactivity = (function(exports) {
|
|
|
187
155
|
const sub = link.sub;
|
|
188
156
|
let flags = sub.flags;
|
|
189
157
|
if (flags & 3) {
|
|
190
|
-
if (!(flags &
|
|
191
|
-
|
|
192
|
-
if (runDepth) sub.flags |= 8;
|
|
193
|
-
} else if (!(flags & 12)) flags = 0;
|
|
158
|
+
if (!(flags & 44)) sub.flags = flags | 32;
|
|
159
|
+
else if (!(flags & 12)) flags = 0;
|
|
194
160
|
else if (!(flags & 4)) sub.flags = flags & -9 | 32;
|
|
195
161
|
else if (!(flags & 48) && isValidLink(link, sub)) {
|
|
196
162
|
sub.flags = flags | 40;
|
|
197
|
-
flags
|
|
163
|
+
flags = sub === activeSub || activeSub === void 0 ? 0 : flags & 1;
|
|
198
164
|
} else flags = 0;
|
|
199
165
|
if (flags & 2) notifyBuffer[notifyBufferLength++] = sub;
|
|
200
166
|
if (flags & 1) {
|
|
@@ -230,7 +196,7 @@ var VueReactivity = (function(exports) {
|
|
|
230
196
|
function startTracking(sub) {
|
|
231
197
|
++globalVersion;
|
|
232
198
|
sub.depsTail = void 0;
|
|
233
|
-
sub.flags = sub.flags & -
|
|
199
|
+
sub.flags = sub.flags & -569 | 4;
|
|
234
200
|
return setActiveSub(sub);
|
|
235
201
|
}
|
|
236
202
|
function endTracking(sub, prevSub) {
|
|
@@ -238,8 +204,11 @@ var VueReactivity = (function(exports) {
|
|
|
238
204
|
activeSub = prevSub;
|
|
239
205
|
const depsTail = sub.depsTail;
|
|
240
206
|
let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
241
|
-
while (toRemove !== void 0)
|
|
242
|
-
|
|
207
|
+
while (toRemove !== void 0) {
|
|
208
|
+
unlink(toRemove, sub);
|
|
209
|
+
toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
210
|
+
}
|
|
211
|
+
if ((sub.flags &= -5) & 8) markRecursed(sub);
|
|
243
212
|
}
|
|
244
213
|
function flush() {
|
|
245
214
|
let hasError = false;
|
|
@@ -261,45 +230,67 @@ var VueReactivity = (function(exports) {
|
|
|
261
230
|
if (hasError) throw error;
|
|
262
231
|
}
|
|
263
232
|
function checkDirty(link, sub) {
|
|
233
|
+
try {
|
|
234
|
+
return walkDirty(link, sub);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
markStale(sub);
|
|
237
|
+
throw err;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function walkDirty(link, sub) {
|
|
241
|
+
const root = sub;
|
|
264
242
|
let stack;
|
|
265
243
|
let checkDepth = 0;
|
|
244
|
+
let staleDepth = 0;
|
|
245
|
+
let staleFloor = 0;
|
|
266
246
|
top: do {
|
|
267
247
|
const dep = link.dep;
|
|
268
248
|
const depFlags = dep.flags;
|
|
269
249
|
let dirty = false;
|
|
270
250
|
if (sub.flags & 16) dirty = true;
|
|
271
251
|
else if ((depFlags & 17) === 17) {
|
|
272
|
-
const subs = dep.subs;
|
|
273
252
|
if (dep.update()) {
|
|
274
|
-
|
|
253
|
+
const subs = dep.subs;
|
|
254
|
+
if (subs !== void 0 && (subs !== link || subs.nextSub !== void 0)) shallowPropagate(subs);
|
|
275
255
|
dirty = true;
|
|
276
256
|
}
|
|
277
257
|
} else if ((depFlags & 33) === 33) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
258
|
+
const depth = dep === root ? 0 : depFlags & CHECKING ? checkingDepth(dep, stack, checkDepth) : -1;
|
|
259
|
+
if (depth < 0) {
|
|
260
|
+
if (link.nextSub !== void 0 || link.prevSub !== void 0) dep.flags = depFlags | CHECKING;
|
|
261
|
+
stack = {
|
|
262
|
+
value: link,
|
|
263
|
+
prev: stack
|
|
264
|
+
};
|
|
265
|
+
link = dep.deps;
|
|
266
|
+
sub = dep;
|
|
267
|
+
++checkDepth;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (depth < checkDepth) {
|
|
271
|
+
staleFloor = staleDepth && staleFloor < depth ? staleFloor : depth;
|
|
272
|
+
staleDepth = checkDepth;
|
|
273
|
+
}
|
|
286
274
|
}
|
|
287
275
|
if (!dirty && link.nextDep !== void 0) {
|
|
288
276
|
link = link.nextDep;
|
|
289
277
|
continue;
|
|
290
278
|
}
|
|
291
279
|
while (checkDepth) {
|
|
280
|
+
const stale = checkDepth === staleDepth;
|
|
281
|
+
if (stale && --staleDepth === staleFloor) staleDepth = 0;
|
|
292
282
|
--checkDepth;
|
|
293
283
|
link = stack.value;
|
|
294
284
|
stack = stack.prev;
|
|
295
285
|
if (dirty) {
|
|
296
|
-
const subs = sub.subs;
|
|
297
286
|
if (sub.update()) {
|
|
298
|
-
|
|
287
|
+
const subs = sub.subs;
|
|
288
|
+
if (subs !== void 0 && (subs !== link || subs.nextSub !== void 0)) shallowPropagate(subs);
|
|
299
289
|
sub = link.sub;
|
|
300
290
|
continue;
|
|
301
291
|
}
|
|
302
|
-
} else sub.flags
|
|
292
|
+
} else if (stale) sub.flags = sub.flags & -545 | 16;
|
|
293
|
+
else sub.flags &= -545;
|
|
303
294
|
sub = link.sub;
|
|
304
295
|
if (link.nextDep !== void 0) {
|
|
305
296
|
link = link.nextDep;
|
|
@@ -307,9 +298,21 @@ var VueReactivity = (function(exports) {
|
|
|
307
298
|
}
|
|
308
299
|
dirty = false;
|
|
309
300
|
}
|
|
310
|
-
return dirty && !!sub.flags;
|
|
301
|
+
return (dirty || !!(sub.flags & 16)) && !!sub.flags;
|
|
311
302
|
} while (true);
|
|
312
303
|
}
|
|
304
|
+
function checkingDepth(dep, stack, depth) {
|
|
305
|
+
for (; stack !== void 0; stack = stack.prev, --depth) if (stack.value.dep === dep) return depth;
|
|
306
|
+
return -1;
|
|
307
|
+
}
|
|
308
|
+
function markStale(sub) {
|
|
309
|
+
const nodes = [sub];
|
|
310
|
+
do {
|
|
311
|
+
sub = nodes.pop();
|
|
312
|
+
sub.flags = sub.flags & -33 | 16;
|
|
313
|
+
for (let link = sub.deps; link !== void 0; link = link.nextDep) if (link.dep.flags & 32) nodes.push(link.dep);
|
|
314
|
+
} while (nodes.length);
|
|
315
|
+
}
|
|
313
316
|
function shallowPropagate(link) {
|
|
314
317
|
do {
|
|
315
318
|
const sub = link.sub;
|
|
@@ -327,6 +330,71 @@ var VueReactivity = (function(exports) {
|
|
|
327
330
|
}
|
|
328
331
|
return false;
|
|
329
332
|
}
|
|
333
|
+
function markRecursed(sub) {
|
|
334
|
+
const nodes = [sub];
|
|
335
|
+
do {
|
|
336
|
+
sub = nodes.pop();
|
|
337
|
+
for (let link = sub.deps; link !== void 0; link = link.nextDep) {
|
|
338
|
+
const dep = link.dep;
|
|
339
|
+
if ((dep.flags & 40) === 32) {
|
|
340
|
+
dep.flags |= 8;
|
|
341
|
+
nodes.push(dep);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
} while (nodes.length);
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region packages/reactivity/src/debug.ts
|
|
348
|
+
const triggered = [];
|
|
349
|
+
function onTrack(sub, debugInfo) {
|
|
350
|
+
if (sub.onTrack) sub.onTrack(extend({ effect: sub }, debugInfo));
|
|
351
|
+
}
|
|
352
|
+
function onTrigger(sub, debugInfo) {
|
|
353
|
+
if (sub.onTrigger) sub.onTrigger(extend({ effect: sub }, debugInfo));
|
|
354
|
+
}
|
|
355
|
+
function startTrigger() {
|
|
356
|
+
triggered.push([]);
|
|
357
|
+
}
|
|
358
|
+
function endTrigger(debugInfo) {
|
|
359
|
+
const subs = triggered.pop();
|
|
360
|
+
if (subs.length) {
|
|
361
|
+
startBatch();
|
|
362
|
+
try {
|
|
363
|
+
for (let i = 0; i < subs.length; i++) {
|
|
364
|
+
const sub = subs[i];
|
|
365
|
+
if (sub.flags & 3) onTrigger(sub, debugInfo);
|
|
366
|
+
}
|
|
367
|
+
} finally {
|
|
368
|
+
endBatch();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function setupOnTrigger(target) {
|
|
373
|
+
Object.defineProperty(target.prototype, "onTrigger", {
|
|
374
|
+
get() {
|
|
375
|
+
return this._onTrigger;
|
|
376
|
+
},
|
|
377
|
+
set(val) {
|
|
378
|
+
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
379
|
+
this._onTrigger = val;
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
function setupFlagsHandler(target) {
|
|
384
|
+
target._flags = target.flags;
|
|
385
|
+
Object.defineProperty(target, "flags", {
|
|
386
|
+
get() {
|
|
387
|
+
return target._flags;
|
|
388
|
+
},
|
|
389
|
+
set(value) {
|
|
390
|
+
if (!(target._flags & 48) && !!(value & 48)) {
|
|
391
|
+
if (triggered.length) triggered[triggered.length - 1].push(this);
|
|
392
|
+
else onTrigger(this);
|
|
393
|
+
}
|
|
394
|
+
target._flags = value;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
330
398
|
//#endregion
|
|
331
399
|
//#region packages/reactivity/src/dep.ts
|
|
332
400
|
var Dep = class {
|
|
@@ -365,17 +433,17 @@ var VueReactivity = (function(exports) {
|
|
|
365
433
|
function triggerDep(dep, target = dep, key = "value", newValue, oldValue) {
|
|
366
434
|
const subs = dep.subs;
|
|
367
435
|
if (subs !== void 0) {
|
|
368
|
-
|
|
436
|
+
startTrigger();
|
|
437
|
+
propagate(subs);
|
|
438
|
+
shallowPropagate(subs);
|
|
439
|
+
endTrigger({
|
|
369
440
|
target,
|
|
370
441
|
type: "set",
|
|
371
442
|
key,
|
|
372
443
|
newValue,
|
|
373
444
|
oldValue
|
|
374
445
|
});
|
|
375
|
-
propagate(subs);
|
|
376
|
-
shallowPropagate(subs);
|
|
377
446
|
if (!batchDepth) flush();
|
|
378
|
-
triggerEventInfos.pop();
|
|
379
447
|
}
|
|
380
448
|
}
|
|
381
449
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -419,20 +487,12 @@ var VueReactivity = (function(exports) {
|
|
|
419
487
|
if (!depsMap) return;
|
|
420
488
|
const run = (dep) => {
|
|
421
489
|
if (dep !== void 0 && dep.subs !== void 0) {
|
|
422
|
-
triggerEventInfos.push({
|
|
423
|
-
target,
|
|
424
|
-
type,
|
|
425
|
-
key,
|
|
426
|
-
newValue,
|
|
427
|
-
oldValue,
|
|
428
|
-
oldTarget
|
|
429
|
-
});
|
|
430
490
|
propagate(dep.subs);
|
|
431
491
|
shallowPropagate(dep.subs);
|
|
432
|
-
triggerEventInfos.pop();
|
|
433
492
|
}
|
|
434
493
|
};
|
|
435
494
|
startBatch();
|
|
495
|
+
startTrigger();
|
|
436
496
|
if (type === "clear") depsMap.forEach(run);
|
|
437
497
|
else {
|
|
438
498
|
const targetIsArray = isArray(target);
|
|
@@ -462,6 +522,14 @@ var VueReactivity = (function(exports) {
|
|
|
462
522
|
}
|
|
463
523
|
}
|
|
464
524
|
}
|
|
525
|
+
endTrigger({
|
|
526
|
+
target,
|
|
527
|
+
type,
|
|
528
|
+
key,
|
|
529
|
+
newValue,
|
|
530
|
+
oldValue,
|
|
531
|
+
oldTarget
|
|
532
|
+
});
|
|
465
533
|
endBatch();
|
|
466
534
|
}
|
|
467
535
|
function getDepFromReactive(object, key) {
|
|
@@ -676,7 +744,7 @@ var VueReactivity = (function(exports) {
|
|
|
676
744
|
//#endregion
|
|
677
745
|
//#region packages/reactivity/src/baseHandlers.ts
|
|
678
746
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
679
|
-
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
747
|
+
const builtInSymbols = /*@__PURE__*/ new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
680
748
|
function hasOwnProperty(key) {
|
|
681
749
|
if (!isSymbol(key)) key = String(key);
|
|
682
750
|
const obj = /* @__PURE__ */ toRaw(this);
|
|
@@ -1260,16 +1328,16 @@ var VueReactivity = (function(exports) {
|
|
|
1260
1328
|
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1261
1329
|
const subs = this.subs;
|
|
1262
1330
|
if (subs !== void 0) {
|
|
1263
|
-
|
|
1331
|
+
startTrigger();
|
|
1332
|
+
propagate(subs);
|
|
1333
|
+
endTrigger({
|
|
1264
1334
|
target: this,
|
|
1265
1335
|
type: "set",
|
|
1266
1336
|
key: "value",
|
|
1267
1337
|
newValue,
|
|
1268
1338
|
oldValue
|
|
1269
1339
|
});
|
|
1270
|
-
propagate(subs);
|
|
1271
1340
|
if (!batchDepth) flush();
|
|
1272
|
-
triggerEventInfos.pop();
|
|
1273
1341
|
}
|
|
1274
1342
|
}
|
|
1275
1343
|
}
|
|
@@ -1306,8 +1374,10 @@ var VueReactivity = (function(exports) {
|
|
|
1306
1374
|
function triggerRef(ref) {
|
|
1307
1375
|
const dep = ref.dep;
|
|
1308
1376
|
if (dep !== void 0 && dep.subs !== void 0) {
|
|
1377
|
+
startTrigger();
|
|
1309
1378
|
propagate(dep.subs);
|
|
1310
1379
|
shallowPropagate(dep.subs);
|
|
1380
|
+
endTrigger();
|
|
1311
1381
|
if (!batchDepth) flush();
|
|
1312
1382
|
}
|
|
1313
1383
|
}
|
|
@@ -1506,6 +1576,10 @@ var VueReactivity = (function(exports) {
|
|
|
1506
1576
|
get active() {
|
|
1507
1577
|
return !(this.flags & 1024);
|
|
1508
1578
|
}
|
|
1579
|
+
/** @internal */
|
|
1580
|
+
get running() {
|
|
1581
|
+
return !!(this.flags & 4);
|
|
1582
|
+
}
|
|
1509
1583
|
pause() {
|
|
1510
1584
|
this.flags |= 256;
|
|
1511
1585
|
}
|
|
@@ -1519,11 +1593,9 @@ var VueReactivity = (function(exports) {
|
|
|
1519
1593
|
if (!this.active) return this.fn();
|
|
1520
1594
|
cleanup(this);
|
|
1521
1595
|
const prevSub = startTracking(this);
|
|
1522
|
-
incRunDepth();
|
|
1523
1596
|
try {
|
|
1524
1597
|
return this.fn();
|
|
1525
1598
|
} finally {
|
|
1526
|
-
decRunDepth();
|
|
1527
1599
|
endTracking(this, prevSub);
|
|
1528
1600
|
const flags = this.flags;
|
|
1529
1601
|
if ((flags & 136) === 136) {
|
|
@@ -1546,9 +1618,9 @@ var VueReactivity = (function(exports) {
|
|
|
1546
1618
|
if (flags & 16) return true;
|
|
1547
1619
|
if (flags & 32) {
|
|
1548
1620
|
if (checkDirty(this.deps, this)) {
|
|
1549
|
-
this.
|
|
1621
|
+
if (this.active) this.flags |= 16;
|
|
1550
1622
|
return true;
|
|
1551
|
-
} else this.flags
|
|
1623
|
+
} else this.flags &= -33;
|
|
1552
1624
|
}
|
|
1553
1625
|
return false;
|
|
1554
1626
|
}
|
|
@@ -1560,20 +1632,17 @@ var VueReactivity = (function(exports) {
|
|
|
1560
1632
|
if (options) {
|
|
1561
1633
|
const { onStop, scheduler } = options;
|
|
1562
1634
|
if (onStop) {
|
|
1563
|
-
options.onStop = void 0;
|
|
1564
1635
|
const stop = e.stop.bind(e);
|
|
1565
1636
|
e.stop = () => {
|
|
1566
1637
|
stop();
|
|
1567
1638
|
onStop();
|
|
1568
1639
|
};
|
|
1569
1640
|
}
|
|
1570
|
-
if (scheduler) {
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
}
|
|
1576
|
-
extend(e, options);
|
|
1641
|
+
if (scheduler) e.notify = () => {
|
|
1642
|
+
if (!(e.flags & 1280)) scheduler();
|
|
1643
|
+
};
|
|
1644
|
+
e.onTrack = options.onTrack;
|
|
1645
|
+
e.onTrigger = options.onTrigger;
|
|
1577
1646
|
}
|
|
1578
1647
|
try {
|
|
1579
1648
|
e.run();
|
|
@@ -1686,8 +1755,10 @@ var VueReactivity = (function(exports) {
|
|
|
1686
1755
|
const flags = this.flags;
|
|
1687
1756
|
if (flags & 256) {
|
|
1688
1757
|
this.flags = flags & -257;
|
|
1689
|
-
|
|
1690
|
-
|
|
1758
|
+
const deps = [];
|
|
1759
|
+
for (let link = this.deps; link !== void 0; link = link.nextDep) deps.push(link.dep);
|
|
1760
|
+
for (let i = 0; i < deps.length; i++) {
|
|
1761
|
+
const dep = deps[i];
|
|
1691
1762
|
if ("resume" in dep) dep.resume();
|
|
1692
1763
|
}
|
|
1693
1764
|
}
|
|
@@ -1716,8 +1787,10 @@ var VueReactivity = (function(exports) {
|
|
|
1716
1787
|
while (dep !== void 0) {
|
|
1717
1788
|
const node = dep.dep;
|
|
1718
1789
|
if ("stop" in node) {
|
|
1719
|
-
|
|
1790
|
+
const prev = dep.prevDep;
|
|
1720
1791
|
node.stop();
|
|
1792
|
+
const next = prev !== void 0 ? prev.nextDep : this.deps;
|
|
1793
|
+
dep = next === dep ? dep.nextDep : next;
|
|
1721
1794
|
} else dep = unlink(dep, this);
|
|
1722
1795
|
}
|
|
1723
1796
|
cleanup(this);
|
|
@@ -1758,11 +1831,14 @@ var VueReactivity = (function(exports) {
|
|
|
1758
1831
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
1759
1832
|
*/
|
|
1760
1833
|
function onScopeDispose(fn, failSilently = false) {
|
|
1761
|
-
if (activeEffectScope !== void 0)
|
|
1762
|
-
|
|
1834
|
+
if (activeEffectScope !== void 0) {
|
|
1835
|
+
if (activeEffectScope.active) activeEffectScope.cleanups[activeEffectScope.cleanupsLength++] = fn;
|
|
1836
|
+
else fn();
|
|
1837
|
+
} else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
1763
1838
|
}
|
|
1764
1839
|
//#endregion
|
|
1765
1840
|
//#region packages/reactivity/src/computed.ts
|
|
1841
|
+
const FAILED = 64;
|
|
1766
1842
|
/**
|
|
1767
1843
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1768
1844
|
* the main vue package
|
|
@@ -1811,12 +1887,24 @@ var VueReactivity = (function(exports) {
|
|
|
1811
1887
|
}
|
|
1812
1888
|
get value() {
|
|
1813
1889
|
const flags = this.flags;
|
|
1814
|
-
|
|
1815
|
-
if (this.
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1890
|
+
try {
|
|
1891
|
+
if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
|
|
1892
|
+
if (this.update()) {
|
|
1893
|
+
const subs = this.subs;
|
|
1894
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1895
|
+
}
|
|
1896
|
+
} else if (flags & 32) this.flags = flags & -33;
|
|
1897
|
+
} catch (err) {
|
|
1898
|
+
if (activeSub !== void 0) {
|
|
1899
|
+
onTrack(activeSub, {
|
|
1900
|
+
target: this,
|
|
1901
|
+
type: "get",
|
|
1902
|
+
key: "value"
|
|
1903
|
+
});
|
|
1904
|
+
link(this, activeSub);
|
|
1905
|
+
} else if (activeEffectScope !== void 0) link(this, activeEffectScope);
|
|
1906
|
+
throw err;
|
|
1907
|
+
}
|
|
1820
1908
|
if (activeSub !== void 0) {
|
|
1821
1909
|
onTrack(activeSub, {
|
|
1822
1910
|
target: this,
|
|
@@ -1824,7 +1912,18 @@ var VueReactivity = (function(exports) {
|
|
|
1824
1912
|
key: "value"
|
|
1825
1913
|
});
|
|
1826
1914
|
link(this, activeSub);
|
|
1827
|
-
} else if (activeEffectScope !== void 0)
|
|
1915
|
+
} else if (activeEffectScope !== void 0) {
|
|
1916
|
+
if (activeEffectScope.active) link(this, activeEffectScope);
|
|
1917
|
+
else if (this.subs === void 0) {
|
|
1918
|
+
let dep = this.deps;
|
|
1919
|
+
if (dep !== void 0) {
|
|
1920
|
+
do
|
|
1921
|
+
dep = unlink(dep, this);
|
|
1922
|
+
while (dep !== void 0);
|
|
1923
|
+
this.flags |= 16;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1828
1927
|
return this._value;
|
|
1829
1928
|
}
|
|
1830
1929
|
set value(newValue) {
|
|
@@ -1836,11 +1935,15 @@ var VueReactivity = (function(exports) {
|
|
|
1836
1935
|
try {
|
|
1837
1936
|
const oldValue = this._value;
|
|
1838
1937
|
const newValue = this.fn(oldValue);
|
|
1839
|
-
if (hasChanged(oldValue, newValue)) {
|
|
1938
|
+
if (hasChanged(oldValue, newValue) || this.flags & FAILED) {
|
|
1840
1939
|
this._value = newValue;
|
|
1940
|
+
this.flags &= -65;
|
|
1841
1941
|
return true;
|
|
1842
1942
|
}
|
|
1843
1943
|
return false;
|
|
1944
|
+
} catch (err) {
|
|
1945
|
+
this.flags |= FAILED;
|
|
1946
|
+
throw err;
|
|
1844
1947
|
} finally {
|
|
1845
1948
|
endTracking(this, prevSub);
|
|
1846
1949
|
}
|
|
@@ -1861,6 +1964,7 @@ var VueReactivity = (function(exports) {
|
|
|
1861
1964
|
cRef.onTrack = debugOptions.onTrack;
|
|
1862
1965
|
cRef.onTrigger = debugOptions.onTrigger;
|
|
1863
1966
|
}
|
|
1967
|
+
if (isSSR && activeEffectScope !== void 0) link(cRef, activeEffectScope);
|
|
1864
1968
|
return cRef;
|
|
1865
1969
|
}
|
|
1866
1970
|
//#endregion
|