@vue/reactivity
Advanced tools
Comparing version 3.4.25 to 3.5.0-alpha.1
/** | ||
* @vue/reactivity v3.4.25 | ||
* @vue/reactivity v3.5.0-alpha.1 | ||
* (c) 2018-present Yuxi (Evan) You and Vue contributors | ||
@@ -98,14 +98,9 @@ * @license MIT | ||
} | ||
function recordEffectScope(effect, scope = activeEffectScope) { | ||
if (scope && scope.active) { | ||
scope.effects.push(effect); | ||
} | ||
} | ||
function getCurrentScope() { | ||
return activeEffectScope; | ||
} | ||
function onScopeDispose(fn) { | ||
function onScopeDispose(fn, failSilently = false) { | ||
if (activeEffectScope) { | ||
activeEffectScope.cleanups.push(fn); | ||
} else { | ||
} else if (!failSilently) { | ||
warn( | ||
@@ -117,109 +112,257 @@ `onScopeDispose() is called when there is no active effect scope to be associated with.` | ||
let activeEffect; | ||
let activeSub; | ||
const EffectFlags = { | ||
"ACTIVE": 1, | ||
"1": "ACTIVE", | ||
"RUNNING": 2, | ||
"2": "RUNNING", | ||
"TRACKING": 4, | ||
"4": "TRACKING", | ||
"NOTIFIED": 8, | ||
"8": "NOTIFIED", | ||
"DIRTY": 16, | ||
"16": "DIRTY", | ||
"ALLOW_RECURSE": 32, | ||
"32": "ALLOW_RECURSE", | ||
"NO_BATCH": 64, | ||
"64": "NO_BATCH" | ||
}; | ||
class ReactiveEffect { | ||
constructor(fn, trigger, scheduler, scope) { | ||
constructor(fn) { | ||
this.fn = fn; | ||
this.trigger = trigger; | ||
this.scheduler = scheduler; | ||
this.active = true; | ||
this.deps = []; | ||
/** | ||
* @internal | ||
*/ | ||
this._dirtyLevel = 4; | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._trackId = 0; | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._runnings = 0; | ||
this.flags = 1 | 4; | ||
/** | ||
* @internal | ||
*/ | ||
this._shouldSchedule = false; | ||
this.nextEffect = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._depsLength = 0; | ||
recordEffectScope(this, scope); | ||
this.cleanup = void 0; | ||
this.scheduler = void 0; | ||
if (activeEffectScope && activeEffectScope.active) { | ||
activeEffectScope.effects.push(this); | ||
} | ||
} | ||
get dirty() { | ||
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) { | ||
this._dirtyLevel = 1; | ||
pauseTracking(); | ||
for (let i = 0; i < this._depsLength; i++) { | ||
const dep = this.deps[i]; | ||
if (dep.computed) { | ||
triggerComputed(dep.computed); | ||
if (this._dirtyLevel >= 4) { | ||
break; | ||
} | ||
} | ||
} | ||
if (this._dirtyLevel === 1) { | ||
this._dirtyLevel = 0; | ||
} | ||
resetTracking(); | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (this.flags & 2 && !(this.flags & 32)) { | ||
return; | ||
} | ||
return this._dirtyLevel >= 4; | ||
if (this.flags & 64) { | ||
return this.trigger(); | ||
} | ||
if (!(this.flags & 8)) { | ||
this.flags |= 8; | ||
this.nextEffect = batchedEffect; | ||
batchedEffect = this; | ||
} | ||
} | ||
set dirty(v) { | ||
this._dirtyLevel = v ? 4 : 0; | ||
} | ||
run() { | ||
this._dirtyLevel = 0; | ||
if (!this.active) { | ||
if (!(this.flags & 1)) { | ||
return this.fn(); | ||
} | ||
let lastShouldTrack = shouldTrack; | ||
let lastEffect = activeEffect; | ||
this.flags |= 2; | ||
cleanupEffect(this); | ||
prepareDeps(this); | ||
const prevEffect = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = this; | ||
shouldTrack = true; | ||
try { | ||
shouldTrack = true; | ||
activeEffect = this; | ||
this._runnings++; | ||
preCleanupEffect(this); | ||
return this.fn(); | ||
} finally { | ||
postCleanupEffect(this); | ||
this._runnings--; | ||
activeEffect = lastEffect; | ||
shouldTrack = lastShouldTrack; | ||
if (activeSub !== this) { | ||
warn( | ||
"Active effect was not restored correctly - this is likely a Vue internal bug." | ||
); | ||
} | ||
cleanupDeps(this); | ||
activeSub = prevEffect; | ||
shouldTrack = prevShouldTrack; | ||
this.flags &= ~2; | ||
} | ||
} | ||
stop() { | ||
var _a; | ||
if (this.active) { | ||
preCleanupEffect(this); | ||
postCleanupEffect(this); | ||
(_a = this.onStop) == null ? void 0 : _a.call(this); | ||
this.active = false; | ||
if (this.flags & 1) { | ||
for (let link = this.deps; link; link = link.nextDep) { | ||
removeSub(link); | ||
} | ||
this.deps = this.depsTail = void 0; | ||
cleanupEffect(this); | ||
this.onStop && this.onStop(); | ||
this.flags &= ~1; | ||
} | ||
} | ||
trigger() { | ||
if (this.scheduler) { | ||
this.scheduler(); | ||
} else { | ||
this.runIfDirty(); | ||
} | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
runIfDirty() { | ||
if (isDirty(this)) { | ||
this.run(); | ||
} | ||
} | ||
get dirty() { | ||
return isDirty(this); | ||
} | ||
} | ||
function triggerComputed(computed) { | ||
return computed.value; | ||
let batchDepth = 0; | ||
let batchedEffect; | ||
function startBatch() { | ||
batchDepth++; | ||
} | ||
function preCleanupEffect(effect2) { | ||
effect2._trackId++; | ||
effect2._depsLength = 0; | ||
function endBatch() { | ||
if (batchDepth > 1) { | ||
batchDepth--; | ||
return; | ||
} | ||
let error; | ||
while (batchedEffect) { | ||
let e = batchedEffect; | ||
batchedEffect = void 0; | ||
while (e) { | ||
const next = e.nextEffect; | ||
e.nextEffect = void 0; | ||
e.flags &= ~8; | ||
if (e.flags & 1) { | ||
try { | ||
e.trigger(); | ||
} catch (err) { | ||
if (!error) | ||
error = err; | ||
} | ||
} | ||
e = next; | ||
} | ||
} | ||
batchDepth--; | ||
if (error) | ||
throw error; | ||
} | ||
function postCleanupEffect(effect2) { | ||
if (effect2.deps.length > effect2._depsLength) { | ||
for (let i = effect2._depsLength; i < effect2.deps.length; i++) { | ||
cleanupDepEffect(effect2.deps[i], effect2); | ||
function prepareDeps(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
link.version = -1; | ||
link.prevActiveLink = link.dep.activeLink; | ||
link.dep.activeLink = link; | ||
} | ||
} | ||
function cleanupDeps(sub) { | ||
let head; | ||
let tail = sub.depsTail; | ||
for (let link = tail; link; link = link.prevDep) { | ||
if (link.version === -1) { | ||
if (link === tail) | ||
tail = link.prevDep; | ||
removeSub(link); | ||
removeDep(link); | ||
} else { | ||
head = link; | ||
} | ||
effect2.deps.length = effect2._depsLength; | ||
link.dep.activeLink = link.prevActiveLink; | ||
link.prevActiveLink = void 0; | ||
} | ||
sub.deps = head; | ||
sub.depsTail = tail; | ||
} | ||
function cleanupDepEffect(dep, effect2) { | ||
const trackId = dep.get(effect2); | ||
if (trackId !== void 0 && effect2._trackId !== trackId) { | ||
dep.delete(effect2); | ||
if (dep.size === 0) { | ||
dep.cleanup(); | ||
function isDirty(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) { | ||
return true; | ||
} | ||
} | ||
if (sub._dirty) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function refreshComputed(computed) { | ||
if (computed.flags & 2) { | ||
return false; | ||
} | ||
if (computed.flags & 4 && !(computed.flags & 16)) { | ||
return; | ||
} | ||
computed.flags &= ~16; | ||
if (computed.globalVersion === globalVersion) { | ||
return; | ||
} | ||
computed.globalVersion = globalVersion; | ||
const dep = computed.dep; | ||
computed.flags |= 2; | ||
if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) { | ||
computed.flags &= ~2; | ||
return; | ||
} | ||
const prevSub = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = computed; | ||
shouldTrack = true; | ||
try { | ||
prepareDeps(computed); | ||
const value = computed.fn(); | ||
if (dep.version === 0 || shared.hasChanged(value, computed._value)) { | ||
computed._value = value; | ||
dep.version++; | ||
} | ||
} catch (err) { | ||
dep.version++; | ||
throw err; | ||
} finally { | ||
activeSub = prevSub; | ||
shouldTrack = prevShouldTrack; | ||
cleanupDeps(computed); | ||
computed.flags &= ~2; | ||
} | ||
} | ||
function removeSub(link) { | ||
const { dep, prevSub, nextSub } = link; | ||
if (prevSub) { | ||
prevSub.nextSub = nextSub; | ||
link.prevSub = void 0; | ||
} | ||
if (nextSub) { | ||
nextSub.prevSub = prevSub; | ||
link.nextSub = void 0; | ||
} | ||
if (dep.subs === link) { | ||
dep.subs = prevSub; | ||
} | ||
if (!dep.subs && dep.computed) { | ||
dep.computed.flags &= ~4; | ||
for (let l = dep.computed.deps; l; l = l.nextDep) { | ||
removeSub(l); | ||
} | ||
} | ||
} | ||
function removeDep(link) { | ||
const { prevDep, nextDep } = link; | ||
if (prevDep) { | ||
prevDep.nextDep = nextDep; | ||
link.prevDep = void 0; | ||
} | ||
if (nextDep) { | ||
nextDep.prevDep = prevDep; | ||
link.nextDep = void 0; | ||
} | ||
} | ||
function effect(fn, options) { | ||
@@ -229,17 +372,14 @@ if (fn.effect instanceof ReactiveEffect) { | ||
} | ||
const _effect = new ReactiveEffect(fn, shared.NOOP, () => { | ||
if (_effect.dirty) { | ||
_effect.run(); | ||
} | ||
}); | ||
const e = new ReactiveEffect(fn); | ||
if (options) { | ||
shared.extend(_effect, options); | ||
if (options.scope) | ||
recordEffectScope(_effect, options.scope); | ||
shared.extend(e, options); | ||
} | ||
if (!options || !options.lazy) { | ||
_effect.run(); | ||
try { | ||
e.run(); | ||
} catch (err) { | ||
e.stop(); | ||
throw err; | ||
} | ||
const runner = _effect.run.bind(_effect); | ||
runner.effect = _effect; | ||
const runner = e.run.bind(e); | ||
runner.effect = e; | ||
return runner; | ||
@@ -251,3 +391,2 @@ } | ||
let shouldTrack = true; | ||
let pauseScheduleStack = 0; | ||
const trackStack = []; | ||
@@ -266,67 +405,152 @@ function pauseTracking() { | ||
} | ||
function pauseScheduling() { | ||
pauseScheduleStack++; | ||
function onEffectCleanup(fn, failSilently = false) { | ||
if (activeSub instanceof ReactiveEffect) { | ||
activeSub.cleanup = fn; | ||
} else if (!failSilently) { | ||
warn( | ||
`onEffectCleanup() was called when there was no active effect to associate with.` | ||
); | ||
} | ||
} | ||
function resetScheduling() { | ||
pauseScheduleStack--; | ||
while (!pauseScheduleStack && queueEffectSchedulers.length) { | ||
queueEffectSchedulers.shift()(); | ||
function cleanupEffect(e) { | ||
const { cleanup } = e; | ||
e.cleanup = void 0; | ||
if (cleanup) { | ||
const prevSub = activeSub; | ||
activeSub = void 0; | ||
try { | ||
cleanup(); | ||
} finally { | ||
activeSub = prevSub; | ||
} | ||
} | ||
} | ||
function trackEffect(effect2, dep, debuggerEventExtraInfo) { | ||
var _a; | ||
if (dep.get(effect2) !== effect2._trackId) { | ||
dep.set(effect2, effect2._trackId); | ||
const oldDep = effect2.deps[effect2._depsLength]; | ||
if (oldDep !== dep) { | ||
if (oldDep) { | ||
cleanupDepEffect(oldDep, effect2); | ||
} | ||
effect2.deps[effect2._depsLength++] = dep; | ||
} else { | ||
effect2._depsLength++; | ||
} | ||
let globalVersion = 0; | ||
class Dep { | ||
constructor(computed) { | ||
this.computed = computed; | ||
this.version = 0; | ||
/** | ||
* Link between this dep and the current active effect | ||
*/ | ||
this.activeLink = void 0; | ||
/** | ||
* Doubly linked list representing the subscribing effects (tail) | ||
*/ | ||
this.subs = void 0; | ||
{ | ||
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, shared.extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
this.subsHead = void 0; | ||
} | ||
} | ||
} | ||
const queueEffectSchedulers = []; | ||
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) { | ||
var _a; | ||
pauseScheduling(); | ||
for (const effect2 of dep.keys()) { | ||
let tracking; | ||
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0); | ||
effect2._dirtyLevel = dirtyLevel; | ||
track(debugInfo) { | ||
if (!activeSub || !shouldTrack) { | ||
return; | ||
} | ||
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
{ | ||
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, shared.extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
let link = this.activeLink; | ||
if (link === void 0 || link.sub !== activeSub) { | ||
link = this.activeLink = { | ||
dep: this, | ||
sub: activeSub, | ||
version: this.version, | ||
nextDep: void 0, | ||
prevDep: void 0, | ||
nextSub: void 0, | ||
prevSub: void 0, | ||
prevActiveLink: void 0 | ||
}; | ||
if (!activeSub.deps) { | ||
activeSub.deps = activeSub.depsTail = link; | ||
} else { | ||
link.prevDep = activeSub.depsTail; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
} | ||
effect2.trigger(); | ||
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) { | ||
effect2._shouldSchedule = false; | ||
if (effect2.scheduler) { | ||
queueEffectSchedulers.push(effect2.scheduler); | ||
if (activeSub.flags & 4) { | ||
addSub(link); | ||
} | ||
} else if (link.version === -1) { | ||
link.version = this.version; | ||
if (link.nextDep) { | ||
const next = link.nextDep; | ||
next.prevDep = link.prevDep; | ||
if (link.prevDep) { | ||
link.prevDep.nextDep = next; | ||
} | ||
link.prevDep = activeSub.depsTail; | ||
link.nextDep = void 0; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
if (activeSub.deps === link) { | ||
activeSub.deps = next; | ||
} | ||
} | ||
} | ||
if (activeSub.onTrack) { | ||
activeSub.onTrack( | ||
shared.extend( | ||
{ | ||
effect: activeSub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
return link; | ||
} | ||
resetScheduling(); | ||
trigger(debugInfo) { | ||
this.version++; | ||
globalVersion++; | ||
this.notify(debugInfo); | ||
} | ||
notify(debugInfo) { | ||
startBatch(); | ||
try { | ||
if (true) { | ||
for (let head = this.subsHead; head; head = head.nextSub) { | ||
if (head.sub.onTrigger && !(head.sub.flags & 8)) { | ||
head.sub.onTrigger( | ||
shared.extend( | ||
{ | ||
effect: head.sub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
} | ||
} | ||
for (let link = this.subs; link; link = link.prevSub) { | ||
link.sub.notify(); | ||
} | ||
} finally { | ||
endBatch(); | ||
} | ||
} | ||
} | ||
const createDep = (cleanup, computed) => { | ||
const dep = /* @__PURE__ */ new Map(); | ||
dep.cleanup = cleanup; | ||
dep.computed = computed; | ||
return dep; | ||
}; | ||
function addSub(link) { | ||
const computed = link.dep.computed; | ||
if (computed && !link.dep.subs) { | ||
computed.flags |= 4 | 16; | ||
for (let l = computed.deps; l; l = l.nextDep) { | ||
addSub(l); | ||
} | ||
} | ||
const currentTail = link.dep.subs; | ||
if (currentTail !== link) { | ||
link.prevSub = currentTail; | ||
if (currentTail) | ||
currentTail.nextSub = link; | ||
} | ||
if (link.dep.subsHead === void 0) { | ||
link.dep.subsHead = link; | ||
} | ||
link.dep.subs = link; | ||
} | ||
const targetMap = /* @__PURE__ */ new WeakMap(); | ||
const ITERATE_KEY = Symbol("iterate" ); | ||
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" ); | ||
const ITERATE_KEY = Symbol("Object iterate" ); | ||
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" ); | ||
const ARRAY_ITERATE_KEY = Symbol("Array iterate" ); | ||
function track(target, type, key) { | ||
if (shouldTrack && activeEffect) { | ||
if (shouldTrack && activeSub) { | ||
let depsMap = targetMap.get(target); | ||
@@ -338,13 +562,11 @@ if (!depsMap) { | ||
if (!dep) { | ||
depsMap.set(key, dep = createDep(() => depsMap.delete(key))); | ||
depsMap.set(key, dep = new Dep()); | ||
} | ||
trackEffect( | ||
activeEffect, | ||
dep, | ||
{ | ||
{ | ||
dep.track({ | ||
target, | ||
type, | ||
key | ||
} | ||
); | ||
}); | ||
} | ||
} | ||
@@ -355,2 +577,3 @@ } | ||
if (!depsMap) { | ||
globalVersion++; | ||
return; | ||
@@ -361,57 +584,61 @@ } | ||
deps = [...depsMap.values()]; | ||
} else if (key === "length" && shared.isArray(target)) { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || !shared.isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} else { | ||
const targetIsArray = shared.isArray(target); | ||
const isArrayIndex = targetIsArray && shared.isIntegerKey(key); | ||
if (targetIsArray && key === "length") { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !shared.isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} | ||
}); | ||
} else { | ||
const push = (dep) => dep && deps.push(dep); | ||
if (key !== void 0) { | ||
push(depsMap.get(key)); | ||
} | ||
}); | ||
} else { | ||
if (key !== void 0) { | ||
deps.push(depsMap.get(key)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!shared.isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
if (shared.isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
if (isArrayIndex) { | ||
push(depsMap.get(ARRAY_ITERATE_KEY)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (shared.isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} else if (isArrayIndex) { | ||
push(depsMap.get("length")); | ||
} | ||
} else if (shared.isIntegerKey(key)) { | ||
deps.push(depsMap.get("length")); | ||
} | ||
break; | ||
case "delete": | ||
if (!shared.isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
break; | ||
case "delete": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (shared.isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (shared.isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
push(depsMap.get(ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (shared.isMap(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
} | ||
break; | ||
break; | ||
} | ||
} | ||
} | ||
pauseScheduling(); | ||
startBatch(); | ||
for (const dep of deps) { | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
4, | ||
{ | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
} | ||
); | ||
{ | ||
dep.trigger({ | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
}); | ||
} | ||
} | ||
resetScheduling(); | ||
endBatch(); | ||
} | ||
@@ -423,2 +650,174 @@ function getDepFromReactive(object, key) { | ||
function reactiveReadArray(array) { | ||
const raw = toRaw(array); | ||
if (raw === array) | ||
return raw; | ||
track(raw, "iterate", ARRAY_ITERATE_KEY); | ||
return isShallow(array) ? raw : raw.map(toReactive); | ||
} | ||
function shallowReadArray(arr) { | ||
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY); | ||
return arr; | ||
} | ||
const arrayInstrumentations = { | ||
__proto__: null, | ||
[Symbol.iterator]() { | ||
return iterator(this, Symbol.iterator, toReactive); | ||
}, | ||
concat(...args) { | ||
return reactiveReadArray(this).concat( | ||
...args.map((x) => reactiveReadArray(x)) | ||
); | ||
}, | ||
entries() { | ||
return iterator(this, "entries", (value) => { | ||
value[1] = toReactive(value[1]); | ||
return value; | ||
}); | ||
}, | ||
every(fn, thisArg) { | ||
return apply(this, "every", fn, thisArg); | ||
}, | ||
filter(fn, thisArg) { | ||
const result = apply(this, "filter", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result; | ||
}, | ||
find(fn, thisArg) { | ||
const result = apply(this, "find", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findIndex(fn, thisArg) { | ||
return apply(this, "findIndex", fn, thisArg); | ||
}, | ||
findLast(fn, thisArg) { | ||
const result = apply(this, "findLast", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findLastIndex(fn, thisArg) { | ||
return apply(this, "findLastIndex", fn, thisArg); | ||
}, | ||
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement | ||
forEach(fn, thisArg) { | ||
return apply(this, "forEach", fn, thisArg); | ||
}, | ||
includes(...args) { | ||
return searchProxy(this, "includes", args); | ||
}, | ||
indexOf(...args) { | ||
return searchProxy(this, "indexOf", args); | ||
}, | ||
join(separator) { | ||
return reactiveReadArray(this).join(separator); | ||
}, | ||
// keys() iterator only reads `length`, no optimisation required | ||
lastIndexOf(...args) { | ||
return searchProxy(this, "lastIndexOf", args); | ||
}, | ||
map(fn, thisArg) { | ||
return apply(this, "map", fn, thisArg); | ||
}, | ||
pop() { | ||
return noTracking(this, "pop"); | ||
}, | ||
push(...args) { | ||
return noTracking(this, "push", args); | ||
}, | ||
reduce(fn, ...args) { | ||
return reduce(this, "reduce", fn, args); | ||
}, | ||
reduceRight(fn, ...args) { | ||
return reduce(this, "reduceRight", fn, args); | ||
}, | ||
shift() { | ||
return noTracking(this, "shift"); | ||
}, | ||
// slice could use ARRAY_ITERATE but also seems to beg for range tracking | ||
some(fn, thisArg) { | ||
return apply(this, "some", fn, thisArg); | ||
}, | ||
splice(...args) { | ||
return noTracking(this, "splice", args); | ||
}, | ||
toReversed() { | ||
return reactiveReadArray(this).toReversed(); | ||
}, | ||
toSorted(comparer) { | ||
return reactiveReadArray(this).toSorted(comparer); | ||
}, | ||
toSpliced(...args) { | ||
return reactiveReadArray(this).toSpliced(...args); | ||
}, | ||
unshift(...args) { | ||
return noTracking(this, "unshift", args); | ||
}, | ||
values() { | ||
return iterator(this, "values", toReactive); | ||
} | ||
}; | ||
function iterator(self, method, wrapValue) { | ||
const arr = shallowReadArray(self); | ||
const iter = arr[method](); | ||
if (arr !== self && !isShallow(self)) { | ||
iter._next = iter.next; | ||
iter.next = () => { | ||
const result = iter._next(); | ||
if (result.value) { | ||
result.value = wrapValue(result.value); | ||
} | ||
return result; | ||
}; | ||
} | ||
return iter; | ||
} | ||
function apply(self, method, fn, thisArg) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 2) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, thisArg); | ||
} | ||
function reduce(self, method, fn, args) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 3) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, ...args); | ||
} | ||
function searchProxy(self, method, args) { | ||
const arr = toRaw(self); | ||
track(arr, "iterate", ARRAY_ITERATE_KEY); | ||
const res = arr[method](...args); | ||
if ((res === -1 || res === false) && isProxy(args[0])) { | ||
args[0] = toRaw(args[0]); | ||
return arr[method](...args); | ||
} | ||
return res; | ||
} | ||
function noTracking(self, method, args = []) { | ||
pauseTracking(); | ||
startBatch(); | ||
const res = toRaw(self)[method].apply(self, args); | ||
endBatch(); | ||
resetTracking(); | ||
return res; | ||
} | ||
const isNonTrackableKeys = /* @__PURE__ */ shared.makeMap(`__proto__,__v_isRef,__isVue`); | ||
@@ -428,31 +827,2 @@ const builtInSymbols = new Set( | ||
); | ||
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); | ||
function createArrayInstrumentations() { | ||
const instrumentations = {}; | ||
["includes", "indexOf", "lastIndexOf"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
const arr = toRaw(this); | ||
for (let i = 0, l = this.length; i < l; i++) { | ||
track(arr, "get", i + ""); | ||
} | ||
const res = arr[key](...args); | ||
if (res === -1 || res === false) { | ||
return arr[key](...args.map(toRaw)); | ||
} else { | ||
return res; | ||
} | ||
}; | ||
}); | ||
["push", "pop", "shift", "unshift", "splice"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
pauseTracking(); | ||
pauseScheduling(); | ||
const res = toRaw(this)[key].apply(this, args); | ||
resetScheduling(); | ||
resetTracking(); | ||
return res; | ||
}; | ||
}); | ||
return instrumentations; | ||
} | ||
function hasOwnProperty(key) { | ||
@@ -488,4 +858,5 @@ if (!shared.isSymbol(key)) | ||
if (!isReadonly2) { | ||
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) { | ||
return Reflect.get(arrayInstrumentations, key, receiver); | ||
let fn; | ||
if (targetIsArray && (fn = arrayInstrumentations[key])) { | ||
return fn; | ||
} | ||
@@ -496,3 +867,10 @@ if (key === "hasOwnProperty") { | ||
} | ||
const res = Reflect.get(target, key, receiver); | ||
const res = Reflect.get( | ||
target, | ||
key, | ||
// if this is a proxy wrapping a ref, return methods using the raw ref | ||
// as receiver so that we don't have to call `toRaw` on the ref in all | ||
// its class methods | ||
isRef(target) ? target : receiver | ||
); | ||
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { | ||
@@ -996,106 +1374,4 @@ return res; | ||
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`; | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly, isSSR) { | ||
this.getter = getter; | ||
this._setter = _setter; | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
this["__v_isReadonly"] = false; | ||
this.effect = new ReactiveEffect( | ||
() => getter(this._value), | ||
() => triggerRefValue( | ||
this, | ||
this.effect._dirtyLevel === 2 ? 2 : 3 | ||
) | ||
); | ||
this.effect.computed = this; | ||
this.effect.active = this._cacheable = !isSSR; | ||
this["__v_isReadonly"] = isReadonly; | ||
} | ||
get value() { | ||
const self = toRaw(this); | ||
if ((!self._cacheable || self.effect.dirty) && shared.hasChanged(self._value, self._value = self.effect.run())) { | ||
triggerRefValue(self, 4); | ||
} | ||
trackRefValue(self); | ||
if (self.effect._dirtyLevel >= 2) { | ||
if (this._warnRecursive) { | ||
warn(COMPUTED_SIDE_EFFECT_WARN, ` | ||
getter: `, this.getter); | ||
} | ||
triggerRefValue(self, 2); | ||
} | ||
return self._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x | ||
get _dirty() { | ||
return this.effect.dirty; | ||
} | ||
set _dirty(v) { | ||
this.effect.dirty = v; | ||
} | ||
// #endregion | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
const onlyGetter = shared.isFunction(getterOrOptions); | ||
if (onlyGetter) { | ||
getter = getterOrOptions; | ||
setter = () => { | ||
warn("Write operation failed: computed value is readonly"); | ||
} ; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR); | ||
if (debugOptions && !isSSR) { | ||
cRef.effect.onTrack = debugOptions.onTrack; | ||
cRef.effect.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
function trackRefValue(ref2) { | ||
var _a; | ||
if (shouldTrack && activeEffect) { | ||
ref2 = toRaw(ref2); | ||
trackEffect( | ||
activeEffect, | ||
(_a = ref2.dep) != null ? _a : ref2.dep = createDep( | ||
() => ref2.dep = void 0, | ||
ref2 instanceof ComputedRefImpl ? ref2 : void 0 | ||
), | ||
{ | ||
target: ref2, | ||
type: "get", | ||
key: "value" | ||
} | ||
); | ||
} | ||
} | ||
function triggerRefValue(ref2, dirtyLevel = 4, newVal) { | ||
ref2 = toRaw(ref2); | ||
const dep = ref2.dep; | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
dirtyLevel, | ||
{ | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: newVal | ||
} | ||
); | ||
} | ||
} | ||
function isRef(r) { | ||
return !!(r && r.__v_isRef === true); | ||
return r ? r.__v_isRef === true : false; | ||
} | ||
@@ -1117,3 +1393,3 @@ function ref(value) { | ||
this.__v_isShallow = __v_isShallow; | ||
this.dep = void 0; | ||
this.dep = new Dep(); | ||
this.__v_isRef = true; | ||
@@ -1124,12 +1400,27 @@ this._rawValue = __v_isShallow ? value : toRaw(value); | ||
get value() { | ||
trackRefValue(this); | ||
{ | ||
this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}); | ||
} | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal); | ||
newVal = useDirectValue ? newVal : toRaw(newVal); | ||
if (shared.hasChanged(newVal, this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = useDirectValue ? newVal : toReactive(newVal); | ||
triggerRefValue(this, 4, newVal); | ||
set value(newValue) { | ||
const oldValue = this._rawValue; | ||
const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue); | ||
newValue = useDirectValue ? newValue : toRaw(newValue); | ||
if (shared.hasChanged(newValue, oldValue)) { | ||
this._rawValue = newValue; | ||
this._value = useDirectValue ? newValue : toReactive(newValue); | ||
{ | ||
this.dep.trigger({ | ||
target: this, | ||
type: "set", | ||
key: "value", | ||
newValue, | ||
oldValue | ||
}); | ||
} | ||
} | ||
@@ -1139,3 +1430,10 @@ } | ||
function triggerRef(ref2) { | ||
triggerRefValue(ref2, 4, ref2.value ); | ||
{ | ||
ref2.dep.trigger({ | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: ref2._value | ||
}); | ||
} | ||
} | ||
@@ -1165,8 +1463,5 @@ function unref(ref2) { | ||
constructor(factory) { | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
const { get, set } = factory( | ||
() => trackRefValue(this), | ||
() => triggerRefValue(this) | ||
); | ||
const dep = this.dep = new Dep(); | ||
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep)); | ||
this._get = get; | ||
@@ -1239,3 +1534,85 @@ this._set = set; | ||
const deferredComputed = computed; | ||
class ComputedRefImpl { | ||
constructor(fn, setter, isSSR) { | ||
this.fn = fn; | ||
this.setter = setter; | ||
/** | ||
* @internal | ||
*/ | ||
this._value = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.dep = new Dep(this); | ||
/** | ||
* @internal | ||
*/ | ||
this.__v_isRef = true; | ||
// A computed is also a subscriber that tracks other deps | ||
/** | ||
* @internal | ||
*/ | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.flags = 16; | ||
/** | ||
* @internal | ||
*/ | ||
this.globalVersion = globalVersion - 1; | ||
// for backwards compat | ||
this.effect = this; | ||
this.__v_isReadonly = !setter; | ||
this.isSSR = isSSR; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (activeSub !== this) { | ||
this.flags |= 16; | ||
this.dep.notify(); | ||
} | ||
} | ||
get value() { | ||
const link = this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}) ; | ||
refreshComputed(this); | ||
if (link) { | ||
link.version = this.dep.version; | ||
} | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
if (this.setter) { | ||
this.setter(newValue); | ||
} else { | ||
warn("Write operation failed: computed value is readonly"); | ||
} | ||
} | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
if (shared.isFunction(getterOrOptions)) { | ||
getter = getterOrOptions; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, isSSR); | ||
if (debugOptions && !isSSR) { | ||
cRef.onTrack = debugOptions.onTrack; | ||
cRef.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
@@ -1261,4 +1638,7 @@ const TrackOpTypes = { | ||
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY; | ||
exports.EffectFlags = EffectFlags; | ||
exports.EffectScope = EffectScope; | ||
exports.ITERATE_KEY = ITERATE_KEY; | ||
exports.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY; | ||
exports.ReactiveEffect = ReactiveEffect; | ||
@@ -1270,3 +1650,2 @@ exports.ReactiveFlags = ReactiveFlags; | ||
exports.customRef = customRef; | ||
exports.deferredComputed = deferredComputed; | ||
exports.effect = effect; | ||
@@ -1282,12 +1661,13 @@ exports.effectScope = effectScope; | ||
exports.markRaw = markRaw; | ||
exports.onEffectCleanup = onEffectCleanup; | ||
exports.onScopeDispose = onScopeDispose; | ||
exports.pauseScheduling = pauseScheduling; | ||
exports.pauseTracking = pauseTracking; | ||
exports.proxyRefs = proxyRefs; | ||
exports.reactive = reactive; | ||
exports.reactiveReadArray = reactiveReadArray; | ||
exports.readonly = readonly; | ||
exports.ref = ref; | ||
exports.resetScheduling = resetScheduling; | ||
exports.resetTracking = resetTracking; | ||
exports.shallowReactive = shallowReactive; | ||
exports.shallowReadArray = shallowReadArray; | ||
exports.shallowReadonly = shallowReadonly; | ||
@@ -1297,2 +1677,4 @@ exports.shallowRef = shallowRef; | ||
exports.toRaw = toRaw; | ||
exports.toReactive = toReactive; | ||
exports.toReadonly = toReadonly; | ||
exports.toRef = toRef; | ||
@@ -1299,0 +1681,0 @@ exports.toRefs = toRefs; |
/** | ||
* @vue/reactivity v3.4.25 | ||
* @vue/reactivity v3.5.0-alpha.1 | ||
* (c) 2018-present Yuxi (Evan) You and Vue contributors | ||
@@ -92,11 +92,6 @@ * @license MIT | ||
} | ||
function recordEffectScope(effect, scope = activeEffectScope) { | ||
if (scope && scope.active) { | ||
scope.effects.push(effect); | ||
} | ||
} | ||
function getCurrentScope() { | ||
return activeEffectScope; | ||
} | ||
function onScopeDispose(fn) { | ||
function onScopeDispose(fn, failSilently = false) { | ||
if (activeEffectScope) { | ||
@@ -107,109 +102,252 @@ activeEffectScope.cleanups.push(fn); | ||
let activeEffect; | ||
let activeSub; | ||
const EffectFlags = { | ||
"ACTIVE": 1, | ||
"1": "ACTIVE", | ||
"RUNNING": 2, | ||
"2": "RUNNING", | ||
"TRACKING": 4, | ||
"4": "TRACKING", | ||
"NOTIFIED": 8, | ||
"8": "NOTIFIED", | ||
"DIRTY": 16, | ||
"16": "DIRTY", | ||
"ALLOW_RECURSE": 32, | ||
"32": "ALLOW_RECURSE", | ||
"NO_BATCH": 64, | ||
"64": "NO_BATCH" | ||
}; | ||
class ReactiveEffect { | ||
constructor(fn, trigger, scheduler, scope) { | ||
constructor(fn) { | ||
this.fn = fn; | ||
this.trigger = trigger; | ||
this.scheduler = scheduler; | ||
this.active = true; | ||
this.deps = []; | ||
/** | ||
* @internal | ||
*/ | ||
this._dirtyLevel = 4; | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._trackId = 0; | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._runnings = 0; | ||
this.flags = 1 | 4; | ||
/** | ||
* @internal | ||
*/ | ||
this._shouldSchedule = false; | ||
this.nextEffect = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._depsLength = 0; | ||
recordEffectScope(this, scope); | ||
this.cleanup = void 0; | ||
this.scheduler = void 0; | ||
if (activeEffectScope && activeEffectScope.active) { | ||
activeEffectScope.effects.push(this); | ||
} | ||
} | ||
get dirty() { | ||
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) { | ||
this._dirtyLevel = 1; | ||
pauseTracking(); | ||
for (let i = 0; i < this._depsLength; i++) { | ||
const dep = this.deps[i]; | ||
if (dep.computed) { | ||
triggerComputed(dep.computed); | ||
if (this._dirtyLevel >= 4) { | ||
break; | ||
} | ||
} | ||
} | ||
if (this._dirtyLevel === 1) { | ||
this._dirtyLevel = 0; | ||
} | ||
resetTracking(); | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (this.flags & 2 && !(this.flags & 32)) { | ||
return; | ||
} | ||
return this._dirtyLevel >= 4; | ||
if (this.flags & 64) { | ||
return this.trigger(); | ||
} | ||
if (!(this.flags & 8)) { | ||
this.flags |= 8; | ||
this.nextEffect = batchedEffect; | ||
batchedEffect = this; | ||
} | ||
} | ||
set dirty(v) { | ||
this._dirtyLevel = v ? 4 : 0; | ||
} | ||
run() { | ||
this._dirtyLevel = 0; | ||
if (!this.active) { | ||
if (!(this.flags & 1)) { | ||
return this.fn(); | ||
} | ||
let lastShouldTrack = shouldTrack; | ||
let lastEffect = activeEffect; | ||
this.flags |= 2; | ||
cleanupEffect(this); | ||
prepareDeps(this); | ||
const prevEffect = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = this; | ||
shouldTrack = true; | ||
try { | ||
shouldTrack = true; | ||
activeEffect = this; | ||
this._runnings++; | ||
preCleanupEffect(this); | ||
return this.fn(); | ||
} finally { | ||
postCleanupEffect(this); | ||
this._runnings--; | ||
activeEffect = lastEffect; | ||
shouldTrack = lastShouldTrack; | ||
cleanupDeps(this); | ||
activeSub = prevEffect; | ||
shouldTrack = prevShouldTrack; | ||
this.flags &= ~2; | ||
} | ||
} | ||
stop() { | ||
var _a; | ||
if (this.active) { | ||
preCleanupEffect(this); | ||
postCleanupEffect(this); | ||
(_a = this.onStop) == null ? void 0 : _a.call(this); | ||
this.active = false; | ||
if (this.flags & 1) { | ||
for (let link = this.deps; link; link = link.nextDep) { | ||
removeSub(link); | ||
} | ||
this.deps = this.depsTail = void 0; | ||
cleanupEffect(this); | ||
this.onStop && this.onStop(); | ||
this.flags &= ~1; | ||
} | ||
} | ||
trigger() { | ||
if (this.scheduler) { | ||
this.scheduler(); | ||
} else { | ||
this.runIfDirty(); | ||
} | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
runIfDirty() { | ||
if (isDirty(this)) { | ||
this.run(); | ||
} | ||
} | ||
get dirty() { | ||
return isDirty(this); | ||
} | ||
} | ||
function triggerComputed(computed) { | ||
return computed.value; | ||
let batchDepth = 0; | ||
let batchedEffect; | ||
function startBatch() { | ||
batchDepth++; | ||
} | ||
function preCleanupEffect(effect2) { | ||
effect2._trackId++; | ||
effect2._depsLength = 0; | ||
function endBatch() { | ||
if (batchDepth > 1) { | ||
batchDepth--; | ||
return; | ||
} | ||
let error; | ||
while (batchedEffect) { | ||
let e = batchedEffect; | ||
batchedEffect = void 0; | ||
while (e) { | ||
const next = e.nextEffect; | ||
e.nextEffect = void 0; | ||
e.flags &= ~8; | ||
if (e.flags & 1) { | ||
try { | ||
e.trigger(); | ||
} catch (err) { | ||
if (!error) | ||
error = err; | ||
} | ||
} | ||
e = next; | ||
} | ||
} | ||
batchDepth--; | ||
if (error) | ||
throw error; | ||
} | ||
function postCleanupEffect(effect2) { | ||
if (effect2.deps.length > effect2._depsLength) { | ||
for (let i = effect2._depsLength; i < effect2.deps.length; i++) { | ||
cleanupDepEffect(effect2.deps[i], effect2); | ||
function prepareDeps(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
link.version = -1; | ||
link.prevActiveLink = link.dep.activeLink; | ||
link.dep.activeLink = link; | ||
} | ||
} | ||
function cleanupDeps(sub) { | ||
let head; | ||
let tail = sub.depsTail; | ||
for (let link = tail; link; link = link.prevDep) { | ||
if (link.version === -1) { | ||
if (link === tail) | ||
tail = link.prevDep; | ||
removeSub(link); | ||
removeDep(link); | ||
} else { | ||
head = link; | ||
} | ||
effect2.deps.length = effect2._depsLength; | ||
link.dep.activeLink = link.prevActiveLink; | ||
link.prevActiveLink = void 0; | ||
} | ||
sub.deps = head; | ||
sub.depsTail = tail; | ||
} | ||
function cleanupDepEffect(dep, effect2) { | ||
const trackId = dep.get(effect2); | ||
if (trackId !== void 0 && effect2._trackId !== trackId) { | ||
dep.delete(effect2); | ||
if (dep.size === 0) { | ||
dep.cleanup(); | ||
function isDirty(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) { | ||
return true; | ||
} | ||
} | ||
if (sub._dirty) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function refreshComputed(computed) { | ||
if (computed.flags & 2) { | ||
return false; | ||
} | ||
if (computed.flags & 4 && !(computed.flags & 16)) { | ||
return; | ||
} | ||
computed.flags &= ~16; | ||
if (computed.globalVersion === globalVersion) { | ||
return; | ||
} | ||
computed.globalVersion = globalVersion; | ||
const dep = computed.dep; | ||
computed.flags |= 2; | ||
if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) { | ||
computed.flags &= ~2; | ||
return; | ||
} | ||
const prevSub = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = computed; | ||
shouldTrack = true; | ||
try { | ||
prepareDeps(computed); | ||
const value = computed.fn(); | ||
if (dep.version === 0 || shared.hasChanged(value, computed._value)) { | ||
computed._value = value; | ||
dep.version++; | ||
} | ||
} catch (err) { | ||
dep.version++; | ||
throw err; | ||
} finally { | ||
activeSub = prevSub; | ||
shouldTrack = prevShouldTrack; | ||
cleanupDeps(computed); | ||
computed.flags &= ~2; | ||
} | ||
} | ||
function removeSub(link) { | ||
const { dep, prevSub, nextSub } = link; | ||
if (prevSub) { | ||
prevSub.nextSub = nextSub; | ||
link.prevSub = void 0; | ||
} | ||
if (nextSub) { | ||
nextSub.prevSub = prevSub; | ||
link.nextSub = void 0; | ||
} | ||
if (dep.subs === link) { | ||
dep.subs = prevSub; | ||
} | ||
if (!dep.subs && dep.computed) { | ||
dep.computed.flags &= ~4; | ||
for (let l = dep.computed.deps; l; l = l.nextDep) { | ||
removeSub(l); | ||
} | ||
} | ||
} | ||
function removeDep(link) { | ||
const { prevDep, nextDep } = link; | ||
if (prevDep) { | ||
prevDep.nextDep = nextDep; | ||
link.prevDep = void 0; | ||
} | ||
if (nextDep) { | ||
nextDep.prevDep = prevDep; | ||
link.nextDep = void 0; | ||
} | ||
} | ||
function effect(fn, options) { | ||
@@ -219,17 +357,14 @@ if (fn.effect instanceof ReactiveEffect) { | ||
} | ||
const _effect = new ReactiveEffect(fn, shared.NOOP, () => { | ||
if (_effect.dirty) { | ||
_effect.run(); | ||
} | ||
}); | ||
const e = new ReactiveEffect(fn); | ||
if (options) { | ||
shared.extend(_effect, options); | ||
if (options.scope) | ||
recordEffectScope(_effect, options.scope); | ||
shared.extend(e, options); | ||
} | ||
if (!options || !options.lazy) { | ||
_effect.run(); | ||
try { | ||
e.run(); | ||
} catch (err) { | ||
e.stop(); | ||
throw err; | ||
} | ||
const runner = _effect.run.bind(_effect); | ||
runner.effect = _effect; | ||
const runner = e.run.bind(e); | ||
runner.effect = e; | ||
return runner; | ||
@@ -241,3 +376,2 @@ } | ||
let shouldTrack = true; | ||
let pauseScheduleStack = 0; | ||
const trackStack = []; | ||
@@ -256,59 +390,119 @@ function pauseTracking() { | ||
} | ||
function pauseScheduling() { | ||
pauseScheduleStack++; | ||
} | ||
function resetScheduling() { | ||
pauseScheduleStack--; | ||
while (!pauseScheduleStack && queueEffectSchedulers.length) { | ||
queueEffectSchedulers.shift()(); | ||
function onEffectCleanup(fn, failSilently = false) { | ||
if (activeSub instanceof ReactiveEffect) { | ||
activeSub.cleanup = fn; | ||
} | ||
} | ||
function trackEffect(effect2, dep, debuggerEventExtraInfo) { | ||
if (dep.get(effect2) !== effect2._trackId) { | ||
dep.set(effect2, effect2._trackId); | ||
const oldDep = effect2.deps[effect2._depsLength]; | ||
if (oldDep !== dep) { | ||
if (oldDep) { | ||
cleanupDepEffect(oldDep, effect2); | ||
} | ||
effect2.deps[effect2._depsLength++] = dep; | ||
} else { | ||
effect2._depsLength++; | ||
function cleanupEffect(e) { | ||
const { cleanup } = e; | ||
e.cleanup = void 0; | ||
if (cleanup) { | ||
const prevSub = activeSub; | ||
activeSub = void 0; | ||
try { | ||
cleanup(); | ||
} finally { | ||
activeSub = prevSub; | ||
} | ||
} | ||
} | ||
const queueEffectSchedulers = []; | ||
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) { | ||
pauseScheduling(); | ||
for (const effect2 of dep.keys()) { | ||
let tracking; | ||
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0); | ||
effect2._dirtyLevel = dirtyLevel; | ||
let globalVersion = 0; | ||
class Dep { | ||
constructor(computed) { | ||
this.computed = computed; | ||
this.version = 0; | ||
/** | ||
* Link between this dep and the current active effect | ||
*/ | ||
this.activeLink = void 0; | ||
/** | ||
* Doubly linked list representing the subscribing effects (tail) | ||
*/ | ||
this.subs = void 0; | ||
} | ||
track(debugInfo) { | ||
if (!activeSub || !shouldTrack) { | ||
return; | ||
} | ||
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
effect2.trigger(); | ||
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) { | ||
effect2._shouldSchedule = false; | ||
if (effect2.scheduler) { | ||
queueEffectSchedulers.push(effect2.scheduler); | ||
let link = this.activeLink; | ||
if (link === void 0 || link.sub !== activeSub) { | ||
link = this.activeLink = { | ||
dep: this, | ||
sub: activeSub, | ||
version: this.version, | ||
nextDep: void 0, | ||
prevDep: void 0, | ||
nextSub: void 0, | ||
prevSub: void 0, | ||
prevActiveLink: void 0 | ||
}; | ||
if (!activeSub.deps) { | ||
activeSub.deps = activeSub.depsTail = link; | ||
} else { | ||
link.prevDep = activeSub.depsTail; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
} | ||
if (activeSub.flags & 4) { | ||
addSub(link); | ||
} | ||
} else if (link.version === -1) { | ||
link.version = this.version; | ||
if (link.nextDep) { | ||
const next = link.nextDep; | ||
next.prevDep = link.prevDep; | ||
if (link.prevDep) { | ||
link.prevDep.nextDep = next; | ||
} | ||
link.prevDep = activeSub.depsTail; | ||
link.nextDep = void 0; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
if (activeSub.deps === link) { | ||
activeSub.deps = next; | ||
} | ||
} | ||
} | ||
return link; | ||
} | ||
resetScheduling(); | ||
trigger(debugInfo) { | ||
this.version++; | ||
globalVersion++; | ||
this.notify(debugInfo); | ||
} | ||
notify(debugInfo) { | ||
startBatch(); | ||
try { | ||
if (false) ; | ||
for (let link = this.subs; link; link = link.prevSub) { | ||
link.sub.notify(); | ||
} | ||
} finally { | ||
endBatch(); | ||
} | ||
} | ||
} | ||
const createDep = (cleanup, computed) => { | ||
const dep = /* @__PURE__ */ new Map(); | ||
dep.cleanup = cleanup; | ||
dep.computed = computed; | ||
return dep; | ||
}; | ||
function addSub(link) { | ||
const computed = link.dep.computed; | ||
if (computed && !link.dep.subs) { | ||
computed.flags |= 4 | 16; | ||
for (let l = computed.deps; l; l = l.nextDep) { | ||
addSub(l); | ||
} | ||
} | ||
const currentTail = link.dep.subs; | ||
if (currentTail !== link) { | ||
link.prevSub = currentTail; | ||
if (currentTail) | ||
currentTail.nextSub = link; | ||
} | ||
link.dep.subs = link; | ||
} | ||
const targetMap = /* @__PURE__ */ new WeakMap(); | ||
const ITERATE_KEY = Symbol(""); | ||
const MAP_KEY_ITERATE_KEY = Symbol(""); | ||
const ARRAY_ITERATE_KEY = Symbol(""); | ||
function track(target, type, key) { | ||
if (shouldTrack && activeEffect) { | ||
if (shouldTrack && activeSub) { | ||
let depsMap = targetMap.get(target); | ||
@@ -320,7 +514,7 @@ if (!depsMap) { | ||
if (!dep) { | ||
depsMap.set(key, dep = createDep(() => depsMap.delete(key))); | ||
depsMap.set(key, dep = new Dep()); | ||
} | ||
trackEffect( | ||
activeEffect, | ||
dep); | ||
{ | ||
dep.track(); | ||
} | ||
} | ||
@@ -331,2 +525,3 @@ } | ||
if (!depsMap) { | ||
globalVersion++; | ||
return; | ||
@@ -337,48 +532,54 @@ } | ||
deps = [...depsMap.values()]; | ||
} else if (key === "length" && shared.isArray(target)) { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || !shared.isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} else { | ||
const targetIsArray = shared.isArray(target); | ||
const isArrayIndex = targetIsArray && shared.isIntegerKey(key); | ||
if (targetIsArray && key === "length") { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !shared.isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} | ||
}); | ||
} else { | ||
const push = (dep) => dep && deps.push(dep); | ||
if (key !== void 0) { | ||
push(depsMap.get(key)); | ||
} | ||
}); | ||
} else { | ||
if (key !== void 0) { | ||
deps.push(depsMap.get(key)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!shared.isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
if (shared.isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
if (isArrayIndex) { | ||
push(depsMap.get(ARRAY_ITERATE_KEY)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (shared.isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} else if (isArrayIndex) { | ||
push(depsMap.get("length")); | ||
} | ||
} else if (shared.isIntegerKey(key)) { | ||
deps.push(depsMap.get("length")); | ||
} | ||
break; | ||
case "delete": | ||
if (!shared.isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
break; | ||
case "delete": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (shared.isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (shared.isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
push(depsMap.get(ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (shared.isMap(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
} | ||
break; | ||
break; | ||
} | ||
} | ||
} | ||
pauseScheduling(); | ||
startBatch(); | ||
for (const dep of deps) { | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
4); | ||
{ | ||
dep.trigger(); | ||
} | ||
} | ||
resetScheduling(); | ||
endBatch(); | ||
} | ||
@@ -390,2 +591,174 @@ function getDepFromReactive(object, key) { | ||
function reactiveReadArray(array) { | ||
const raw = toRaw(array); | ||
if (raw === array) | ||
return raw; | ||
track(raw, "iterate", ARRAY_ITERATE_KEY); | ||
return isShallow(array) ? raw : raw.map(toReactive); | ||
} | ||
function shallowReadArray(arr) { | ||
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY); | ||
return arr; | ||
} | ||
const arrayInstrumentations = { | ||
__proto__: null, | ||
[Symbol.iterator]() { | ||
return iterator(this, Symbol.iterator, toReactive); | ||
}, | ||
concat(...args) { | ||
return reactiveReadArray(this).concat( | ||
...args.map((x) => reactiveReadArray(x)) | ||
); | ||
}, | ||
entries() { | ||
return iterator(this, "entries", (value) => { | ||
value[1] = toReactive(value[1]); | ||
return value; | ||
}); | ||
}, | ||
every(fn, thisArg) { | ||
return apply(this, "every", fn, thisArg); | ||
}, | ||
filter(fn, thisArg) { | ||
const result = apply(this, "filter", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result; | ||
}, | ||
find(fn, thisArg) { | ||
const result = apply(this, "find", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findIndex(fn, thisArg) { | ||
return apply(this, "findIndex", fn, thisArg); | ||
}, | ||
findLast(fn, thisArg) { | ||
const result = apply(this, "findLast", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findLastIndex(fn, thisArg) { | ||
return apply(this, "findLastIndex", fn, thisArg); | ||
}, | ||
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement | ||
forEach(fn, thisArg) { | ||
return apply(this, "forEach", fn, thisArg); | ||
}, | ||
includes(...args) { | ||
return searchProxy(this, "includes", args); | ||
}, | ||
indexOf(...args) { | ||
return searchProxy(this, "indexOf", args); | ||
}, | ||
join(separator) { | ||
return reactiveReadArray(this).join(separator); | ||
}, | ||
// keys() iterator only reads `length`, no optimisation required | ||
lastIndexOf(...args) { | ||
return searchProxy(this, "lastIndexOf", args); | ||
}, | ||
map(fn, thisArg) { | ||
return apply(this, "map", fn, thisArg); | ||
}, | ||
pop() { | ||
return noTracking(this, "pop"); | ||
}, | ||
push(...args) { | ||
return noTracking(this, "push", args); | ||
}, | ||
reduce(fn, ...args) { | ||
return reduce(this, "reduce", fn, args); | ||
}, | ||
reduceRight(fn, ...args) { | ||
return reduce(this, "reduceRight", fn, args); | ||
}, | ||
shift() { | ||
return noTracking(this, "shift"); | ||
}, | ||
// slice could use ARRAY_ITERATE but also seems to beg for range tracking | ||
some(fn, thisArg) { | ||
return apply(this, "some", fn, thisArg); | ||
}, | ||
splice(...args) { | ||
return noTracking(this, "splice", args); | ||
}, | ||
toReversed() { | ||
return reactiveReadArray(this).toReversed(); | ||
}, | ||
toSorted(comparer) { | ||
return reactiveReadArray(this).toSorted(comparer); | ||
}, | ||
toSpliced(...args) { | ||
return reactiveReadArray(this).toSpliced(...args); | ||
}, | ||
unshift(...args) { | ||
return noTracking(this, "unshift", args); | ||
}, | ||
values() { | ||
return iterator(this, "values", toReactive); | ||
} | ||
}; | ||
function iterator(self, method, wrapValue) { | ||
const arr = shallowReadArray(self); | ||
const iter = arr[method](); | ||
if (arr !== self && !isShallow(self)) { | ||
iter._next = iter.next; | ||
iter.next = () => { | ||
const result = iter._next(); | ||
if (result.value) { | ||
result.value = wrapValue(result.value); | ||
} | ||
return result; | ||
}; | ||
} | ||
return iter; | ||
} | ||
function apply(self, method, fn, thisArg) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 2) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, thisArg); | ||
} | ||
function reduce(self, method, fn, args) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 3) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, ...args); | ||
} | ||
function searchProxy(self, method, args) { | ||
const arr = toRaw(self); | ||
track(arr, "iterate", ARRAY_ITERATE_KEY); | ||
const res = arr[method](...args); | ||
if ((res === -1 || res === false) && isProxy(args[0])) { | ||
args[0] = toRaw(args[0]); | ||
return arr[method](...args); | ||
} | ||
return res; | ||
} | ||
function noTracking(self, method, args = []) { | ||
pauseTracking(); | ||
startBatch(); | ||
const res = toRaw(self)[method].apply(self, args); | ||
endBatch(); | ||
resetTracking(); | ||
return res; | ||
} | ||
const isNonTrackableKeys = /* @__PURE__ */ shared.makeMap(`__proto__,__v_isRef,__isVue`); | ||
@@ -395,31 +768,2 @@ const builtInSymbols = new Set( | ||
); | ||
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); | ||
function createArrayInstrumentations() { | ||
const instrumentations = {}; | ||
["includes", "indexOf", "lastIndexOf"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
const arr = toRaw(this); | ||
for (let i = 0, l = this.length; i < l; i++) { | ||
track(arr, "get", i + ""); | ||
} | ||
const res = arr[key](...args); | ||
if (res === -1 || res === false) { | ||
return arr[key](...args.map(toRaw)); | ||
} else { | ||
return res; | ||
} | ||
}; | ||
}); | ||
["push", "pop", "shift", "unshift", "splice"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
pauseTracking(); | ||
pauseScheduling(); | ||
const res = toRaw(this)[key].apply(this, args); | ||
resetScheduling(); | ||
resetTracking(); | ||
return res; | ||
}; | ||
}); | ||
return instrumentations; | ||
} | ||
function hasOwnProperty(key) { | ||
@@ -455,4 +799,5 @@ if (!shared.isSymbol(key)) | ||
if (!isReadonly2) { | ||
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) { | ||
return Reflect.get(arrayInstrumentations, key, receiver); | ||
let fn; | ||
if (targetIsArray && (fn = arrayInstrumentations[key])) { | ||
return fn; | ||
} | ||
@@ -463,3 +808,10 @@ if (key === "hasOwnProperty") { | ||
} | ||
const res = Reflect.get(target, key, receiver); | ||
const res = Reflect.get( | ||
target, | ||
key, | ||
// if this is a proxy wrapping a ref, return methods using the raw ref | ||
// as receiver so that we don't have to call `toRaw` on the ref in all | ||
// its class methods | ||
isRef(target) ? target : receiver | ||
); | ||
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { | ||
@@ -927,81 +1279,4 @@ return res; | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly, isSSR) { | ||
this.getter = getter; | ||
this._setter = _setter; | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
this["__v_isReadonly"] = false; | ||
this.effect = new ReactiveEffect( | ||
() => getter(this._value), | ||
() => triggerRefValue( | ||
this, | ||
this.effect._dirtyLevel === 2 ? 2 : 3 | ||
) | ||
); | ||
this.effect.computed = this; | ||
this.effect.active = this._cacheable = !isSSR; | ||
this["__v_isReadonly"] = isReadonly; | ||
} | ||
get value() { | ||
const self = toRaw(this); | ||
if ((!self._cacheable || self.effect.dirty) && shared.hasChanged(self._value, self._value = self.effect.run())) { | ||
triggerRefValue(self, 4); | ||
} | ||
trackRefValue(self); | ||
if (self.effect._dirtyLevel >= 2) { | ||
triggerRefValue(self, 2); | ||
} | ||
return self._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x | ||
get _dirty() { | ||
return this.effect.dirty; | ||
} | ||
set _dirty(v) { | ||
this.effect.dirty = v; | ||
} | ||
// #endregion | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
const onlyGetter = shared.isFunction(getterOrOptions); | ||
if (onlyGetter) { | ||
getter = getterOrOptions; | ||
setter = shared.NOOP; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR); | ||
return cRef; | ||
} | ||
function trackRefValue(ref2) { | ||
var _a; | ||
if (shouldTrack && activeEffect) { | ||
ref2 = toRaw(ref2); | ||
trackEffect( | ||
activeEffect, | ||
(_a = ref2.dep) != null ? _a : ref2.dep = createDep( | ||
() => ref2.dep = void 0, | ||
ref2 instanceof ComputedRefImpl ? ref2 : void 0 | ||
)); | ||
} | ||
} | ||
function triggerRefValue(ref2, dirtyLevel = 4, newVal) { | ||
ref2 = toRaw(ref2); | ||
const dep = ref2.dep; | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
dirtyLevel); | ||
} | ||
} | ||
function isRef(r) { | ||
return !!(r && r.__v_isRef === true); | ||
return r ? r.__v_isRef === true : false; | ||
} | ||
@@ -1023,3 +1298,3 @@ function ref(value) { | ||
this.__v_isShallow = __v_isShallow; | ||
this.dep = void 0; | ||
this.dep = new Dep(); | ||
this.__v_isRef = true; | ||
@@ -1030,12 +1305,17 @@ this._rawValue = __v_isShallow ? value : toRaw(value); | ||
get value() { | ||
trackRefValue(this); | ||
{ | ||
this.dep.track(); | ||
} | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal); | ||
newVal = useDirectValue ? newVal : toRaw(newVal); | ||
if (shared.hasChanged(newVal, this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = useDirectValue ? newVal : toReactive(newVal); | ||
triggerRefValue(this, 4); | ||
set value(newValue) { | ||
const oldValue = this._rawValue; | ||
const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue); | ||
newValue = useDirectValue ? newValue : toRaw(newValue); | ||
if (shared.hasChanged(newValue, oldValue)) { | ||
this._rawValue = newValue; | ||
this._value = useDirectValue ? newValue : toReactive(newValue); | ||
{ | ||
this.dep.trigger(); | ||
} | ||
} | ||
@@ -1045,3 +1325,5 @@ } | ||
function triggerRef(ref2) { | ||
triggerRefValue(ref2, 4); | ||
{ | ||
ref2.dep.trigger(); | ||
} | ||
} | ||
@@ -1071,8 +1353,5 @@ function unref(ref2) { | ||
constructor(factory) { | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
const { get, set } = factory( | ||
() => trackRefValue(this), | ||
() => triggerRefValue(this) | ||
); | ||
const dep = this.dep = new Dep(); | ||
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep)); | ||
this._get = get; | ||
@@ -1142,3 +1421,75 @@ this._set = set; | ||
const deferredComputed = computed; | ||
class ComputedRefImpl { | ||
constructor(fn, setter, isSSR) { | ||
this.fn = fn; | ||
this.setter = setter; | ||
/** | ||
* @internal | ||
*/ | ||
this._value = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.dep = new Dep(this); | ||
/** | ||
* @internal | ||
*/ | ||
this.__v_isRef = true; | ||
// A computed is also a subscriber that tracks other deps | ||
/** | ||
* @internal | ||
*/ | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.flags = 16; | ||
/** | ||
* @internal | ||
*/ | ||
this.globalVersion = globalVersion - 1; | ||
// for backwards compat | ||
this.effect = this; | ||
this.__v_isReadonly = !setter; | ||
this.isSSR = isSSR; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (activeSub !== this) { | ||
this.flags |= 16; | ||
this.dep.notify(); | ||
} | ||
} | ||
get value() { | ||
const link = this.dep.track(); | ||
refreshComputed(this); | ||
if (link) { | ||
link.version = this.dep.version; | ||
} | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
if (this.setter) { | ||
this.setter(newValue); | ||
} | ||
} | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
if (shared.isFunction(getterOrOptions)) { | ||
getter = getterOrOptions; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, isSSR); | ||
return cRef; | ||
} | ||
@@ -1164,4 +1515,7 @@ const TrackOpTypes = { | ||
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY; | ||
exports.EffectFlags = EffectFlags; | ||
exports.EffectScope = EffectScope; | ||
exports.ITERATE_KEY = ITERATE_KEY; | ||
exports.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY; | ||
exports.ReactiveEffect = ReactiveEffect; | ||
@@ -1173,3 +1527,2 @@ exports.ReactiveFlags = ReactiveFlags; | ||
exports.customRef = customRef; | ||
exports.deferredComputed = deferredComputed; | ||
exports.effect = effect; | ||
@@ -1185,12 +1538,13 @@ exports.effectScope = effectScope; | ||
exports.markRaw = markRaw; | ||
exports.onEffectCleanup = onEffectCleanup; | ||
exports.onScopeDispose = onScopeDispose; | ||
exports.pauseScheduling = pauseScheduling; | ||
exports.pauseTracking = pauseTracking; | ||
exports.proxyRefs = proxyRefs; | ||
exports.reactive = reactive; | ||
exports.reactiveReadArray = reactiveReadArray; | ||
exports.readonly = readonly; | ||
exports.ref = ref; | ||
exports.resetScheduling = resetScheduling; | ||
exports.resetTracking = resetTracking; | ||
exports.shallowReactive = shallowReactive; | ||
exports.shallowReadArray = shallowReadArray; | ||
exports.shallowReadonly = shallowReadonly; | ||
@@ -1200,2 +1554,4 @@ exports.shallowRef = shallowRef; | ||
exports.toRaw = toRaw; | ||
exports.toReactive = toReactive; | ||
exports.toReadonly = toReadonly; | ||
exports.toRef = toRef; | ||
@@ -1202,0 +1558,0 @@ exports.toRefs = toRefs; |
@@ -22,182 +22,2 @@ import { IfAny } from '@vue/shared'; | ||
type Dep = Map<ReactiveEffect, number> & { | ||
cleanup: () => void; | ||
computed?: ComputedRefImpl<any>; | ||
}; | ||
export declare class EffectScope { | ||
detached: boolean; | ||
constructor(detached?: boolean); | ||
get active(): boolean; | ||
run<T>(fn: () => T): T | undefined; | ||
stop(fromParent?: boolean): void; | ||
} | ||
/** | ||
* Creates an effect scope object which can capture the reactive effects (i.e. | ||
* computed and watchers) created within it so that these effects can be | ||
* disposed together. For detailed use cases of this API, please consult its | ||
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}. | ||
* | ||
* @param detached - Can be used to create a "detached" effect scope. | ||
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope} | ||
*/ | ||
export declare function effectScope(detached?: boolean): EffectScope; | ||
/** | ||
* Returns the current active effect scope if there is one. | ||
* | ||
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope} | ||
*/ | ||
export declare function getCurrentScope(): EffectScope | undefined; | ||
/** | ||
* Registers a dispose callback on the current active effect scope. The | ||
* callback will be invoked when the associated effect scope is stopped. | ||
* | ||
* @param fn - The callback function to attach to the scope's cleanup. | ||
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose} | ||
*/ | ||
export declare function onScopeDispose(fn: () => void): void; | ||
export type EffectScheduler = (...args: any[]) => any; | ||
export type DebuggerEvent = { | ||
effect: ReactiveEffect; | ||
} & DebuggerEventExtraInfo; | ||
export type DebuggerEventExtraInfo = { | ||
target: object; | ||
type: TrackOpTypes | TriggerOpTypes; | ||
key: any; | ||
newValue?: any; | ||
oldValue?: any; | ||
oldTarget?: Map<any, any> | Set<any>; | ||
}; | ||
export declare class ReactiveEffect<T = any> { | ||
fn: () => T; | ||
trigger: () => void; | ||
scheduler?: EffectScheduler | undefined; | ||
active: boolean; | ||
deps: Dep[]; | ||
onStop?: () => void; | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
constructor(fn: () => T, trigger: () => void, scheduler?: EffectScheduler | undefined, scope?: EffectScope); | ||
get dirty(): boolean; | ||
set dirty(v: boolean); | ||
run(): T; | ||
stop(): void; | ||
} | ||
export interface DebuggerOptions { | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
} | ||
export interface ReactiveEffectOptions extends DebuggerOptions { | ||
lazy?: boolean; | ||
scheduler?: EffectScheduler; | ||
scope?: EffectScope; | ||
allowRecurse?: boolean; | ||
onStop?: () => void; | ||
} | ||
export interface ReactiveEffectRunner<T = any> { | ||
(): T; | ||
effect: ReactiveEffect; | ||
} | ||
/** | ||
* Registers the given function to track reactive updates. | ||
* | ||
* The given function will be run once immediately. Every time any reactive | ||
* property that's accessed within it gets updated, the function will run again. | ||
* | ||
* @param fn - The function that will track reactive updates. | ||
* @param options - Allows to control the effect's behaviour. | ||
* @returns A runner that can be used to control the effect after creation. | ||
*/ | ||
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner; | ||
/** | ||
* Stops the effect associated with the given runner. | ||
* | ||
* @param runner - Association with the effect to stop tracking. | ||
*/ | ||
export declare function stop(runner: ReactiveEffectRunner): void; | ||
/** | ||
* Temporarily pauses tracking. | ||
*/ | ||
export declare function pauseTracking(): void; | ||
/** | ||
* Re-enables effect tracking (if it was paused). | ||
*/ | ||
export declare function enableTracking(): void; | ||
/** | ||
* Resets the previous global effect tracking state. | ||
*/ | ||
export declare function resetTracking(): void; | ||
export declare function pauseScheduling(): void; | ||
export declare function resetScheduling(): void; | ||
declare const ComputedRefSymbol: unique symbol; | ||
export interface ComputedRef<T = any> extends WritableComputedRef<T> { | ||
readonly value: T; | ||
[ComputedRefSymbol]: true; | ||
} | ||
export interface WritableComputedRef<T> extends Ref<T> { | ||
readonly effect: ReactiveEffect<T>; | ||
} | ||
export type ComputedGetter<T> = (oldValue?: T) => T; | ||
export type ComputedSetter<T> = (newValue: T) => void; | ||
export interface WritableComputedOptions<T> { | ||
get: ComputedGetter<T>; | ||
set: ComputedSetter<T>; | ||
} | ||
export declare class ComputedRefImpl<T> { | ||
private getter; | ||
private readonly _setter; | ||
dep?: Dep; | ||
private _value; | ||
readonly effect: ReactiveEffect<T>; | ||
readonly __v_isRef = true; | ||
readonly [ReactiveFlags.IS_READONLY]: boolean; | ||
_cacheable: boolean; | ||
/** | ||
* Dev only | ||
*/ | ||
_warnRecursive?: boolean; | ||
constructor(getter: ComputedGetter<T>, _setter: ComputedSetter<T>, isReadonly: boolean, isSSR: boolean); | ||
get value(): T; | ||
set value(newValue: T); | ||
get _dirty(): boolean; | ||
set _dirty(v: boolean); | ||
} | ||
/** | ||
* Takes a getter function and returns a readonly reactive ref object for the | ||
* returned value from the getter. It can also take an object with get and set | ||
* functions to create a writable ref object. | ||
* | ||
* @example | ||
* ```js | ||
* // Creating a readonly computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed(() => count.value + 1) | ||
* | ||
* console.log(plusOne.value) // 2 | ||
* plusOne.value++ // error | ||
* ``` | ||
* | ||
* ```js | ||
* // Creating a writable computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed({ | ||
* get: () => count.value + 1, | ||
* set: (val) => { | ||
* count.value = val - 1 | ||
* } | ||
* }) | ||
* | ||
* plusOne.value = 1 | ||
* console.log(count.value) // 0 | ||
* ``` | ||
* | ||
* @param getter - Function that produces the next value. | ||
* @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}. | ||
* @see {@link https://vuejs.org/api/reactivity-core.html#computed} | ||
*/ | ||
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>; | ||
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>; | ||
export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>; | ||
@@ -411,3 +231,174 @@ /** | ||
export declare function markRaw<T extends object>(value: T): Raw<T>; | ||
/** | ||
* Returns a reactive proxy of the given value (if possible). | ||
* | ||
* If the given value is not an object, the original value itself is returned. | ||
* | ||
* @param value - The value for which a reactive proxy shall be created. | ||
*/ | ||
export declare const toReactive: <T extends unknown>(value: T) => T; | ||
/** | ||
* Returns a readonly proxy of the given value (if possible). | ||
* | ||
* If the given value is not an object, the original value itself is returned. | ||
* | ||
* @param value - The value for which a readonly proxy shall be created. | ||
*/ | ||
export declare const toReadonly: <T extends unknown>(value: T) => DeepReadonly<T>; | ||
export type EffectScheduler = (...args: any[]) => any; | ||
export type DebuggerEvent = { | ||
effect: Subscriber; | ||
} & DebuggerEventExtraInfo; | ||
export type DebuggerEventExtraInfo = { | ||
target: object; | ||
type: TrackOpTypes | TriggerOpTypes; | ||
key: any; | ||
newValue?: any; | ||
oldValue?: any; | ||
oldTarget?: Map<any, any> | Set<any>; | ||
}; | ||
export interface DebuggerOptions { | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
} | ||
export interface ReactiveEffectOptions extends DebuggerOptions { | ||
scheduler?: EffectScheduler; | ||
allowRecurse?: boolean; | ||
onStop?: () => void; | ||
} | ||
export declare enum EffectFlags { | ||
ACTIVE = 1, | ||
RUNNING = 2, | ||
TRACKING = 4, | ||
NOTIFIED = 8, | ||
DIRTY = 16, | ||
ALLOW_RECURSE = 32, | ||
NO_BATCH = 64 | ||
} | ||
/** | ||
* Subscriber is a type that tracks (or subscribes to) a list of deps. | ||
*/ | ||
interface Subscriber extends DebuggerOptions { | ||
} | ||
export declare class ReactiveEffect<T = any> implements Subscriber, ReactiveEffectOptions { | ||
fn: () => T; | ||
scheduler?: EffectScheduler; | ||
onStop?: () => void; | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
constructor(fn: () => T); | ||
run(): T; | ||
stop(): void; | ||
trigger(): void; | ||
get dirty(): boolean; | ||
} | ||
export interface ReactiveEffectRunner<T = any> { | ||
(): T; | ||
effect: ReactiveEffect; | ||
} | ||
export interface ReactiveEffectRunner<T = any> { | ||
(): T; | ||
effect: ReactiveEffect; | ||
} | ||
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner<T>; | ||
/** | ||
* Stops the effect associated with the given runner. | ||
* | ||
* @param runner - Association with the effect to stop tracking. | ||
*/ | ||
export declare function stop(runner: ReactiveEffectRunner): void; | ||
/** | ||
* Temporarily pauses tracking. | ||
*/ | ||
export declare function pauseTracking(): void; | ||
/** | ||
* Re-enables effect tracking (if it was paused). | ||
*/ | ||
export declare function enableTracking(): void; | ||
/** | ||
* Resets the previous global effect tracking state. | ||
*/ | ||
export declare function resetTracking(): void; | ||
/** | ||
* Registers a cleanup function for the current active effect. | ||
* The cleanup function is called right before the next effect run, or when the | ||
* effect is stopped. | ||
* | ||
* Throws a warning iff there is no currenct active effect. The warning can be | ||
* suppressed by passing `true` to the second argument. | ||
* | ||
* @param fn - the cleanup function to be registered | ||
* @param failSilently - if `true`, will not throw warning when called without | ||
* an active effect. | ||
*/ | ||
export declare function onEffectCleanup(fn: () => void, failSilently?: boolean): void; | ||
declare const ComputedRefSymbol: unique symbol; | ||
export interface ComputedRef<T = any> extends WritableComputedRef<T> { | ||
readonly value: T; | ||
[ComputedRefSymbol]: true; | ||
} | ||
export interface WritableComputedRef<T> extends Ref<T> { | ||
/** | ||
* @deprecated computed no longer uses effect | ||
*/ | ||
effect: ComputedRefImpl; | ||
} | ||
export type ComputedGetter<T> = (oldValue?: T) => T; | ||
export type ComputedSetter<T> = (newValue: T) => void; | ||
export interface WritableComputedOptions<T> { | ||
get: ComputedGetter<T>; | ||
set: ComputedSetter<T>; | ||
} | ||
/** | ||
* @private exported by @vue/reactivity for Vue core use, but not exported from | ||
* the main vue package | ||
*/ | ||
export declare class ComputedRefImpl<T = any> implements Subscriber { | ||
fn: ComputedGetter<T>; | ||
private readonly setter; | ||
effect: this; | ||
onTrack?: (event: DebuggerEvent) => void; | ||
onTrigger?: (event: DebuggerEvent) => void; | ||
constructor(fn: ComputedGetter<T>, setter: ComputedSetter<T> | undefined, isSSR: boolean); | ||
get value(): any; | ||
set value(newValue: any); | ||
} | ||
/** | ||
* Takes a getter function and returns a readonly reactive ref object for the | ||
* returned value from the getter. It can also take an object with get and set | ||
* functions to create a writable ref object. | ||
* | ||
* @example | ||
* ```js | ||
* // Creating a readonly computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed(() => count.value + 1) | ||
* | ||
* console.log(plusOne.value) // 2 | ||
* plusOne.value++ // error | ||
* ``` | ||
* | ||
* ```js | ||
* // Creating a writable computed ref: | ||
* const count = ref(1) | ||
* const plusOne = computed({ | ||
* get: () => count.value + 1, | ||
* set: (val) => { | ||
* count.value = val - 1 | ||
* } | ||
* }) | ||
* | ||
* plusOne.value = 1 | ||
* console.log(count.value) // 0 | ||
* ``` | ||
* | ||
* @param getter - Function that produces the next value. | ||
* @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}. | ||
* @see {@link https://vuejs.org/api/reactivity-core.html#computed} | ||
*/ | ||
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>; | ||
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>; | ||
declare const RefSymbol: unique symbol; | ||
@@ -638,8 +629,5 @@ declare const RawSymbol: unique symbol; | ||
/** | ||
* @deprecated use `computed` instead. See #5912 | ||
*/ | ||
export declare const deferredComputed: typeof computed; | ||
export declare const ITERATE_KEY: unique symbol; | ||
export declare const MAP_KEY_ITERATE_KEY: unique symbol; | ||
export declare const ARRAY_ITERATE_KEY: unique symbol; | ||
/** | ||
@@ -666,1 +654,44 @@ * Tracks access to a reactive property. | ||
export declare class EffectScope { | ||
detached: boolean; | ||
constructor(detached?: boolean); | ||
get active(): boolean; | ||
run<T>(fn: () => T): T | undefined; | ||
stop(fromParent?: boolean): void; | ||
} | ||
/** | ||
* Creates an effect scope object which can capture the reactive effects (i.e. | ||
* computed and watchers) created within it so that these effects can be | ||
* disposed together. For detailed use cases of this API, please consult its | ||
* corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}. | ||
* | ||
* @param detached - Can be used to create a "detached" effect scope. | ||
* @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope} | ||
*/ | ||
export declare function effectScope(detached?: boolean): EffectScope; | ||
/** | ||
* Returns the current active effect scope if there is one. | ||
* | ||
* @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope} | ||
*/ | ||
export declare function getCurrentScope(): EffectScope | undefined; | ||
/** | ||
* Registers a dispose callback on the current active effect scope. The | ||
* callback will be invoked when the associated effect scope is stopped. | ||
* | ||
* @param fn - The callback function to attach to the scope's cleanup. | ||
* @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose} | ||
*/ | ||
export declare function onScopeDispose(fn: () => void, failSilently?: boolean): void; | ||
/** | ||
* Track array iteration and return: | ||
* - if input is reactive: a cloned raw array with reactive values | ||
* - if input is non-reactive or shallowReactive: the original raw array | ||
*/ | ||
export declare function reactiveReadArray<T>(array: T[]): T[]; | ||
/** | ||
* Track array iteration and return raw array | ||
*/ | ||
export declare function shallowReadArray<T>(arr: T[]): T[]; | ||
/** | ||
* @vue/reactivity v3.4.25 | ||
* @vue/reactivity v3.5.0-alpha.1 | ||
* (c) 2018-present Yuxi (Evan) You and Vue contributors | ||
@@ -13,4 +13,2 @@ * @license MIT | ||
const NOOP = () => { | ||
}; | ||
const extend = Object.assign; | ||
@@ -136,14 +134,9 @@ const hasOwnProperty$1 = Object.prototype.hasOwnProperty; | ||
} | ||
function recordEffectScope(effect, scope = activeEffectScope) { | ||
if (scope && scope.active) { | ||
scope.effects.push(effect); | ||
} | ||
} | ||
function getCurrentScope() { | ||
return activeEffectScope; | ||
} | ||
function onScopeDispose(fn) { | ||
function onScopeDispose(fn, failSilently = false) { | ||
if (activeEffectScope) { | ||
activeEffectScope.cleanups.push(fn); | ||
} else { | ||
} else if (!failSilently) { | ||
warn( | ||
@@ -155,109 +148,257 @@ `onScopeDispose() is called when there is no active effect scope to be associated with.` | ||
let activeEffect; | ||
let activeSub; | ||
const EffectFlags = { | ||
"ACTIVE": 1, | ||
"1": "ACTIVE", | ||
"RUNNING": 2, | ||
"2": "RUNNING", | ||
"TRACKING": 4, | ||
"4": "TRACKING", | ||
"NOTIFIED": 8, | ||
"8": "NOTIFIED", | ||
"DIRTY": 16, | ||
"16": "DIRTY", | ||
"ALLOW_RECURSE": 32, | ||
"32": "ALLOW_RECURSE", | ||
"NO_BATCH": 64, | ||
"64": "NO_BATCH" | ||
}; | ||
class ReactiveEffect { | ||
constructor(fn, trigger, scheduler, scope) { | ||
constructor(fn) { | ||
this.fn = fn; | ||
this.trigger = trigger; | ||
this.scheduler = scheduler; | ||
this.active = true; | ||
this.deps = []; | ||
/** | ||
* @internal | ||
*/ | ||
this._dirtyLevel = 4; | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._trackId = 0; | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._runnings = 0; | ||
this.flags = 1 | 4; | ||
/** | ||
* @internal | ||
*/ | ||
this._shouldSchedule = false; | ||
this.nextEffect = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._depsLength = 0; | ||
recordEffectScope(this, scope); | ||
this.cleanup = void 0; | ||
this.scheduler = void 0; | ||
if (activeEffectScope && activeEffectScope.active) { | ||
activeEffectScope.effects.push(this); | ||
} | ||
} | ||
get dirty() { | ||
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) { | ||
this._dirtyLevel = 1; | ||
pauseTracking(); | ||
for (let i = 0; i < this._depsLength; i++) { | ||
const dep = this.deps[i]; | ||
if (dep.computed) { | ||
triggerComputed(dep.computed); | ||
if (this._dirtyLevel >= 4) { | ||
break; | ||
} | ||
} | ||
} | ||
if (this._dirtyLevel === 1) { | ||
this._dirtyLevel = 0; | ||
} | ||
resetTracking(); | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (this.flags & 2 && !(this.flags & 32)) { | ||
return; | ||
} | ||
return this._dirtyLevel >= 4; | ||
if (this.flags & 64) { | ||
return this.trigger(); | ||
} | ||
if (!(this.flags & 8)) { | ||
this.flags |= 8; | ||
this.nextEffect = batchedEffect; | ||
batchedEffect = this; | ||
} | ||
} | ||
set dirty(v) { | ||
this._dirtyLevel = v ? 4 : 0; | ||
} | ||
run() { | ||
this._dirtyLevel = 0; | ||
if (!this.active) { | ||
if (!(this.flags & 1)) { | ||
return this.fn(); | ||
} | ||
let lastShouldTrack = shouldTrack; | ||
let lastEffect = activeEffect; | ||
this.flags |= 2; | ||
cleanupEffect(this); | ||
prepareDeps(this); | ||
const prevEffect = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = this; | ||
shouldTrack = true; | ||
try { | ||
shouldTrack = true; | ||
activeEffect = this; | ||
this._runnings++; | ||
preCleanupEffect(this); | ||
return this.fn(); | ||
} finally { | ||
postCleanupEffect(this); | ||
this._runnings--; | ||
activeEffect = lastEffect; | ||
shouldTrack = lastShouldTrack; | ||
if (activeSub !== this) { | ||
warn( | ||
"Active effect was not restored correctly - this is likely a Vue internal bug." | ||
); | ||
} | ||
cleanupDeps(this); | ||
activeSub = prevEffect; | ||
shouldTrack = prevShouldTrack; | ||
this.flags &= ~2; | ||
} | ||
} | ||
stop() { | ||
var _a; | ||
if (this.active) { | ||
preCleanupEffect(this); | ||
postCleanupEffect(this); | ||
(_a = this.onStop) == null ? void 0 : _a.call(this); | ||
this.active = false; | ||
if (this.flags & 1) { | ||
for (let link = this.deps; link; link = link.nextDep) { | ||
removeSub(link); | ||
} | ||
this.deps = this.depsTail = void 0; | ||
cleanupEffect(this); | ||
this.onStop && this.onStop(); | ||
this.flags &= ~1; | ||
} | ||
} | ||
trigger() { | ||
if (this.scheduler) { | ||
this.scheduler(); | ||
} else { | ||
this.runIfDirty(); | ||
} | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
runIfDirty() { | ||
if (isDirty(this)) { | ||
this.run(); | ||
} | ||
} | ||
get dirty() { | ||
return isDirty(this); | ||
} | ||
} | ||
function triggerComputed(computed) { | ||
return computed.value; | ||
let batchDepth = 0; | ||
let batchedEffect; | ||
function startBatch() { | ||
batchDepth++; | ||
} | ||
function preCleanupEffect(effect2) { | ||
effect2._trackId++; | ||
effect2._depsLength = 0; | ||
function endBatch() { | ||
if (batchDepth > 1) { | ||
batchDepth--; | ||
return; | ||
} | ||
let error; | ||
while (batchedEffect) { | ||
let e = batchedEffect; | ||
batchedEffect = void 0; | ||
while (e) { | ||
const next = e.nextEffect; | ||
e.nextEffect = void 0; | ||
e.flags &= ~8; | ||
if (e.flags & 1) { | ||
try { | ||
e.trigger(); | ||
} catch (err) { | ||
if (!error) | ||
error = err; | ||
} | ||
} | ||
e = next; | ||
} | ||
} | ||
batchDepth--; | ||
if (error) | ||
throw error; | ||
} | ||
function postCleanupEffect(effect2) { | ||
if (effect2.deps.length > effect2._depsLength) { | ||
for (let i = effect2._depsLength; i < effect2.deps.length; i++) { | ||
cleanupDepEffect(effect2.deps[i], effect2); | ||
function prepareDeps(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
link.version = -1; | ||
link.prevActiveLink = link.dep.activeLink; | ||
link.dep.activeLink = link; | ||
} | ||
} | ||
function cleanupDeps(sub) { | ||
let head; | ||
let tail = sub.depsTail; | ||
for (let link = tail; link; link = link.prevDep) { | ||
if (link.version === -1) { | ||
if (link === tail) | ||
tail = link.prevDep; | ||
removeSub(link); | ||
removeDep(link); | ||
} else { | ||
head = link; | ||
} | ||
effect2.deps.length = effect2._depsLength; | ||
link.dep.activeLink = link.prevActiveLink; | ||
link.prevActiveLink = void 0; | ||
} | ||
sub.deps = head; | ||
sub.depsTail = tail; | ||
} | ||
function cleanupDepEffect(dep, effect2) { | ||
const trackId = dep.get(effect2); | ||
if (trackId !== void 0 && effect2._trackId !== trackId) { | ||
dep.delete(effect2); | ||
if (dep.size === 0) { | ||
dep.cleanup(); | ||
function isDirty(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) { | ||
return true; | ||
} | ||
} | ||
if (sub._dirty) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function refreshComputed(computed) { | ||
if (computed.flags & 2) { | ||
return false; | ||
} | ||
if (computed.flags & 4 && !(computed.flags & 16)) { | ||
return; | ||
} | ||
computed.flags &= ~16; | ||
if (computed.globalVersion === globalVersion) { | ||
return; | ||
} | ||
computed.globalVersion = globalVersion; | ||
const dep = computed.dep; | ||
computed.flags |= 2; | ||
if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) { | ||
computed.flags &= ~2; | ||
return; | ||
} | ||
const prevSub = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = computed; | ||
shouldTrack = true; | ||
try { | ||
prepareDeps(computed); | ||
const value = computed.fn(); | ||
if (dep.version === 0 || hasChanged(value, computed._value)) { | ||
computed._value = value; | ||
dep.version++; | ||
} | ||
} catch (err) { | ||
dep.version++; | ||
throw err; | ||
} finally { | ||
activeSub = prevSub; | ||
shouldTrack = prevShouldTrack; | ||
cleanupDeps(computed); | ||
computed.flags &= ~2; | ||
} | ||
} | ||
function removeSub(link) { | ||
const { dep, prevSub, nextSub } = link; | ||
if (prevSub) { | ||
prevSub.nextSub = nextSub; | ||
link.prevSub = void 0; | ||
} | ||
if (nextSub) { | ||
nextSub.prevSub = prevSub; | ||
link.nextSub = void 0; | ||
} | ||
if (dep.subs === link) { | ||
dep.subs = prevSub; | ||
} | ||
if (!dep.subs && dep.computed) { | ||
dep.computed.flags &= ~4; | ||
for (let l = dep.computed.deps; l; l = l.nextDep) { | ||
removeSub(l); | ||
} | ||
} | ||
} | ||
function removeDep(link) { | ||
const { prevDep, nextDep } = link; | ||
if (prevDep) { | ||
prevDep.nextDep = nextDep; | ||
link.prevDep = void 0; | ||
} | ||
if (nextDep) { | ||
nextDep.prevDep = prevDep; | ||
link.nextDep = void 0; | ||
} | ||
} | ||
function effect(fn, options) { | ||
@@ -267,17 +408,14 @@ if (fn.effect instanceof ReactiveEffect) { | ||
} | ||
const _effect = new ReactiveEffect(fn, NOOP, () => { | ||
if (_effect.dirty) { | ||
_effect.run(); | ||
} | ||
}); | ||
const e = new ReactiveEffect(fn); | ||
if (options) { | ||
extend(_effect, options); | ||
if (options.scope) | ||
recordEffectScope(_effect, options.scope); | ||
extend(e, options); | ||
} | ||
if (!options || !options.lazy) { | ||
_effect.run(); | ||
try { | ||
e.run(); | ||
} catch (err) { | ||
e.stop(); | ||
throw err; | ||
} | ||
const runner = _effect.run.bind(_effect); | ||
runner.effect = _effect; | ||
const runner = e.run.bind(e); | ||
runner.effect = e; | ||
return runner; | ||
@@ -289,3 +427,2 @@ } | ||
let shouldTrack = true; | ||
let pauseScheduleStack = 0; | ||
const trackStack = []; | ||
@@ -304,67 +441,152 @@ function pauseTracking() { | ||
} | ||
function pauseScheduling() { | ||
pauseScheduleStack++; | ||
function onEffectCleanup(fn, failSilently = false) { | ||
if (activeSub instanceof ReactiveEffect) { | ||
activeSub.cleanup = fn; | ||
} else if (!failSilently) { | ||
warn( | ||
`onEffectCleanup() was called when there was no active effect to associate with.` | ||
); | ||
} | ||
} | ||
function resetScheduling() { | ||
pauseScheduleStack--; | ||
while (!pauseScheduleStack && queueEffectSchedulers.length) { | ||
queueEffectSchedulers.shift()(); | ||
function cleanupEffect(e) { | ||
const { cleanup } = e; | ||
e.cleanup = void 0; | ||
if (cleanup) { | ||
const prevSub = activeSub; | ||
activeSub = void 0; | ||
try { | ||
cleanup(); | ||
} finally { | ||
activeSub = prevSub; | ||
} | ||
} | ||
} | ||
function trackEffect(effect2, dep, debuggerEventExtraInfo) { | ||
var _a; | ||
if (dep.get(effect2) !== effect2._trackId) { | ||
dep.set(effect2, effect2._trackId); | ||
const oldDep = effect2.deps[effect2._depsLength]; | ||
if (oldDep !== dep) { | ||
if (oldDep) { | ||
cleanupDepEffect(oldDep, effect2); | ||
} | ||
effect2.deps[effect2._depsLength++] = dep; | ||
} else { | ||
effect2._depsLength++; | ||
} | ||
let globalVersion = 0; | ||
class Dep { | ||
constructor(computed) { | ||
this.computed = computed; | ||
this.version = 0; | ||
/** | ||
* Link between this dep and the current active effect | ||
*/ | ||
this.activeLink = void 0; | ||
/** | ||
* Doubly linked list representing the subscribing effects (tail) | ||
*/ | ||
this.subs = void 0; | ||
{ | ||
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
this.subsHead = void 0; | ||
} | ||
} | ||
} | ||
const queueEffectSchedulers = []; | ||
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) { | ||
var _a; | ||
pauseScheduling(); | ||
for (const effect2 of dep.keys()) { | ||
let tracking; | ||
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0); | ||
effect2._dirtyLevel = dirtyLevel; | ||
track(debugInfo) { | ||
if (!activeSub || !shouldTrack) { | ||
return; | ||
} | ||
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
{ | ||
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
let link = this.activeLink; | ||
if (link === void 0 || link.sub !== activeSub) { | ||
link = this.activeLink = { | ||
dep: this, | ||
sub: activeSub, | ||
version: this.version, | ||
nextDep: void 0, | ||
prevDep: void 0, | ||
nextSub: void 0, | ||
prevSub: void 0, | ||
prevActiveLink: void 0 | ||
}; | ||
if (!activeSub.deps) { | ||
activeSub.deps = activeSub.depsTail = link; | ||
} else { | ||
link.prevDep = activeSub.depsTail; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
} | ||
effect2.trigger(); | ||
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) { | ||
effect2._shouldSchedule = false; | ||
if (effect2.scheduler) { | ||
queueEffectSchedulers.push(effect2.scheduler); | ||
if (activeSub.flags & 4) { | ||
addSub(link); | ||
} | ||
} else if (link.version === -1) { | ||
link.version = this.version; | ||
if (link.nextDep) { | ||
const next = link.nextDep; | ||
next.prevDep = link.prevDep; | ||
if (link.prevDep) { | ||
link.prevDep.nextDep = next; | ||
} | ||
link.prevDep = activeSub.depsTail; | ||
link.nextDep = void 0; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
if (activeSub.deps === link) { | ||
activeSub.deps = next; | ||
} | ||
} | ||
} | ||
if (activeSub.onTrack) { | ||
activeSub.onTrack( | ||
extend( | ||
{ | ||
effect: activeSub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
return link; | ||
} | ||
resetScheduling(); | ||
trigger(debugInfo) { | ||
this.version++; | ||
globalVersion++; | ||
this.notify(debugInfo); | ||
} | ||
notify(debugInfo) { | ||
startBatch(); | ||
try { | ||
if (true) { | ||
for (let head = this.subsHead; head; head = head.nextSub) { | ||
if (head.sub.onTrigger && !(head.sub.flags & 8)) { | ||
head.sub.onTrigger( | ||
extend( | ||
{ | ||
effect: head.sub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
} | ||
} | ||
for (let link = this.subs; link; link = link.prevSub) { | ||
link.sub.notify(); | ||
} | ||
} finally { | ||
endBatch(); | ||
} | ||
} | ||
} | ||
const createDep = (cleanup, computed) => { | ||
const dep = /* @__PURE__ */ new Map(); | ||
dep.cleanup = cleanup; | ||
dep.computed = computed; | ||
return dep; | ||
}; | ||
function addSub(link) { | ||
const computed = link.dep.computed; | ||
if (computed && !link.dep.subs) { | ||
computed.flags |= 4 | 16; | ||
for (let l = computed.deps; l; l = l.nextDep) { | ||
addSub(l); | ||
} | ||
} | ||
const currentTail = link.dep.subs; | ||
if (currentTail !== link) { | ||
link.prevSub = currentTail; | ||
if (currentTail) | ||
currentTail.nextSub = link; | ||
} | ||
if (link.dep.subsHead === void 0) { | ||
link.dep.subsHead = link; | ||
} | ||
link.dep.subs = link; | ||
} | ||
const targetMap = /* @__PURE__ */ new WeakMap(); | ||
const ITERATE_KEY = Symbol("iterate" ); | ||
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" ); | ||
const ITERATE_KEY = Symbol("Object iterate" ); | ||
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" ); | ||
const ARRAY_ITERATE_KEY = Symbol("Array iterate" ); | ||
function track(target, type, key) { | ||
if (shouldTrack && activeEffect) { | ||
if (shouldTrack && activeSub) { | ||
let depsMap = targetMap.get(target); | ||
@@ -376,13 +598,11 @@ if (!depsMap) { | ||
if (!dep) { | ||
depsMap.set(key, dep = createDep(() => depsMap.delete(key))); | ||
depsMap.set(key, dep = new Dep()); | ||
} | ||
trackEffect( | ||
activeEffect, | ||
dep, | ||
{ | ||
{ | ||
dep.track({ | ||
target, | ||
type, | ||
key | ||
} | ||
); | ||
}); | ||
} | ||
} | ||
@@ -393,2 +613,3 @@ } | ||
if (!depsMap) { | ||
globalVersion++; | ||
return; | ||
@@ -399,57 +620,61 @@ } | ||
deps = [...depsMap.values()]; | ||
} else if (key === "length" && isArray(target)) { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} else { | ||
const targetIsArray = isArray(target); | ||
const isArrayIndex = targetIsArray && isIntegerKey(key); | ||
if (targetIsArray && key === "length") { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} | ||
}); | ||
} else { | ||
const push = (dep) => dep && deps.push(dep); | ||
if (key !== void 0) { | ||
push(depsMap.get(key)); | ||
} | ||
}); | ||
} else { | ||
if (key !== void 0) { | ||
deps.push(depsMap.get(key)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
if (isArrayIndex) { | ||
push(depsMap.get(ARRAY_ITERATE_KEY)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} else if (isArrayIndex) { | ||
push(depsMap.get("length")); | ||
} | ||
} else if (isIntegerKey(key)) { | ||
deps.push(depsMap.get("length")); | ||
} | ||
break; | ||
case "delete": | ||
if (!isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
break; | ||
case "delete": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
push(depsMap.get(ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
} | ||
break; | ||
break; | ||
} | ||
} | ||
} | ||
pauseScheduling(); | ||
startBatch(); | ||
for (const dep of deps) { | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
4, | ||
{ | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
} | ||
); | ||
{ | ||
dep.trigger({ | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
}); | ||
} | ||
} | ||
resetScheduling(); | ||
endBatch(); | ||
} | ||
@@ -461,2 +686,174 @@ function getDepFromReactive(object, key) { | ||
function reactiveReadArray(array) { | ||
const raw = toRaw(array); | ||
if (raw === array) | ||
return raw; | ||
track(raw, "iterate", ARRAY_ITERATE_KEY); | ||
return isShallow(array) ? raw : raw.map(toReactive); | ||
} | ||
function shallowReadArray(arr) { | ||
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY); | ||
return arr; | ||
} | ||
const arrayInstrumentations = { | ||
__proto__: null, | ||
[Symbol.iterator]() { | ||
return iterator(this, Symbol.iterator, toReactive); | ||
}, | ||
concat(...args) { | ||
return reactiveReadArray(this).concat( | ||
...args.map((x) => reactiveReadArray(x)) | ||
); | ||
}, | ||
entries() { | ||
return iterator(this, "entries", (value) => { | ||
value[1] = toReactive(value[1]); | ||
return value; | ||
}); | ||
}, | ||
every(fn, thisArg) { | ||
return apply(this, "every", fn, thisArg); | ||
}, | ||
filter(fn, thisArg) { | ||
const result = apply(this, "filter", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result; | ||
}, | ||
find(fn, thisArg) { | ||
const result = apply(this, "find", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findIndex(fn, thisArg) { | ||
return apply(this, "findIndex", fn, thisArg); | ||
}, | ||
findLast(fn, thisArg) { | ||
const result = apply(this, "findLast", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findLastIndex(fn, thisArg) { | ||
return apply(this, "findLastIndex", fn, thisArg); | ||
}, | ||
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement | ||
forEach(fn, thisArg) { | ||
return apply(this, "forEach", fn, thisArg); | ||
}, | ||
includes(...args) { | ||
return searchProxy(this, "includes", args); | ||
}, | ||
indexOf(...args) { | ||
return searchProxy(this, "indexOf", args); | ||
}, | ||
join(separator) { | ||
return reactiveReadArray(this).join(separator); | ||
}, | ||
// keys() iterator only reads `length`, no optimisation required | ||
lastIndexOf(...args) { | ||
return searchProxy(this, "lastIndexOf", args); | ||
}, | ||
map(fn, thisArg) { | ||
return apply(this, "map", fn, thisArg); | ||
}, | ||
pop() { | ||
return noTracking(this, "pop"); | ||
}, | ||
push(...args) { | ||
return noTracking(this, "push", args); | ||
}, | ||
reduce(fn, ...args) { | ||
return reduce(this, "reduce", fn, args); | ||
}, | ||
reduceRight(fn, ...args) { | ||
return reduce(this, "reduceRight", fn, args); | ||
}, | ||
shift() { | ||
return noTracking(this, "shift"); | ||
}, | ||
// slice could use ARRAY_ITERATE but also seems to beg for range tracking | ||
some(fn, thisArg) { | ||
return apply(this, "some", fn, thisArg); | ||
}, | ||
splice(...args) { | ||
return noTracking(this, "splice", args); | ||
}, | ||
toReversed() { | ||
return reactiveReadArray(this).toReversed(); | ||
}, | ||
toSorted(comparer) { | ||
return reactiveReadArray(this).toSorted(comparer); | ||
}, | ||
toSpliced(...args) { | ||
return reactiveReadArray(this).toSpliced(...args); | ||
}, | ||
unshift(...args) { | ||
return noTracking(this, "unshift", args); | ||
}, | ||
values() { | ||
return iterator(this, "values", toReactive); | ||
} | ||
}; | ||
function iterator(self, method, wrapValue) { | ||
const arr = shallowReadArray(self); | ||
const iter = arr[method](); | ||
if (arr !== self && !isShallow(self)) { | ||
iter._next = iter.next; | ||
iter.next = () => { | ||
const result = iter._next(); | ||
if (result.value) { | ||
result.value = wrapValue(result.value); | ||
} | ||
return result; | ||
}; | ||
} | ||
return iter; | ||
} | ||
function apply(self, method, fn, thisArg) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 2) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, thisArg); | ||
} | ||
function reduce(self, method, fn, args) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 3) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, ...args); | ||
} | ||
function searchProxy(self, method, args) { | ||
const arr = toRaw(self); | ||
track(arr, "iterate", ARRAY_ITERATE_KEY); | ||
const res = arr[method](...args); | ||
if ((res === -1 || res === false) && isProxy(args[0])) { | ||
args[0] = toRaw(args[0]); | ||
return arr[method](...args); | ||
} | ||
return res; | ||
} | ||
function noTracking(self, method, args = []) { | ||
pauseTracking(); | ||
startBatch(); | ||
const res = toRaw(self)[method].apply(self, args); | ||
endBatch(); | ||
resetTracking(); | ||
return res; | ||
} | ||
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); | ||
@@ -466,31 +863,2 @@ const builtInSymbols = new Set( | ||
); | ||
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); | ||
function createArrayInstrumentations() { | ||
const instrumentations = {}; | ||
["includes", "indexOf", "lastIndexOf"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
const arr = toRaw(this); | ||
for (let i = 0, l = this.length; i < l; i++) { | ||
track(arr, "get", i + ""); | ||
} | ||
const res = arr[key](...args); | ||
if (res === -1 || res === false) { | ||
return arr[key](...args.map(toRaw)); | ||
} else { | ||
return res; | ||
} | ||
}; | ||
}); | ||
["push", "pop", "shift", "unshift", "splice"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
pauseTracking(); | ||
pauseScheduling(); | ||
const res = toRaw(this)[key].apply(this, args); | ||
resetScheduling(); | ||
resetTracking(); | ||
return res; | ||
}; | ||
}); | ||
return instrumentations; | ||
} | ||
function hasOwnProperty(key) { | ||
@@ -526,4 +894,5 @@ if (!isSymbol(key)) | ||
if (!isReadonly2) { | ||
if (targetIsArray && hasOwn(arrayInstrumentations, key)) { | ||
return Reflect.get(arrayInstrumentations, key, receiver); | ||
let fn; | ||
if (targetIsArray && (fn = arrayInstrumentations[key])) { | ||
return fn; | ||
} | ||
@@ -534,3 +903,10 @@ if (key === "hasOwnProperty") { | ||
} | ||
const res = Reflect.get(target, key, receiver); | ||
const res = Reflect.get( | ||
target, | ||
key, | ||
// if this is a proxy wrapping a ref, return methods using the raw ref | ||
// as receiver so that we don't have to call `toRaw` on the ref in all | ||
// its class methods | ||
isRef(target) ? target : receiver | ||
); | ||
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { | ||
@@ -1034,106 +1410,4 @@ return res; | ||
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`; | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly, isSSR) { | ||
this.getter = getter; | ||
this._setter = _setter; | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
this["__v_isReadonly"] = false; | ||
this.effect = new ReactiveEffect( | ||
() => getter(this._value), | ||
() => triggerRefValue( | ||
this, | ||
this.effect._dirtyLevel === 2 ? 2 : 3 | ||
) | ||
); | ||
this.effect.computed = this; | ||
this.effect.active = this._cacheable = !isSSR; | ||
this["__v_isReadonly"] = isReadonly; | ||
} | ||
get value() { | ||
const self = toRaw(this); | ||
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) { | ||
triggerRefValue(self, 4); | ||
} | ||
trackRefValue(self); | ||
if (self.effect._dirtyLevel >= 2) { | ||
if (this._warnRecursive) { | ||
warn(COMPUTED_SIDE_EFFECT_WARN, ` | ||
getter: `, this.getter); | ||
} | ||
triggerRefValue(self, 2); | ||
} | ||
return self._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x | ||
get _dirty() { | ||
return this.effect.dirty; | ||
} | ||
set _dirty(v) { | ||
this.effect.dirty = v; | ||
} | ||
// #endregion | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
const onlyGetter = isFunction(getterOrOptions); | ||
if (onlyGetter) { | ||
getter = getterOrOptions; | ||
setter = () => { | ||
warn("Write operation failed: computed value is readonly"); | ||
} ; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR); | ||
if (debugOptions && !isSSR) { | ||
cRef.effect.onTrack = debugOptions.onTrack; | ||
cRef.effect.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
function trackRefValue(ref2) { | ||
var _a; | ||
if (shouldTrack && activeEffect) { | ||
ref2 = toRaw(ref2); | ||
trackEffect( | ||
activeEffect, | ||
(_a = ref2.dep) != null ? _a : ref2.dep = createDep( | ||
() => ref2.dep = void 0, | ||
ref2 instanceof ComputedRefImpl ? ref2 : void 0 | ||
), | ||
{ | ||
target: ref2, | ||
type: "get", | ||
key: "value" | ||
} | ||
); | ||
} | ||
} | ||
function triggerRefValue(ref2, dirtyLevel = 4, newVal) { | ||
ref2 = toRaw(ref2); | ||
const dep = ref2.dep; | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
dirtyLevel, | ||
{ | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: newVal | ||
} | ||
); | ||
} | ||
} | ||
function isRef(r) { | ||
return !!(r && r.__v_isRef === true); | ||
return r ? r.__v_isRef === true : false; | ||
} | ||
@@ -1155,3 +1429,3 @@ function ref(value) { | ||
this.__v_isShallow = __v_isShallow; | ||
this.dep = void 0; | ||
this.dep = new Dep(); | ||
this.__v_isRef = true; | ||
@@ -1162,12 +1436,27 @@ this._rawValue = __v_isShallow ? value : toRaw(value); | ||
get value() { | ||
trackRefValue(this); | ||
{ | ||
this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}); | ||
} | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal); | ||
newVal = useDirectValue ? newVal : toRaw(newVal); | ||
if (hasChanged(newVal, this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = useDirectValue ? newVal : toReactive(newVal); | ||
triggerRefValue(this, 4, newVal); | ||
set value(newValue) { | ||
const oldValue = this._rawValue; | ||
const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue); | ||
newValue = useDirectValue ? newValue : toRaw(newValue); | ||
if (hasChanged(newValue, oldValue)) { | ||
this._rawValue = newValue; | ||
this._value = useDirectValue ? newValue : toReactive(newValue); | ||
{ | ||
this.dep.trigger({ | ||
target: this, | ||
type: "set", | ||
key: "value", | ||
newValue, | ||
oldValue | ||
}); | ||
} | ||
} | ||
@@ -1177,3 +1466,10 @@ } | ||
function triggerRef(ref2) { | ||
triggerRefValue(ref2, 4, ref2.value ); | ||
{ | ||
ref2.dep.trigger({ | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: ref2._value | ||
}); | ||
} | ||
} | ||
@@ -1203,8 +1499,5 @@ function unref(ref2) { | ||
constructor(factory) { | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
const { get, set } = factory( | ||
() => trackRefValue(this), | ||
() => triggerRefValue(this) | ||
); | ||
const dep = this.dep = new Dep(); | ||
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep)); | ||
this._get = get; | ||
@@ -1277,3 +1570,85 @@ this._set = set; | ||
const deferredComputed = computed; | ||
class ComputedRefImpl { | ||
constructor(fn, setter, isSSR) { | ||
this.fn = fn; | ||
this.setter = setter; | ||
/** | ||
* @internal | ||
*/ | ||
this._value = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.dep = new Dep(this); | ||
/** | ||
* @internal | ||
*/ | ||
this.__v_isRef = true; | ||
// A computed is also a subscriber that tracks other deps | ||
/** | ||
* @internal | ||
*/ | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.flags = 16; | ||
/** | ||
* @internal | ||
*/ | ||
this.globalVersion = globalVersion - 1; | ||
// for backwards compat | ||
this.effect = this; | ||
this.__v_isReadonly = !setter; | ||
this.isSSR = isSSR; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (activeSub !== this) { | ||
this.flags |= 16; | ||
this.dep.notify(); | ||
} | ||
} | ||
get value() { | ||
const link = this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}) ; | ||
refreshComputed(this); | ||
if (link) { | ||
link.version = this.dep.version; | ||
} | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
if (this.setter) { | ||
this.setter(newValue); | ||
} else { | ||
warn("Write operation failed: computed value is readonly"); | ||
} | ||
} | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
if (isFunction(getterOrOptions)) { | ||
getter = getterOrOptions; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, isSSR); | ||
if (debugOptions && !isSSR) { | ||
cRef.onTrack = debugOptions.onTrack; | ||
cRef.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
@@ -1299,2 +1674,2 @@ const TrackOpTypes = { | ||
export { EffectScope, ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseScheduling, pauseTracking, proxyRefs, reactive, readonly, ref, resetScheduling, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, track, trigger, triggerRef, unref }; | ||
export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, trigger, triggerRef, unref }; |
/** | ||
* @vue/reactivity v3.4.25 | ||
* @vue/reactivity v3.5.0-alpha.1 | ||
* (c) 2018-present Yuxi (Evan) You and Vue contributors | ||
@@ -7,2 +7,2 @@ * @license MIT | ||
/*! #__NO_SIDE_EFFECTS__ */ | ||
function t(t,e){const s=new Set(t.split(","));return t=>s.has(t)}const e=()=>{},s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,c=t=>"[object Map]"===a(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,l=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,a=t=>h.call(t),_=t=>a(t).slice(8,-1),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let v,p;class g{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=v,!t&&v&&(this.index=(v.scopes||(v.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=v;try{return v=this,t()}finally{v=e}}}on(){v=this}off(){v=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function y(t){return new g(t)}function w(t,e=v){e&&e.active&&e.effects.push(t)}function R(){return v}function b(t){v&&v.cleanups.push(t)}class S{constructor(t,e,s,n){this.fn=t,this.trigger=e,this.scheduler=s,this.active=!0,this.deps=[],this._dirtyLevel=4,this._trackId=0,this._runnings=0,this._shouldSchedule=!1,this._depsLength=0,w(this,n)}get dirty(){if(2===this._dirtyLevel||3===this._dirtyLevel){this._dirtyLevel=1,A();for(let t=0;t<this._depsLength;t++){const e=this.deps[t];if(e.computed&&(L(e.computed),this._dirtyLevel>=4))break}1===this._dirtyLevel&&(this._dirtyLevel=0),W()}return this._dirtyLevel>=4}set dirty(t){this._dirtyLevel=t?4:0}run(){if(this._dirtyLevel=0,!this.active)return this.fn();let t=x,e=p;try{return x=!0,p=this,this._runnings++,k(this),this.fn()}finally{E(this),this._runnings--,p=e,x=t}}stop(){var t;this.active&&(k(this),E(this),null==(t=this.onStop)||t.call(this),this.active=!1)}}function L(t){return t.value}function k(t){t._trackId++,t._depsLength=0}function E(t){if(t.deps.length>t._depsLength){for(let e=t._depsLength;e<t.deps.length;e++)O(t.deps[e],t);t.deps.length=t._depsLength}}function O(t,e){const s=t.get(e);void 0!==s&&e._trackId!==s&&(t.delete(e),0===t.size&&t.cleanup())}function m(t,n){t.effect instanceof S&&(t=t.effect.fn);const i=new S(t,e,(()=>{i.dirty&&i.run()}));n&&(s(i,n),n.scope&&w(i,n.scope)),n&&n.lazy||i.run();const r=i.run.bind(i);return r.effect=i,r}function j(t){t.effect.stop()}let x=!0,I=0;const P=[];function A(){P.push(x),x=!1}function M(){P.push(x),x=!0}function W(){const t=P.pop();x=void 0===t||t}function z(){I++}function V(){for(I--;!I&&T.length;)T.shift()()}function N(t,e,s){if(e.get(t)!==t._trackId){e.set(t,t._trackId);const s=t.deps[t._depsLength];s!==e?(s&&O(s,t),t.deps[t._depsLength++]=e):t._depsLength++}}const T=[];function D(t,e,s){z();for(const n of t.keys()){let s;n._dirtyLevel<e&&(null!=s?s:s=t.get(n)===n._trackId)&&(n._shouldSchedule||(n._shouldSchedule=0===n._dirtyLevel),n._dirtyLevel=e),n._shouldSchedule&&(null!=s?s:s=t.get(n)===n._trackId)&&(n.trigger(),n._runnings&&!n.allowRecurse||2===n._dirtyLevel||(n._shouldSchedule=!1,n.scheduler&&T.push(n.scheduler)))}V()}const K=(t,e)=>{const s=new Map;return s.cleanup=t,s.computed=e,s},C=new WeakMap,H=Symbol(""),G=Symbol("");function Y(t,e,s){if(x&&p){let e=C.get(t);e||C.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=K((()=>e.delete(s)))),N(p,n)}}function q(t,e,s,n,i,o){const l=C.get(t);if(!l)return;let h=[];if("clear"===e)h=[...l.values()];else if("length"===s&&r(t)){const t=Number(n);l.forEach(((e,s)=>{("length"===s||!u(s)&&s>=t)&&h.push(e)}))}else switch(void 0!==s&&h.push(l.get(s)),e){case"add":r(t)?f(s)&&h.push(l.get("length")):(h.push(l.get(H)),c(t)&&h.push(l.get(G)));break;case"delete":r(t)||(h.push(l.get(H)),c(t)&&h.push(l.get(G)));break;case"set":c(t)&&h.push(l.get(H))}z();for(const r of h)r&&D(r,4);V()}const B=t("__proto__,__v_isRef,__isVue"),F=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u)),J=Q();function Q(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Dt(this);for(let e=0,i=this.length;e<i;e++)Y(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Dt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){A(),z();const s=Dt(this)[e].apply(this,t);return V(),W(),s}})),t}function U(t){u(t)||(t=String(t));const e=Dt(this);return Y(e,0,t),e.hasOwnProperty(t)}class X{constructor(t=!1,e=!1){this._isReadonly=t,this._isShallow=e}get(t,e,s){const n=this._isReadonly,c=this._isShallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return c;if("__v_raw"===e)return s===(n?c?xt:jt:c?mt:Ot).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=r(t);if(!n){if(o&&i(J,e))return Reflect.get(J,e,s);if("hasOwnProperty"===e)return U}const h=Reflect.get(t,e,s);return(u(e)?F.has(e):B(e))?h:(n||Y(t,0,e),c?h:Ft(h)?o&&f(e)?h:h.value:l(h)?n?At(h):It(h):h)}}class Z extends X{constructor(t=!1){super(!1,t)}set(t,e,s,n){let c=t[e];if(!this._isShallow){const e=Vt(c);if(Nt(s)||Vt(s)||(c=Dt(c),s=Dt(s)),!r(t)&&Ft(c)&&!Ft(s))return!e&&(c.value=s,!0)}const o=r(t)&&f(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Dt(n)&&(o?d(s,c)&&q(t,"set",e,s):q(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&q(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&F.has(e)||Y(t,0,e),s}ownKeys(t){return Y(t,0,r(t)?"length":H),Reflect.ownKeys(t)}}class $ extends X{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const tt=new Z,et=new $,st=new Z(!0),nt=new $(!0),it=t=>t,rt=t=>Reflect.getPrototypeOf(t);function ct(t,e,s=!1,n=!1){const i=Dt(t=t.__v_raw),r=Dt(e);s||(d(e,r)&&Y(i,0,e),Y(i,0,r));const{has:c}=rt(i),o=n?it:s?Ht:Ct;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function ot(t,e=!1){const s=this.__v_raw,n=Dt(s),i=Dt(t);return e||(d(t,i)&&Y(n,0,t),Y(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ut(t,e=!1){return t=t.__v_raw,!e&&Y(Dt(t),0,H),Reflect.get(t,"size",t)}function lt(t){t=Dt(t);const e=Dt(this);return rt(e).has.call(e,t)||(e.add(t),q(e,"add",t,t)),this}function ht(t,e){e=Dt(e);const s=Dt(this),{has:n,get:i}=rt(s);let r=n.call(s,t);r||(t=Dt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?d(e,c)&&q(s,"set",t,e):q(s,"add",t,e),this}function at(t){const e=Dt(this),{has:s,get:n}=rt(e);let i=s.call(e,t);i||(t=Dt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&q(e,"delete",t,void 0),r}function _t(){const t=Dt(this),e=0!==t.size,s=t.clear();return e&&q(t,"clear",void 0,void 0),s}function ft(t,e){return function(s,n){const i=this,r=i.__v_raw,c=Dt(r),o=e?it:t?Ht:Ct;return!t&&Y(c,0,H),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function dt(t,e,s){return function(...n){const i=this.__v_raw,r=Dt(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,l="keys"===t&&o,h=i[t](...n),a=s?it:e?Ht:Ct;return!e&&Y(r,0,l?G:H),{next(){const{value:t,done:e}=h.next();return e?{value:t,done:e}:{value:u?[a(t[0]),a(t[1])]:a(t),done:e}},[Symbol.iterator](){return this}}}}function vt(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function pt(){const t={get(t){return ct(this,t)},get size(){return ut(this)},has:ot,add:lt,set:ht,delete:at,clear:_t,forEach:ft(!1,!1)},e={get(t){return ct(this,t,!1,!0)},get size(){return ut(this)},has:ot,add:lt,set:ht,delete:at,clear:_t,forEach:ft(!1,!0)},s={get(t){return ct(this,t,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:vt("add"),set:vt("set"),delete:vt("delete"),clear:vt("clear"),forEach:ft(!0,!1)},n={get(t){return ct(this,t,!0,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:vt("add"),set:vt("set"),delete:vt("delete"),clear:vt("clear"),forEach:ft(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=dt(i,!1,!1),s[i]=dt(i,!0,!1),e[i]=dt(i,!1,!0),n[i]=dt(i,!0,!0)})),[t,s,e,n]}const[gt,yt,wt,Rt]=pt();function bt(t,e){const s=e?t?Rt:wt:t?yt:gt;return(e,n,r)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(i(s,n)&&n in e?s:e,n,r)}const St={get:bt(!1,!1)},Lt={get:bt(!1,!0)},kt={get:bt(!0,!1)},Et={get:bt(!0,!0)},Ot=new WeakMap,mt=new WeakMap,jt=new WeakMap,xt=new WeakMap;function It(t){return Vt(t)?t:Wt(t,!1,tt,St,Ot)}function Pt(t){return Wt(t,!1,st,Lt,mt)}function At(t){return Wt(t,!0,et,kt,jt)}function Mt(t){return Wt(t,!0,nt,Et,xt)}function Wt(t,e,s,n,i){if(!l(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__v_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(_(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function zt(t){return Vt(t)?zt(t.__v_raw):!(!t||!t.__v_isReactive)}function Vt(t){return!(!t||!t.__v_isReadonly)}function Nt(t){return!(!t||!t.__v_isShallow)}function Tt(t){return!!t&&!!t.__v_raw}function Dt(t){const e=t&&t.__v_raw;return e?Dt(e):t}function Kt(t){return Object.isExtensible(t)&&((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t}const Ct=t=>l(t)?It(t):t,Ht=t=>l(t)?At(t):t;class Gt{constructor(t,e,s,n){this.getter=t,this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this.effect=new S((()=>t(this._value)),(()=>Bt(this,2===this.effect._dirtyLevel?2:3))),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=s}get value(){const t=Dt(this);return t._cacheable&&!t.effect.dirty||!d(t._value,t._value=t.effect.run())||Bt(t,4),qt(t),t.effect._dirtyLevel>=2&&Bt(t,2),t._value}set value(t){this._setter(t)}get _dirty(){return this.effect.dirty}set _dirty(t){this.effect.dirty=t}}function Yt(t,s,n=!1){let i,r;const c=o(t);c?(i=t,r=e):(i=t.get,r=t.set);return new Gt(i,r,c||!r,n)}function qt(t){var e;x&&p&&(t=Dt(t),N(p,null!=(e=t.dep)?e:t.dep=K((()=>t.dep=void 0),t instanceof Gt?t:void 0)))}function Bt(t,e=4,s){const n=(t=Dt(t)).dep;n&&D(n,e)}function Ft(t){return!(!t||!0!==t.__v_isRef)}function Jt(t){return Ut(t,!1)}function Qt(t){return Ut(t,!0)}function Ut(t,e){return Ft(t)?t:new Xt(t,e)}class Xt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Dt(t),this._value=e?t:Ct(t)}get value(){return qt(this),this._value}set value(t){const e=this.__v_isShallow||Nt(t)||Vt(t);t=e?t:Dt(t),d(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Ct(t),Bt(this,4))}}function Zt(t){Bt(t,4)}function $t(t){return Ft(t)?t.value:t}function te(t){return o(t)?t():$t(t)}const ee={get:(t,e,s)=>$t(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Ft(i)&&!Ft(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function se(t){return zt(t)?t:new Proxy(t,ee)}class ne{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:s}=t((()=>qt(this)),(()=>Bt(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}function ie(t){return new ne(t)}function re(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=le(t,s);return e}class ce{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Dt(this._object),e=this._key,null==(s=C.get(t))?void 0:s.get(e);var t,e,s}}class oe{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function ue(t,e,s){return Ft(t)?t:o(t)?new oe(t):l(t)&&arguments.length>1?le(t,e,s):Jt(t)}function le(t,e,s){const n=t[e];return Ft(n)?n:new ce(t,e,s)}const he=Yt,ae={GET:"get",HAS:"has",ITERATE:"iterate"},_e={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},fe={SKIP:"__v_skip",IS_REACTIVE:"__v_isReactive",IS_READONLY:"__v_isReadonly",IS_SHALLOW:"__v_isShallow",RAW:"__v_raw"};export{g as EffectScope,H as ITERATE_KEY,S as ReactiveEffect,fe as ReactiveFlags,ae as TrackOpTypes,_e as TriggerOpTypes,Yt as computed,ie as customRef,he as deferredComputed,m as effect,y as effectScope,M as enableTracking,R as getCurrentScope,Tt as isProxy,zt as isReactive,Vt as isReadonly,Ft as isRef,Nt as isShallow,Kt as markRaw,b as onScopeDispose,z as pauseScheduling,A as pauseTracking,se as proxyRefs,It as reactive,At as readonly,Jt as ref,V as resetScheduling,W as resetTracking,Pt as shallowReactive,Mt as shallowReadonly,Qt as shallowRef,j as stop,Dt as toRaw,ue as toRef,re as toRefs,te as toValue,Y as track,q as trigger,Zt as triggerRef,$t as unref}; | ||
function t(t,e){const s=new Set(t.split(","));return t=>s.has(t)}const e=Object.assign,s=Object.prototype.hasOwnProperty,n=(t,e)=>s.call(t,e),i=Array.isArray,r=t=>"[object Map]"===l(t),o=t=>"function"==typeof t,c=t=>"symbol"==typeof t,u=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>a.call(t),h=t=>l(t).slice(8,-1),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,p=(t,e)=>!Object.is(t,e);let d,v;class _{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=d,!t&&d&&(this.index=(d.scopes||(d.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=d;try{return d=this,t()}finally{d=e}}}on(){d=this}off(){d=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function g(t){return new _(t)}function y(){return d}function b(t,e=!1){d&&d.cleanups.push(t)}const w={ACTIVE:1,1:"ACTIVE",RUNNING:2,2:"RUNNING",TRACKING:4,4:"TRACKING",NOTIFIED:8,8:"NOTIFIED",DIRTY:16,16:"DIRTY",ALLOW_RECURSE:32,32:"ALLOW_RECURSE",NO_BATCH:64,64:"NO_BATCH"};class S{constructor(t){this.fn=t,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.nextEffect=void 0,this.cleanup=void 0,this.scheduler=void 0,d&&d.active&&d.effects.push(this)}notify(){if(!(2&this.flags)||32&this.flags)return 64&this.flags?this.trigger():void(8&this.flags||(this.flags|=8,this.nextEffect=R,R=this))}run(){if(!(1&this.flags))return this.fn();this.flags|=2,z(this),k(this);const t=v,e=N;v=this,N=!0;try{return this.fn()}finally{m(this),v=t,N=e,this.flags&=-3}}stop(){if(1&this.flags){for(let t=this.deps;t;t=t.nextDep)I(t);this.deps=this.depsTail=void 0,z(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){O(this)&&this.run()}get dirty(){return O(this)}}let R,x=0;function D(){x++}function E(){if(x>1)return void x--;let t;for(;R;){let s=R;for(R=void 0;s;){const n=s.nextEffect;if(s.nextEffect=void 0,s.flags&=-9,1&s.flags)try{s.trigger()}catch(e){t||(t=e)}s=n}}if(x--,t)throw t}function k(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function m(t){let e,s=t.depsTail;for(let n=s;n;n=n.prevDep)-1===n.version?(n===s&&(s=n.prevDep),I(n),A(n)):e=n,n.dep.activeLink=n.prevActiveLink,n.prevActiveLink=void 0;t.deps=e,t.depsTail=s}function O(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&!1===T(e.dep.computed)||e.dep.version!==e.version)return!0;return!!t._dirty}function T(t){if(2&t.flags)return!1;if(4&t.flags&&!(16&t.flags))return;if(t.flags&=-17,t.globalVersion===G)return;t.globalVersion=G;const e=t.dep;if(t.flags|=2,e.version>0&&!t.isSSR&&!O(t))return void(t.flags&=-3);const s=v,n=N;v=t,N=!0;try{k(t);const s=t.fn();(0===e.version||p(s,t._value))&&(t._value=s,e.version++)}catch(i){throw e.version++,i}finally{v=s,N=n,m(t),t.flags&=-3}}function I(t){const{dep:e,prevSub:s,nextSub:n}=t;if(s&&(s.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=s,t.nextSub=void 0),e.subs===t&&(e.subs=s),!e.subs&&e.computed){e.computed.flags&=-5;for(let t=e.computed.deps;t;t=t.nextDep)I(t)}}function A(t){const{prevDep:e,nextDep:s}=t;e&&(e.nextDep=s,t.prevDep=void 0),s&&(s.prevDep=e,t.nextDep=void 0)}function L(t,s){t.effect instanceof S&&(t=t.effect.fn);const n=new S(t);s&&e(n,s);try{n.run()}catch(r){throw n.stop(),r}const i=n.run.bind(n);return i.effect=n,i}function j(t){t.effect.stop()}let N=!0;const P=[];function V(){P.push(N),N=!1}function W(){P.push(N),N=!0}function C(){const t=P.pop();N=void 0===t||t}function M(t,e=!1){v instanceof S&&(v.cleanup=t)}function z(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const t=v;v=void 0;try{e()}finally{v=t}}}let G=0;class K{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0}track(t){if(!v||!N)return;let e=this.activeLink;if(void 0===e||e.sub!==v)e=this.activeLink={dep:this,sub:v,version:this.version,nextDep:void 0,prevDep:void 0,nextSub:void 0,prevSub:void 0,prevActiveLink:void 0},v.deps?(e.prevDep=v.depsTail,v.depsTail.nextDep=e,v.depsTail=e):v.deps=v.depsTail=e,4&v.flags&&H(e);else if(-1===e.version&&(e.version=this.version,e.nextDep)){const t=e.nextDep;t.prevDep=e.prevDep,e.prevDep&&(e.prevDep.nextDep=t),e.prevDep=v.depsTail,e.nextDep=void 0,v.depsTail.nextDep=e,v.depsTail=e,v.deps===e&&(v.deps=t)}return e}trigger(t){this.version++,G++,this.notify(t)}notify(t){D();try{0;for(let t=this.subs;t;t=t.prevSub)t.sub.notify()}finally{E()}}}function H(t){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let t=e.deps;t;t=t.nextDep)H(t)}const s=t.dep.subs;s!==t&&(t.prevSub=s,s&&(s.nextSub=t)),t.dep.subs=t}const U=new WeakMap,Y=Symbol(""),B=Symbol(""),F=Symbol("");function q(t,e,s){if(N&&v){let e=U.get(t);e||U.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=new K),n.track()}}function J(t,e,s,n,o,u){const a=U.get(t);if(!a)return void G++;let l=[];if("clear"===e)l=[...a.values()];else{const o=i(t),u=o&&f(s);if(o&&"length"===s){const t=Number(n);a.forEach(((e,s)=>{("length"===s||s===F||!c(s)&&s>=t)&&l.push(e)}))}else{const n=t=>t&&l.push(t);switch(void 0!==s&&n(a.get(s)),u&&n(a.get(F)),e){case"add":o?u&&n(a.get("length")):(n(a.get(Y)),r(t)&&n(a.get(B)));break;case"delete":o||(n(a.get(Y)),r(t)&&n(a.get(B)));break;case"set":r(t)&&n(a.get(Y))}}}D();for(const i of l)i.trigger();E()}function Q(t){const e=Jt(t);return e===t?e:(q(e,0,F),Ft(t)?e:e.map(Xt))}function X(t){return q(t=Jt(t),0,F),t}const Z={__proto__:null,[Symbol.iterator](){return $(this,Symbol.iterator,Xt)},concat(...t){return Q(this).concat(...t.map((t=>Q(t))))},entries(){return $(this,"entries",(t=>(t[1]=Xt(t[1]),t)))},every(t,e){return tt(this,"every",t,e)},filter(t,e){const s=tt(this,"filter",t,e);return qt(this)&&!Ft(this)?s.map(Xt):s},find(t,e){const s=tt(this,"find",t,e);return qt(this)&&!Ft(this)?Xt(s):s},findIndex(t,e){return tt(this,"findIndex",t,e)},findLast(t,e){const s=tt(this,"findLast",t,e);return qt(this)&&!Ft(this)?Xt(s):s},findLastIndex(t,e){return tt(this,"findLastIndex",t,e)},forEach(t,e){return tt(this,"forEach",t,e)},includes(...t){return st(this,"includes",t)},indexOf(...t){return st(this,"indexOf",t)},join(t){return Q(this).join(t)},lastIndexOf(...t){return st(this,"lastIndexOf",t)},map(t,e){return tt(this,"map",t,e)},pop(){return nt(this,"pop")},push(...t){return nt(this,"push",t)},reduce(t,...e){return et(this,"reduce",t,e)},reduceRight(t,...e){return et(this,"reduceRight",t,e)},shift(){return nt(this,"shift")},some(t,e){return tt(this,"some",t,e)},splice(...t){return nt(this,"splice",t)},toReversed(){return Q(this).toReversed()},toSorted(t){return Q(this).toSorted(t)},toSpliced(...t){return Q(this).toSpliced(...t)},unshift(...t){return nt(this,"unshift",t)},values(){return $(this,"values",Xt)}};function $(t,e,s){const n=X(t),i=n[e]();return n===t||Ft(t)||(i._next=i.next,i.next=()=>{const t=i._next();return t.value&&(t.value=s(t.value)),t}),i}function tt(t,e,s,n){const i=X(t);let r=s;return i!==t&&(Ft(t)?s.length>2&&(r=function(e,n){return s.call(this,e,n,t)}):r=function(e,n){return s.call(this,Xt(e),n,t)}),i[e](r,n)}function et(t,e,s,n){const i=X(t);let r=s;return i!==t&&(Ft(t)?s.length>3&&(r=function(e,n,i){return s.call(this,e,n,i,t)}):r=function(e,n,i){return s.call(this,e,Xt(n),i,t)}),i[e](r,...n)}function st(t,e,s){const n=Jt(t);q(n,0,F);const i=n[e](...s);return-1!==i&&!1!==i||!qt(s[0])?i:(s[0]=Jt(s[0]),n[e](...s))}function nt(t,e,s=[]){V(),D();const n=Jt(t)[e].apply(t,s);return E(),C(),n}const it=t("__proto__,__v_isRef,__isVue"),rt=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(c));function ot(t){c(t)||(t=String(t));const e=Jt(this);return q(e,0,t),e.hasOwnProperty(t)}class ct{constructor(t=!1,e=!1){this._isReadonly=t,this._isShallow=e}get(t,e,s){const n=this._isReadonly,r=this._isShallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return r;if("__v_raw"===e)return s===(n?r?Mt:Ct:r?Wt:Vt).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=i(t);if(!n){let t;if(o&&(t=Z[e]))return t;if("hasOwnProperty"===e)return ot}const a=Reflect.get(t,e,$t(t)?t:s);return(c(e)?rt.has(e):it(e))?a:(n||q(t,0,e),r?a:$t(a)?o&&f(e)?a:a.value:u(a)?n?Kt(a):zt(a):a)}}class ut extends ct{constructor(t=!1){super(!1,t)}set(t,e,s,r){let o=t[e];if(!this._isShallow){const e=Bt(o);if(Ft(s)||Bt(s)||(o=Jt(o),s=Jt(s)),!i(t)&&$t(o)&&!$t(s))return!e&&(o.value=s,!0)}const c=i(t)&&f(e)?Number(e)<t.length:n(t,e),u=Reflect.set(t,e,s,r);return t===Jt(r)&&(c?p(s,o)&&J(t,"set",e,s):J(t,"add",e,s)),u}deleteProperty(t,e){const s=n(t,e),i=Reflect.deleteProperty(t,e);return i&&s&&J(t,"delete",e,void 0),i}has(t,e){const s=Reflect.has(t,e);return c(e)&&rt.has(e)||q(t,0,e),s}ownKeys(t){return q(t,0,i(t)?"length":Y),Reflect.ownKeys(t)}}class at extends ct{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const lt=new ut,ht=new at,ft=new ut(!0),pt=new at(!0),dt=t=>t,vt=t=>Reflect.getPrototypeOf(t);function _t(t,e,s=!1,n=!1){const i=Jt(t=t.__v_raw),r=Jt(e);s||(p(e,r)&&q(i,0,e),q(i,0,r));const{has:o}=vt(i),c=n?dt:s?Zt:Xt;return o.call(i,e)?c(t.get(e)):o.call(i,r)?c(t.get(r)):void(t!==i&&t.get(e))}function gt(t,e=!1){const s=this.__v_raw,n=Jt(s),i=Jt(t);return e||(p(t,i)&&q(n,0,t),q(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function yt(t,e=!1){return t=t.__v_raw,!e&&q(Jt(t),0,Y),Reflect.get(t,"size",t)}function bt(t){t=Jt(t);const e=Jt(this);return vt(e).has.call(e,t)||(e.add(t),J(e,"add",t,t)),this}function wt(t,e){e=Jt(e);const s=Jt(this),{has:n,get:i}=vt(s);let r=n.call(s,t);r||(t=Jt(t),r=n.call(s,t));const o=i.call(s,t);return s.set(t,e),r?p(e,o)&&J(s,"set",t,e):J(s,"add",t,e),this}function St(t){const e=Jt(this),{has:s,get:n}=vt(e);let i=s.call(e,t);i||(t=Jt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&J(e,"delete",t,void 0),r}function Rt(){const t=Jt(this),e=0!==t.size,s=t.clear();return e&&J(t,"clear",void 0,void 0),s}function xt(t,e){return function(s,n){const i=this,r=i.__v_raw,o=Jt(r),c=e?dt:t?Zt:Xt;return!t&&q(o,0,Y),r.forEach(((t,e)=>s.call(n,c(t),c(e),i)))}}function Dt(t,e,s){return function(...n){const i=this.__v_raw,o=Jt(i),c=r(o),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,l=i[t](...n),h=s?dt:e?Zt:Xt;return!e&&q(o,0,a?B:Y),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[h(t[0]),h(t[1])]:h(t),done:e}},[Symbol.iterator](){return this}}}}function Et(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function kt(){const t={get(t){return _t(this,t)},get size(){return yt(this)},has:gt,add:bt,set:wt,delete:St,clear:Rt,forEach:xt(!1,!1)},e={get(t){return _t(this,t,!1,!0)},get size(){return yt(this)},has:gt,add:bt,set:wt,delete:St,clear:Rt,forEach:xt(!1,!0)},s={get(t){return _t(this,t,!0)},get size(){return yt(this,!0)},has(t){return gt.call(this,t,!0)},add:Et("add"),set:Et("set"),delete:Et("delete"),clear:Et("clear"),forEach:xt(!0,!1)},n={get(t){return _t(this,t,!0,!0)},get size(){return yt(this,!0)},has(t){return gt.call(this,t,!0)},add:Et("add"),set:Et("set"),delete:Et("delete"),clear:Et("clear"),forEach:xt(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=Dt(i,!1,!1),s[i]=Dt(i,!0,!1),e[i]=Dt(i,!1,!0),n[i]=Dt(i,!0,!0)})),[t,s,e,n]}const[mt,Ot,Tt,It]=kt();function At(t,e){const s=e?t?It:Tt:t?Ot:mt;return(e,i,r)=>"__v_isReactive"===i?!t:"__v_isReadonly"===i?t:"__v_raw"===i?e:Reflect.get(n(s,i)&&i in e?s:e,i,r)}const Lt={get:At(!1,!1)},jt={get:At(!1,!0)},Nt={get:At(!0,!1)},Pt={get:At(!0,!0)},Vt=new WeakMap,Wt=new WeakMap,Ct=new WeakMap,Mt=new WeakMap;function zt(t){return Bt(t)?t:Ut(t,!1,lt,Lt,Vt)}function Gt(t){return Ut(t,!1,ft,jt,Wt)}function Kt(t){return Ut(t,!0,ht,Nt,Ct)}function Ht(t){return Ut(t,!0,pt,Pt,Mt)}function Ut(t,e,s,n,i){if(!u(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const o=(c=t).__v_skip||!Object.isExtensible(c)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(h(c));var c;if(0===o)return t;const a=new Proxy(t,2===o?n:s);return i.set(t,a),a}function Yt(t){return Bt(t)?Yt(t.__v_raw):!(!t||!t.__v_isReactive)}function Bt(t){return!(!t||!t.__v_isReadonly)}function Ft(t){return!(!t||!t.__v_isShallow)}function qt(t){return!!t&&!!t.__v_raw}function Jt(t){const e=t&&t.__v_raw;return e?Jt(e):t}function Qt(t){return Object.isExtensible(t)&&((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t}const Xt=t=>u(t)?zt(t):t,Zt=t=>u(t)?Kt(t):t;function $t(t){return!!t&&!0===t.__v_isRef}function te(t){return se(t,!1)}function ee(t){return se(t,!0)}function se(t,e){return $t(t)?t:new ne(t,e)}class ne{constructor(t,e){this.__v_isShallow=e,this.dep=new K,this.__v_isRef=!0,this._rawValue=e?t:Jt(t),this._value=e?t:Xt(t)}get value(){return this.dep.track(),this._value}set value(t){const e=this._rawValue,s=this.__v_isShallow||Ft(t)||Bt(t);t=s?t:Jt(t),p(t,e)&&(this._rawValue=t,this._value=s?t:Xt(t),this.dep.trigger())}}function ie(t){t.dep.trigger()}function re(t){return $t(t)?t.value:t}function oe(t){return o(t)?t():re(t)}const ce={get:(t,e,s)=>re(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return $t(i)&&!$t(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};function ue(t){return Yt(t)?t:new Proxy(t,ce)}class ae{constructor(t){this.__v_isRef=!0;const e=this.dep=new K,{get:s,set:n}=t(e.track.bind(e),e.trigger.bind(e));this._get=s,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function le(t){return new ae(t)}function he(t){const e=i(t)?new Array(t.length):{};for(const s in t)e[s]=ve(t,s);return e}class fe{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Jt(this._object),e=this._key,null==(s=U.get(t))?void 0:s.get(e);var t,e,s}}class pe{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function de(t,e,s){return $t(t)?t:o(t)?new pe(t):u(t)&&arguments.length>1?ve(t,e,s):te(t)}function ve(t,e,s){const n=t[e];return $t(n)?n:new fe(t,e,s)}class _e{constructor(t,e,s){this.fn=t,this.setter=e,this._value=void 0,this.dep=new K(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=G-1,this.effect=this,this.__v_isReadonly=!e,this.isSSR=s}notify(){v!==this&&(this.flags|=16,this.dep.notify())}get value(){const t=this.dep.track();return T(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function ge(t,e,s=!1){let n,i;o(t)?n=t:(n=t.get,i=t.set);return new _e(n,i,s)}const ye={GET:"get",HAS:"has",ITERATE:"iterate"},be={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},we={SKIP:"__v_skip",IS_REACTIVE:"__v_isReactive",IS_READONLY:"__v_isReadonly",IS_SHALLOW:"__v_isShallow",RAW:"__v_raw"};export{F as ARRAY_ITERATE_KEY,w as EffectFlags,_ as EffectScope,Y as ITERATE_KEY,B as MAP_KEY_ITERATE_KEY,S as ReactiveEffect,we as ReactiveFlags,ye as TrackOpTypes,be as TriggerOpTypes,ge as computed,le as customRef,L as effect,g as effectScope,W as enableTracking,y as getCurrentScope,qt as isProxy,Yt as isReactive,Bt as isReadonly,$t as isRef,Ft as isShallow,Qt as markRaw,M as onEffectCleanup,b as onScopeDispose,V as pauseTracking,ue as proxyRefs,zt as reactive,Q as reactiveReadArray,Kt as readonly,te as ref,C as resetTracking,Gt as shallowReactive,X as shallowReadArray,Ht as shallowReadonly,ee as shallowRef,j as stop,Jt as toRaw,Xt as toReactive,Zt as toReadonly,de as toRef,he as toRefs,oe as toValue,q as track,J as trigger,ie as triggerRef,re as unref}; |
/** | ||
* @vue/reactivity v3.4.25 | ||
* @vue/reactivity v3.5.0-alpha.1 | ||
* (c) 2018-present Yuxi (Evan) You and Vue contributors | ||
* @license MIT | ||
**/ | ||
import { NOOP, extend, isArray, isSymbol, isMap, isIntegerKey, hasOwn, hasChanged, isObject, makeMap, capitalize, toRawType, def, isFunction } from '@vue/shared'; | ||
import { hasChanged, extend, isArray, isIntegerKey, isSymbol, isMap, hasOwn, isObject, makeMap, capitalize, toRawType, def, isFunction } from '@vue/shared'; | ||
@@ -94,14 +94,9 @@ function warn(msg, ...args) { | ||
} | ||
function recordEffectScope(effect, scope = activeEffectScope) { | ||
if (scope && scope.active) { | ||
scope.effects.push(effect); | ||
} | ||
} | ||
function getCurrentScope() { | ||
return activeEffectScope; | ||
} | ||
function onScopeDispose(fn) { | ||
function onScopeDispose(fn, failSilently = false) { | ||
if (activeEffectScope) { | ||
activeEffectScope.cleanups.push(fn); | ||
} else if (!!(process.env.NODE_ENV !== "production")) { | ||
} else if (!!(process.env.NODE_ENV !== "production") && !failSilently) { | ||
warn( | ||
@@ -113,109 +108,257 @@ `onScopeDispose() is called when there is no active effect scope to be associated with.` | ||
let activeEffect; | ||
let activeSub; | ||
const EffectFlags = { | ||
"ACTIVE": 1, | ||
"1": "ACTIVE", | ||
"RUNNING": 2, | ||
"2": "RUNNING", | ||
"TRACKING": 4, | ||
"4": "TRACKING", | ||
"NOTIFIED": 8, | ||
"8": "NOTIFIED", | ||
"DIRTY": 16, | ||
"16": "DIRTY", | ||
"ALLOW_RECURSE": 32, | ||
"32": "ALLOW_RECURSE", | ||
"NO_BATCH": 64, | ||
"64": "NO_BATCH" | ||
}; | ||
class ReactiveEffect { | ||
constructor(fn, trigger, scheduler, scope) { | ||
constructor(fn) { | ||
this.fn = fn; | ||
this.trigger = trigger; | ||
this.scheduler = scheduler; | ||
this.active = true; | ||
this.deps = []; | ||
/** | ||
* @internal | ||
*/ | ||
this._dirtyLevel = 4; | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._trackId = 0; | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._runnings = 0; | ||
this.flags = 1 | 4; | ||
/** | ||
* @internal | ||
*/ | ||
this._shouldSchedule = false; | ||
this.nextEffect = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._depsLength = 0; | ||
recordEffectScope(this, scope); | ||
this.cleanup = void 0; | ||
this.scheduler = void 0; | ||
if (activeEffectScope && activeEffectScope.active) { | ||
activeEffectScope.effects.push(this); | ||
} | ||
} | ||
get dirty() { | ||
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) { | ||
this._dirtyLevel = 1; | ||
pauseTracking(); | ||
for (let i = 0; i < this._depsLength; i++) { | ||
const dep = this.deps[i]; | ||
if (dep.computed) { | ||
triggerComputed(dep.computed); | ||
if (this._dirtyLevel >= 4) { | ||
break; | ||
} | ||
} | ||
} | ||
if (this._dirtyLevel === 1) { | ||
this._dirtyLevel = 0; | ||
} | ||
resetTracking(); | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (this.flags & 2 && !(this.flags & 32)) { | ||
return; | ||
} | ||
return this._dirtyLevel >= 4; | ||
if (this.flags & 64) { | ||
return this.trigger(); | ||
} | ||
if (!(this.flags & 8)) { | ||
this.flags |= 8; | ||
this.nextEffect = batchedEffect; | ||
batchedEffect = this; | ||
} | ||
} | ||
set dirty(v) { | ||
this._dirtyLevel = v ? 4 : 0; | ||
} | ||
run() { | ||
this._dirtyLevel = 0; | ||
if (!this.active) { | ||
if (!(this.flags & 1)) { | ||
return this.fn(); | ||
} | ||
let lastShouldTrack = shouldTrack; | ||
let lastEffect = activeEffect; | ||
this.flags |= 2; | ||
cleanupEffect(this); | ||
prepareDeps(this); | ||
const prevEffect = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = this; | ||
shouldTrack = true; | ||
try { | ||
shouldTrack = true; | ||
activeEffect = this; | ||
this._runnings++; | ||
preCleanupEffect(this); | ||
return this.fn(); | ||
} finally { | ||
postCleanupEffect(this); | ||
this._runnings--; | ||
activeEffect = lastEffect; | ||
shouldTrack = lastShouldTrack; | ||
if (!!(process.env.NODE_ENV !== "production") && activeSub !== this) { | ||
warn( | ||
"Active effect was not restored correctly - this is likely a Vue internal bug." | ||
); | ||
} | ||
cleanupDeps(this); | ||
activeSub = prevEffect; | ||
shouldTrack = prevShouldTrack; | ||
this.flags &= ~2; | ||
} | ||
} | ||
stop() { | ||
var _a; | ||
if (this.active) { | ||
preCleanupEffect(this); | ||
postCleanupEffect(this); | ||
(_a = this.onStop) == null ? void 0 : _a.call(this); | ||
this.active = false; | ||
if (this.flags & 1) { | ||
for (let link = this.deps; link; link = link.nextDep) { | ||
removeSub(link); | ||
} | ||
this.deps = this.depsTail = void 0; | ||
cleanupEffect(this); | ||
this.onStop && this.onStop(); | ||
this.flags &= ~1; | ||
} | ||
} | ||
trigger() { | ||
if (this.scheduler) { | ||
this.scheduler(); | ||
} else { | ||
this.runIfDirty(); | ||
} | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
runIfDirty() { | ||
if (isDirty(this)) { | ||
this.run(); | ||
} | ||
} | ||
get dirty() { | ||
return isDirty(this); | ||
} | ||
} | ||
function triggerComputed(computed) { | ||
return computed.value; | ||
let batchDepth = 0; | ||
let batchedEffect; | ||
function startBatch() { | ||
batchDepth++; | ||
} | ||
function preCleanupEffect(effect2) { | ||
effect2._trackId++; | ||
effect2._depsLength = 0; | ||
function endBatch() { | ||
if (batchDepth > 1) { | ||
batchDepth--; | ||
return; | ||
} | ||
let error; | ||
while (batchedEffect) { | ||
let e = batchedEffect; | ||
batchedEffect = void 0; | ||
while (e) { | ||
const next = e.nextEffect; | ||
e.nextEffect = void 0; | ||
e.flags &= ~8; | ||
if (e.flags & 1) { | ||
try { | ||
e.trigger(); | ||
} catch (err) { | ||
if (!error) | ||
error = err; | ||
} | ||
} | ||
e = next; | ||
} | ||
} | ||
batchDepth--; | ||
if (error) | ||
throw error; | ||
} | ||
function postCleanupEffect(effect2) { | ||
if (effect2.deps.length > effect2._depsLength) { | ||
for (let i = effect2._depsLength; i < effect2.deps.length; i++) { | ||
cleanupDepEffect(effect2.deps[i], effect2); | ||
function prepareDeps(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
link.version = -1; | ||
link.prevActiveLink = link.dep.activeLink; | ||
link.dep.activeLink = link; | ||
} | ||
} | ||
function cleanupDeps(sub) { | ||
let head; | ||
let tail = sub.depsTail; | ||
for (let link = tail; link; link = link.prevDep) { | ||
if (link.version === -1) { | ||
if (link === tail) | ||
tail = link.prevDep; | ||
removeSub(link); | ||
removeDep(link); | ||
} else { | ||
head = link; | ||
} | ||
effect2.deps.length = effect2._depsLength; | ||
link.dep.activeLink = link.prevActiveLink; | ||
link.prevActiveLink = void 0; | ||
} | ||
sub.deps = head; | ||
sub.depsTail = tail; | ||
} | ||
function cleanupDepEffect(dep, effect2) { | ||
const trackId = dep.get(effect2); | ||
if (trackId !== void 0 && effect2._trackId !== trackId) { | ||
dep.delete(effect2); | ||
if (dep.size === 0) { | ||
dep.cleanup(); | ||
function isDirty(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) { | ||
return true; | ||
} | ||
} | ||
if (sub._dirty) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function refreshComputed(computed) { | ||
if (computed.flags & 2) { | ||
return false; | ||
} | ||
if (computed.flags & 4 && !(computed.flags & 16)) { | ||
return; | ||
} | ||
computed.flags &= ~16; | ||
if (computed.globalVersion === globalVersion) { | ||
return; | ||
} | ||
computed.globalVersion = globalVersion; | ||
const dep = computed.dep; | ||
computed.flags |= 2; | ||
if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) { | ||
computed.flags &= ~2; | ||
return; | ||
} | ||
const prevSub = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = computed; | ||
shouldTrack = true; | ||
try { | ||
prepareDeps(computed); | ||
const value = computed.fn(); | ||
if (dep.version === 0 || hasChanged(value, computed._value)) { | ||
computed._value = value; | ||
dep.version++; | ||
} | ||
} catch (err) { | ||
dep.version++; | ||
throw err; | ||
} finally { | ||
activeSub = prevSub; | ||
shouldTrack = prevShouldTrack; | ||
cleanupDeps(computed); | ||
computed.flags &= ~2; | ||
} | ||
} | ||
function removeSub(link) { | ||
const { dep, prevSub, nextSub } = link; | ||
if (prevSub) { | ||
prevSub.nextSub = nextSub; | ||
link.prevSub = void 0; | ||
} | ||
if (nextSub) { | ||
nextSub.prevSub = prevSub; | ||
link.nextSub = void 0; | ||
} | ||
if (dep.subs === link) { | ||
dep.subs = prevSub; | ||
} | ||
if (!dep.subs && dep.computed) { | ||
dep.computed.flags &= ~4; | ||
for (let l = dep.computed.deps; l; l = l.nextDep) { | ||
removeSub(l); | ||
} | ||
} | ||
} | ||
function removeDep(link) { | ||
const { prevDep, nextDep } = link; | ||
if (prevDep) { | ||
prevDep.nextDep = nextDep; | ||
link.prevDep = void 0; | ||
} | ||
if (nextDep) { | ||
nextDep.prevDep = prevDep; | ||
link.nextDep = void 0; | ||
} | ||
} | ||
function effect(fn, options) { | ||
@@ -225,17 +368,14 @@ if (fn.effect instanceof ReactiveEffect) { | ||
} | ||
const _effect = new ReactiveEffect(fn, NOOP, () => { | ||
if (_effect.dirty) { | ||
_effect.run(); | ||
} | ||
}); | ||
const e = new ReactiveEffect(fn); | ||
if (options) { | ||
extend(_effect, options); | ||
if (options.scope) | ||
recordEffectScope(_effect, options.scope); | ||
extend(e, options); | ||
} | ||
if (!options || !options.lazy) { | ||
_effect.run(); | ||
try { | ||
e.run(); | ||
} catch (err) { | ||
e.stop(); | ||
throw err; | ||
} | ||
const runner = _effect.run.bind(_effect); | ||
runner.effect = _effect; | ||
const runner = e.run.bind(e); | ||
runner.effect = e; | ||
return runner; | ||
@@ -247,3 +387,2 @@ } | ||
let shouldTrack = true; | ||
let pauseScheduleStack = 0; | ||
const trackStack = []; | ||
@@ -262,67 +401,152 @@ function pauseTracking() { | ||
} | ||
function pauseScheduling() { | ||
pauseScheduleStack++; | ||
function onEffectCleanup(fn, failSilently = false) { | ||
if (activeSub instanceof ReactiveEffect) { | ||
activeSub.cleanup = fn; | ||
} else if (!!(process.env.NODE_ENV !== "production") && !failSilently) { | ||
warn( | ||
`onEffectCleanup() was called when there was no active effect to associate with.` | ||
); | ||
} | ||
} | ||
function resetScheduling() { | ||
pauseScheduleStack--; | ||
while (!pauseScheduleStack && queueEffectSchedulers.length) { | ||
queueEffectSchedulers.shift()(); | ||
function cleanupEffect(e) { | ||
const { cleanup } = e; | ||
e.cleanup = void 0; | ||
if (cleanup) { | ||
const prevSub = activeSub; | ||
activeSub = void 0; | ||
try { | ||
cleanup(); | ||
} finally { | ||
activeSub = prevSub; | ||
} | ||
} | ||
} | ||
function trackEffect(effect2, dep, debuggerEventExtraInfo) { | ||
var _a; | ||
if (dep.get(effect2) !== effect2._trackId) { | ||
dep.set(effect2, effect2._trackId); | ||
const oldDep = effect2.deps[effect2._depsLength]; | ||
if (oldDep !== dep) { | ||
if (oldDep) { | ||
cleanupDepEffect(oldDep, effect2); | ||
} | ||
effect2.deps[effect2._depsLength++] = dep; | ||
} else { | ||
effect2._depsLength++; | ||
} | ||
let globalVersion = 0; | ||
class Dep { | ||
constructor(computed) { | ||
this.computed = computed; | ||
this.version = 0; | ||
/** | ||
* Link between this dep and the current active effect | ||
*/ | ||
this.activeLink = void 0; | ||
/** | ||
* Doubly linked list representing the subscribing effects (tail) | ||
*/ | ||
this.subs = void 0; | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
this.subsHead = void 0; | ||
} | ||
} | ||
} | ||
const queueEffectSchedulers = []; | ||
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) { | ||
var _a; | ||
pauseScheduling(); | ||
for (const effect2 of dep.keys()) { | ||
let tracking; | ||
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0); | ||
effect2._dirtyLevel = dirtyLevel; | ||
track(debugInfo) { | ||
if (!activeSub || !shouldTrack) { | ||
return; | ||
} | ||
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
let link = this.activeLink; | ||
if (link === void 0 || link.sub !== activeSub) { | ||
link = this.activeLink = { | ||
dep: this, | ||
sub: activeSub, | ||
version: this.version, | ||
nextDep: void 0, | ||
prevDep: void 0, | ||
nextSub: void 0, | ||
prevSub: void 0, | ||
prevActiveLink: void 0 | ||
}; | ||
if (!activeSub.deps) { | ||
activeSub.deps = activeSub.depsTail = link; | ||
} else { | ||
link.prevDep = activeSub.depsTail; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
} | ||
effect2.trigger(); | ||
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) { | ||
effect2._shouldSchedule = false; | ||
if (effect2.scheduler) { | ||
queueEffectSchedulers.push(effect2.scheduler); | ||
if (activeSub.flags & 4) { | ||
addSub(link); | ||
} | ||
} else if (link.version === -1) { | ||
link.version = this.version; | ||
if (link.nextDep) { | ||
const next = link.nextDep; | ||
next.prevDep = link.prevDep; | ||
if (link.prevDep) { | ||
link.prevDep.nextDep = next; | ||
} | ||
link.prevDep = activeSub.depsTail; | ||
link.nextDep = void 0; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
if (activeSub.deps === link) { | ||
activeSub.deps = next; | ||
} | ||
} | ||
} | ||
if (!!(process.env.NODE_ENV !== "production") && activeSub.onTrack) { | ||
activeSub.onTrack( | ||
extend( | ||
{ | ||
effect: activeSub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
return link; | ||
} | ||
resetScheduling(); | ||
trigger(debugInfo) { | ||
this.version++; | ||
globalVersion++; | ||
this.notify(debugInfo); | ||
} | ||
notify(debugInfo) { | ||
startBatch(); | ||
try { | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
for (let head = this.subsHead; head; head = head.nextSub) { | ||
if (!!(process.env.NODE_ENV !== "production") && head.sub.onTrigger && !(head.sub.flags & 8)) { | ||
head.sub.onTrigger( | ||
extend( | ||
{ | ||
effect: head.sub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
} | ||
} | ||
for (let link = this.subs; link; link = link.prevSub) { | ||
link.sub.notify(); | ||
} | ||
} finally { | ||
endBatch(); | ||
} | ||
} | ||
} | ||
const createDep = (cleanup, computed) => { | ||
const dep = /* @__PURE__ */ new Map(); | ||
dep.cleanup = cleanup; | ||
dep.computed = computed; | ||
return dep; | ||
}; | ||
function addSub(link) { | ||
const computed = link.dep.computed; | ||
if (computed && !link.dep.subs) { | ||
computed.flags |= 4 | 16; | ||
for (let l = computed.deps; l; l = l.nextDep) { | ||
addSub(l); | ||
} | ||
} | ||
const currentTail = link.dep.subs; | ||
if (currentTail !== link) { | ||
link.prevSub = currentTail; | ||
if (currentTail) | ||
currentTail.nextSub = link; | ||
} | ||
if (!!(process.env.NODE_ENV !== "production") && link.dep.subsHead === void 0) { | ||
link.dep.subsHead = link; | ||
} | ||
link.dep.subs = link; | ||
} | ||
const targetMap = /* @__PURE__ */ new WeakMap(); | ||
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : ""); | ||
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : ""); | ||
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : ""); | ||
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : ""); | ||
const ARRAY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Array iterate" : ""); | ||
function track(target, type, key) { | ||
if (shouldTrack && activeEffect) { | ||
if (shouldTrack && activeSub) { | ||
let depsMap = targetMap.get(target); | ||
@@ -334,13 +558,13 @@ if (!depsMap) { | ||
if (!dep) { | ||
depsMap.set(key, dep = createDep(() => depsMap.delete(key))); | ||
depsMap.set(key, dep = new Dep()); | ||
} | ||
trackEffect( | ||
activeEffect, | ||
dep, | ||
!!(process.env.NODE_ENV !== "production") ? { | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
dep.track({ | ||
target, | ||
type, | ||
key | ||
} : void 0 | ||
); | ||
}); | ||
} else { | ||
dep.track(); | ||
} | ||
} | ||
@@ -351,2 +575,3 @@ } | ||
if (!depsMap) { | ||
globalVersion++; | ||
return; | ||
@@ -357,57 +582,63 @@ } | ||
deps = [...depsMap.values()]; | ||
} else if (key === "length" && isArray(target)) { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} else { | ||
const targetIsArray = isArray(target); | ||
const isArrayIndex = targetIsArray && isIntegerKey(key); | ||
if (targetIsArray && key === "length") { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} | ||
}); | ||
} else { | ||
const push = (dep) => dep && deps.push(dep); | ||
if (key !== void 0) { | ||
push(depsMap.get(key)); | ||
} | ||
}); | ||
} else { | ||
if (key !== void 0) { | ||
deps.push(depsMap.get(key)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
if (isArrayIndex) { | ||
push(depsMap.get(ARRAY_ITERATE_KEY)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} else if (isArrayIndex) { | ||
push(depsMap.get("length")); | ||
} | ||
} else if (isIntegerKey(key)) { | ||
deps.push(depsMap.get("length")); | ||
} | ||
break; | ||
case "delete": | ||
if (!isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
break; | ||
case "delete": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
push(depsMap.get(ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
} | ||
break; | ||
break; | ||
} | ||
} | ||
} | ||
pauseScheduling(); | ||
startBatch(); | ||
for (const dep of deps) { | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
4, | ||
!!(process.env.NODE_ENV !== "production") ? { | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
} : void 0 | ||
); | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
dep.trigger({ | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
}); | ||
} else { | ||
dep.trigger(); | ||
} | ||
} | ||
resetScheduling(); | ||
endBatch(); | ||
} | ||
@@ -419,2 +650,174 @@ function getDepFromReactive(object, key) { | ||
function reactiveReadArray(array) { | ||
const raw = toRaw(array); | ||
if (raw === array) | ||
return raw; | ||
track(raw, "iterate", ARRAY_ITERATE_KEY); | ||
return isShallow(array) ? raw : raw.map(toReactive); | ||
} | ||
function shallowReadArray(arr) { | ||
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY); | ||
return arr; | ||
} | ||
const arrayInstrumentations = { | ||
__proto__: null, | ||
[Symbol.iterator]() { | ||
return iterator(this, Symbol.iterator, toReactive); | ||
}, | ||
concat(...args) { | ||
return reactiveReadArray(this).concat( | ||
...args.map((x) => reactiveReadArray(x)) | ||
); | ||
}, | ||
entries() { | ||
return iterator(this, "entries", (value) => { | ||
value[1] = toReactive(value[1]); | ||
return value; | ||
}); | ||
}, | ||
every(fn, thisArg) { | ||
return apply(this, "every", fn, thisArg); | ||
}, | ||
filter(fn, thisArg) { | ||
const result = apply(this, "filter", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result; | ||
}, | ||
find(fn, thisArg) { | ||
const result = apply(this, "find", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findIndex(fn, thisArg) { | ||
return apply(this, "findIndex", fn, thisArg); | ||
}, | ||
findLast(fn, thisArg) { | ||
const result = apply(this, "findLast", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findLastIndex(fn, thisArg) { | ||
return apply(this, "findLastIndex", fn, thisArg); | ||
}, | ||
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement | ||
forEach(fn, thisArg) { | ||
return apply(this, "forEach", fn, thisArg); | ||
}, | ||
includes(...args) { | ||
return searchProxy(this, "includes", args); | ||
}, | ||
indexOf(...args) { | ||
return searchProxy(this, "indexOf", args); | ||
}, | ||
join(separator) { | ||
return reactiveReadArray(this).join(separator); | ||
}, | ||
// keys() iterator only reads `length`, no optimisation required | ||
lastIndexOf(...args) { | ||
return searchProxy(this, "lastIndexOf", args); | ||
}, | ||
map(fn, thisArg) { | ||
return apply(this, "map", fn, thisArg); | ||
}, | ||
pop() { | ||
return noTracking(this, "pop"); | ||
}, | ||
push(...args) { | ||
return noTracking(this, "push", args); | ||
}, | ||
reduce(fn, ...args) { | ||
return reduce(this, "reduce", fn, args); | ||
}, | ||
reduceRight(fn, ...args) { | ||
return reduce(this, "reduceRight", fn, args); | ||
}, | ||
shift() { | ||
return noTracking(this, "shift"); | ||
}, | ||
// slice could use ARRAY_ITERATE but also seems to beg for range tracking | ||
some(fn, thisArg) { | ||
return apply(this, "some", fn, thisArg); | ||
}, | ||
splice(...args) { | ||
return noTracking(this, "splice", args); | ||
}, | ||
toReversed() { | ||
return reactiveReadArray(this).toReversed(); | ||
}, | ||
toSorted(comparer) { | ||
return reactiveReadArray(this).toSorted(comparer); | ||
}, | ||
toSpliced(...args) { | ||
return reactiveReadArray(this).toSpliced(...args); | ||
}, | ||
unshift(...args) { | ||
return noTracking(this, "unshift", args); | ||
}, | ||
values() { | ||
return iterator(this, "values", toReactive); | ||
} | ||
}; | ||
function iterator(self, method, wrapValue) { | ||
const arr = shallowReadArray(self); | ||
const iter = arr[method](); | ||
if (arr !== self && !isShallow(self)) { | ||
iter._next = iter.next; | ||
iter.next = () => { | ||
const result = iter._next(); | ||
if (result.value) { | ||
result.value = wrapValue(result.value); | ||
} | ||
return result; | ||
}; | ||
} | ||
return iter; | ||
} | ||
function apply(self, method, fn, thisArg) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 2) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, thisArg); | ||
} | ||
function reduce(self, method, fn, args) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 3) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, ...args); | ||
} | ||
function searchProxy(self, method, args) { | ||
const arr = toRaw(self); | ||
track(arr, "iterate", ARRAY_ITERATE_KEY); | ||
const res = arr[method](...args); | ||
if ((res === -1 || res === false) && isProxy(args[0])) { | ||
args[0] = toRaw(args[0]); | ||
return arr[method](...args); | ||
} | ||
return res; | ||
} | ||
function noTracking(self, method, args = []) { | ||
pauseTracking(); | ||
startBatch(); | ||
const res = toRaw(self)[method].apply(self, args); | ||
endBatch(); | ||
resetTracking(); | ||
return res; | ||
} | ||
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); | ||
@@ -424,31 +827,2 @@ const builtInSymbols = new Set( | ||
); | ||
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); | ||
function createArrayInstrumentations() { | ||
const instrumentations = {}; | ||
["includes", "indexOf", "lastIndexOf"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
const arr = toRaw(this); | ||
for (let i = 0, l = this.length; i < l; i++) { | ||
track(arr, "get", i + ""); | ||
} | ||
const res = arr[key](...args); | ||
if (res === -1 || res === false) { | ||
return arr[key](...args.map(toRaw)); | ||
} else { | ||
return res; | ||
} | ||
}; | ||
}); | ||
["push", "pop", "shift", "unshift", "splice"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
pauseTracking(); | ||
pauseScheduling(); | ||
const res = toRaw(this)[key].apply(this, args); | ||
resetScheduling(); | ||
resetTracking(); | ||
return res; | ||
}; | ||
}); | ||
return instrumentations; | ||
} | ||
function hasOwnProperty(key) { | ||
@@ -484,4 +858,5 @@ if (!isSymbol(key)) | ||
if (!isReadonly2) { | ||
if (targetIsArray && hasOwn(arrayInstrumentations, key)) { | ||
return Reflect.get(arrayInstrumentations, key, receiver); | ||
let fn; | ||
if (targetIsArray && (fn = arrayInstrumentations[key])) { | ||
return fn; | ||
} | ||
@@ -492,3 +867,10 @@ if (key === "hasOwnProperty") { | ||
} | ||
const res = Reflect.get(target, key, receiver); | ||
const res = Reflect.get( | ||
target, | ||
key, | ||
// if this is a proxy wrapping a ref, return methods using the raw ref | ||
// as receiver so that we don't have to call `toRaw` on the ref in all | ||
// its class methods | ||
isRef(target) ? target : receiver | ||
); | ||
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { | ||
@@ -992,106 +1374,4 @@ return res; | ||
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`; | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly, isSSR) { | ||
this.getter = getter; | ||
this._setter = _setter; | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
this["__v_isReadonly"] = false; | ||
this.effect = new ReactiveEffect( | ||
() => getter(this._value), | ||
() => triggerRefValue( | ||
this, | ||
this.effect._dirtyLevel === 2 ? 2 : 3 | ||
) | ||
); | ||
this.effect.computed = this; | ||
this.effect.active = this._cacheable = !isSSR; | ||
this["__v_isReadonly"] = isReadonly; | ||
} | ||
get value() { | ||
const self = toRaw(this); | ||
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) { | ||
triggerRefValue(self, 4); | ||
} | ||
trackRefValue(self); | ||
if (self.effect._dirtyLevel >= 2) { | ||
if (!!(process.env.NODE_ENV !== "production") && this._warnRecursive) { | ||
warn(COMPUTED_SIDE_EFFECT_WARN, ` | ||
getter: `, this.getter); | ||
} | ||
triggerRefValue(self, 2); | ||
} | ||
return self._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x | ||
get _dirty() { | ||
return this.effect.dirty; | ||
} | ||
set _dirty(v) { | ||
this.effect.dirty = v; | ||
} | ||
// #endregion | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
const onlyGetter = isFunction(getterOrOptions); | ||
if (onlyGetter) { | ||
getter = getterOrOptions; | ||
setter = !!(process.env.NODE_ENV !== "production") ? () => { | ||
warn("Write operation failed: computed value is readonly"); | ||
} : NOOP; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR); | ||
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) { | ||
cRef.effect.onTrack = debugOptions.onTrack; | ||
cRef.effect.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
function trackRefValue(ref2) { | ||
var _a; | ||
if (shouldTrack && activeEffect) { | ||
ref2 = toRaw(ref2); | ||
trackEffect( | ||
activeEffect, | ||
(_a = ref2.dep) != null ? _a : ref2.dep = createDep( | ||
() => ref2.dep = void 0, | ||
ref2 instanceof ComputedRefImpl ? ref2 : void 0 | ||
), | ||
!!(process.env.NODE_ENV !== "production") ? { | ||
target: ref2, | ||
type: "get", | ||
key: "value" | ||
} : void 0 | ||
); | ||
} | ||
} | ||
function triggerRefValue(ref2, dirtyLevel = 4, newVal) { | ||
ref2 = toRaw(ref2); | ||
const dep = ref2.dep; | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
dirtyLevel, | ||
!!(process.env.NODE_ENV !== "production") ? { | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: newVal | ||
} : void 0 | ||
); | ||
} | ||
} | ||
function isRef(r) { | ||
return !!(r && r.__v_isRef === true); | ||
return r ? r.__v_isRef === true : false; | ||
} | ||
@@ -1113,3 +1393,3 @@ function ref(value) { | ||
this.__v_isShallow = __v_isShallow; | ||
this.dep = void 0; | ||
this.dep = new Dep(); | ||
this.__v_isRef = true; | ||
@@ -1120,12 +1400,31 @@ this._rawValue = __v_isShallow ? value : toRaw(value); | ||
get value() { | ||
trackRefValue(this); | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}); | ||
} else { | ||
this.dep.track(); | ||
} | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal); | ||
newVal = useDirectValue ? newVal : toRaw(newVal); | ||
if (hasChanged(newVal, this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = useDirectValue ? newVal : toReactive(newVal); | ||
triggerRefValue(this, 4, newVal); | ||
set value(newValue) { | ||
const oldValue = this._rawValue; | ||
const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue); | ||
newValue = useDirectValue ? newValue : toRaw(newValue); | ||
if (hasChanged(newValue, oldValue)) { | ||
this._rawValue = newValue; | ||
this._value = useDirectValue ? newValue : toReactive(newValue); | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
this.dep.trigger({ | ||
target: this, | ||
type: "set", | ||
key: "value", | ||
newValue, | ||
oldValue | ||
}); | ||
} else { | ||
this.dep.trigger(); | ||
} | ||
} | ||
@@ -1135,3 +1434,12 @@ } | ||
function triggerRef(ref2) { | ||
triggerRefValue(ref2, 4, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0); | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
ref2.dep.trigger({ | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: ref2._value | ||
}); | ||
} else { | ||
ref2.dep.trigger(); | ||
} | ||
} | ||
@@ -1161,8 +1469,5 @@ function unref(ref2) { | ||
constructor(factory) { | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
const { get, set } = factory( | ||
() => trackRefValue(this), | ||
() => triggerRefValue(this) | ||
); | ||
const dep = this.dep = new Dep(); | ||
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep)); | ||
this._get = get; | ||
@@ -1235,3 +1540,85 @@ this._set = set; | ||
const deferredComputed = computed; | ||
class ComputedRefImpl { | ||
constructor(fn, setter, isSSR) { | ||
this.fn = fn; | ||
this.setter = setter; | ||
/** | ||
* @internal | ||
*/ | ||
this._value = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.dep = new Dep(this); | ||
/** | ||
* @internal | ||
*/ | ||
this.__v_isRef = true; | ||
// A computed is also a subscriber that tracks other deps | ||
/** | ||
* @internal | ||
*/ | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.flags = 16; | ||
/** | ||
* @internal | ||
*/ | ||
this.globalVersion = globalVersion - 1; | ||
// for backwards compat | ||
this.effect = this; | ||
this.__v_isReadonly = !setter; | ||
this.isSSR = isSSR; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (activeSub !== this) { | ||
this.flags |= 16; | ||
this.dep.notify(); | ||
} else if (!!(process.env.NODE_ENV !== "production")) ; | ||
} | ||
get value() { | ||
const link = !!(process.env.NODE_ENV !== "production") ? this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}) : this.dep.track(); | ||
refreshComputed(this); | ||
if (link) { | ||
link.version = this.dep.version; | ||
} | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
if (this.setter) { | ||
this.setter(newValue); | ||
} else if (!!(process.env.NODE_ENV !== "production")) { | ||
warn("Write operation failed: computed value is readonly"); | ||
} | ||
} | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
if (isFunction(getterOrOptions)) { | ||
getter = getterOrOptions; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, isSSR); | ||
if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) { | ||
cRef.onTrack = debugOptions.onTrack; | ||
cRef.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
@@ -1257,2 +1644,2 @@ const TrackOpTypes = { | ||
export { EffectScope, ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, pauseScheduling, pauseTracking, proxyRefs, reactive, readonly, ref, resetScheduling, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, track, trigger, triggerRef, unref }; | ||
export { ARRAY_ITERATE_KEY, EffectFlags, EffectScope, ITERATE_KEY, MAP_KEY_ITERATE_KEY, ReactiveEffect, ReactiveFlags, TrackOpTypes, TriggerOpTypes, computed, customRef, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onEffectCleanup, onScopeDispose, pauseTracking, proxyRefs, reactive, reactiveReadArray, readonly, ref, resetTracking, shallowReactive, shallowReadArray, shallowReadonly, shallowRef, stop, toRaw, toReactive, toReadonly, toRef, toRefs, toValue, track, trigger, triggerRef, unref }; |
/** | ||
* @vue/reactivity v3.4.25 | ||
* @vue/reactivity v3.5.0-alpha.1 | ||
* (c) 2018-present Yuxi (Evan) You and Vue contributors | ||
@@ -16,4 +16,2 @@ * @license MIT | ||
const NOOP = () => { | ||
}; | ||
const extend = Object.assign; | ||
@@ -139,14 +137,9 @@ const hasOwnProperty$1 = Object.prototype.hasOwnProperty; | ||
} | ||
function recordEffectScope(effect, scope = activeEffectScope) { | ||
if (scope && scope.active) { | ||
scope.effects.push(effect); | ||
} | ||
} | ||
function getCurrentScope() { | ||
return activeEffectScope; | ||
} | ||
function onScopeDispose(fn) { | ||
function onScopeDispose(fn, failSilently = false) { | ||
if (activeEffectScope) { | ||
activeEffectScope.cleanups.push(fn); | ||
} else { | ||
} else if (!failSilently) { | ||
warn( | ||
@@ -158,109 +151,257 @@ `onScopeDispose() is called when there is no active effect scope to be associated with.` | ||
let activeEffect; | ||
let activeSub; | ||
const EffectFlags = { | ||
"ACTIVE": 1, | ||
"1": "ACTIVE", | ||
"RUNNING": 2, | ||
"2": "RUNNING", | ||
"TRACKING": 4, | ||
"4": "TRACKING", | ||
"NOTIFIED": 8, | ||
"8": "NOTIFIED", | ||
"DIRTY": 16, | ||
"16": "DIRTY", | ||
"ALLOW_RECURSE": 32, | ||
"32": "ALLOW_RECURSE", | ||
"NO_BATCH": 64, | ||
"64": "NO_BATCH" | ||
}; | ||
class ReactiveEffect { | ||
constructor(fn, trigger, scheduler, scope) { | ||
constructor(fn) { | ||
this.fn = fn; | ||
this.trigger = trigger; | ||
this.scheduler = scheduler; | ||
this.active = true; | ||
this.deps = []; | ||
/** | ||
* @internal | ||
*/ | ||
this._dirtyLevel = 4; | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._trackId = 0; | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._runnings = 0; | ||
this.flags = 1 | 4; | ||
/** | ||
* @internal | ||
*/ | ||
this._shouldSchedule = false; | ||
this.nextEffect = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this._depsLength = 0; | ||
recordEffectScope(this, scope); | ||
this.cleanup = void 0; | ||
this.scheduler = void 0; | ||
if (activeEffectScope && activeEffectScope.active) { | ||
activeEffectScope.effects.push(this); | ||
} | ||
} | ||
get dirty() { | ||
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) { | ||
this._dirtyLevel = 1; | ||
pauseTracking(); | ||
for (let i = 0; i < this._depsLength; i++) { | ||
const dep = this.deps[i]; | ||
if (dep.computed) { | ||
triggerComputed(dep.computed); | ||
if (this._dirtyLevel >= 4) { | ||
break; | ||
} | ||
} | ||
} | ||
if (this._dirtyLevel === 1) { | ||
this._dirtyLevel = 0; | ||
} | ||
resetTracking(); | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (this.flags & 2 && !(this.flags & 32)) { | ||
return; | ||
} | ||
return this._dirtyLevel >= 4; | ||
if (this.flags & 64) { | ||
return this.trigger(); | ||
} | ||
if (!(this.flags & 8)) { | ||
this.flags |= 8; | ||
this.nextEffect = batchedEffect; | ||
batchedEffect = this; | ||
} | ||
} | ||
set dirty(v) { | ||
this._dirtyLevel = v ? 4 : 0; | ||
} | ||
run() { | ||
this._dirtyLevel = 0; | ||
if (!this.active) { | ||
if (!(this.flags & 1)) { | ||
return this.fn(); | ||
} | ||
let lastShouldTrack = shouldTrack; | ||
let lastEffect = activeEffect; | ||
this.flags |= 2; | ||
cleanupEffect(this); | ||
prepareDeps(this); | ||
const prevEffect = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = this; | ||
shouldTrack = true; | ||
try { | ||
shouldTrack = true; | ||
activeEffect = this; | ||
this._runnings++; | ||
preCleanupEffect(this); | ||
return this.fn(); | ||
} finally { | ||
postCleanupEffect(this); | ||
this._runnings--; | ||
activeEffect = lastEffect; | ||
shouldTrack = lastShouldTrack; | ||
if (activeSub !== this) { | ||
warn( | ||
"Active effect was not restored correctly - this is likely a Vue internal bug." | ||
); | ||
} | ||
cleanupDeps(this); | ||
activeSub = prevEffect; | ||
shouldTrack = prevShouldTrack; | ||
this.flags &= ~2; | ||
} | ||
} | ||
stop() { | ||
var _a; | ||
if (this.active) { | ||
preCleanupEffect(this); | ||
postCleanupEffect(this); | ||
(_a = this.onStop) == null ? void 0 : _a.call(this); | ||
this.active = false; | ||
if (this.flags & 1) { | ||
for (let link = this.deps; link; link = link.nextDep) { | ||
removeSub(link); | ||
} | ||
this.deps = this.depsTail = void 0; | ||
cleanupEffect(this); | ||
this.onStop && this.onStop(); | ||
this.flags &= ~1; | ||
} | ||
} | ||
trigger() { | ||
if (this.scheduler) { | ||
this.scheduler(); | ||
} else { | ||
this.runIfDirty(); | ||
} | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
runIfDirty() { | ||
if (isDirty(this)) { | ||
this.run(); | ||
} | ||
} | ||
get dirty() { | ||
return isDirty(this); | ||
} | ||
} | ||
function triggerComputed(computed) { | ||
return computed.value; | ||
let batchDepth = 0; | ||
let batchedEffect; | ||
function startBatch() { | ||
batchDepth++; | ||
} | ||
function preCleanupEffect(effect2) { | ||
effect2._trackId++; | ||
effect2._depsLength = 0; | ||
function endBatch() { | ||
if (batchDepth > 1) { | ||
batchDepth--; | ||
return; | ||
} | ||
let error; | ||
while (batchedEffect) { | ||
let e = batchedEffect; | ||
batchedEffect = void 0; | ||
while (e) { | ||
const next = e.nextEffect; | ||
e.nextEffect = void 0; | ||
e.flags &= ~8; | ||
if (e.flags & 1) { | ||
try { | ||
e.trigger(); | ||
} catch (err) { | ||
if (!error) | ||
error = err; | ||
} | ||
} | ||
e = next; | ||
} | ||
} | ||
batchDepth--; | ||
if (error) | ||
throw error; | ||
} | ||
function postCleanupEffect(effect2) { | ||
if (effect2.deps.length > effect2._depsLength) { | ||
for (let i = effect2._depsLength; i < effect2.deps.length; i++) { | ||
cleanupDepEffect(effect2.deps[i], effect2); | ||
function prepareDeps(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
link.version = -1; | ||
link.prevActiveLink = link.dep.activeLink; | ||
link.dep.activeLink = link; | ||
} | ||
} | ||
function cleanupDeps(sub) { | ||
let head; | ||
let tail = sub.depsTail; | ||
for (let link = tail; link; link = link.prevDep) { | ||
if (link.version === -1) { | ||
if (link === tail) | ||
tail = link.prevDep; | ||
removeSub(link); | ||
removeDep(link); | ||
} else { | ||
head = link; | ||
} | ||
effect2.deps.length = effect2._depsLength; | ||
link.dep.activeLink = link.prevActiveLink; | ||
link.prevActiveLink = void 0; | ||
} | ||
sub.deps = head; | ||
sub.depsTail = tail; | ||
} | ||
function cleanupDepEffect(dep, effect2) { | ||
const trackId = dep.get(effect2); | ||
if (trackId !== void 0 && effect2._trackId !== trackId) { | ||
dep.delete(effect2); | ||
if (dep.size === 0) { | ||
dep.cleanup(); | ||
function isDirty(sub) { | ||
for (let link = sub.deps; link; link = link.nextDep) { | ||
if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) { | ||
return true; | ||
} | ||
} | ||
if (sub._dirty) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function refreshComputed(computed) { | ||
if (computed.flags & 2) { | ||
return false; | ||
} | ||
if (computed.flags & 4 && !(computed.flags & 16)) { | ||
return; | ||
} | ||
computed.flags &= ~16; | ||
if (computed.globalVersion === globalVersion) { | ||
return; | ||
} | ||
computed.globalVersion = globalVersion; | ||
const dep = computed.dep; | ||
computed.flags |= 2; | ||
if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) { | ||
computed.flags &= ~2; | ||
return; | ||
} | ||
const prevSub = activeSub; | ||
const prevShouldTrack = shouldTrack; | ||
activeSub = computed; | ||
shouldTrack = true; | ||
try { | ||
prepareDeps(computed); | ||
const value = computed.fn(); | ||
if (dep.version === 0 || hasChanged(value, computed._value)) { | ||
computed._value = value; | ||
dep.version++; | ||
} | ||
} catch (err) { | ||
dep.version++; | ||
throw err; | ||
} finally { | ||
activeSub = prevSub; | ||
shouldTrack = prevShouldTrack; | ||
cleanupDeps(computed); | ||
computed.flags &= ~2; | ||
} | ||
} | ||
function removeSub(link) { | ||
const { dep, prevSub, nextSub } = link; | ||
if (prevSub) { | ||
prevSub.nextSub = nextSub; | ||
link.prevSub = void 0; | ||
} | ||
if (nextSub) { | ||
nextSub.prevSub = prevSub; | ||
link.nextSub = void 0; | ||
} | ||
if (dep.subs === link) { | ||
dep.subs = prevSub; | ||
} | ||
if (!dep.subs && dep.computed) { | ||
dep.computed.flags &= ~4; | ||
for (let l = dep.computed.deps; l; l = l.nextDep) { | ||
removeSub(l); | ||
} | ||
} | ||
} | ||
function removeDep(link) { | ||
const { prevDep, nextDep } = link; | ||
if (prevDep) { | ||
prevDep.nextDep = nextDep; | ||
link.prevDep = void 0; | ||
} | ||
if (nextDep) { | ||
nextDep.prevDep = prevDep; | ||
link.nextDep = void 0; | ||
} | ||
} | ||
function effect(fn, options) { | ||
@@ -270,17 +411,14 @@ if (fn.effect instanceof ReactiveEffect) { | ||
} | ||
const _effect = new ReactiveEffect(fn, NOOP, () => { | ||
if (_effect.dirty) { | ||
_effect.run(); | ||
} | ||
}); | ||
const e = new ReactiveEffect(fn); | ||
if (options) { | ||
extend(_effect, options); | ||
if (options.scope) | ||
recordEffectScope(_effect, options.scope); | ||
extend(e, options); | ||
} | ||
if (!options || !options.lazy) { | ||
_effect.run(); | ||
try { | ||
e.run(); | ||
} catch (err) { | ||
e.stop(); | ||
throw err; | ||
} | ||
const runner = _effect.run.bind(_effect); | ||
runner.effect = _effect; | ||
const runner = e.run.bind(e); | ||
runner.effect = e; | ||
return runner; | ||
@@ -292,3 +430,2 @@ } | ||
let shouldTrack = true; | ||
let pauseScheduleStack = 0; | ||
const trackStack = []; | ||
@@ -307,67 +444,152 @@ function pauseTracking() { | ||
} | ||
function pauseScheduling() { | ||
pauseScheduleStack++; | ||
function onEffectCleanup(fn, failSilently = false) { | ||
if (activeSub instanceof ReactiveEffect) { | ||
activeSub.cleanup = fn; | ||
} else if (!failSilently) { | ||
warn( | ||
`onEffectCleanup() was called when there was no active effect to associate with.` | ||
); | ||
} | ||
} | ||
function resetScheduling() { | ||
pauseScheduleStack--; | ||
while (!pauseScheduleStack && queueEffectSchedulers.length) { | ||
queueEffectSchedulers.shift()(); | ||
function cleanupEffect(e) { | ||
const { cleanup } = e; | ||
e.cleanup = void 0; | ||
if (cleanup) { | ||
const prevSub = activeSub; | ||
activeSub = void 0; | ||
try { | ||
cleanup(); | ||
} finally { | ||
activeSub = prevSub; | ||
} | ||
} | ||
} | ||
function trackEffect(effect2, dep, debuggerEventExtraInfo) { | ||
var _a; | ||
if (dep.get(effect2) !== effect2._trackId) { | ||
dep.set(effect2, effect2._trackId); | ||
const oldDep = effect2.deps[effect2._depsLength]; | ||
if (oldDep !== dep) { | ||
if (oldDep) { | ||
cleanupDepEffect(oldDep, effect2); | ||
} | ||
effect2.deps[effect2._depsLength++] = dep; | ||
} else { | ||
effect2._depsLength++; | ||
} | ||
let globalVersion = 0; | ||
class Dep { | ||
constructor(computed) { | ||
this.computed = computed; | ||
this.version = 0; | ||
/** | ||
* Link between this dep and the current active effect | ||
*/ | ||
this.activeLink = void 0; | ||
/** | ||
* Doubly linked list representing the subscribing effects (tail) | ||
*/ | ||
this.subs = void 0; | ||
{ | ||
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
this.subsHead = void 0; | ||
} | ||
} | ||
} | ||
const queueEffectSchedulers = []; | ||
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) { | ||
var _a; | ||
pauseScheduling(); | ||
for (const effect2 of dep.keys()) { | ||
let tracking; | ||
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0); | ||
effect2._dirtyLevel = dirtyLevel; | ||
track(debugInfo) { | ||
if (!activeSub || !shouldTrack) { | ||
return; | ||
} | ||
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { | ||
{ | ||
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); | ||
let link = this.activeLink; | ||
if (link === void 0 || link.sub !== activeSub) { | ||
link = this.activeLink = { | ||
dep: this, | ||
sub: activeSub, | ||
version: this.version, | ||
nextDep: void 0, | ||
prevDep: void 0, | ||
nextSub: void 0, | ||
prevSub: void 0, | ||
prevActiveLink: void 0 | ||
}; | ||
if (!activeSub.deps) { | ||
activeSub.deps = activeSub.depsTail = link; | ||
} else { | ||
link.prevDep = activeSub.depsTail; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
} | ||
effect2.trigger(); | ||
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) { | ||
effect2._shouldSchedule = false; | ||
if (effect2.scheduler) { | ||
queueEffectSchedulers.push(effect2.scheduler); | ||
if (activeSub.flags & 4) { | ||
addSub(link); | ||
} | ||
} else if (link.version === -1) { | ||
link.version = this.version; | ||
if (link.nextDep) { | ||
const next = link.nextDep; | ||
next.prevDep = link.prevDep; | ||
if (link.prevDep) { | ||
link.prevDep.nextDep = next; | ||
} | ||
link.prevDep = activeSub.depsTail; | ||
link.nextDep = void 0; | ||
activeSub.depsTail.nextDep = link; | ||
activeSub.depsTail = link; | ||
if (activeSub.deps === link) { | ||
activeSub.deps = next; | ||
} | ||
} | ||
} | ||
if (activeSub.onTrack) { | ||
activeSub.onTrack( | ||
extend( | ||
{ | ||
effect: activeSub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
return link; | ||
} | ||
resetScheduling(); | ||
trigger(debugInfo) { | ||
this.version++; | ||
globalVersion++; | ||
this.notify(debugInfo); | ||
} | ||
notify(debugInfo) { | ||
startBatch(); | ||
try { | ||
if (true) { | ||
for (let head = this.subsHead; head; head = head.nextSub) { | ||
if (head.sub.onTrigger && !(head.sub.flags & 8)) { | ||
head.sub.onTrigger( | ||
extend( | ||
{ | ||
effect: head.sub | ||
}, | ||
debugInfo | ||
) | ||
); | ||
} | ||
} | ||
} | ||
for (let link = this.subs; link; link = link.prevSub) { | ||
link.sub.notify(); | ||
} | ||
} finally { | ||
endBatch(); | ||
} | ||
} | ||
} | ||
const createDep = (cleanup, computed) => { | ||
const dep = /* @__PURE__ */ new Map(); | ||
dep.cleanup = cleanup; | ||
dep.computed = computed; | ||
return dep; | ||
}; | ||
function addSub(link) { | ||
const computed = link.dep.computed; | ||
if (computed && !link.dep.subs) { | ||
computed.flags |= 4 | 16; | ||
for (let l = computed.deps; l; l = l.nextDep) { | ||
addSub(l); | ||
} | ||
} | ||
const currentTail = link.dep.subs; | ||
if (currentTail !== link) { | ||
link.prevSub = currentTail; | ||
if (currentTail) | ||
currentTail.nextSub = link; | ||
} | ||
if (link.dep.subsHead === void 0) { | ||
link.dep.subsHead = link; | ||
} | ||
link.dep.subs = link; | ||
} | ||
const targetMap = /* @__PURE__ */ new WeakMap(); | ||
const ITERATE_KEY = Symbol("iterate" ); | ||
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" ); | ||
const ITERATE_KEY = Symbol("Object iterate" ); | ||
const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" ); | ||
const ARRAY_ITERATE_KEY = Symbol("Array iterate" ); | ||
function track(target, type, key) { | ||
if (shouldTrack && activeEffect) { | ||
if (shouldTrack && activeSub) { | ||
let depsMap = targetMap.get(target); | ||
@@ -379,13 +601,11 @@ if (!depsMap) { | ||
if (!dep) { | ||
depsMap.set(key, dep = createDep(() => depsMap.delete(key))); | ||
depsMap.set(key, dep = new Dep()); | ||
} | ||
trackEffect( | ||
activeEffect, | ||
dep, | ||
{ | ||
{ | ||
dep.track({ | ||
target, | ||
type, | ||
key | ||
} | ||
); | ||
}); | ||
} | ||
} | ||
@@ -396,2 +616,3 @@ } | ||
if (!depsMap) { | ||
globalVersion++; | ||
return; | ||
@@ -402,57 +623,61 @@ } | ||
deps = [...depsMap.values()]; | ||
} else if (key === "length" && isArray(target)) { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} else { | ||
const targetIsArray = isArray(target); | ||
const isArrayIndex = targetIsArray && isIntegerKey(key); | ||
if (targetIsArray && key === "length") { | ||
const newLength = Number(newValue); | ||
depsMap.forEach((dep, key2) => { | ||
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) { | ||
deps.push(dep); | ||
} | ||
}); | ||
} else { | ||
const push = (dep) => dep && deps.push(dep); | ||
if (key !== void 0) { | ||
push(depsMap.get(key)); | ||
} | ||
}); | ||
} else { | ||
if (key !== void 0) { | ||
deps.push(depsMap.get(key)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
if (isArrayIndex) { | ||
push(depsMap.get(ARRAY_ITERATE_KEY)); | ||
} | ||
switch (type) { | ||
case "add": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} else if (isArrayIndex) { | ||
push(depsMap.get("length")); | ||
} | ||
} else if (isIntegerKey(key)) { | ||
deps.push(depsMap.get("length")); | ||
} | ||
break; | ||
case "delete": | ||
if (!isArray(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
break; | ||
case "delete": | ||
if (!targetIsArray) { | ||
push(depsMap.get(ITERATE_KEY)); | ||
if (isMap(target)) { | ||
push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); | ||
push(depsMap.get(ITERATE_KEY)); | ||
} | ||
} | ||
break; | ||
case "set": | ||
if (isMap(target)) { | ||
deps.push(depsMap.get(ITERATE_KEY)); | ||
} | ||
break; | ||
break; | ||
} | ||
} | ||
} | ||
pauseScheduling(); | ||
startBatch(); | ||
for (const dep of deps) { | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
4, | ||
{ | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
} | ||
); | ||
{ | ||
dep.trigger({ | ||
target, | ||
type, | ||
key, | ||
newValue, | ||
oldValue, | ||
oldTarget | ||
}); | ||
} | ||
} | ||
resetScheduling(); | ||
endBatch(); | ||
} | ||
@@ -464,2 +689,174 @@ function getDepFromReactive(object, key) { | ||
function reactiveReadArray(array) { | ||
const raw = toRaw(array); | ||
if (raw === array) | ||
return raw; | ||
track(raw, "iterate", ARRAY_ITERATE_KEY); | ||
return isShallow(array) ? raw : raw.map(toReactive); | ||
} | ||
function shallowReadArray(arr) { | ||
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY); | ||
return arr; | ||
} | ||
const arrayInstrumentations = { | ||
__proto__: null, | ||
[Symbol.iterator]() { | ||
return iterator(this, Symbol.iterator, toReactive); | ||
}, | ||
concat(...args) { | ||
return reactiveReadArray(this).concat( | ||
...args.map((x) => reactiveReadArray(x)) | ||
); | ||
}, | ||
entries() { | ||
return iterator(this, "entries", (value) => { | ||
value[1] = toReactive(value[1]); | ||
return value; | ||
}); | ||
}, | ||
every(fn, thisArg) { | ||
return apply(this, "every", fn, thisArg); | ||
}, | ||
filter(fn, thisArg) { | ||
const result = apply(this, "filter", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result; | ||
}, | ||
find(fn, thisArg) { | ||
const result = apply(this, "find", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findIndex(fn, thisArg) { | ||
return apply(this, "findIndex", fn, thisArg); | ||
}, | ||
findLast(fn, thisArg) { | ||
const result = apply(this, "findLast", fn, thisArg); | ||
return isProxy(this) && !isShallow(this) ? toReactive(result) : result; | ||
}, | ||
findLastIndex(fn, thisArg) { | ||
return apply(this, "findLastIndex", fn, thisArg); | ||
}, | ||
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement | ||
forEach(fn, thisArg) { | ||
return apply(this, "forEach", fn, thisArg); | ||
}, | ||
includes(...args) { | ||
return searchProxy(this, "includes", args); | ||
}, | ||
indexOf(...args) { | ||
return searchProxy(this, "indexOf", args); | ||
}, | ||
join(separator) { | ||
return reactiveReadArray(this).join(separator); | ||
}, | ||
// keys() iterator only reads `length`, no optimisation required | ||
lastIndexOf(...args) { | ||
return searchProxy(this, "lastIndexOf", args); | ||
}, | ||
map(fn, thisArg) { | ||
return apply(this, "map", fn, thisArg); | ||
}, | ||
pop() { | ||
return noTracking(this, "pop"); | ||
}, | ||
push(...args) { | ||
return noTracking(this, "push", args); | ||
}, | ||
reduce(fn, ...args) { | ||
return reduce(this, "reduce", fn, args); | ||
}, | ||
reduceRight(fn, ...args) { | ||
return reduce(this, "reduceRight", fn, args); | ||
}, | ||
shift() { | ||
return noTracking(this, "shift"); | ||
}, | ||
// slice could use ARRAY_ITERATE but also seems to beg for range tracking | ||
some(fn, thisArg) { | ||
return apply(this, "some", fn, thisArg); | ||
}, | ||
splice(...args) { | ||
return noTracking(this, "splice", args); | ||
}, | ||
toReversed() { | ||
return reactiveReadArray(this).toReversed(); | ||
}, | ||
toSorted(comparer) { | ||
return reactiveReadArray(this).toSorted(comparer); | ||
}, | ||
toSpliced(...args) { | ||
return reactiveReadArray(this).toSpliced(...args); | ||
}, | ||
unshift(...args) { | ||
return noTracking(this, "unshift", args); | ||
}, | ||
values() { | ||
return iterator(this, "values", toReactive); | ||
} | ||
}; | ||
function iterator(self, method, wrapValue) { | ||
const arr = shallowReadArray(self); | ||
const iter = arr[method](); | ||
if (arr !== self && !isShallow(self)) { | ||
iter._next = iter.next; | ||
iter.next = () => { | ||
const result = iter._next(); | ||
if (result.value) { | ||
result.value = wrapValue(result.value); | ||
} | ||
return result; | ||
}; | ||
} | ||
return iter; | ||
} | ||
function apply(self, method, fn, thisArg) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 2) { | ||
wrappedFn = function(item, index) { | ||
return fn.call(this, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, thisArg); | ||
} | ||
function reduce(self, method, fn, args) { | ||
const arr = shallowReadArray(self); | ||
let wrappedFn = fn; | ||
if (arr !== self) { | ||
if (!isShallow(self)) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, toReactive(item), index, self); | ||
}; | ||
} else if (fn.length > 3) { | ||
wrappedFn = function(acc, item, index) { | ||
return fn.call(this, acc, item, index, self); | ||
}; | ||
} | ||
} | ||
return arr[method](wrappedFn, ...args); | ||
} | ||
function searchProxy(self, method, args) { | ||
const arr = toRaw(self); | ||
track(arr, "iterate", ARRAY_ITERATE_KEY); | ||
const res = arr[method](...args); | ||
if ((res === -1 || res === false) && isProxy(args[0])) { | ||
args[0] = toRaw(args[0]); | ||
return arr[method](...args); | ||
} | ||
return res; | ||
} | ||
function noTracking(self, method, args = []) { | ||
pauseTracking(); | ||
startBatch(); | ||
const res = toRaw(self)[method].apply(self, args); | ||
endBatch(); | ||
resetTracking(); | ||
return res; | ||
} | ||
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); | ||
@@ -469,31 +866,2 @@ const builtInSymbols = new Set( | ||
); | ||
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); | ||
function createArrayInstrumentations() { | ||
const instrumentations = {}; | ||
["includes", "indexOf", "lastIndexOf"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
const arr = toRaw(this); | ||
for (let i = 0, l = this.length; i < l; i++) { | ||
track(arr, "get", i + ""); | ||
} | ||
const res = arr[key](...args); | ||
if (res === -1 || res === false) { | ||
return arr[key](...args.map(toRaw)); | ||
} else { | ||
return res; | ||
} | ||
}; | ||
}); | ||
["push", "pop", "shift", "unshift", "splice"].forEach((key) => { | ||
instrumentations[key] = function(...args) { | ||
pauseTracking(); | ||
pauseScheduling(); | ||
const res = toRaw(this)[key].apply(this, args); | ||
resetScheduling(); | ||
resetTracking(); | ||
return res; | ||
}; | ||
}); | ||
return instrumentations; | ||
} | ||
function hasOwnProperty(key) { | ||
@@ -529,4 +897,5 @@ if (!isSymbol(key)) | ||
if (!isReadonly2) { | ||
if (targetIsArray && hasOwn(arrayInstrumentations, key)) { | ||
return Reflect.get(arrayInstrumentations, key, receiver); | ||
let fn; | ||
if (targetIsArray && (fn = arrayInstrumentations[key])) { | ||
return fn; | ||
} | ||
@@ -537,3 +906,10 @@ if (key === "hasOwnProperty") { | ||
} | ||
const res = Reflect.get(target, key, receiver); | ||
const res = Reflect.get( | ||
target, | ||
key, | ||
// if this is a proxy wrapping a ref, return methods using the raw ref | ||
// as receiver so that we don't have to call `toRaw` on the ref in all | ||
// its class methods | ||
isRef(target) ? target : receiver | ||
); | ||
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { | ||
@@ -1037,106 +1413,4 @@ return res; | ||
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`; | ||
class ComputedRefImpl { | ||
constructor(getter, _setter, isReadonly, isSSR) { | ||
this.getter = getter; | ||
this._setter = _setter; | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
this["__v_isReadonly"] = false; | ||
this.effect = new ReactiveEffect( | ||
() => getter(this._value), | ||
() => triggerRefValue( | ||
this, | ||
this.effect._dirtyLevel === 2 ? 2 : 3 | ||
) | ||
); | ||
this.effect.computed = this; | ||
this.effect.active = this._cacheable = !isSSR; | ||
this["__v_isReadonly"] = isReadonly; | ||
} | ||
get value() { | ||
const self = toRaw(this); | ||
if ((!self._cacheable || self.effect.dirty) && hasChanged(self._value, self._value = self.effect.run())) { | ||
triggerRefValue(self, 4); | ||
} | ||
trackRefValue(self); | ||
if (self.effect._dirtyLevel >= 2) { | ||
if (this._warnRecursive) { | ||
warn(COMPUTED_SIDE_EFFECT_WARN, ` | ||
getter: `, this.getter); | ||
} | ||
triggerRefValue(self, 2); | ||
} | ||
return self._value; | ||
} | ||
set value(newValue) { | ||
this._setter(newValue); | ||
} | ||
// #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x | ||
get _dirty() { | ||
return this.effect.dirty; | ||
} | ||
set _dirty(v) { | ||
this.effect.dirty = v; | ||
} | ||
// #endregion | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
const onlyGetter = isFunction(getterOrOptions); | ||
if (onlyGetter) { | ||
getter = getterOrOptions; | ||
setter = () => { | ||
warn("Write operation failed: computed value is readonly"); | ||
} ; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR); | ||
if (debugOptions && !isSSR) { | ||
cRef.effect.onTrack = debugOptions.onTrack; | ||
cRef.effect.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
function trackRefValue(ref2) { | ||
var _a; | ||
if (shouldTrack && activeEffect) { | ||
ref2 = toRaw(ref2); | ||
trackEffect( | ||
activeEffect, | ||
(_a = ref2.dep) != null ? _a : ref2.dep = createDep( | ||
() => ref2.dep = void 0, | ||
ref2 instanceof ComputedRefImpl ? ref2 : void 0 | ||
), | ||
{ | ||
target: ref2, | ||
type: "get", | ||
key: "value" | ||
} | ||
); | ||
} | ||
} | ||
function triggerRefValue(ref2, dirtyLevel = 4, newVal) { | ||
ref2 = toRaw(ref2); | ||
const dep = ref2.dep; | ||
if (dep) { | ||
triggerEffects( | ||
dep, | ||
dirtyLevel, | ||
{ | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: newVal | ||
} | ||
); | ||
} | ||
} | ||
function isRef(r) { | ||
return !!(r && r.__v_isRef === true); | ||
return r ? r.__v_isRef === true : false; | ||
} | ||
@@ -1158,3 +1432,3 @@ function ref(value) { | ||
this.__v_isShallow = __v_isShallow; | ||
this.dep = void 0; | ||
this.dep = new Dep(); | ||
this.__v_isRef = true; | ||
@@ -1165,12 +1439,27 @@ this._rawValue = __v_isShallow ? value : toRaw(value); | ||
get value() { | ||
trackRefValue(this); | ||
{ | ||
this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}); | ||
} | ||
return this._value; | ||
} | ||
set value(newVal) { | ||
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal); | ||
newVal = useDirectValue ? newVal : toRaw(newVal); | ||
if (hasChanged(newVal, this._rawValue)) { | ||
this._rawValue = newVal; | ||
this._value = useDirectValue ? newVal : toReactive(newVal); | ||
triggerRefValue(this, 4, newVal); | ||
set value(newValue) { | ||
const oldValue = this._rawValue; | ||
const useDirectValue = this.__v_isShallow || isShallow(newValue) || isReadonly(newValue); | ||
newValue = useDirectValue ? newValue : toRaw(newValue); | ||
if (hasChanged(newValue, oldValue)) { | ||
this._rawValue = newValue; | ||
this._value = useDirectValue ? newValue : toReactive(newValue); | ||
{ | ||
this.dep.trigger({ | ||
target: this, | ||
type: "set", | ||
key: "value", | ||
newValue, | ||
oldValue | ||
}); | ||
} | ||
} | ||
@@ -1180,3 +1469,10 @@ } | ||
function triggerRef(ref2) { | ||
triggerRefValue(ref2, 4, ref2.value ); | ||
{ | ||
ref2.dep.trigger({ | ||
target: ref2, | ||
type: "set", | ||
key: "value", | ||
newValue: ref2._value | ||
}); | ||
} | ||
} | ||
@@ -1206,8 +1502,5 @@ function unref(ref2) { | ||
constructor(factory) { | ||
this.dep = void 0; | ||
this.__v_isRef = true; | ||
const { get, set } = factory( | ||
() => trackRefValue(this), | ||
() => triggerRefValue(this) | ||
); | ||
const dep = this.dep = new Dep(); | ||
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep)); | ||
this._get = get; | ||
@@ -1280,3 +1573,85 @@ this._set = set; | ||
const deferredComputed = computed; | ||
class ComputedRefImpl { | ||
constructor(fn, setter, isSSR) { | ||
this.fn = fn; | ||
this.setter = setter; | ||
/** | ||
* @internal | ||
*/ | ||
this._value = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.dep = new Dep(this); | ||
/** | ||
* @internal | ||
*/ | ||
this.__v_isRef = true; | ||
// A computed is also a subscriber that tracks other deps | ||
/** | ||
* @internal | ||
*/ | ||
this.deps = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.depsTail = void 0; | ||
/** | ||
* @internal | ||
*/ | ||
this.flags = 16; | ||
/** | ||
* @internal | ||
*/ | ||
this.globalVersion = globalVersion - 1; | ||
// for backwards compat | ||
this.effect = this; | ||
this.__v_isReadonly = !setter; | ||
this.isSSR = isSSR; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
notify() { | ||
if (activeSub !== this) { | ||
this.flags |= 16; | ||
this.dep.notify(); | ||
} | ||
} | ||
get value() { | ||
const link = this.dep.track({ | ||
target: this, | ||
type: "get", | ||
key: "value" | ||
}) ; | ||
refreshComputed(this); | ||
if (link) { | ||
link.version = this.dep.version; | ||
} | ||
return this._value; | ||
} | ||
set value(newValue) { | ||
if (this.setter) { | ||
this.setter(newValue); | ||
} else { | ||
warn("Write operation failed: computed value is readonly"); | ||
} | ||
} | ||
} | ||
function computed(getterOrOptions, debugOptions, isSSR = false) { | ||
let getter; | ||
let setter; | ||
if (isFunction(getterOrOptions)) { | ||
getter = getterOrOptions; | ||
} else { | ||
getter = getterOrOptions.get; | ||
setter = getterOrOptions.set; | ||
} | ||
const cRef = new ComputedRefImpl(getter, setter, isSSR); | ||
if (debugOptions && !isSSR) { | ||
cRef.onTrack = debugOptions.onTrack; | ||
cRef.onTrigger = debugOptions.onTrigger; | ||
} | ||
return cRef; | ||
} | ||
@@ -1302,4 +1677,7 @@ const TrackOpTypes = { | ||
exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY; | ||
exports.EffectFlags = EffectFlags; | ||
exports.EffectScope = EffectScope; | ||
exports.ITERATE_KEY = ITERATE_KEY; | ||
exports.MAP_KEY_ITERATE_KEY = MAP_KEY_ITERATE_KEY; | ||
exports.ReactiveEffect = ReactiveEffect; | ||
@@ -1311,3 +1689,2 @@ exports.ReactiveFlags = ReactiveFlags; | ||
exports.customRef = customRef; | ||
exports.deferredComputed = deferredComputed; | ||
exports.effect = effect; | ||
@@ -1323,12 +1700,13 @@ exports.effectScope = effectScope; | ||
exports.markRaw = markRaw; | ||
exports.onEffectCleanup = onEffectCleanup; | ||
exports.onScopeDispose = onScopeDispose; | ||
exports.pauseScheduling = pauseScheduling; | ||
exports.pauseTracking = pauseTracking; | ||
exports.proxyRefs = proxyRefs; | ||
exports.reactive = reactive; | ||
exports.reactiveReadArray = reactiveReadArray; | ||
exports.readonly = readonly; | ||
exports.ref = ref; | ||
exports.resetScheduling = resetScheduling; | ||
exports.resetTracking = resetTracking; | ||
exports.shallowReactive = shallowReactive; | ||
exports.shallowReadArray = shallowReadArray; | ||
exports.shallowReadonly = shallowReadonly; | ||
@@ -1338,2 +1716,4 @@ exports.shallowRef = shallowRef; | ||
exports.toRaw = toRaw; | ||
exports.toReactive = toReactive; | ||
exports.toReadonly = toReadonly; | ||
exports.toRef = toRef; | ||
@@ -1340,0 +1720,0 @@ exports.toRefs = toRefs; |
/** | ||
* @vue/reactivity v3.4.25 | ||
* @vue/reactivity v3.5.0-alpha.1 | ||
* (c) 2018-present Yuxi (Evan) You and Vue contributors | ||
@@ -7,2 +7,2 @@ * @license MIT | ||
var VueReactivity=function(t){"use strict"; | ||
/*! #__NO_SIDE_EFFECTS__ */function e(t,e){const s=new Set(t.split(","));return t=>s.has(t)}const s=()=>{},n=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===f(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,l=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,f=t=>h.call(t),_=t=>f(t).slice(8,-1),d=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,p=(t,e)=>!Object.is(t,e);let v,g;class y{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=v,!t&&v&&(this.index=(v.scopes||(v.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=v;try{return v=this,t()}finally{v=e}}}on(){v=this}off(){v=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function w(t,e=v){e&&e.active&&e.effects.push(t)}class R{constructor(t,e,s,n){this.fn=t,this.trigger=e,this.scheduler=s,this.active=!0,this.deps=[],this._dirtyLevel=4,this._trackId=0,this._runnings=0,this._shouldSchedule=!1,this._depsLength=0,w(this,n)}get dirty(){if(2===this._dirtyLevel||3===this._dirtyLevel){this._dirtyLevel=1,j();for(let t=0;t<this._depsLength;t++){const e=this.deps[t];if(e.computed&&(S(e.computed),this._dirtyLevel>=4))break}1===this._dirtyLevel&&(this._dirtyLevel=0),x()}return this._dirtyLevel>=4}set dirty(t){this._dirtyLevel=t?4:0}run(){if(this._dirtyLevel=0,!this.active)return this.fn();let t=E,e=g;try{return E=!0,g=this,this._runnings++,b(this),this.fn()}finally{k(this),this._runnings--,g=e,E=t}}stop(){var t;this.active&&(b(this),k(this),null==(t=this.onStop)||t.call(this),this.active=!1)}}function S(t){return t.value}function b(t){t._trackId++,t._depsLength=0}function k(t){if(t.deps.length>t._depsLength){for(let e=t._depsLength;e<t.deps.length;e++)L(t.deps[e],t);t.deps.length=t._depsLength}}function L(t,e){const s=t.get(e);void 0!==s&&e._trackId!==s&&(t.delete(e),0===t.size&&t.cleanup())}let E=!0,O=0;const m=[];function j(){m.push(E),E=!1}function x(){const t=m.pop();E=void 0===t||t}function I(){O++}function P(){for(O--;!O&&A.length;)A.shift()()}function T(t,e,s){if(e.get(t)!==t._trackId){e.set(t,t._trackId);const s=t.deps[t._depsLength];s!==e?(s&&L(s,t),t.deps[t._depsLength++]=e):t._depsLength++}}const A=[];function M(t,e,s){I();for(const n of t.keys()){let s;n._dirtyLevel<e&&(null!=s?s:s=t.get(n)===n._trackId)&&(n._shouldSchedule||(n._shouldSchedule=0===n._dirtyLevel),n._dirtyLevel=e),n._shouldSchedule&&(null!=s?s:s=t.get(n)===n._trackId)&&(n.trigger(),n._runnings&&!n.allowRecurse||2===n._dirtyLevel||(n._shouldSchedule=!1,n.scheduler&&A.push(n.scheduler)))}P()}const V=(t,e)=>{const s=new Map;return s.cleanup=t,s.computed=e,s},W=new WeakMap,z=Symbol(""),N=Symbol("");function D(t,e,s){if(E&&g){let e=W.get(t);e||W.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=V((()=>e.delete(s)))),T(g,n)}}function C(t,e,s,n,i,r){const u=W.get(t);if(!u)return;let l=[];if("clear"===e)l=[...u.values()];else if("length"===s&&c(t)){const t=Number(n);u.forEach(((e,s)=>{("length"===s||!a(s)&&s>=t)&&l.push(e)}))}else switch(void 0!==s&&l.push(u.get(s)),e){case"add":c(t)?d(s)&&l.push(u.get("length")):(l.push(u.get(z)),o(t)&&l.push(u.get(N)));break;case"delete":c(t)||(l.push(u.get(z)),o(t)&&l.push(u.get(N)));break;case"set":o(t)&&l.push(u.get(z))}I();for(const c of l)c&&M(c,4);P()}const K=e("__proto__,__v_isRef,__isVue"),H=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),Y=F();function F(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const s=Pt(this);for(let e=0,i=this.length;e<i;e++)D(s,0,e+"");const n=s[e](...t);return-1===n||!1===n?s[e](...t.map(Pt)):n}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){j(),I();const s=Pt(this)[e].apply(this,t);return P(),x(),s}})),t}function G(t){a(t)||(t=String(t));const e=Pt(this);return D(e,0,t),e.hasOwnProperty(t)}class q{constructor(t=!1,e=!1){this._isReadonly=t,this._isShallow=e}get(t,e,s){const n=this._isReadonly,i=this._isShallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return i;if("__v_raw"===e)return s===(n?i?Lt:kt:i?bt:St).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=c(t);if(!n){if(o&&r(Y,e))return Reflect.get(Y,e,s);if("hasOwnProperty"===e)return G}const u=Reflect.get(t,e,s);return(a(e)?H.has(e):K(e))?u:(n||D(t,0,e),i?u:Nt(u)?o&&d(e)?u:u.value:l(u)?n?Ot(u):Et(u):u)}}class B extends q{constructor(t=!1){super(!1,t)}set(t,e,s,n){let i=t[e];if(!this._isShallow){const e=xt(i);if(It(s)||xt(s)||(i=Pt(i),s=Pt(s)),!c(t)&&Nt(i)&&!Nt(s))return!e&&(i.value=s,!0)}const o=c(t)&&d(e)?Number(e)<t.length:r(t,e),u=Reflect.set(t,e,s,n);return t===Pt(n)&&(o?p(s,i)&&C(t,"set",e,s):C(t,"add",e,s)),u}deleteProperty(t,e){const s=r(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&C(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return a(e)&&H.has(e)||D(t,0,e),s}ownKeys(t){return D(t,0,c(t)?"length":z),Reflect.ownKeys(t)}}class J extends q{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const Q=new B,U=new J,X=new B(!0),Z=new J(!0),$=t=>t,tt=t=>Reflect.getPrototypeOf(t);function et(t,e,s=!1,n=!1){const i=Pt(t=t.__v_raw),r=Pt(e);s||(p(e,r)&&D(i,0,e),D(i,0,r));const{has:c}=tt(i),o=n?$:s?At:Tt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function st(t,e=!1){const s=this.__v_raw,n=Pt(s),i=Pt(t);return e||(p(t,i)&&D(n,0,t),D(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function nt(t,e=!1){return t=t.__v_raw,!e&&D(Pt(t),0,z),Reflect.get(t,"size",t)}function it(t){t=Pt(t);const e=Pt(this);return tt(e).has.call(e,t)||(e.add(t),C(e,"add",t,t)),this}function rt(t,e){e=Pt(e);const s=Pt(this),{has:n,get:i}=tt(s);let r=n.call(s,t);r||(t=Pt(t),r=n.call(s,t));const c=i.call(s,t);return s.set(t,e),r?p(e,c)&&C(s,"set",t,e):C(s,"add",t,e),this}function ct(t){const e=Pt(this),{has:s,get:n}=tt(e);let i=s.call(e,t);i||(t=Pt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&C(e,"delete",t,void 0),r}function ot(){const t=Pt(this),e=0!==t.size,s=t.clear();return e&&C(t,"clear",void 0,void 0),s}function ut(t,e){return function(s,n){const i=this,r=i.__v_raw,c=Pt(r),o=e?$:t?At:Tt;return!t&&D(c,0,z),r.forEach(((t,e)=>s.call(n,o(t),o(e),i)))}}function at(t,e,s){return function(...n){const i=this.__v_raw,r=Pt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,l=i[t](...n),h=s?$:e?At:Tt;return!e&&D(r,0,a?N:z),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[h(t[0]),h(t[1])]:h(t),done:e}},[Symbol.iterator](){return this}}}}function lt(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function ht(){const t={get(t){return et(this,t)},get size(){return nt(this)},has:st,add:it,set:rt,delete:ct,clear:ot,forEach:ut(!1,!1)},e={get(t){return et(this,t,!1,!0)},get size(){return nt(this)},has:st,add:it,set:rt,delete:ct,clear:ot,forEach:ut(!1,!0)},s={get(t){return et(this,t,!0)},get size(){return nt(this,!0)},has(t){return st.call(this,t,!0)},add:lt("add"),set:lt("set"),delete:lt("delete"),clear:lt("clear"),forEach:ut(!0,!1)},n={get(t){return et(this,t,!0,!0)},get size(){return nt(this,!0)},has(t){return st.call(this,t,!0)},add:lt("add"),set:lt("set"),delete:lt("delete"),clear:lt("clear"),forEach:ut(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=at(i,!1,!1),s[i]=at(i,!0,!1),e[i]=at(i,!1,!0),n[i]=at(i,!0,!0)})),[t,s,e,n]}const[ft,_t,dt,pt]=ht();function vt(t,e){const s=e?t?pt:dt:t?_t:ft;return(e,n,i)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(r(s,n)&&n in e?s:e,n,i)}const gt={get:vt(!1,!1)},yt={get:vt(!1,!0)},wt={get:vt(!0,!1)},Rt={get:vt(!0,!0)},St=new WeakMap,bt=new WeakMap,kt=new WeakMap,Lt=new WeakMap;function Et(t){return xt(t)?t:mt(t,!1,Q,gt,St)}function Ot(t){return mt(t,!0,U,wt,kt)}function mt(t,e,s,n,i){if(!l(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=(o=t).__v_skip||!Object.isExtensible(o)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(_(o));var o;if(0===c)return t;const u=new Proxy(t,2===c?n:s);return i.set(t,u),u}function jt(t){return xt(t)?jt(t.__v_raw):!(!t||!t.__v_isReactive)}function xt(t){return!(!t||!t.__v_isReadonly)}function It(t){return!(!t||!t.__v_isShallow)}function Pt(t){const e=t&&t.__v_raw;return e?Pt(e):t}const Tt=t=>l(t)?Et(t):t,At=t=>l(t)?Ot(t):t;class Mt{constructor(t,e,s,n){this.getter=t,this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this.effect=new R((()=>t(this._value)),(()=>zt(this,2===this.effect._dirtyLevel?2:3))),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=s}get value(){const t=Pt(this);return t._cacheable&&!t.effect.dirty||!p(t._value,t._value=t.effect.run())||zt(t,4),Wt(t),t.effect._dirtyLevel>=2&&zt(t,2),t._value}set value(t){this._setter(t)}get _dirty(){return this.effect.dirty}set _dirty(t){this.effect.dirty=t}}function Vt(t,e,n=!1){let i,r;const c=u(t);c?(i=t,r=s):(i=t.get,r=t.set);return new Mt(i,r,c||!r,n)}function Wt(t){var e;E&&g&&(t=Pt(t),T(g,null!=(e=t.dep)?e:t.dep=V((()=>t.dep=void 0),t instanceof Mt?t:void 0)))}function zt(t,e=4,s){const n=(t=Pt(t)).dep;n&&M(n,e)}function Nt(t){return!(!t||!0!==t.__v_isRef)}function Dt(t){return Ct(t,!1)}function Ct(t,e){return Nt(t)?t:new Kt(t,e)}class Kt{constructor(t,e){this.__v_isShallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Pt(t),this._value=e?t:Tt(t)}get value(){return Wt(this),this._value}set value(t){const e=this.__v_isShallow||It(t)||xt(t);t=e?t:Pt(t),p(t,this._rawValue)&&(this._rawValue=t,this._value=e?t:Tt(t),zt(this,4))}}function Ht(t){return Nt(t)?t.value:t}const Yt={get:(t,e,s)=>Ht(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Nt(i)&&!Nt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};class Ft{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:s}=t((()=>Wt(this)),(()=>zt(this)));this._get=e,this._set=s}get value(){return this._get()}set value(t){this._set(t)}}class Gt{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Pt(this._object),e=this._key,null==(s=W.get(t))?void 0:s.get(e);var t,e,s}}class qt{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function Bt(t,e,s){const n=t[e];return Nt(n)?n:new Gt(t,e,s)}const Jt=Vt;return t.EffectScope=y,t.ITERATE_KEY=z,t.ReactiveEffect=R,t.ReactiveFlags={SKIP:"__v_skip",IS_REACTIVE:"__v_isReactive",IS_READONLY:"__v_isReadonly",IS_SHALLOW:"__v_isShallow",RAW:"__v_raw"},t.TrackOpTypes={GET:"get",HAS:"has",ITERATE:"iterate"},t.TriggerOpTypes={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},t.computed=Vt,t.customRef=function(t){return new Ft(t)},t.deferredComputed=Jt,t.effect=function(t,e){t.effect instanceof R&&(t=t.effect.fn);const i=new R(t,s,(()=>{i.dirty&&i.run()}));e&&(n(i,e),e.scope&&w(i,e.scope)),e&&e.lazy||i.run();const r=i.run.bind(i);return r.effect=i,r},t.effectScope=function(t){return new y(t)},t.enableTracking=function(){m.push(E),E=!0},t.getCurrentScope=function(){return v},t.isProxy=function(t){return!!t&&!!t.__v_raw},t.isReactive=jt,t.isReadonly=xt,t.isRef=Nt,t.isShallow=It,t.markRaw=function(t){return Object.isExtensible(t)&&((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t},t.onScopeDispose=function(t){v&&v.cleanups.push(t)},t.pauseScheduling=I,t.pauseTracking=j,t.proxyRefs=function(t){return jt(t)?t:new Proxy(t,Yt)},t.reactive=Et,t.readonly=Ot,t.ref=Dt,t.resetScheduling=P,t.resetTracking=x,t.shallowReactive=function(t){return mt(t,!1,X,yt,bt)},t.shallowReadonly=function(t){return mt(t,!0,Z,Rt,Lt)},t.shallowRef=function(t){return Ct(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Pt,t.toRef=function(t,e,s){return Nt(t)?t:u(t)?new qt(t):l(t)&&arguments.length>1?Bt(t,e,s):Dt(t)},t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const s in t)e[s]=Bt(t,s);return e},t.toValue=function(t){return u(t)?t():Ht(t)},t.track=D,t.trigger=C,t.triggerRef=function(t){zt(t,4)},t.unref=Ht,t}({}); | ||
/*! #__NO_SIDE_EFFECTS__ */function e(t,e){const s=new Set(t.split(","));return t=>s.has(t)}const s=Object.assign,n=Object.prototype.hasOwnProperty,i=(t,e)=>n.call(t,e),r=Array.isArray,o=t=>"[object Map]"===f(t),c=t=>"function"==typeof t,u=t=>"symbol"==typeof t,a=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),h=t=>f(t).slice(8,-1),p=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let v,_;class g{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=v,!t&&v&&(this.index=(v.scopes||(v.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=v;try{return v=this,t()}finally{v=e}}}on(){v=this}off(){v=this.parent}stop(t){if(this._active){let e,s;for(e=0,s=this.effects.length;e<s;e++)this.effects[e].stop();for(e=0,s=this.cleanups.length;e<s;e++)this.cleanups[e]();if(this.scopes)for(e=0,s=this.scopes.length;e<s;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}class y{constructor(t){this.fn=t,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.nextEffect=void 0,this.cleanup=void 0,this.scheduler=void 0,v&&v.active&&v.effects.push(this)}notify(){if(!(2&this.flags)||32&this.flags)return 64&this.flags?this.trigger():void(8&this.flags||(this.flags|=8,this.nextEffect=R,R=this))}run(){if(!(1&this.flags))return this.fn();this.flags|=2,j(this),x(this);const t=_,e=A;_=this,A=!0;try{return this.fn()}finally{E(this),_=t,A=e,this.flags&=-3}}stop(){if(1&this.flags){for(let t=this.deps;t;t=t.nextDep)D(t);this.deps=this.depsTail=void 0,j(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){T(this)&&this.run()}get dirty(){return T(this)}}let R,w=0;function b(){w++}function S(){if(w>1)return void w--;let t;for(;R;){let s=R;for(R=void 0;s;){const n=s.nextEffect;if(s.nextEffect=void 0,s.flags&=-9,1&s.flags)try{s.trigger()}catch(e){t||(t=e)}s=n}}if(w--,t)throw t}function x(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function E(t){let e,s=t.depsTail;for(let n=s;n;n=n.prevDep)-1===n.version?(n===s&&(s=n.prevDep),D(n),m(n)):e=n,n.dep.activeLink=n.prevActiveLink,n.prevActiveLink=void 0;t.deps=e,t.depsTail=s}function T(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&!1===k(e.dep.computed)||e.dep.version!==e.version)return!0;return!!t._dirty}function k(t){if(2&t.flags)return!1;if(4&t.flags&&!(16&t.flags))return;if(t.flags&=-17,t.globalVersion===N)return;t.globalVersion=N;const e=t.dep;if(t.flags|=2,e.version>0&&!t.isSSR&&!T(t))return void(t.flags&=-3);const s=_,n=A;_=t,A=!0;try{x(t);const s=t.fn();(0===e.version||d(s,t._value))&&(t._value=s,e.version++)}catch(i){throw e.version++,i}finally{_=s,A=n,E(t),t.flags&=-3}}function D(t){const{dep:e,prevSub:s,nextSub:n}=t;if(s&&(s.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=s,t.nextSub=void 0),e.subs===t&&(e.subs=s),!e.subs&&e.computed){e.computed.flags&=-5;for(let t=e.computed.deps;t;t=t.nextDep)D(t)}}function m(t){const{prevDep:e,nextDep:s}=t;e&&(e.nextDep=s,t.prevDep=void 0),s&&(s.prevDep=e,t.nextDep=void 0)}let A=!0;const O=[];function I(){O.push(A),A=!1}function L(){const t=O.pop();A=void 0===t||t}function j(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const t=_;_=void 0;try{e()}finally{_=t}}}let N=0;class P{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0}track(t){if(!_||!A)return;let e=this.activeLink;if(void 0===e||e.sub!==_)e=this.activeLink={dep:this,sub:_,version:this.version,nextDep:void 0,prevDep:void 0,nextSub:void 0,prevSub:void 0,prevActiveLink:void 0},_.deps?(e.prevDep=_.depsTail,_.depsTail.nextDep=e,_.depsTail=e):_.deps=_.depsTail=e,4&_.flags&&V(e);else if(-1===e.version&&(e.version=this.version,e.nextDep)){const t=e.nextDep;t.prevDep=e.prevDep,e.prevDep&&(e.prevDep.nextDep=t),e.prevDep=_.depsTail,e.nextDep=void 0,_.depsTail.nextDep=e,_.depsTail=e,_.deps===e&&(_.deps=t)}return e}trigger(t){this.version++,N++,this.notify(t)}notify(t){b();try{0;for(let t=this.subs;t;t=t.prevSub)t.sub.notify()}finally{S()}}}function V(t){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let t=e.deps;t;t=t.nextDep)V(t)}const s=t.dep.subs;s!==t&&(t.prevSub=s,s&&(s.nextSub=t)),t.dep.subs=t}const C=new WeakMap,W=Symbol(""),M=Symbol(""),K=Symbol("");function Y(t,e,s){if(A&&_){let e=C.get(t);e||C.set(t,e=new Map);let n=e.get(s);n||e.set(s,n=new P),n.track()}}function z(t,e,s,n,i,c){const a=C.get(t);if(!a)return void N++;let l=[];if("clear"===e)l=[...a.values()];else{const i=r(t),c=i&&p(s);if(i&&"length"===s){const t=Number(n);a.forEach(((e,s)=>{("length"===s||s===K||!u(s)&&s>=t)&&l.push(e)}))}else{const n=t=>t&&l.push(t);switch(void 0!==s&&n(a.get(s)),c&&n(a.get(K)),e){case"add":i?c&&n(a.get("length")):(n(a.get(W)),o(t)&&n(a.get(M)));break;case"delete":i||(n(a.get(W)),o(t)&&n(a.get(M)));break;case"set":o(t)&&n(a.get(W))}}}b();for(const r of l)r.trigger();S()}function G(t){const e=Kt(t);return e===t?e:(Y(e,0,K),Wt(t)?e:e.map(Yt))}function F(t){return Y(t=Kt(t),0,K),t}const H={__proto__:null,[Symbol.iterator](){return U(this,Symbol.iterator,Yt)},concat(...t){return G(this).concat(...t.map((t=>G(t))))},entries(){return U(this,"entries",(t=>(t[1]=Yt(t[1]),t)))},every(t,e){return B(this,"every",t,e)},filter(t,e){const s=B(this,"filter",t,e);return Mt(this)&&!Wt(this)?s.map(Yt):s},find(t,e){const s=B(this,"find",t,e);return Mt(this)&&!Wt(this)?Yt(s):s},findIndex(t,e){return B(this,"findIndex",t,e)},findLast(t,e){const s=B(this,"findLast",t,e);return Mt(this)&&!Wt(this)?Yt(s):s},findLastIndex(t,e){return B(this,"findLastIndex",t,e)},forEach(t,e){return B(this,"forEach",t,e)},includes(...t){return J(this,"includes",t)},indexOf(...t){return J(this,"indexOf",t)},join(t){return G(this).join(t)},lastIndexOf(...t){return J(this,"lastIndexOf",t)},map(t,e){return B(this,"map",t,e)},pop(){return Q(this,"pop")},push(...t){return Q(this,"push",t)},reduce(t,...e){return q(this,"reduce",t,e)},reduceRight(t,...e){return q(this,"reduceRight",t,e)},shift(){return Q(this,"shift")},some(t,e){return B(this,"some",t,e)},splice(...t){return Q(this,"splice",t)},toReversed(){return G(this).toReversed()},toSorted(t){return G(this).toSorted(t)},toSpliced(...t){return G(this).toSpliced(...t)},unshift(...t){return Q(this,"unshift",t)},values(){return U(this,"values",Yt)}};function U(t,e,s){const n=F(t),i=n[e]();return n===t||Wt(t)||(i._next=i.next,i.next=()=>{const t=i._next();return t.value&&(t.value=s(t.value)),t}),i}function B(t,e,s,n){const i=F(t);let r=s;return i!==t&&(Wt(t)?s.length>2&&(r=function(e,n){return s.call(this,e,n,t)}):r=function(e,n){return s.call(this,Yt(e),n,t)}),i[e](r,n)}function q(t,e,s,n){const i=F(t);let r=s;return i!==t&&(Wt(t)?s.length>3&&(r=function(e,n,i){return s.call(this,e,n,i,t)}):r=function(e,n,i){return s.call(this,e,Yt(n),i,t)}),i[e](r,...n)}function J(t,e,s){const n=Kt(t);Y(n,0,K);const i=n[e](...s);return-1!==i&&!1!==i||!Mt(s[0])?i:(s[0]=Kt(s[0]),n[e](...s))}function Q(t,e,s=[]){I(),b();const n=Kt(t)[e].apply(t,s);return S(),L(),n}const X=e("__proto__,__v_isRef,__isVue"),Z=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(u));function $(t){u(t)||(t=String(t));const e=Kt(this);return Y(e,0,t),e.hasOwnProperty(t)}class tt{constructor(t=!1,e=!1){this._isReadonly=t,this._isShallow=e}get(t,e,s){const n=this._isReadonly,i=this._isShallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return i;if("__v_raw"===e)return s===(n?i?Lt:It:i?Ot:At).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=r(t);if(!n){let t;if(o&&(t=H[e]))return t;if("hasOwnProperty"===e)return $}const c=Reflect.get(t,e,Gt(t)?t:s);return(u(e)?Z.has(e):X(e))?c:(n||Y(t,0,e),i?c:Gt(c)?o&&p(e)?c:c.value:a(c)?n?Nt(c):jt(c):c)}}class et extends tt{constructor(t=!1){super(!1,t)}set(t,e,s,n){let o=t[e];if(!this._isShallow){const e=Ct(o);if(Wt(s)||Ct(s)||(o=Kt(o),s=Kt(s)),!r(t)&&Gt(o)&&!Gt(s))return!e&&(o.value=s,!0)}const c=r(t)&&p(e)?Number(e)<t.length:i(t,e),u=Reflect.set(t,e,s,n);return t===Kt(n)&&(c?d(s,o)&&z(t,"set",e,s):z(t,"add",e,s)),u}deleteProperty(t,e){const s=i(t,e),n=Reflect.deleteProperty(t,e);return n&&s&&z(t,"delete",e,void 0),n}has(t,e){const s=Reflect.has(t,e);return u(e)&&Z.has(e)||Y(t,0,e),s}ownKeys(t){return Y(t,0,r(t)?"length":W),Reflect.ownKeys(t)}}class st extends tt{constructor(t=!1){super(!0,t)}set(t,e){return!0}deleteProperty(t,e){return!0}}const nt=new et,it=new st,rt=new et(!0),ot=new st(!0),ct=t=>t,ut=t=>Reflect.getPrototypeOf(t);function at(t,e,s=!1,n=!1){const i=Kt(t=t.__v_raw),r=Kt(e);s||(d(e,r)&&Y(i,0,e),Y(i,0,r));const{has:o}=ut(i),c=n?ct:s?zt:Yt;return o.call(i,e)?c(t.get(e)):o.call(i,r)?c(t.get(r)):void(t!==i&&t.get(e))}function lt(t,e=!1){const s=this.__v_raw,n=Kt(s),i=Kt(t);return e||(d(t,i)&&Y(n,0,t),Y(n,0,i)),t===i?s.has(t):s.has(t)||s.has(i)}function ft(t,e=!1){return t=t.__v_raw,!e&&Y(Kt(t),0,W),Reflect.get(t,"size",t)}function ht(t){t=Kt(t);const e=Kt(this);return ut(e).has.call(e,t)||(e.add(t),z(e,"add",t,t)),this}function pt(t,e){e=Kt(e);const s=Kt(this),{has:n,get:i}=ut(s);let r=n.call(s,t);r||(t=Kt(t),r=n.call(s,t));const o=i.call(s,t);return s.set(t,e),r?d(e,o)&&z(s,"set",t,e):z(s,"add",t,e),this}function dt(t){const e=Kt(this),{has:s,get:n}=ut(e);let i=s.call(e,t);i||(t=Kt(t),i=s.call(e,t)),n&&n.call(e,t);const r=e.delete(t);return i&&z(e,"delete",t,void 0),r}function vt(){const t=Kt(this),e=0!==t.size,s=t.clear();return e&&z(t,"clear",void 0,void 0),s}function _t(t,e){return function(s,n){const i=this,r=i.__v_raw,o=Kt(r),c=e?ct:t?zt:Yt;return!t&&Y(o,0,W),r.forEach(((t,e)=>s.call(n,c(t),c(e),i)))}}function gt(t,e,s){return function(...n){const i=this.__v_raw,r=Kt(i),c=o(r),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,l=i[t](...n),f=s?ct:e?zt:Yt;return!e&&Y(r,0,a?M:W),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[f(t[0]),f(t[1])]:f(t),done:e}},[Symbol.iterator](){return this}}}}function yt(t){return function(...e){return"delete"!==t&&("clear"===t?void 0:this)}}function Rt(){const t={get(t){return at(this,t)},get size(){return ft(this)},has:lt,add:ht,set:pt,delete:dt,clear:vt,forEach:_t(!1,!1)},e={get(t){return at(this,t,!1,!0)},get size(){return ft(this)},has:lt,add:ht,set:pt,delete:dt,clear:vt,forEach:_t(!1,!0)},s={get(t){return at(this,t,!0)},get size(){return ft(this,!0)},has(t){return lt.call(this,t,!0)},add:yt("add"),set:yt("set"),delete:yt("delete"),clear:yt("clear"),forEach:_t(!0,!1)},n={get(t){return at(this,t,!0,!0)},get size(){return ft(this,!0)},has(t){return lt.call(this,t,!0)},add:yt("add"),set:yt("set"),delete:yt("delete"),clear:yt("clear"),forEach:_t(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=gt(i,!1,!1),s[i]=gt(i,!0,!1),e[i]=gt(i,!1,!0),n[i]=gt(i,!0,!0)})),[t,s,e,n]}const[wt,bt,St,xt]=Rt();function Et(t,e){const s=e?t?xt:St:t?bt:wt;return(e,n,r)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(i(s,n)&&n in e?s:e,n,r)}const Tt={get:Et(!1,!1)},kt={get:Et(!1,!0)},Dt={get:Et(!0,!1)},mt={get:Et(!0,!0)},At=new WeakMap,Ot=new WeakMap,It=new WeakMap,Lt=new WeakMap;function jt(t){return Ct(t)?t:Pt(t,!1,nt,Tt,At)}function Nt(t){return Pt(t,!0,it,Dt,It)}function Pt(t,e,s,n,i){if(!a(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const o=(c=t).__v_skip||!Object.isExtensible(c)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(h(c));var c;if(0===o)return t;const u=new Proxy(t,2===o?n:s);return i.set(t,u),u}function Vt(t){return Ct(t)?Vt(t.__v_raw):!(!t||!t.__v_isReactive)}function Ct(t){return!(!t||!t.__v_isReadonly)}function Wt(t){return!(!t||!t.__v_isShallow)}function Mt(t){return!!t&&!!t.__v_raw}function Kt(t){const e=t&&t.__v_raw;return e?Kt(e):t}const Yt=t=>a(t)?jt(t):t,zt=t=>a(t)?Nt(t):t;function Gt(t){return!!t&&!0===t.__v_isRef}function Ft(t){return Ht(t,!1)}function Ht(t,e){return Gt(t)?t:new Ut(t,e)}class Ut{constructor(t,e){this.__v_isShallow=e,this.dep=new P,this.__v_isRef=!0,this._rawValue=e?t:Kt(t),this._value=e?t:Yt(t)}get value(){return this.dep.track(),this._value}set value(t){const e=this._rawValue,s=this.__v_isShallow||Wt(t)||Ct(t);t=s?t:Kt(t),d(t,e)&&(this._rawValue=t,this._value=s?t:Yt(t),this.dep.trigger())}}function Bt(t){return Gt(t)?t.value:t}const qt={get:(t,e,s)=>Bt(Reflect.get(t,e,s)),set:(t,e,s,n)=>{const i=t[e];return Gt(i)&&!Gt(s)?(i.value=s,!0):Reflect.set(t,e,s,n)}};class Jt{constructor(t){this.__v_isRef=!0;const e=this.dep=new P,{get:s,set:n}=t(e.track.bind(e),e.trigger.bind(e));this._get=s,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class Qt{constructor(t,e,s){this._object=t,this._key=e,this._defaultValue=s,this.__v_isRef=!0}get value(){const t=this._object[this._key];return void 0===t?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return t=Kt(this._object),e=this._key,null==(s=C.get(t))?void 0:s.get(e);var t,e,s}}class Xt{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0}get value(){return this._getter()}}function Zt(t,e,s){const n=t[e];return Gt(n)?n:new Qt(t,e,s)}class $t{constructor(t,e,s){this.fn=t,this.setter=e,this._value=void 0,this.dep=new P(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=N-1,this.effect=this,this.__v_isReadonly=!e,this.isSSR=s}notify(){_!==this&&(this.flags|=16,this.dep.notify())}get value(){const t=this.dep.track();return k(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}return t.ARRAY_ITERATE_KEY=K,t.EffectFlags={ACTIVE:1,1:"ACTIVE",RUNNING:2,2:"RUNNING",TRACKING:4,4:"TRACKING",NOTIFIED:8,8:"NOTIFIED",DIRTY:16,16:"DIRTY",ALLOW_RECURSE:32,32:"ALLOW_RECURSE",NO_BATCH:64,64:"NO_BATCH"},t.EffectScope=g,t.ITERATE_KEY=W,t.MAP_KEY_ITERATE_KEY=M,t.ReactiveEffect=y,t.ReactiveFlags={SKIP:"__v_skip",IS_REACTIVE:"__v_isReactive",IS_READONLY:"__v_isReadonly",IS_SHALLOW:"__v_isShallow",RAW:"__v_raw"},t.TrackOpTypes={GET:"get",HAS:"has",ITERATE:"iterate"},t.TriggerOpTypes={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},t.computed=function(t,e,s=!1){let n,i;return c(t)?n=t:(n=t.get,i=t.set),new $t(n,i,s)},t.customRef=function(t){return new Jt(t)},t.effect=function(t,e){t.effect instanceof y&&(t=t.effect.fn);const n=new y(t);e&&s(n,e);try{n.run()}catch(r){throw n.stop(),r}const i=n.run.bind(n);return i.effect=n,i},t.effectScope=function(t){return new g(t)},t.enableTracking=function(){O.push(A),A=!0},t.getCurrentScope=function(){return v},t.isProxy=Mt,t.isReactive=Vt,t.isReadonly=Ct,t.isRef=Gt,t.isShallow=Wt,t.markRaw=function(t){return Object.isExtensible(t)&&((t,e,s)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:s})})(t,"__v_skip",!0),t},t.onEffectCleanup=function(t,e=!1){_ instanceof y&&(_.cleanup=t)},t.onScopeDispose=function(t,e=!1){v&&v.cleanups.push(t)},t.pauseTracking=I,t.proxyRefs=function(t){return Vt(t)?t:new Proxy(t,qt)},t.reactive=jt,t.reactiveReadArray=G,t.readonly=Nt,t.ref=Ft,t.resetTracking=L,t.shallowReactive=function(t){return Pt(t,!1,rt,kt,Ot)},t.shallowReadArray=F,t.shallowReadonly=function(t){return Pt(t,!0,ot,mt,Lt)},t.shallowRef=function(t){return Ht(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Kt,t.toReactive=Yt,t.toReadonly=zt,t.toRef=function(t,e,s){return Gt(t)?t:c(t)?new Xt(t):a(t)&&arguments.length>1?Zt(t,e,s):Ft(t)},t.toRefs=function(t){const e=r(t)?new Array(t.length):{};for(const s in t)e[s]=Zt(t,s);return e},t.toValue=function(t){return c(t)?t():Bt(t)},t.track=Y,t.trigger=z,t.triggerRef=function(t){t.dep.trigger()},t.unref=Bt,t}({}); |
{ | ||
"name": "@vue/reactivity", | ||
"version": "3.4.25", | ||
"version": "3.5.0-alpha.1", | ||
"description": "@vue/reactivity", | ||
@@ -53,4 +53,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vue/shared": "3.4.25" | ||
"@vue/shared": "3.5.0-alpha.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
275193
8956
1
30
+ Added@vue/shared@3.5.0-alpha.1(transitive)
- Removed@vue/shared@3.4.25(transitive)
Updated@vue/shared@3.5.0-alpha.1