@vue/reactivity 3.3.9 → 3.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactivity.cjs.js +251 -280
- package/dist/reactivity.cjs.prod.js +216 -257
- package/dist/reactivity.d.ts +105 -95
- package/dist/reactivity.esm-browser.js +254 -287
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +251 -290
- package/dist/reactivity.global.js +255 -286
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
|
@@ -2,14 +2,12 @@ var VueReactivity = (function (exports) {
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
function makeMap(str, expectsLowerCase) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
for (let i = 0; i < list.length; i++) {
|
|
8
|
-
map[list[i]] = true;
|
|
9
|
-
}
|
|
10
|
-
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
|
|
5
|
+
const set = new Set(str.split(","));
|
|
6
|
+
return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
|
|
11
7
|
}
|
|
12
8
|
|
|
9
|
+
const NOOP = () => {
|
|
10
|
+
};
|
|
13
11
|
const extend = Object.assign;
|
|
14
12
|
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
15
13
|
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
@@ -148,117 +146,120 @@ var VueReactivity = (function (exports) {
|
|
|
148
146
|
}
|
|
149
147
|
}
|
|
150
148
|
|
|
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
149
|
let activeEffect;
|
|
189
|
-
const ITERATE_KEY = Symbol("iterate" );
|
|
190
|
-
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
|
|
191
150
|
class ReactiveEffect {
|
|
192
|
-
constructor(fn, scheduler
|
|
151
|
+
constructor(fn, trigger, scheduler, scope) {
|
|
193
152
|
this.fn = fn;
|
|
153
|
+
this.trigger = trigger;
|
|
194
154
|
this.scheduler = scheduler;
|
|
195
155
|
this.active = true;
|
|
196
156
|
this.deps = [];
|
|
197
|
-
|
|
157
|
+
/**
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
this._dirtyLevel = 3;
|
|
161
|
+
/**
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
this._trackId = 0;
|
|
165
|
+
/**
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
this._runnings = 0;
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
this._queryings = 0;
|
|
173
|
+
/**
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
this._depsLength = 0;
|
|
198
177
|
recordEffectScope(this, scope);
|
|
199
178
|
}
|
|
179
|
+
get dirty() {
|
|
180
|
+
if (this._dirtyLevel === 1) {
|
|
181
|
+
this._dirtyLevel = 0;
|
|
182
|
+
this._queryings++;
|
|
183
|
+
pauseTracking();
|
|
184
|
+
for (const dep of this.deps) {
|
|
185
|
+
if (dep.computed) {
|
|
186
|
+
triggerComputed(dep.computed);
|
|
187
|
+
if (this._dirtyLevel >= 2) {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
resetTracking();
|
|
193
|
+
this._queryings--;
|
|
194
|
+
}
|
|
195
|
+
return this._dirtyLevel >= 2;
|
|
196
|
+
}
|
|
197
|
+
set dirty(v) {
|
|
198
|
+
this._dirtyLevel = v ? 3 : 0;
|
|
199
|
+
}
|
|
200
200
|
run() {
|
|
201
|
+
this._dirtyLevel = 0;
|
|
201
202
|
if (!this.active) {
|
|
202
203
|
return this.fn();
|
|
203
204
|
}
|
|
204
|
-
let parent = activeEffect;
|
|
205
205
|
let lastShouldTrack = shouldTrack;
|
|
206
|
-
|
|
207
|
-
if (parent === this) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
parent = parent.parent;
|
|
211
|
-
}
|
|
206
|
+
let lastEffect = activeEffect;
|
|
212
207
|
try {
|
|
213
|
-
this.parent = activeEffect;
|
|
214
|
-
activeEffect = this;
|
|
215
208
|
shouldTrack = true;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} else {
|
|
220
|
-
cleanupEffect(this);
|
|
221
|
-
}
|
|
209
|
+
activeEffect = this;
|
|
210
|
+
this._runnings++;
|
|
211
|
+
preCleanupEffect(this);
|
|
222
212
|
return this.fn();
|
|
223
213
|
} finally {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
trackOpBit = 1 << --effectTrackDepth;
|
|
228
|
-
activeEffect = this.parent;
|
|
214
|
+
postCleanupEffect(this);
|
|
215
|
+
this._runnings--;
|
|
216
|
+
activeEffect = lastEffect;
|
|
229
217
|
shouldTrack = lastShouldTrack;
|
|
230
|
-
this.parent = void 0;
|
|
231
|
-
if (this.deferStop) {
|
|
232
|
-
this.stop();
|
|
233
|
-
}
|
|
234
218
|
}
|
|
235
219
|
}
|
|
236
220
|
stop() {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.onStop();
|
|
243
|
-
}
|
|
221
|
+
var _a;
|
|
222
|
+
if (this.active) {
|
|
223
|
+
preCleanupEffect(this);
|
|
224
|
+
postCleanupEffect(this);
|
|
225
|
+
(_a = this.onStop) == null ? void 0 : _a.call(this);
|
|
244
226
|
this.active = false;
|
|
245
227
|
}
|
|
246
228
|
}
|
|
247
229
|
}
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
230
|
+
function triggerComputed(computed) {
|
|
231
|
+
return computed.value;
|
|
232
|
+
}
|
|
233
|
+
function preCleanupEffect(effect2) {
|
|
234
|
+
effect2._trackId++;
|
|
235
|
+
effect2._depsLength = 0;
|
|
236
|
+
}
|
|
237
|
+
function postCleanupEffect(effect2) {
|
|
238
|
+
if (effect2.deps && effect2.deps.length > effect2._depsLength) {
|
|
239
|
+
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
|
240
|
+
cleanupDepEffect(effect2.deps[i], effect2);
|
|
241
|
+
}
|
|
242
|
+
effect2.deps.length = effect2._depsLength;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function cleanupDepEffect(dep, effect2) {
|
|
246
|
+
const trackId = dep.get(effect2);
|
|
247
|
+
if (trackId !== void 0 && effect2._trackId !== trackId) {
|
|
248
|
+
dep.delete(effect2);
|
|
249
|
+
if (dep.size === 0) {
|
|
250
|
+
dep.cleanup();
|
|
253
251
|
}
|
|
254
|
-
deps.length = 0;
|
|
255
252
|
}
|
|
256
253
|
}
|
|
257
254
|
function effect(fn, options) {
|
|
258
255
|
if (fn.effect instanceof ReactiveEffect) {
|
|
259
256
|
fn = fn.effect.fn;
|
|
260
257
|
}
|
|
261
|
-
const _effect = new ReactiveEffect(fn)
|
|
258
|
+
const _effect = new ReactiveEffect(fn, NOOP, () => {
|
|
259
|
+
if (_effect.dirty) {
|
|
260
|
+
_effect.run();
|
|
261
|
+
}
|
|
262
|
+
});
|
|
262
263
|
if (options) {
|
|
263
264
|
extend(_effect, options);
|
|
264
265
|
if (options.scope)
|
|
@@ -275,6 +276,7 @@ var VueReactivity = (function (exports) {
|
|
|
275
276
|
runner.effect.stop();
|
|
276
277
|
}
|
|
277
278
|
let shouldTrack = true;
|
|
279
|
+
let pauseScheduleStack = 0;
|
|
278
280
|
const trackStack = [];
|
|
279
281
|
function pauseTracking() {
|
|
280
282
|
trackStack.push(shouldTrack);
|
|
@@ -288,6 +290,68 @@ var VueReactivity = (function (exports) {
|
|
|
288
290
|
const last = trackStack.pop();
|
|
289
291
|
shouldTrack = last === void 0 ? true : last;
|
|
290
292
|
}
|
|
293
|
+
function pauseScheduling() {
|
|
294
|
+
pauseScheduleStack++;
|
|
295
|
+
}
|
|
296
|
+
function resetScheduling() {
|
|
297
|
+
pauseScheduleStack--;
|
|
298
|
+
while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
|
299
|
+
queueEffectSchedulers.shift()();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
|
303
|
+
var _a;
|
|
304
|
+
if (dep.get(effect2) !== effect2._trackId) {
|
|
305
|
+
dep.set(effect2, effect2._trackId);
|
|
306
|
+
const oldDep = effect2.deps[effect2._depsLength];
|
|
307
|
+
if (oldDep !== dep) {
|
|
308
|
+
if (oldDep) {
|
|
309
|
+
cleanupDepEffect(oldDep, effect2);
|
|
310
|
+
}
|
|
311
|
+
effect2.deps[effect2._depsLength++] = dep;
|
|
312
|
+
} else {
|
|
313
|
+
effect2._depsLength++;
|
|
314
|
+
}
|
|
315
|
+
{
|
|
316
|
+
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const queueEffectSchedulers = [];
|
|
321
|
+
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
322
|
+
var _a;
|
|
323
|
+
pauseScheduling();
|
|
324
|
+
for (const effect2 of dep.keys()) {
|
|
325
|
+
if (!effect2.allowRecurse && effect2._runnings) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
|
|
329
|
+
const lastDirtyLevel = effect2._dirtyLevel;
|
|
330
|
+
effect2._dirtyLevel = dirtyLevel;
|
|
331
|
+
if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
|
|
332
|
+
{
|
|
333
|
+
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
334
|
+
}
|
|
335
|
+
effect2.trigger();
|
|
336
|
+
if (effect2.scheduler) {
|
|
337
|
+
queueEffectSchedulers.push(effect2.scheduler);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
resetScheduling();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const createDep = (cleanup, computed) => {
|
|
346
|
+
const dep = /* @__PURE__ */ new Map();
|
|
347
|
+
dep.cleanup = cleanup;
|
|
348
|
+
dep.computed = computed;
|
|
349
|
+
return dep;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
353
|
+
const ITERATE_KEY = Symbol("iterate" );
|
|
354
|
+
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
|
|
291
355
|
function track(target, type, key) {
|
|
292
356
|
if (shouldTrack && activeEffect) {
|
|
293
357
|
let depsMap = targetMap.get(target);
|
|
@@ -296,35 +360,17 @@ var VueReactivity = (function (exports) {
|
|
|
296
360
|
}
|
|
297
361
|
let dep = depsMap.get(key);
|
|
298
362
|
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
|
-
);
|
|
363
|
+
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
|
327
364
|
}
|
|
365
|
+
trackEffect(
|
|
366
|
+
activeEffect,
|
|
367
|
+
dep,
|
|
368
|
+
{
|
|
369
|
+
target,
|
|
370
|
+
type,
|
|
371
|
+
key
|
|
372
|
+
}
|
|
373
|
+
);
|
|
328
374
|
}
|
|
329
375
|
}
|
|
330
376
|
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
@@ -372,49 +418,24 @@ var VueReactivity = (function (exports) {
|
|
|
372
418
|
break;
|
|
373
419
|
}
|
|
374
420
|
}
|
|
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();
|
|
421
|
+
pauseScheduling();
|
|
422
|
+
for (const dep of deps) {
|
|
423
|
+
if (dep) {
|
|
424
|
+
triggerEffects(
|
|
425
|
+
dep,
|
|
426
|
+
3,
|
|
427
|
+
{
|
|
428
|
+
target,
|
|
429
|
+
type,
|
|
430
|
+
key,
|
|
431
|
+
newValue,
|
|
432
|
+
oldValue,
|
|
433
|
+
oldTarget
|
|
434
|
+
}
|
|
435
|
+
);
|
|
416
436
|
}
|
|
417
437
|
}
|
|
438
|
+
resetScheduling();
|
|
418
439
|
}
|
|
419
440
|
function getDepFromReactive(object, key) {
|
|
420
441
|
var _a;
|
|
@@ -445,7 +466,9 @@ var VueReactivity = (function (exports) {
|
|
|
445
466
|
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
446
467
|
instrumentations[key] = function(...args) {
|
|
447
468
|
pauseTracking();
|
|
469
|
+
pauseScheduling();
|
|
448
470
|
const res = toRaw(this)[key].apply(this, args);
|
|
471
|
+
resetScheduling();
|
|
449
472
|
resetTracking();
|
|
450
473
|
return res;
|
|
451
474
|
};
|
|
@@ -984,30 +1007,94 @@ var VueReactivity = (function (exports) {
|
|
|
984
1007
|
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
985
1008
|
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
986
1009
|
|
|
1010
|
+
class ComputedRefImpl {
|
|
1011
|
+
constructor(getter, _setter, isReadonly, isSSR) {
|
|
1012
|
+
this._setter = _setter;
|
|
1013
|
+
this.dep = void 0;
|
|
1014
|
+
this.__v_isRef = true;
|
|
1015
|
+
this["__v_isReadonly"] = false;
|
|
1016
|
+
this.effect = new ReactiveEffect(
|
|
1017
|
+
() => getter(this._value),
|
|
1018
|
+
() => triggerRefValue(this, 1)
|
|
1019
|
+
);
|
|
1020
|
+
this.effect.computed = this;
|
|
1021
|
+
this.effect.active = this._cacheable = !isSSR;
|
|
1022
|
+
this["__v_isReadonly"] = isReadonly;
|
|
1023
|
+
}
|
|
1024
|
+
get value() {
|
|
1025
|
+
const self = toRaw(this);
|
|
1026
|
+
trackRefValue(self);
|
|
1027
|
+
if (!self._cacheable || self.effect.dirty) {
|
|
1028
|
+
if (hasChanged(self._value, self._value = self.effect.run())) {
|
|
1029
|
+
triggerRefValue(self, 2);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
return self._value;
|
|
1033
|
+
}
|
|
1034
|
+
set value(newValue) {
|
|
1035
|
+
this._setter(newValue);
|
|
1036
|
+
}
|
|
1037
|
+
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
|
|
1038
|
+
get _dirty() {
|
|
1039
|
+
return this.effect.dirty;
|
|
1040
|
+
}
|
|
1041
|
+
set _dirty(v) {
|
|
1042
|
+
this.effect.dirty = v;
|
|
1043
|
+
}
|
|
1044
|
+
// #endregion
|
|
1045
|
+
}
|
|
1046
|
+
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1047
|
+
let getter;
|
|
1048
|
+
let setter;
|
|
1049
|
+
const onlyGetter = isFunction(getterOrOptions);
|
|
1050
|
+
if (onlyGetter) {
|
|
1051
|
+
getter = getterOrOptions;
|
|
1052
|
+
setter = () => {
|
|
1053
|
+
console.warn("Write operation failed: computed value is readonly");
|
|
1054
|
+
} ;
|
|
1055
|
+
} else {
|
|
1056
|
+
getter = getterOrOptions.get;
|
|
1057
|
+
setter = getterOrOptions.set;
|
|
1058
|
+
}
|
|
1059
|
+
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
1060
|
+
if (debugOptions && !isSSR) {
|
|
1061
|
+
cRef.effect.onTrack = debugOptions.onTrack;
|
|
1062
|
+
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
1063
|
+
}
|
|
1064
|
+
return cRef;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
987
1067
|
function trackRefValue(ref2) {
|
|
988
1068
|
if (shouldTrack && activeEffect) {
|
|
989
1069
|
ref2 = toRaw(ref2);
|
|
990
|
-
|
|
991
|
-
|
|
1070
|
+
trackEffect(
|
|
1071
|
+
activeEffect,
|
|
1072
|
+
ref2.dep || (ref2.dep = createDep(
|
|
1073
|
+
() => ref2.dep = void 0,
|
|
1074
|
+
ref2 instanceof ComputedRefImpl ? ref2 : void 0
|
|
1075
|
+
)),
|
|
1076
|
+
{
|
|
992
1077
|
target: ref2,
|
|
993
1078
|
type: "get",
|
|
994
1079
|
key: "value"
|
|
995
|
-
}
|
|
996
|
-
|
|
1080
|
+
}
|
|
1081
|
+
);
|
|
997
1082
|
}
|
|
998
1083
|
}
|
|
999
|
-
function triggerRefValue(ref2, newVal) {
|
|
1084
|
+
function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
|
|
1000
1085
|
ref2 = toRaw(ref2);
|
|
1001
1086
|
const dep = ref2.dep;
|
|
1002
1087
|
if (dep) {
|
|
1003
|
-
|
|
1004
|
-
|
|
1088
|
+
triggerEffects(
|
|
1089
|
+
dep,
|
|
1090
|
+
dirtyLevel,
|
|
1091
|
+
{
|
|
1005
1092
|
target: ref2,
|
|
1006
1093
|
type: "set",
|
|
1007
1094
|
key: "value",
|
|
1008
1095
|
newValue: newVal
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1096
|
+
}
|
|
1097
|
+
);
|
|
1011
1098
|
}
|
|
1012
1099
|
}
|
|
1013
1100
|
function isRef(r) {
|
|
@@ -1043,12 +1130,12 @@ var VueReactivity = (function (exports) {
|
|
|
1043
1130
|
if (hasChanged(newVal, this._rawValue)) {
|
|
1044
1131
|
this._rawValue = newVal;
|
|
1045
1132
|
this._value = useDirectValue ? newVal : toReactive(newVal);
|
|
1046
|
-
triggerRefValue(this, newVal);
|
|
1133
|
+
triggerRefValue(this, 3, newVal);
|
|
1047
1134
|
}
|
|
1048
1135
|
}
|
|
1049
1136
|
}
|
|
1050
1137
|
function triggerRef(ref2) {
|
|
1051
|
-
triggerRefValue(ref2, ref2.value );
|
|
1138
|
+
triggerRefValue(ref2, 3, ref2.value );
|
|
1052
1139
|
}
|
|
1053
1140
|
function unref(ref2) {
|
|
1054
1141
|
return isRef(ref2) ? ref2.value : ref2;
|
|
@@ -1146,127 +1233,7 @@ var VueReactivity = (function (exports) {
|
|
|
1146
1233
|
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
1147
1234
|
}
|
|
1148
1235
|
|
|
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
|
-
}
|
|
1236
|
+
const deferredComputed = computed;
|
|
1270
1237
|
|
|
1271
1238
|
exports.EffectScope = EffectScope;
|
|
1272
1239
|
exports.ITERATE_KEY = ITERATE_KEY;
|
|
@@ -1285,11 +1252,13 @@ var VueReactivity = (function (exports) {
|
|
|
1285
1252
|
exports.isShallow = isShallow;
|
|
1286
1253
|
exports.markRaw = markRaw;
|
|
1287
1254
|
exports.onScopeDispose = onScopeDispose;
|
|
1255
|
+
exports.pauseScheduling = pauseScheduling;
|
|
1288
1256
|
exports.pauseTracking = pauseTracking;
|
|
1289
1257
|
exports.proxyRefs = proxyRefs;
|
|
1290
1258
|
exports.reactive = reactive;
|
|
1291
1259
|
exports.readonly = readonly;
|
|
1292
1260
|
exports.ref = ref;
|
|
1261
|
+
exports.resetScheduling = resetScheduling;
|
|
1293
1262
|
exports.resetTracking = resetTracking;
|
|
1294
1263
|
exports.shallowReactive = shallowReactive;
|
|
1295
1264
|
exports.shallowReadonly = shallowReadonly;
|