@vue/reactivity 3.6.0-rc.14 → 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
package/dist/reactivity.cjs.js
CHANGED
|
@@ -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
|
**/
|
|
@@ -8,41 +8,6 @@ Object.defineProperties(exports, {
|
|
|
8
8
|
[Symbol.toStringTag]: { value: "Module" }
|
|
9
9
|
});
|
|
10
10
|
let _vue_shared = require("@vue/shared");
|
|
11
|
-
//#region packages/reactivity/src/debug.ts
|
|
12
|
-
const triggerEventInfos = [];
|
|
13
|
-
function onTrack(sub, debugInfo) {
|
|
14
|
-
if (sub.onTrack) sub.onTrack((0, _vue_shared.extend)({ effect: sub }, debugInfo));
|
|
15
|
-
}
|
|
16
|
-
function onTrigger(sub) {
|
|
17
|
-
if (sub.onTrigger) {
|
|
18
|
-
const debugInfo = triggerEventInfos[triggerEventInfos.length - 1];
|
|
19
|
-
sub.onTrigger((0, _vue_shared.extend)({ effect: sub }, debugInfo));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function setupOnTrigger(target) {
|
|
23
|
-
Object.defineProperty(target.prototype, "onTrigger", {
|
|
24
|
-
get() {
|
|
25
|
-
return this._onTrigger;
|
|
26
|
-
},
|
|
27
|
-
set(val) {
|
|
28
|
-
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
29
|
-
this._onTrigger = val;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
function setupFlagsHandler(target) {
|
|
34
|
-
target._flags = target.flags;
|
|
35
|
-
Object.defineProperty(target, "flags", {
|
|
36
|
-
get() {
|
|
37
|
-
return target._flags;
|
|
38
|
-
},
|
|
39
|
-
set(value) {
|
|
40
|
-
if (!(target._flags & 48) && !!(value & 48)) onTrigger(this);
|
|
41
|
-
target._flags = value;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
11
|
//#region packages/reactivity/src/warning.ts
|
|
47
12
|
function warn(msg, ...args) {
|
|
48
13
|
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
@@ -52,13 +17,7 @@ function warn(msg, ...args) {
|
|
|
52
17
|
const notifyBuffer = [];
|
|
53
18
|
let batchDepth = 0;
|
|
54
19
|
let activeSub = void 0;
|
|
55
|
-
|
|
56
|
-
function incRunDepth() {
|
|
57
|
-
++runDepth;
|
|
58
|
-
}
|
|
59
|
-
function decRunDepth() {
|
|
60
|
-
--runDepth;
|
|
61
|
-
}
|
|
20
|
+
const CHECKING = 512;
|
|
62
21
|
let globalVersion = 0;
|
|
63
22
|
let notifyIndex = 0;
|
|
64
23
|
let notifyBufferLength = 0;
|
|
@@ -107,6 +66,7 @@ function unlink(link, sub = link.sub) {
|
|
|
107
66
|
const nextDep = link.nextDep;
|
|
108
67
|
const nextSub = link.nextSub;
|
|
109
68
|
const prevSub = link.prevSub;
|
|
69
|
+
link.prevDep = link.nextDep = link.prevSub = link.nextSub = void 0;
|
|
110
70
|
if (nextDep !== void 0) nextDep.prevDep = prevDep;
|
|
111
71
|
else sub.depsTail = prevDep;
|
|
112
72
|
if (prevDep !== void 0) prevDep.nextDep = nextDep;
|
|
@@ -114,7 +74,7 @@ function unlink(link, sub = link.sub) {
|
|
|
114
74
|
if (nextSub !== void 0) nextSub.prevSub = prevSub;
|
|
115
75
|
else dep.subsTail = prevSub;
|
|
116
76
|
if (prevSub !== void 0) prevSub.nextSub = nextSub;
|
|
117
|
-
else if ((dep.subs = nextSub) === void 0) {
|
|
77
|
+
else if ((dep.subs = nextSub) === void 0 && dep.flags & 1) {
|
|
118
78
|
let toRemove = dep.deps;
|
|
119
79
|
if (toRemove !== void 0) {
|
|
120
80
|
do
|
|
@@ -132,14 +92,12 @@ function propagate(link) {
|
|
|
132
92
|
const sub = link.sub;
|
|
133
93
|
let flags = sub.flags;
|
|
134
94
|
if (flags & 3) {
|
|
135
|
-
if (!(flags &
|
|
136
|
-
|
|
137
|
-
if (runDepth) sub.flags |= 8;
|
|
138
|
-
} else if (!(flags & 12)) flags = 0;
|
|
95
|
+
if (!(flags & 44)) sub.flags = flags | 32;
|
|
96
|
+
else if (!(flags & 12)) flags = 0;
|
|
139
97
|
else if (!(flags & 4)) sub.flags = flags & -9 | 32;
|
|
140
98
|
else if (!(flags & 48) && isValidLink(link, sub)) {
|
|
141
99
|
sub.flags = flags | 40;
|
|
142
|
-
flags
|
|
100
|
+
flags = sub === activeSub || activeSub === void 0 ? 0 : flags & 1;
|
|
143
101
|
} else flags = 0;
|
|
144
102
|
if (flags & 2) notifyBuffer[notifyBufferLength++] = sub;
|
|
145
103
|
if (flags & 1) {
|
|
@@ -175,7 +133,7 @@ function propagate(link) {
|
|
|
175
133
|
function startTracking(sub) {
|
|
176
134
|
++globalVersion;
|
|
177
135
|
sub.depsTail = void 0;
|
|
178
|
-
sub.flags = sub.flags & -
|
|
136
|
+
sub.flags = sub.flags & -569 | 4;
|
|
179
137
|
return setActiveSub(sub);
|
|
180
138
|
}
|
|
181
139
|
function endTracking(sub, prevSub) {
|
|
@@ -183,8 +141,11 @@ function endTracking(sub, prevSub) {
|
|
|
183
141
|
activeSub = prevSub;
|
|
184
142
|
const depsTail = sub.depsTail;
|
|
185
143
|
let toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
186
|
-
while (toRemove !== void 0)
|
|
187
|
-
|
|
144
|
+
while (toRemove !== void 0) {
|
|
145
|
+
unlink(toRemove, sub);
|
|
146
|
+
toRemove = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
147
|
+
}
|
|
148
|
+
if ((sub.flags &= -5) & 8) markRecursed(sub);
|
|
188
149
|
}
|
|
189
150
|
function flush() {
|
|
190
151
|
let hasError = false;
|
|
@@ -206,45 +167,67 @@ function flush() {
|
|
|
206
167
|
if (hasError) throw error;
|
|
207
168
|
}
|
|
208
169
|
function checkDirty(link, sub) {
|
|
170
|
+
try {
|
|
171
|
+
return walkDirty(link, sub);
|
|
172
|
+
} catch (err) {
|
|
173
|
+
markStale(sub);
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function walkDirty(link, sub) {
|
|
178
|
+
const root = sub;
|
|
209
179
|
let stack;
|
|
210
180
|
let checkDepth = 0;
|
|
181
|
+
let staleDepth = 0;
|
|
182
|
+
let staleFloor = 0;
|
|
211
183
|
top: do {
|
|
212
184
|
const dep = link.dep;
|
|
213
185
|
const depFlags = dep.flags;
|
|
214
186
|
let dirty = false;
|
|
215
187
|
if (sub.flags & 16) dirty = true;
|
|
216
188
|
else if ((depFlags & 17) === 17) {
|
|
217
|
-
const subs = dep.subs;
|
|
218
189
|
if (dep.update()) {
|
|
219
|
-
|
|
190
|
+
const subs = dep.subs;
|
|
191
|
+
if (subs !== void 0 && (subs !== link || subs.nextSub !== void 0)) shallowPropagate(subs);
|
|
220
192
|
dirty = true;
|
|
221
193
|
}
|
|
222
194
|
} else if ((depFlags & 33) === 33) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
195
|
+
const depth = dep === root ? 0 : depFlags & CHECKING ? checkingDepth(dep, stack, checkDepth) : -1;
|
|
196
|
+
if (depth < 0) {
|
|
197
|
+
if (link.nextSub !== void 0 || link.prevSub !== void 0) dep.flags = depFlags | CHECKING;
|
|
198
|
+
stack = {
|
|
199
|
+
value: link,
|
|
200
|
+
prev: stack
|
|
201
|
+
};
|
|
202
|
+
link = dep.deps;
|
|
203
|
+
sub = dep;
|
|
204
|
+
++checkDepth;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (depth < checkDepth) {
|
|
208
|
+
staleFloor = staleDepth && staleFloor < depth ? staleFloor : depth;
|
|
209
|
+
staleDepth = checkDepth;
|
|
210
|
+
}
|
|
231
211
|
}
|
|
232
212
|
if (!dirty && link.nextDep !== void 0) {
|
|
233
213
|
link = link.nextDep;
|
|
234
214
|
continue;
|
|
235
215
|
}
|
|
236
216
|
while (checkDepth) {
|
|
217
|
+
const stale = checkDepth === staleDepth;
|
|
218
|
+
if (stale && --staleDepth === staleFloor) staleDepth = 0;
|
|
237
219
|
--checkDepth;
|
|
238
220
|
link = stack.value;
|
|
239
221
|
stack = stack.prev;
|
|
240
222
|
if (dirty) {
|
|
241
|
-
const subs = sub.subs;
|
|
242
223
|
if (sub.update()) {
|
|
243
|
-
|
|
224
|
+
const subs = sub.subs;
|
|
225
|
+
if (subs !== void 0 && (subs !== link || subs.nextSub !== void 0)) shallowPropagate(subs);
|
|
244
226
|
sub = link.sub;
|
|
245
227
|
continue;
|
|
246
228
|
}
|
|
247
|
-
} else sub.flags
|
|
229
|
+
} else if (stale) sub.flags = sub.flags & -545 | 16;
|
|
230
|
+
else sub.flags &= -545;
|
|
248
231
|
sub = link.sub;
|
|
249
232
|
if (link.nextDep !== void 0) {
|
|
250
233
|
link = link.nextDep;
|
|
@@ -252,9 +235,21 @@ function checkDirty(link, sub) {
|
|
|
252
235
|
}
|
|
253
236
|
dirty = false;
|
|
254
237
|
}
|
|
255
|
-
return dirty && !!sub.flags;
|
|
238
|
+
return (dirty || !!(sub.flags & 16)) && !!sub.flags;
|
|
256
239
|
} while (true);
|
|
257
240
|
}
|
|
241
|
+
function checkingDepth(dep, stack, depth) {
|
|
242
|
+
for (; stack !== void 0; stack = stack.prev, --depth) if (stack.value.dep === dep) return depth;
|
|
243
|
+
return -1;
|
|
244
|
+
}
|
|
245
|
+
function markStale(sub) {
|
|
246
|
+
const nodes = [sub];
|
|
247
|
+
do {
|
|
248
|
+
sub = nodes.pop();
|
|
249
|
+
sub.flags = sub.flags & -33 | 16;
|
|
250
|
+
for (let link = sub.deps; link !== void 0; link = link.nextDep) if (link.dep.flags & 32) nodes.push(link.dep);
|
|
251
|
+
} while (nodes.length);
|
|
252
|
+
}
|
|
258
253
|
function shallowPropagate(link) {
|
|
259
254
|
do {
|
|
260
255
|
const sub = link.sub;
|
|
@@ -272,6 +267,71 @@ function isValidLink(checkLink, sub) {
|
|
|
272
267
|
}
|
|
273
268
|
return false;
|
|
274
269
|
}
|
|
270
|
+
function markRecursed(sub) {
|
|
271
|
+
const nodes = [sub];
|
|
272
|
+
do {
|
|
273
|
+
sub = nodes.pop();
|
|
274
|
+
for (let link = sub.deps; link !== void 0; link = link.nextDep) {
|
|
275
|
+
const dep = link.dep;
|
|
276
|
+
if ((dep.flags & 40) === 32) {
|
|
277
|
+
dep.flags |= 8;
|
|
278
|
+
nodes.push(dep);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
} while (nodes.length);
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region packages/reactivity/src/debug.ts
|
|
285
|
+
const triggered = [];
|
|
286
|
+
function onTrack(sub, debugInfo) {
|
|
287
|
+
if (sub.onTrack) sub.onTrack((0, _vue_shared.extend)({ effect: sub }, debugInfo));
|
|
288
|
+
}
|
|
289
|
+
function onTrigger(sub, debugInfo) {
|
|
290
|
+
if (sub.onTrigger) sub.onTrigger((0, _vue_shared.extend)({ effect: sub }, debugInfo));
|
|
291
|
+
}
|
|
292
|
+
function startTrigger() {
|
|
293
|
+
triggered.push([]);
|
|
294
|
+
}
|
|
295
|
+
function endTrigger(debugInfo) {
|
|
296
|
+
const subs = triggered.pop();
|
|
297
|
+
if (subs.length) {
|
|
298
|
+
startBatch();
|
|
299
|
+
try {
|
|
300
|
+
for (let i = 0; i < subs.length; i++) {
|
|
301
|
+
const sub = subs[i];
|
|
302
|
+
if (sub.flags & 3) onTrigger(sub, debugInfo);
|
|
303
|
+
}
|
|
304
|
+
} finally {
|
|
305
|
+
endBatch();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function setupOnTrigger(target) {
|
|
310
|
+
Object.defineProperty(target.prototype, "onTrigger", {
|
|
311
|
+
get() {
|
|
312
|
+
return this._onTrigger;
|
|
313
|
+
},
|
|
314
|
+
set(val) {
|
|
315
|
+
if (val && !this._onTrigger) setupFlagsHandler(this);
|
|
316
|
+
this._onTrigger = val;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function setupFlagsHandler(target) {
|
|
321
|
+
target._flags = target.flags;
|
|
322
|
+
Object.defineProperty(target, "flags", {
|
|
323
|
+
get() {
|
|
324
|
+
return target._flags;
|
|
325
|
+
},
|
|
326
|
+
set(value) {
|
|
327
|
+
if (!(target._flags & 48) && !!(value & 48)) {
|
|
328
|
+
if (triggered.length) triggered[triggered.length - 1].push(this);
|
|
329
|
+
else onTrigger(this);
|
|
330
|
+
}
|
|
331
|
+
target._flags = value;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
275
335
|
//#endregion
|
|
276
336
|
//#region packages/reactivity/src/dep.ts
|
|
277
337
|
var Dep = class {
|
|
@@ -310,17 +370,17 @@ function trackDep(dep, target = dep, key = "value") {
|
|
|
310
370
|
function triggerDep(dep, target = dep, key = "value", newValue, oldValue) {
|
|
311
371
|
const subs = dep.subs;
|
|
312
372
|
if (subs !== void 0) {
|
|
313
|
-
|
|
373
|
+
startTrigger();
|
|
374
|
+
propagate(subs);
|
|
375
|
+
shallowPropagate(subs);
|
|
376
|
+
endTrigger({
|
|
314
377
|
target,
|
|
315
378
|
type: "set",
|
|
316
379
|
key,
|
|
317
380
|
newValue,
|
|
318
381
|
oldValue
|
|
319
382
|
});
|
|
320
|
-
propagate(subs);
|
|
321
|
-
shallowPropagate(subs);
|
|
322
383
|
if (!batchDepth) flush();
|
|
323
|
-
triggerEventInfos.pop();
|
|
324
384
|
}
|
|
325
385
|
}
|
|
326
386
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -364,20 +424,12 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
364
424
|
if (!depsMap) return;
|
|
365
425
|
const run = (dep) => {
|
|
366
426
|
if (dep !== void 0 && dep.subs !== void 0) {
|
|
367
|
-
triggerEventInfos.push({
|
|
368
|
-
target,
|
|
369
|
-
type,
|
|
370
|
-
key,
|
|
371
|
-
newValue,
|
|
372
|
-
oldValue,
|
|
373
|
-
oldTarget
|
|
374
|
-
});
|
|
375
427
|
propagate(dep.subs);
|
|
376
428
|
shallowPropagate(dep.subs);
|
|
377
|
-
triggerEventInfos.pop();
|
|
378
429
|
}
|
|
379
430
|
};
|
|
380
431
|
startBatch();
|
|
432
|
+
startTrigger();
|
|
381
433
|
if (type === "clear") depsMap.forEach(run);
|
|
382
434
|
else {
|
|
383
435
|
const targetIsArray = (0, _vue_shared.isArray)(target);
|
|
@@ -407,6 +459,14 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
407
459
|
}
|
|
408
460
|
}
|
|
409
461
|
}
|
|
462
|
+
endTrigger({
|
|
463
|
+
target,
|
|
464
|
+
type,
|
|
465
|
+
key,
|
|
466
|
+
newValue,
|
|
467
|
+
oldValue,
|
|
468
|
+
oldTarget
|
|
469
|
+
});
|
|
410
470
|
endBatch();
|
|
411
471
|
}
|
|
412
472
|
function getDepFromReactive(object, key) {
|
|
@@ -621,7 +681,7 @@ function noTracking(self, method, args = []) {
|
|
|
621
681
|
//#endregion
|
|
622
682
|
//#region packages/reactivity/src/baseHandlers.ts
|
|
623
683
|
const isNonTrackableKeys = /*@__PURE__*/ (0, _vue_shared.makeMap)(`__proto__,__v_isRef,__isVue`);
|
|
624
|
-
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(_vue_shared.isSymbol));
|
|
684
|
+
const builtInSymbols = /*@__PURE__*/ new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(_vue_shared.isSymbol));
|
|
625
685
|
function hasOwnProperty(key) {
|
|
626
686
|
if (!(0, _vue_shared.isSymbol)(key)) key = String(key);
|
|
627
687
|
const obj = /* @__PURE__ */ toRaw(this);
|
|
@@ -1205,16 +1265,16 @@ var RefImpl = class {
|
|
|
1205
1265
|
this._value = !useDirectValue && this._wrap ? this._wrap(newValue) : newValue;
|
|
1206
1266
|
const subs = this.subs;
|
|
1207
1267
|
if (subs !== void 0) {
|
|
1208
|
-
|
|
1268
|
+
startTrigger();
|
|
1269
|
+
propagate(subs);
|
|
1270
|
+
endTrigger({
|
|
1209
1271
|
target: this,
|
|
1210
1272
|
type: "set",
|
|
1211
1273
|
key: "value",
|
|
1212
1274
|
newValue,
|
|
1213
1275
|
oldValue
|
|
1214
1276
|
});
|
|
1215
|
-
propagate(subs);
|
|
1216
1277
|
if (!batchDepth) flush();
|
|
1217
|
-
triggerEventInfos.pop();
|
|
1218
1278
|
}
|
|
1219
1279
|
}
|
|
1220
1280
|
}
|
|
@@ -1251,8 +1311,10 @@ var RefImpl = class {
|
|
|
1251
1311
|
function triggerRef(ref) {
|
|
1252
1312
|
const dep = ref.dep;
|
|
1253
1313
|
if (dep !== void 0 && dep.subs !== void 0) {
|
|
1314
|
+
startTrigger();
|
|
1254
1315
|
propagate(dep.subs);
|
|
1255
1316
|
shallowPropagate(dep.subs);
|
|
1317
|
+
endTrigger();
|
|
1256
1318
|
if (!batchDepth) flush();
|
|
1257
1319
|
}
|
|
1258
1320
|
}
|
|
@@ -1451,6 +1513,10 @@ var ReactiveEffect = class {
|
|
|
1451
1513
|
get active() {
|
|
1452
1514
|
return !(this.flags & 1024);
|
|
1453
1515
|
}
|
|
1516
|
+
/** @internal */
|
|
1517
|
+
get running() {
|
|
1518
|
+
return !!(this.flags & 4);
|
|
1519
|
+
}
|
|
1454
1520
|
pause() {
|
|
1455
1521
|
this.flags |= 256;
|
|
1456
1522
|
}
|
|
@@ -1464,11 +1530,9 @@ var ReactiveEffect = class {
|
|
|
1464
1530
|
if (!this.active) return this.fn();
|
|
1465
1531
|
cleanup(this);
|
|
1466
1532
|
const prevSub = startTracking(this);
|
|
1467
|
-
incRunDepth();
|
|
1468
1533
|
try {
|
|
1469
1534
|
return this.fn();
|
|
1470
1535
|
} finally {
|
|
1471
|
-
decRunDepth();
|
|
1472
1536
|
endTracking(this, prevSub);
|
|
1473
1537
|
const flags = this.flags;
|
|
1474
1538
|
if ((flags & 136) === 136) {
|
|
@@ -1491,9 +1555,9 @@ var ReactiveEffect = class {
|
|
|
1491
1555
|
if (flags & 16) return true;
|
|
1492
1556
|
if (flags & 32) {
|
|
1493
1557
|
if (checkDirty(this.deps, this)) {
|
|
1494
|
-
this.
|
|
1558
|
+
if (this.active) this.flags |= 16;
|
|
1495
1559
|
return true;
|
|
1496
|
-
} else this.flags
|
|
1560
|
+
} else this.flags &= -33;
|
|
1497
1561
|
}
|
|
1498
1562
|
return false;
|
|
1499
1563
|
}
|
|
@@ -1505,20 +1569,17 @@ function effect(fn, options) {
|
|
|
1505
1569
|
if (options) {
|
|
1506
1570
|
const { onStop, scheduler } = options;
|
|
1507
1571
|
if (onStop) {
|
|
1508
|
-
options.onStop = void 0;
|
|
1509
1572
|
const stop = e.stop.bind(e);
|
|
1510
1573
|
e.stop = () => {
|
|
1511
1574
|
stop();
|
|
1512
1575
|
onStop();
|
|
1513
1576
|
};
|
|
1514
1577
|
}
|
|
1515
|
-
if (scheduler) {
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1521
|
-
(0, _vue_shared.extend)(e, options);
|
|
1578
|
+
if (scheduler) e.notify = () => {
|
|
1579
|
+
if (!(e.flags & 1280)) scheduler();
|
|
1580
|
+
};
|
|
1581
|
+
e.onTrack = options.onTrack;
|
|
1582
|
+
e.onTrigger = options.onTrigger;
|
|
1522
1583
|
}
|
|
1523
1584
|
try {
|
|
1524
1585
|
e.run();
|
|
@@ -1631,8 +1692,10 @@ var EffectScope = class {
|
|
|
1631
1692
|
const flags = this.flags;
|
|
1632
1693
|
if (flags & 256) {
|
|
1633
1694
|
this.flags = flags & -257;
|
|
1634
|
-
|
|
1635
|
-
|
|
1695
|
+
const deps = [];
|
|
1696
|
+
for (let link = this.deps; link !== void 0; link = link.nextDep) deps.push(link.dep);
|
|
1697
|
+
for (let i = 0; i < deps.length; i++) {
|
|
1698
|
+
const dep = deps[i];
|
|
1636
1699
|
if ("resume" in dep) dep.resume();
|
|
1637
1700
|
}
|
|
1638
1701
|
}
|
|
@@ -1661,8 +1724,10 @@ var EffectScope = class {
|
|
|
1661
1724
|
while (dep !== void 0) {
|
|
1662
1725
|
const node = dep.dep;
|
|
1663
1726
|
if ("stop" in node) {
|
|
1664
|
-
|
|
1727
|
+
const prev = dep.prevDep;
|
|
1665
1728
|
node.stop();
|
|
1729
|
+
const next = prev !== void 0 ? prev.nextDep : this.deps;
|
|
1730
|
+
dep = next === dep ? dep.nextDep : next;
|
|
1666
1731
|
} else dep = unlink(dep, this);
|
|
1667
1732
|
}
|
|
1668
1733
|
cleanup(this);
|
|
@@ -1703,11 +1768,14 @@ function setCurrentScope(scope) {
|
|
|
1703
1768
|
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
|
|
1704
1769
|
*/
|
|
1705
1770
|
function onScopeDispose(fn, failSilently = false) {
|
|
1706
|
-
if (activeEffectScope !== void 0)
|
|
1707
|
-
|
|
1771
|
+
if (activeEffectScope !== void 0) {
|
|
1772
|
+
if (activeEffectScope.active) activeEffectScope.cleanups[activeEffectScope.cleanupsLength++] = fn;
|
|
1773
|
+
else fn();
|
|
1774
|
+
} else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
1708
1775
|
}
|
|
1709
1776
|
//#endregion
|
|
1710
1777
|
//#region packages/reactivity/src/computed.ts
|
|
1778
|
+
const FAILED = 64;
|
|
1711
1779
|
/**
|
|
1712
1780
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1713
1781
|
* the main vue package
|
|
@@ -1756,12 +1824,24 @@ var ComputedRefImpl = class {
|
|
|
1756
1824
|
}
|
|
1757
1825
|
get value() {
|
|
1758
1826
|
const flags = this.flags;
|
|
1759
|
-
|
|
1760
|
-
if (this.
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1827
|
+
try {
|
|
1828
|
+
if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) {
|
|
1829
|
+
if (this.update()) {
|
|
1830
|
+
const subs = this.subs;
|
|
1831
|
+
if (subs !== void 0) shallowPropagate(subs);
|
|
1832
|
+
}
|
|
1833
|
+
} else if (flags & 32) this.flags = flags & -33;
|
|
1834
|
+
} catch (err) {
|
|
1835
|
+
if (activeSub !== void 0) {
|
|
1836
|
+
onTrack(activeSub, {
|
|
1837
|
+
target: this,
|
|
1838
|
+
type: "get",
|
|
1839
|
+
key: "value"
|
|
1840
|
+
});
|
|
1841
|
+
link(this, activeSub);
|
|
1842
|
+
} else if (activeEffectScope !== void 0) link(this, activeEffectScope);
|
|
1843
|
+
throw err;
|
|
1844
|
+
}
|
|
1765
1845
|
if (activeSub !== void 0) {
|
|
1766
1846
|
onTrack(activeSub, {
|
|
1767
1847
|
target: this,
|
|
@@ -1769,7 +1849,18 @@ var ComputedRefImpl = class {
|
|
|
1769
1849
|
key: "value"
|
|
1770
1850
|
});
|
|
1771
1851
|
link(this, activeSub);
|
|
1772
|
-
} else if (activeEffectScope !== void 0)
|
|
1852
|
+
} else if (activeEffectScope !== void 0) {
|
|
1853
|
+
if (activeEffectScope.active) link(this, activeEffectScope);
|
|
1854
|
+
else if (this.subs === void 0) {
|
|
1855
|
+
let dep = this.deps;
|
|
1856
|
+
if (dep !== void 0) {
|
|
1857
|
+
do
|
|
1858
|
+
dep = unlink(dep, this);
|
|
1859
|
+
while (dep !== void 0);
|
|
1860
|
+
this.flags |= 16;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1773
1864
|
return this._value;
|
|
1774
1865
|
}
|
|
1775
1866
|
set value(newValue) {
|
|
@@ -1781,11 +1872,15 @@ var ComputedRefImpl = class {
|
|
|
1781
1872
|
try {
|
|
1782
1873
|
const oldValue = this._value;
|
|
1783
1874
|
const newValue = this.fn(oldValue);
|
|
1784
|
-
if ((0, _vue_shared.hasChanged)(oldValue, newValue)) {
|
|
1875
|
+
if ((0, _vue_shared.hasChanged)(oldValue, newValue) || this.flags & FAILED) {
|
|
1785
1876
|
this._value = newValue;
|
|
1877
|
+
this.flags &= -65;
|
|
1786
1878
|
return true;
|
|
1787
1879
|
}
|
|
1788
1880
|
return false;
|
|
1881
|
+
} catch (err) {
|
|
1882
|
+
this.flags |= FAILED;
|
|
1883
|
+
throw err;
|
|
1789
1884
|
} finally {
|
|
1790
1885
|
endTracking(this, prevSub);
|
|
1791
1886
|
}
|
|
@@ -1806,6 +1901,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1806
1901
|
cRef.onTrack = debugOptions.onTrack;
|
|
1807
1902
|
cRef.onTrigger = debugOptions.onTrigger;
|
|
1808
1903
|
}
|
|
1904
|
+
if (isSSR && activeEffectScope !== void 0) link(cRef, activeEffectScope);
|
|
1809
1905
|
return cRef;
|
|
1810
1906
|
}
|
|
1811
1907
|
//#endregion
|