@vue/reactivity 3.3.6 → 3.4.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/reactivity.cjs.js +251 -281
- package/dist/reactivity.cjs.prod.js +216 -258
- package/dist/reactivity.d.ts +103 -93
- package/dist/reactivity.esm-browser.js +252 -282
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +251 -291
- package/dist/reactivity.global.js +253 -281
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
|
@@ -10,6 +10,8 @@ var VueReactivity = (function (exports) {
|
|
|
10
10
|
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const NOOP = () => {
|
|
14
|
+
};
|
|
13
15
|
const extend = Object.assign;
|
|
14
16
|
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
15
17
|
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
@@ -148,117 +150,120 @@ var VueReactivity = (function (exports) {
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
const createDep = (effects) => {
|
|
152
|
-
const dep = new Set(effects);
|
|
153
|
-
dep.w = 0;
|
|
154
|
-
dep.n = 0;
|
|
155
|
-
return dep;
|
|
156
|
-
};
|
|
157
|
-
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
|
|
158
|
-
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
|
|
159
|
-
const initDepMarkers = ({ deps }) => {
|
|
160
|
-
if (deps.length) {
|
|
161
|
-
for (let i = 0; i < deps.length; i++) {
|
|
162
|
-
deps[i].w |= trackOpBit;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
const finalizeDepMarkers = (effect) => {
|
|
167
|
-
const { deps } = effect;
|
|
168
|
-
if (deps.length) {
|
|
169
|
-
let ptr = 0;
|
|
170
|
-
for (let i = 0; i < deps.length; i++) {
|
|
171
|
-
const dep = deps[i];
|
|
172
|
-
if (wasTracked(dep) && !newTracked(dep)) {
|
|
173
|
-
dep.delete(effect);
|
|
174
|
-
} else {
|
|
175
|
-
deps[ptr++] = dep;
|
|
176
|
-
}
|
|
177
|
-
dep.w &= ~trackOpBit;
|
|
178
|
-
dep.n &= ~trackOpBit;
|
|
179
|
-
}
|
|
180
|
-
deps.length = ptr;
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
185
|
-
let effectTrackDepth = 0;
|
|
186
|
-
let trackOpBit = 1;
|
|
187
|
-
const maxMarkerBits = 30;
|
|
188
153
|
let activeEffect;
|
|
189
|
-
const ITERATE_KEY = Symbol("iterate" );
|
|
190
|
-
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
|
|
191
154
|
class ReactiveEffect {
|
|
192
|
-
constructor(fn, scheduler
|
|
155
|
+
constructor(fn, trigger, scheduler, scope) {
|
|
193
156
|
this.fn = fn;
|
|
157
|
+
this.trigger = trigger;
|
|
194
158
|
this.scheduler = scheduler;
|
|
195
159
|
this.active = true;
|
|
196
160
|
this.deps = [];
|
|
197
|
-
|
|
161
|
+
/**
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
this._dirtyLevel = 3;
|
|
165
|
+
/**
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
this._trackId = 0;
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
this._runnings = 0;
|
|
173
|
+
/**
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
this._queryings = 0;
|
|
177
|
+
/**
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
this._depsLength = 0;
|
|
198
181
|
recordEffectScope(this, scope);
|
|
199
182
|
}
|
|
183
|
+
get dirty() {
|
|
184
|
+
if (this._dirtyLevel === 1) {
|
|
185
|
+
this._dirtyLevel = 0;
|
|
186
|
+
this._queryings++;
|
|
187
|
+
pauseTracking();
|
|
188
|
+
for (const dep of this.deps) {
|
|
189
|
+
if (dep.computed) {
|
|
190
|
+
triggerComputed(dep.computed);
|
|
191
|
+
if (this._dirtyLevel >= 2) {
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
resetTracking();
|
|
197
|
+
this._queryings--;
|
|
198
|
+
}
|
|
199
|
+
return this._dirtyLevel >= 2;
|
|
200
|
+
}
|
|
201
|
+
set dirty(v) {
|
|
202
|
+
this._dirtyLevel = v ? 3 : 0;
|
|
203
|
+
}
|
|
200
204
|
run() {
|
|
205
|
+
this._dirtyLevel = 0;
|
|
201
206
|
if (!this.active) {
|
|
202
207
|
return this.fn();
|
|
203
208
|
}
|
|
204
|
-
let parent = activeEffect;
|
|
205
209
|
let lastShouldTrack = shouldTrack;
|
|
206
|
-
|
|
207
|
-
if (parent === this) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
parent = parent.parent;
|
|
211
|
-
}
|
|
210
|
+
let lastEffect = activeEffect;
|
|
212
211
|
try {
|
|
213
|
-
this.parent = activeEffect;
|
|
214
|
-
activeEffect = this;
|
|
215
212
|
shouldTrack = true;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} else {
|
|
220
|
-
cleanupEffect(this);
|
|
221
|
-
}
|
|
213
|
+
activeEffect = this;
|
|
214
|
+
this._runnings++;
|
|
215
|
+
preCleanupEffect(this);
|
|
222
216
|
return this.fn();
|
|
223
217
|
} finally {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
trackOpBit = 1 << --effectTrackDepth;
|
|
228
|
-
activeEffect = this.parent;
|
|
218
|
+
postCleanupEffect(this);
|
|
219
|
+
this._runnings--;
|
|
220
|
+
activeEffect = lastEffect;
|
|
229
221
|
shouldTrack = lastShouldTrack;
|
|
230
|
-
this.parent = void 0;
|
|
231
|
-
if (this.deferStop) {
|
|
232
|
-
this.stop();
|
|
233
|
-
}
|
|
234
222
|
}
|
|
235
223
|
}
|
|
236
224
|
stop() {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.onStop();
|
|
243
|
-
}
|
|
225
|
+
var _a;
|
|
226
|
+
if (this.active) {
|
|
227
|
+
preCleanupEffect(this);
|
|
228
|
+
postCleanupEffect(this);
|
|
229
|
+
(_a = this.onStop) == null ? void 0 : _a.call(this);
|
|
244
230
|
this.active = false;
|
|
245
231
|
}
|
|
246
232
|
}
|
|
247
233
|
}
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
234
|
+
function triggerComputed(computed) {
|
|
235
|
+
return computed.value;
|
|
236
|
+
}
|
|
237
|
+
function preCleanupEffect(effect2) {
|
|
238
|
+
effect2._trackId++;
|
|
239
|
+
effect2._depsLength = 0;
|
|
240
|
+
}
|
|
241
|
+
function postCleanupEffect(effect2) {
|
|
242
|
+
if (effect2.deps && effect2.deps.length > effect2._depsLength) {
|
|
243
|
+
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
|
244
|
+
cleanupDepEffect(effect2.deps[i], effect2);
|
|
245
|
+
}
|
|
246
|
+
effect2.deps.length = effect2._depsLength;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function cleanupDepEffect(dep, effect2) {
|
|
250
|
+
const trackId = dep.get(effect2);
|
|
251
|
+
if (trackId !== void 0 && effect2._trackId !== trackId) {
|
|
252
|
+
dep.delete(effect2);
|
|
253
|
+
if (dep.size === 0) {
|
|
254
|
+
dep.cleanup();
|
|
253
255
|
}
|
|
254
|
-
deps.length = 0;
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
function effect(fn, options) {
|
|
258
259
|
if (fn.effect instanceof ReactiveEffect) {
|
|
259
260
|
fn = fn.effect.fn;
|
|
260
261
|
}
|
|
261
|
-
const _effect = new ReactiveEffect(fn)
|
|
262
|
+
const _effect = new ReactiveEffect(fn, NOOP, () => {
|
|
263
|
+
if (_effect.dirty) {
|
|
264
|
+
_effect.run();
|
|
265
|
+
}
|
|
266
|
+
});
|
|
262
267
|
if (options) {
|
|
263
268
|
extend(_effect, options);
|
|
264
269
|
if (options.scope)
|
|
@@ -275,6 +280,7 @@ var VueReactivity = (function (exports) {
|
|
|
275
280
|
runner.effect.stop();
|
|
276
281
|
}
|
|
277
282
|
let shouldTrack = true;
|
|
283
|
+
let pauseScheduleStack = 0;
|
|
278
284
|
const trackStack = [];
|
|
279
285
|
function pauseTracking() {
|
|
280
286
|
trackStack.push(shouldTrack);
|
|
@@ -288,6 +294,68 @@ var VueReactivity = (function (exports) {
|
|
|
288
294
|
const last = trackStack.pop();
|
|
289
295
|
shouldTrack = last === void 0 ? true : last;
|
|
290
296
|
}
|
|
297
|
+
function pauseScheduling() {
|
|
298
|
+
pauseScheduleStack++;
|
|
299
|
+
}
|
|
300
|
+
function resetScheduling() {
|
|
301
|
+
pauseScheduleStack--;
|
|
302
|
+
while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
|
303
|
+
queueEffectSchedulers.shift()();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
|
307
|
+
var _a;
|
|
308
|
+
if (dep.get(effect2) !== effect2._trackId) {
|
|
309
|
+
dep.set(effect2, effect2._trackId);
|
|
310
|
+
const oldDep = effect2.deps[effect2._depsLength];
|
|
311
|
+
if (oldDep !== dep) {
|
|
312
|
+
if (oldDep) {
|
|
313
|
+
cleanupDepEffect(oldDep, effect2);
|
|
314
|
+
}
|
|
315
|
+
effect2.deps[effect2._depsLength++] = dep;
|
|
316
|
+
} else {
|
|
317
|
+
effect2._depsLength++;
|
|
318
|
+
}
|
|
319
|
+
{
|
|
320
|
+
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const queueEffectSchedulers = [];
|
|
325
|
+
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
326
|
+
var _a;
|
|
327
|
+
pauseScheduling();
|
|
328
|
+
for (const effect2 of dep.keys()) {
|
|
329
|
+
if (!effect2.allowRecurse && effect2._runnings) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
|
|
333
|
+
const lastDirtyLevel = effect2._dirtyLevel;
|
|
334
|
+
effect2._dirtyLevel = dirtyLevel;
|
|
335
|
+
if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
|
|
336
|
+
{
|
|
337
|
+
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
338
|
+
}
|
|
339
|
+
effect2.trigger();
|
|
340
|
+
if (effect2.scheduler) {
|
|
341
|
+
queueEffectSchedulers.push(effect2.scheduler);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
resetScheduling();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const createDep = (cleanup, computed) => {
|
|
350
|
+
const dep = /* @__PURE__ */ new Map();
|
|
351
|
+
dep.cleanup = cleanup;
|
|
352
|
+
dep.computed = computed;
|
|
353
|
+
return dep;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
357
|
+
const ITERATE_KEY = Symbol("iterate" );
|
|
358
|
+
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
|
|
291
359
|
function track(target, type, key) {
|
|
292
360
|
if (shouldTrack && activeEffect) {
|
|
293
361
|
let depsMap = targetMap.get(target);
|
|
@@ -296,35 +364,17 @@ var VueReactivity = (function (exports) {
|
|
|
296
364
|
}
|
|
297
365
|
let dep = depsMap.get(key);
|
|
298
366
|
if (!dep) {
|
|
299
|
-
depsMap.set(key, dep = createDep());
|
|
300
|
-
}
|
|
301
|
-
const eventInfo = { effect: activeEffect, target, type, key } ;
|
|
302
|
-
trackEffects(dep, eventInfo);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function trackEffects(dep, debuggerEventExtraInfo) {
|
|
306
|
-
let shouldTrack2 = false;
|
|
307
|
-
if (effectTrackDepth <= maxMarkerBits) {
|
|
308
|
-
if (!newTracked(dep)) {
|
|
309
|
-
dep.n |= trackOpBit;
|
|
310
|
-
shouldTrack2 = !wasTracked(dep);
|
|
311
|
-
}
|
|
312
|
-
} else {
|
|
313
|
-
shouldTrack2 = !dep.has(activeEffect);
|
|
314
|
-
}
|
|
315
|
-
if (shouldTrack2) {
|
|
316
|
-
dep.add(activeEffect);
|
|
317
|
-
activeEffect.deps.push(dep);
|
|
318
|
-
if (activeEffect.onTrack) {
|
|
319
|
-
activeEffect.onTrack(
|
|
320
|
-
extend(
|
|
321
|
-
{
|
|
322
|
-
effect: activeEffect
|
|
323
|
-
},
|
|
324
|
-
debuggerEventExtraInfo
|
|
325
|
-
)
|
|
326
|
-
);
|
|
367
|
+
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
|
327
368
|
}
|
|
369
|
+
trackEffect(
|
|
370
|
+
activeEffect,
|
|
371
|
+
dep,
|
|
372
|
+
{
|
|
373
|
+
target,
|
|
374
|
+
type,
|
|
375
|
+
key
|
|
376
|
+
}
|
|
377
|
+
);
|
|
328
378
|
}
|
|
329
379
|
}
|
|
330
380
|
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
@@ -338,7 +388,7 @@ var VueReactivity = (function (exports) {
|
|
|
338
388
|
} else if (key === "length" && isArray(target)) {
|
|
339
389
|
const newLength = Number(newValue);
|
|
340
390
|
depsMap.forEach((dep, key2) => {
|
|
341
|
-
if (key2 === "length" || key2 >= newLength) {
|
|
391
|
+
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
|
342
392
|
deps.push(dep);
|
|
343
393
|
}
|
|
344
394
|
});
|
|
@@ -372,49 +422,24 @@ var VueReactivity = (function (exports) {
|
|
|
372
422
|
break;
|
|
373
423
|
}
|
|
374
424
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
triggerEffects(createDep(effects), eventInfo);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
function triggerEffects(dep, debuggerEventExtraInfo) {
|
|
395
|
-
const effects = isArray(dep) ? dep : [...dep];
|
|
396
|
-
for (const effect2 of effects) {
|
|
397
|
-
if (effect2.computed) {
|
|
398
|
-
triggerEffect(effect2, debuggerEventExtraInfo);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
for (const effect2 of effects) {
|
|
402
|
-
if (!effect2.computed) {
|
|
403
|
-
triggerEffect(effect2, debuggerEventExtraInfo);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
function triggerEffect(effect2, debuggerEventExtraInfo) {
|
|
408
|
-
if (effect2 !== activeEffect || effect2.allowRecurse) {
|
|
409
|
-
if (effect2.onTrigger) {
|
|
410
|
-
effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
411
|
-
}
|
|
412
|
-
if (effect2.scheduler) {
|
|
413
|
-
effect2.scheduler();
|
|
414
|
-
} else {
|
|
415
|
-
effect2.run();
|
|
425
|
+
pauseScheduling();
|
|
426
|
+
for (const dep of deps) {
|
|
427
|
+
if (dep) {
|
|
428
|
+
triggerEffects(
|
|
429
|
+
dep,
|
|
430
|
+
3,
|
|
431
|
+
{
|
|
432
|
+
target,
|
|
433
|
+
type,
|
|
434
|
+
key,
|
|
435
|
+
newValue,
|
|
436
|
+
oldValue,
|
|
437
|
+
oldTarget
|
|
438
|
+
}
|
|
439
|
+
);
|
|
416
440
|
}
|
|
417
441
|
}
|
|
442
|
+
resetScheduling();
|
|
418
443
|
}
|
|
419
444
|
function getDepFromReactive(object, key) {
|
|
420
445
|
var _a;
|
|
@@ -445,7 +470,9 @@ var VueReactivity = (function (exports) {
|
|
|
445
470
|
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
446
471
|
instrumentations[key] = function(...args) {
|
|
447
472
|
pauseTracking();
|
|
473
|
+
pauseScheduling();
|
|
448
474
|
const res = toRaw(this)[key].apply(this, args);
|
|
475
|
+
resetScheduling();
|
|
449
476
|
resetTracking();
|
|
450
477
|
return res;
|
|
451
478
|
};
|
|
@@ -984,30 +1011,93 @@ var VueReactivity = (function (exports) {
|
|
|
984
1011
|
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
985
1012
|
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
986
1013
|
|
|
1014
|
+
class ComputedRefImpl {
|
|
1015
|
+
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1016
|
+
this._setter = _setter;
|
|
1017
|
+
this.dep = void 0;
|
|
1018
|
+
this.__v_isRef = true;
|
|
1019
|
+
this["__v_isReadonly"] = false;
|
|
1020
|
+
this.effect = new ReactiveEffect(getter, () => {
|
|
1021
|
+
triggerRefValue(this, 1);
|
|
1022
|
+
});
|
|
1023
|
+
this.effect.computed = this;
|
|
1024
|
+
this.effect.active = this._cacheable = !isSSR;
|
|
1025
|
+
this["__v_isReadonly"] = isReadonly;
|
|
1026
|
+
}
|
|
1027
|
+
get value() {
|
|
1028
|
+
const self = toRaw(this);
|
|
1029
|
+
trackRefValue(self);
|
|
1030
|
+
if (!self._cacheable || self.effect.dirty) {
|
|
1031
|
+
if (hasChanged(self._value, self._value = self.effect.run())) {
|
|
1032
|
+
triggerRefValue(self, 2);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
return self._value;
|
|
1036
|
+
}
|
|
1037
|
+
set value(newValue) {
|
|
1038
|
+
this._setter(newValue);
|
|
1039
|
+
}
|
|
1040
|
+
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
|
|
1041
|
+
get _dirty() {
|
|
1042
|
+
return this.effect.dirty;
|
|
1043
|
+
}
|
|
1044
|
+
set _dirty(v) {
|
|
1045
|
+
this.effect.dirty = v;
|
|
1046
|
+
}
|
|
1047
|
+
// #endregion
|
|
1048
|
+
}
|
|
1049
|
+
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1050
|
+
let getter;
|
|
1051
|
+
let setter;
|
|
1052
|
+
const onlyGetter = isFunction(getterOrOptions);
|
|
1053
|
+
if (onlyGetter) {
|
|
1054
|
+
getter = getterOrOptions;
|
|
1055
|
+
setter = () => {
|
|
1056
|
+
console.warn("Write operation failed: computed value is readonly");
|
|
1057
|
+
} ;
|
|
1058
|
+
} else {
|
|
1059
|
+
getter = getterOrOptions.get;
|
|
1060
|
+
setter = getterOrOptions.set;
|
|
1061
|
+
}
|
|
1062
|
+
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1063
|
+
if (debugOptions && !isSSR) {
|
|
1064
|
+
cRef.effect.onTrack = debugOptions.onTrack;
|
|
1065
|
+
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1066
|
+
}
|
|
1067
|
+
return cRef;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
987
1070
|
function trackRefValue(ref2) {
|
|
988
1071
|
if (shouldTrack && activeEffect) {
|
|
989
1072
|
ref2 = toRaw(ref2);
|
|
990
|
-
|
|
991
|
-
|
|
1073
|
+
trackEffect(
|
|
1074
|
+
activeEffect,
|
|
1075
|
+
ref2.dep || (ref2.dep = createDep(
|
|
1076
|
+
() => ref2.dep = void 0,
|
|
1077
|
+
ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
|
1078
|
+
)),
|
|
1079
|
+
{
|
|
992
1080
|
target: ref2,
|
|
993
1081
|
type: "get",
|
|
994
1082
|
key: "value"
|
|
995
|
-
}
|
|
996
|
-
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
997
1085
|
}
|
|
998
1086
|
}
|
|
999
|
-
function triggerRefValue(ref2, newVal) {
|
|
1087
|
+
function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
|
|
1000
1088
|
ref2 = toRaw(ref2);
|
|
1001
1089
|
const dep = ref2.dep;
|
|
1002
1090
|
if (dep) {
|
|
1003
|
-
|
|
1004
|
-
|
|
1091
|
+
triggerEffects(
|
|
1092
|
+
dep,
|
|
1093
|
+
dirtyLevel,
|
|
1094
|
+
{
|
|
1005
1095
|
target: ref2,
|
|
1006
1096
|
type: "set",
|
|
1007
1097
|
key: "value",
|
|
1008
1098
|
newValue: newVal
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1099
|
+
}
|
|
1100
|
+
);
|
|
1011
1101
|
}
|
|
1012
1102
|
}
|
|
1013
1103
|
function isRef(r) {
|
|
@@ -1043,12 +1133,12 @@ var VueReactivity = (function (exports) {
|
|
|
1043
1133
|
if (hasChanged(newVal, this._rawValue)) {
|
|
1044
1134
|
this._rawValue = newVal;
|
|
1045
1135
|
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
1046
|
-
triggerRefValue(this, newVal);
|
|
1136
|
+
triggerRefValue(this, 3, newVal);
|
|
1047
1137
|
}
|
|
1048
1138
|
}
|
|
1049
1139
|
}
|
|
1050
1140
|
function triggerRef(ref2) {
|
|
1051
|
-
triggerRefValue(ref2, ref2.value );
|
|
1141
|
+
triggerRefValue(ref2, 3, ref2.value );
|
|
1052
1142
|
}
|
|
1053
1143
|
function unref(ref2) {
|
|
1054
1144
|
return isRef(ref2) ? ref2.value : ref2;
|
|
@@ -1146,127 +1236,7 @@ var VueReactivity = (function (exports) {
|
|
|
1146
1236
|
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1147
1237
|
}
|
|
1148
1238
|
|
|
1149
|
-
|
|
1150
|
-
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1151
|
-
this._setter = _setter;
|
|
1152
|
-
this.dep = void 0;
|
|
1153
|
-
this.__v_isRef = true;
|
|
1154
|
-
this["__v_isReadonly"] = false;
|
|
1155
|
-
this._dirty = true;
|
|
1156
|
-
this.effect = new ReactiveEffect(getter, () => {
|
|
1157
|
-
if (!this._dirty) {
|
|
1158
|
-
this._dirty = true;
|
|
1159
|
-
triggerRefValue(this);
|
|
1160
|
-
}
|
|
1161
|
-
});
|
|
1162
|
-
this.effect.computed = this;
|
|
1163
|
-
this.effect.active = this._cacheable = !isSSR;
|
|
1164
|
-
this["__v_isReadonly"] = isReadonly;
|
|
1165
|
-
}
|
|
1166
|
-
get value() {
|
|
1167
|
-
const self = toRaw(this);
|
|
1168
|
-
trackRefValue(self);
|
|
1169
|
-
if (self._dirty || !self._cacheable) {
|
|
1170
|
-
self._dirty = false;
|
|
1171
|
-
self._value = self.effect.run();
|
|
1172
|
-
}
|
|
1173
|
-
return self._value;
|
|
1174
|
-
}
|
|
1175
|
-
set value(newValue) {
|
|
1176
|
-
this._setter(newValue);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1180
|
-
let getter;
|
|
1181
|
-
let setter;
|
|
1182
|
-
const onlyGetter = isFunction(getterOrOptions);
|
|
1183
|
-
if (onlyGetter) {
|
|
1184
|
-
getter = getterOrOptions;
|
|
1185
|
-
setter = () => {
|
|
1186
|
-
console.warn("Write operation failed: computed value is readonly");
|
|
1187
|
-
} ;
|
|
1188
|
-
} else {
|
|
1189
|
-
getter = getterOrOptions.get;
|
|
1190
|
-
setter = getterOrOptions.set;
|
|
1191
|
-
}
|
|
1192
|
-
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1193
|
-
if (debugOptions && !isSSR) {
|
|
1194
|
-
cRef.effect.onTrack = debugOptions.onTrack;
|
|
1195
|
-
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1196
|
-
}
|
|
1197
|
-
return cRef;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
const tick = /* @__PURE__ */ Promise.resolve();
|
|
1201
|
-
const queue = [];
|
|
1202
|
-
let queued = false;
|
|
1203
|
-
const scheduler = (fn) => {
|
|
1204
|
-
queue.push(fn);
|
|
1205
|
-
if (!queued) {
|
|
1206
|
-
queued = true;
|
|
1207
|
-
tick.then(flush);
|
|
1208
|
-
}
|
|
1209
|
-
};
|
|
1210
|
-
const flush = () => {
|
|
1211
|
-
for (let i = 0; i < queue.length; i++) {
|
|
1212
|
-
queue[i]();
|
|
1213
|
-
}
|
|
1214
|
-
queue.length = 0;
|
|
1215
|
-
queued = false;
|
|
1216
|
-
};
|
|
1217
|
-
class DeferredComputedRefImpl {
|
|
1218
|
-
constructor(getter) {
|
|
1219
|
-
this.dep = void 0;
|
|
1220
|
-
this._dirty = true;
|
|
1221
|
-
this.__v_isRef = true;
|
|
1222
|
-
this["__v_isReadonly"] = true;
|
|
1223
|
-
let compareTarget;
|
|
1224
|
-
let hasCompareTarget = false;
|
|
1225
|
-
let scheduled = false;
|
|
1226
|
-
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
|
|
1227
|
-
if (this.dep) {
|
|
1228
|
-
if (computedTrigger) {
|
|
1229
|
-
compareTarget = this._value;
|
|
1230
|
-
hasCompareTarget = true;
|
|
1231
|
-
} else if (!scheduled) {
|
|
1232
|
-
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
|
|
1233
|
-
scheduled = true;
|
|
1234
|
-
hasCompareTarget = false;
|
|
1235
|
-
scheduler(() => {
|
|
1236
|
-
if (this.effect.active && this._get() !== valueToCompare) {
|
|
1237
|
-
triggerRefValue(this);
|
|
1238
|
-
}
|
|
1239
|
-
scheduled = false;
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
|
-
for (const e of this.dep) {
|
|
1243
|
-
if (e.computed instanceof DeferredComputedRefImpl) {
|
|
1244
|
-
e.scheduler(
|
|
1245
|
-
true
|
|
1246
|
-
/* computedTrigger */
|
|
1247
|
-
);
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
this._dirty = true;
|
|
1252
|
-
});
|
|
1253
|
-
this.effect.computed = this;
|
|
1254
|
-
}
|
|
1255
|
-
_get() {
|
|
1256
|
-
if (this._dirty) {
|
|
1257
|
-
this._dirty = false;
|
|
1258
|
-
return this._value = this.effect.run();
|
|
1259
|
-
}
|
|
1260
|
-
return this._value;
|
|
1261
|
-
}
|
|
1262
|
-
get value() {
|
|
1263
|
-
trackRefValue(this);
|
|
1264
|
-
return toRaw(this)._get();
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
function deferredComputed(getter) {
|
|
1268
|
-
return new DeferredComputedRefImpl(getter);
|
|
1269
|
-
}
|
|
1239
|
+
const deferredComputed = computed;
|
|
1270
1240
|
|
|
1271
1241
|
exports.EffectScope = EffectScope;
|
|
1272
1242
|
exports.ITERATE_KEY = ITERATE_KEY;
|
|
@@ -1285,11 +1255,13 @@ var VueReactivity = (function (exports) {
|
|
|
1285
1255
|
exports.isShallow = isShallow;
|
|
1286
1256
|
exports.markRaw = markRaw;
|
|
1287
1257
|
exports.onScopeDispose = onScopeDispose;
|
|
1258
|
+
exports.pauseScheduling = pauseScheduling;
|
|
1288
1259
|
exports.pauseTracking = pauseTracking;
|
|
1289
1260
|
exports.proxyRefs = proxyRefs;
|
|
1290
1261
|
exports.reactive = reactive;
|
|
1291
1262
|
exports.readonly = readonly;
|
|
1292
1263
|
exports.ref = ref;
|
|
1264
|
+
exports.resetScheduling = resetScheduling;
|
|
1293
1265
|
exports.resetTracking = resetTracking;
|
|
1294
1266
|
exports.shallowReactive = shallowReactive;
|
|
1295
1267
|
exports.shallowReadonly = shallowReadonly;
|