🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@atom-vue/reactivity

Package Overview
Dependencies
Maintainers
3
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atom-vue/reactivity - npm Package Compare versions

Comparing version
3.0.0-beta.47
to
3.0.0-beta.48
+579
-241
dist/reactivity.cjs.js

@@ -7,59 +7,184 @@ 'use strict';

const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
function warn(msg, ...args) {
console.warn(`[Vue warn] ${msg}`, ...args);
}
function effect(fn, options = shared.EMPTY_OBJ) {
if (isEffect(fn)) {
fn = fn.raw;
let activeEffectScope;
const effectScopeStack = [];
class EffectScope {
constructor(detached = false) {
this.active = true;
this.effects = [];
this.cleanups = [];
if (!detached && activeEffectScope) {
this.parent = activeEffectScope;
this.index =
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
}
}
const effect = createReactiveEffect(fn, options);
if (!options.lazy) {
effect();
run(fn) {
if (this.active) {
try {
this.on();
return fn();
}
finally {
this.off();
}
}
else {
warn(`cannot run an inactive effect scope.`);
}
}
return effect;
}
function stop(effect) {
if (effect.active) {
cleanup(effect);
if (effect.options.onStop) {
effect.options.onStop();
on() {
if (this.active) {
effectScopeStack.push(this);
activeEffectScope = this;
}
effect.active = false;
}
off() {
if (this.active) {
effectScopeStack.pop();
activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
}
}
stop(fromParent) {
if (this.active) {
this.effects.forEach(e => e.stop());
this.cleanups.forEach(cleanup => cleanup());
if (this.scopes) {
this.scopes.forEach(e => e.stop(true));
}
// nested scope, dereference from parent to avoid memory leaks
if (this.parent && !fromParent) {
// optimized O(1) removal
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.active = false;
}
}
}
let uid = 0;
function createReactiveEffect(fn, options) {
const effect = function reactiveEffect() {
if (!effect.active) {
return options.scheduler ? undefined : fn();
function effectScope(detached) {
return new EffectScope(detached);
}
function recordEffectScope(effect, scope) {
scope = scope || activeEffectScope;
if (scope && scope.active) {
scope.effects.push(effect);
}
}
function getCurrentScope() {
return activeEffectScope;
}
function onScopeDispose(fn) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn);
}
else {
warn(`onScopeDispose() is called when there is no active effect scope` +
` to be associated with.`);
}
}
const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit; // set was tracked
}
if (!effectStack.includes(effect)) {
cleanup(effect);
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
}
else {
deps[ptr++] = dep;
}
// clear bits
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = new WeakMap();
// The number of effects currently being tracked recursively.
let effectTrackDepth = 0;
let trackOpBit = 1;
/**
* The bitwise track markers support at most 30 levels op recursion.
* This value is chosen to enable modern JS engines to use a SMI on all platforms.
* When recursion depth is greater, fall back to using a full cleanup.
*/
const maxMarkerBits = 30;
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
this.fn = fn;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
recordEffectScope(this, scope);
}
run() {
if (!this.active) {
return this.fn();
}
if (!effectStack.includes(this)) {
try {
effectStack.push((activeEffect = this));
enableTracking();
effectStack.push(effect);
activeEffect = effect;
return fn();
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
}
else {
cleanupEffect(this);
}
return this.fn();
}
finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
resetTracking();
effectStack.pop();
resetTracking();
activeEffect = effectStack[effectStack.length - 1];
const n = effectStack.length;
activeEffect = n > 0 ? effectStack[n - 1] : undefined;
}
}
};
effect.id = uid++;
effect._isEffect = true;
effect.active = true;
effect.raw = fn;
effect.deps = [];
effect.options = options;
return effect;
}
stop() {
if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
this.active = false;
}
}
}
function cleanup(effect) {
function cleanupEffect(effect) {
const { deps } = effect;

@@ -73,2 +198,22 @@ if (deps.length) {

}
function effect(fn, options) {
if (fn.effect) {
fn = fn.effect.fn;
}
const _effect = new ReactiveEffect(fn);
if (options) {
shared.extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
}
if (!options || !options.lazy) {
_effect.run();
}
const runner = _effect.run.bind(_effect);
runner.effect = _effect;
return runner;
}
function stop(runner) {
runner.effect.stop();
}
let shouldTrack = true;

@@ -89,3 +234,3 @@ const trackStack = [];

function track(target, type, key) {
if (!shouldTrack || activeEffect === undefined) {
if (!isTracking()) {
return;

@@ -99,14 +244,30 @@ }

if (!dep) {
depsMap.set(key, (dep = new Set()));
depsMap.set(key, (dep = createDep()));
}
if (!dep.has(activeEffect)) {
const eventInfo = { effect: activeEffect, target, type, key }
;
trackEffects(dep, eventInfo);
}
function isTracking() {
return shouldTrack && activeEffect !== undefined;
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit; // set newly tracked
shouldTrack = !wasTracked(dep);
}
}
else {
// Full cleanup mode.
shouldTrack = !dep.has(activeEffect);
}
if (shouldTrack) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
type,
key
});
if (activeEffect.onTrack) {
activeEffect.onTrack(Object.assign({
effect: activeEffect
}, debuggerEventExtraInfo));
}

@@ -121,16 +282,7 @@ }

}
const effects = new Set();
const add = (effectsToAdd) => {
if (effectsToAdd) {
effectsToAdd.forEach(effect => {
if (effect !== activeEffect || effect.options.allowRecurse) {
effects.add(effect);
}
});
}
};
let deps = [];
if (type === "clear" /* CLEAR */) {
// collection being cleared
// trigger all effects for target
depsMap.forEach(add);
deps = [...depsMap.values()];
}

@@ -140,3 +292,3 @@ else if (key === 'length' && shared.isArray(target)) {

if (key === 'length' || key >= newValue) {
add(dep);
deps.push(dep);
}

@@ -148,3 +300,3 @@ });

if (key !== void 0) {
add(depsMap.get(key));
deps.push(depsMap.get(key));
}

@@ -155,5 +307,5 @@ // also run for iteration key on ADD | DELETE | Map.SET

if (!shared.isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (shared.isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -163,3 +315,3 @@ }

// new index added to array -> length changes
add(depsMap.get('length'));
deps.push(depsMap.get('length'));
}

@@ -169,5 +321,5 @@ break;

if (!shared.isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (shared.isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -178,3 +330,3 @@ }

if (shared.isMap(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
}

@@ -184,24 +336,41 @@ break;

}
const run = (effect) => {
if ( effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
key,
type,
newValue,
oldValue,
oldTarget
});
const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
;
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0], eventInfo);
}
}
if (effect.options.scheduler) {
effect.options.scheduler(effect);
}
else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
else {
effect();
{
triggerEffects(createDep(effects), eventInfo);
}
};
effects.forEach(run);
}
}
function triggerEffects(dep, debuggerEventExtraInfo) {
// spread into array for stabilization
for (const effect of shared.isArray(dep) ? dep : [...dep]) {
if (effect !== activeEffect || effect.allowRecurse) {
if (effect.onTrigger) {
effect.onTrigger(shared.extend({ effect }, debuggerEventExtraInfo));
}
if (effect.scheduler) {
effect.scheduler();
}
else {
effect.run();
}
}
}
}
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)

@@ -214,30 +383,32 @@ .map(key => Symbol[key])

const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
const arrayInstrumentations = {};
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
const arr = toRaw(this);
for (let i = 0, l = this.length; i < l; i++) {
track(arr, "get" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = method.apply(arr, args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return method.apply(arr, args.map(toRaw));
}
else {
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" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = arr[key](...args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return arr[key](...args.map(toRaw));
}
else {
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
instrumentations[key] = function (...args) {
pauseTracking();
const res = toRaw(this)[key].apply(this, args);
resetTracking();
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
pauseTracking();
const res = method.apply(this, args);
enableTracking();
return res;
};
});
};
});
return instrumentations;
}
function createGetter(isReadonly = false, shallow = false) {

@@ -252,14 +423,18 @@ return function get(target, key, receiver) {

else if (key === "__v_raw" /* RAW */ &&
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) {
receiver ===
(isReadonly
? shallow
? shallowReadonlyMap
: readonlyMap
: shallow
? shallowReactiveMap
: reactiveMap).get(target)) {
return target;
}
const targetIsArray = shared.isArray(target);
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
const keyIsSymbol = shared.isSymbol(key);
if (keyIsSymbol
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
return res;

@@ -291,5 +466,6 @@ }

return function set(target, key, value, receiver) {
const oldValue = target[key];
let oldValue = target[key];
if (!shallow) {
value = toRaw(value);
oldValue = toRaw(oldValue);
if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) {

@@ -333,3 +509,3 @@ oldValue.value = value;

function ownKeys(target) {
track(target, "iterate" /* ITERATE */, ITERATE_KEY);
track(target, "iterate" /* ITERATE */, shared.isArray(target) ? 'length' : ITERATE_KEY);
return Reflect.ownKeys(target);

@@ -359,3 +535,3 @@ }

};
const shallowReactiveHandlers = shared.extend({}, mutableHandlers, {
const shallowReactiveHandlers = /*#__PURE__*/ shared.extend({}, mutableHandlers, {
get: shallowGet,

@@ -367,8 +543,6 @@ set: shallowSet

// retain the reactivity of the normal readonly object.
const shallowReadonlyHandlers = shared.extend({}, readonlyHandlers, {
const shallowReadonlyHandlers = /*#__PURE__*/ shared.extend({}, readonlyHandlers, {
get: shallowReadonlyGet
});
const toReactive = (value) => shared.isObject(value) ? reactive(value) : value;
const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
const toShallow = (value) => value;

@@ -387,3 +561,3 @@ const getProto = (v) => Reflect.getPrototypeOf(v);

const { has } = getProto(rawTarget);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
if (has.call(rawTarget, key)) {

@@ -395,2 +569,7 @@ return wrap(target.get(key));

}
else if (target !== rawTarget) {
// #3602 readonly(reactive(Map))
// ensure that the nested reactive `Map` can do tracking for itself
target.get(key);
}
}

@@ -419,7 +598,7 @@ function has$1(key, isReadonly = false) {

const hadKey = proto.has.call(target, value);
const result = target.add(value);
if (!hadKey) {
target.add(value);
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}

@@ -439,3 +618,3 @@ function set$1(key, value) {

const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {

@@ -447,3 +626,3 @@ trigger(target, "add" /* ADD */, key, value);

}
return result;
return this;
}

@@ -472,3 +651,3 @@ function deleteEntry(key) {

const hadItems = target.size !== 0;
const oldTarget = shared.isMap(target)
const oldTarget = shared.isMap(target)
? new Map(target)

@@ -489,3 +668,3 @@ : new Set(target)

const rawTarget = toRaw(target);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);

@@ -508,3 +687,3 @@ return target.forEach((value, key) => {

const innerIterator = target[method](...args);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly &&

@@ -541,55 +720,83 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);

}
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
});
function createInstrumentations() {
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations = {
get(key) {
return get$1(this, key, true, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, true)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
});
return [
mutableInstrumentations,
readonlyInstrumentations,
shallowInstrumentations,
shallowReadonlyInstrumentations
];
}
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
function createInstrumentationGetter(isReadonly, shallow) {
const instrumentations = shallow
? shallowInstrumentations
? isReadonly
? shallowReadonlyInstrumentations
: shallowInstrumentations
: isReadonly

@@ -614,10 +821,13 @@ ? readonlyInstrumentations

const mutableCollectionHandlers = {
get: createInstrumentationGetter(false, false)
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
};
const shallowCollectionHandlers = {
get: createInstrumentationGetter(false, true)
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
};
const readonlyCollectionHandlers = {
get: createInstrumentationGetter(true, false)
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
};
const shallowReadonlyCollectionHandlers = {
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
};
function checkIdentityKeys(target, has, key) {

@@ -628,3 +838,3 @@ const rawKey = toRaw(key);

console.warn(`Reactive ${type} contains both the raw and reactive ` +
`versions of the same object${type === `Map` ? `as keys` : ``}, ` +
`versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
`which can lead to inconsistencies. ` +

@@ -637,3 +847,5 @@ `Avoid differentiating between the raw and reactive versions ` +

const reactiveMap = new WeakMap();
const shallowReactiveMap = new WeakMap();
const readonlyMap = new WeakMap();
const shallowReadonlyMap = new WeakMap();
function targetTypeMap(rawType) {

@@ -663,21 +875,29 @@ switch (rawType) {

}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
}
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
if (!shared.isObject(target)) {

@@ -696,3 +916,2 @@ {

// target already has corresponding Proxy
const proxyMap = isReadonly ? readonlyMap : reactiveMap;
const existingProxy = proxyMap.get(target);

@@ -724,3 +943,4 @@ if (existingProxy) {

function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
const raw = observed && observed["__v_raw" /* RAW */];
return raw ? toRaw(raw) : observed;
}

@@ -731,4 +951,33 @@ function markRaw(value) {

}
const toReactive = (value) => shared.isObject(value) ? reactive(value) : value;
const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
const convert = (val) => shared.isObject(val) ? reactive(val) : val;
function trackRefValue(ref) {
if (isTracking()) {
ref = toRaw(ref);
if (!ref.dep) {
ref.dep = createDep();
}
{
trackEffects(ref.dep, {
target: ref,
type: "get" /* GET */,
key: 'value'
});
}
}
}
function triggerRefValue(ref, newVal) {
ref = toRaw(ref);
if (ref.dep) {
{
triggerEffects(ref.dep, {
target: ref,
type: "set" /* SET */,
key: 'value',
newValue: newVal
});
}
}
}
function isRef(r) {

@@ -738,3 +987,3 @@ return Boolean(r && r.__v_isRef === true);

function ref(value) {
return createRef(value);
return createRef(value, false);
}

@@ -744,29 +993,31 @@ function shallowRef(value) {

}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
class RefImpl {
constructor(_rawValue, _shallow = false) {
this._rawValue = _rawValue;
constructor(value, _shallow) {
this._shallow = _shallow;
this.dep = undefined;
this.__v_isRef = true;
this._value = _shallow ? _rawValue : convert(_rawValue);
this._rawValue = _shallow ? value : toRaw(value);
this._value = _shallow ? value : toReactive(value);
}
get value() {
track(toRaw(this), "get" /* GET */, 'value');
trackRefValue(this);
return this._value;
}
set value(newVal) {
if (shared.hasChanged(toRaw(newVal), this._rawValue)) {
newVal = this._shallow ? newVal : toRaw(newVal);
if (shared.hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = this._shallow ? newVal : convert(newVal);
trigger(toRaw(this), "set" /* SET */, 'value', newVal);
this._value = this._shallow ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
}
}
}
function createRef(rawValue, shallow = false) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(ref, "set" /* SET */, 'value', ref.value );
triggerRefValue(ref, ref.value );
}

@@ -796,4 +1047,5 @@ function unref(ref) {

constructor(factory) {
this.dep = undefined;
this.__v_isRef = true;
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value'));
const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
this._get = get;

@@ -813,3 +1065,3 @@ this._set = set;

function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);

@@ -837,5 +1089,4 @@ }

function toRef(object, key) {
return isRef(object[key])
? object[key]
: new ObjectRefImpl(object, key);
const val = object[key];
return isRef(val) ? val : new ObjectRefImpl(object, key);
}

@@ -846,11 +1097,9 @@

this._setter = _setter;
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this.effect = effect(getter, {
lazy: true,
scheduler: () => {
if (!this._dirty) {
this._dirty = true;
trigger(toRaw(this), "set" /* SET */, 'value');
}
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}

@@ -861,8 +1110,10 @@ });

get value() {
if (this._dirty) {
this._value = this.effect();
this._dirty = false;
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
const self = toRaw(this);
trackRefValue(self);
if (self._dirty) {
self._dirty = false;
self._value = self.effect.run();
}
track(toRaw(this), "get" /* GET */, 'value');
return this._value;
return self._value;
}

@@ -873,8 +1124,9 @@ set value(newValue) {

}
function computed(getterOrOptions) {
function computed(getterOrOptions, debugOptions) {
let getter;
let setter;
if (shared.isFunction(getterOrOptions)) {
const onlyGetter = shared.isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');

@@ -888,10 +1140,95 @@ }

}
return new ComputedRefImpl(getter, setter, shared.isFunction(getterOrOptions) || !getterOrOptions.set);
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
if (debugOptions) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
var _a;
const tick = Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this[_a] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
}
else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
// chained upstream computeds are notified synchronously to ensure
// value invalidation in case of sync access; normal effects are
// deferred to be triggered in scheduler.
for (const e of this.dep) {
if (e.computed) {
e.scheduler(true /* computedTrigger */);
}
}
}
this._dirty = true;
});
this.effect.computed = true;
}
_get() {
if (this._dirty) {
this._dirty = false;
return (this._value = this.effect.run());
}
return this._value;
}
get value() {
trackRefValue(this);
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
return toRaw(this)._get();
}
}
_a = "__v_isReadonly" /* IS_READONLY */;
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
exports.EffectScope = EffectScope;
exports.ITERATE_KEY = ITERATE_KEY;
exports.ReactiveEffect = ReactiveEffect;
exports.computed = computed;
exports.customRef = customRef;
exports.deferredComputed = deferredComputed;
exports.effect = effect;
exports.effectScope = effectScope;
exports.enableTracking = enableTracking;
exports.getCurrentScope = getCurrentScope;
exports.isProxy = isProxy;

@@ -902,2 +1239,3 @@ exports.isReactive = isReactive;

exports.markRaw = markRaw;
exports.onScopeDispose = onScopeDispose;
exports.pauseTracking = pauseTracking;

@@ -904,0 +1242,0 @@ exports.proxyRefs = proxyRefs;

@@ -7,59 +7,173 @@ 'use strict';

const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( '');
const MAP_KEY_ITERATE_KEY = Symbol( '');
function isEffect(fn) {
return fn && fn._isEffect === true;
let activeEffectScope;
const effectScopeStack = [];
class EffectScope {
constructor(detached = false) {
this.active = true;
this.effects = [];
this.cleanups = [];
if (!detached && activeEffectScope) {
this.parent = activeEffectScope;
this.index =
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
}
}
run(fn) {
if (this.active) {
try {
this.on();
return fn();
}
finally {
this.off();
}
}
}
on() {
if (this.active) {
effectScopeStack.push(this);
activeEffectScope = this;
}
}
off() {
if (this.active) {
effectScopeStack.pop();
activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
}
}
stop(fromParent) {
if (this.active) {
this.effects.forEach(e => e.stop());
this.cleanups.forEach(cleanup => cleanup());
if (this.scopes) {
this.scopes.forEach(e => e.stop(true));
}
// nested scope, dereference from parent to avoid memory leaks
if (this.parent && !fromParent) {
// optimized O(1) removal
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.active = false;
}
}
}
function effect(fn, options = shared.EMPTY_OBJ) {
if (isEffect(fn)) {
fn = fn.raw;
function effectScope(detached) {
return new EffectScope(detached);
}
function recordEffectScope(effect, scope) {
scope = scope || activeEffectScope;
if (scope && scope.active) {
scope.effects.push(effect);
}
const effect = createReactiveEffect(fn, options);
if (!options.lazy) {
effect();
}
function getCurrentScope() {
return activeEffectScope;
}
function onScopeDispose(fn) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn);
}
return effect;
}
function stop(effect) {
if (effect.active) {
cleanup(effect);
if (effect.options.onStop) {
effect.options.onStop();
const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit; // set was tracked
}
effect.active = false;
}
}
let uid = 0;
function createReactiveEffect(fn, options) {
const effect = function reactiveEffect() {
if (!effect.active) {
return options.scheduler ? undefined : fn();
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
}
else {
deps[ptr++] = dep;
}
// clear bits
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
if (!effectStack.includes(effect)) {
cleanup(effect);
deps.length = ptr;
}
};
const targetMap = new WeakMap();
// The number of effects currently being tracked recursively.
let effectTrackDepth = 0;
let trackOpBit = 1;
/**
* The bitwise track markers support at most 30 levels op recursion.
* This value is chosen to enable modern JS engines to use a SMI on all platforms.
* When recursion depth is greater, fall back to using a full cleanup.
*/
const maxMarkerBits = 30;
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol('');
const MAP_KEY_ITERATE_KEY = Symbol('');
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
this.fn = fn;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
recordEffectScope(this, scope);
}
run() {
if (!this.active) {
return this.fn();
}
if (!effectStack.includes(this)) {
try {
effectStack.push((activeEffect = this));
enableTracking();
effectStack.push(effect);
activeEffect = effect;
return fn();
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
}
else {
cleanupEffect(this);
}
return this.fn();
}
finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
resetTracking();
effectStack.pop();
resetTracking();
activeEffect = effectStack[effectStack.length - 1];
const n = effectStack.length;
activeEffect = n > 0 ? effectStack[n - 1] : undefined;
}
}
};
effect.id = uid++;
effect._isEffect = true;
effect.active = true;
effect.raw = fn;
effect.deps = [];
effect.options = options;
return effect;
}
stop() {
if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
this.active = false;
}
}
}
function cleanup(effect) {
function cleanupEffect(effect) {
const { deps } = effect;

@@ -73,2 +187,22 @@ if (deps.length) {

}
function effect(fn, options) {
if (fn.effect) {
fn = fn.effect.fn;
}
const _effect = new ReactiveEffect(fn);
if (options) {
shared.extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
}
if (!options || !options.lazy) {
_effect.run();
}
const runner = _effect.run.bind(_effect);
runner.effect = _effect;
return runner;
}
function stop(runner) {
runner.effect.stop();
}
let shouldTrack = true;

@@ -89,3 +223,3 @@ const trackStack = [];

function track(target, type, key) {
if (!shouldTrack || activeEffect === undefined) {
if (!isTracking()) {
return;

@@ -99,5 +233,22 @@ }

if (!dep) {
depsMap.set(key, (dep = new Set()));
depsMap.set(key, (dep = createDep()));
}
if (!dep.has(activeEffect)) {
trackEffects(dep);
}
function isTracking() {
return shouldTrack && activeEffect !== undefined;
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit; // set newly tracked
shouldTrack = !wasTracked(dep);
}
}
else {
// Full cleanup mode.
shouldTrack = !dep.has(activeEffect);
}
if (shouldTrack) {
dep.add(activeEffect);

@@ -113,16 +264,7 @@ activeEffect.deps.push(dep);

}
const effects = new Set();
const add = (effectsToAdd) => {
if (effectsToAdd) {
effectsToAdd.forEach(effect => {
if (effect !== activeEffect || effect.options.allowRecurse) {
effects.add(effect);
}
});
}
};
let deps = [];
if (type === "clear" /* CLEAR */) {
// collection being cleared
// trigger all effects for target
depsMap.forEach(add);
deps = [...depsMap.values()];
}

@@ -132,3 +274,3 @@ else if (key === 'length' && shared.isArray(target)) {

if (key === 'length' || key >= newValue) {
add(dep);
deps.push(dep);
}

@@ -140,3 +282,3 @@ });

if (key !== void 0) {
add(depsMap.get(key));
deps.push(depsMap.get(key));
}

@@ -147,5 +289,5 @@ // also run for iteration key on ADD | DELETE | Map.SET

if (!shared.isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (shared.isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -155,3 +297,3 @@ }

// new index added to array -> length changes
add(depsMap.get('length'));
deps.push(depsMap.get('length'));
}

@@ -161,5 +303,5 @@ break;

if (!shared.isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (shared.isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -170,3 +312,3 @@ }

if (shared.isMap(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
}

@@ -176,13 +318,36 @@ break;

}
const run = (effect) => {
if (effect.options.scheduler) {
effect.options.scheduler(effect);
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0]);
}
}
else {
effect();
}
else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
};
effects.forEach(run);
{
triggerEffects(createDep(effects));
}
}
}
function triggerEffects(dep, debuggerEventExtraInfo) {
// spread into array for stabilization
for (const effect of shared.isArray(dep) ? dep : [...dep]) {
if (effect !== activeEffect || effect.allowRecurse) {
if (effect.scheduler) {
effect.scheduler();
}
else {
effect.run();
}
}
}
}
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)

@@ -195,30 +360,32 @@ .map(key => Symbol[key])

const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
const arrayInstrumentations = {};
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
const arr = toRaw(this);
for (let i = 0, l = this.length; i < l; i++) {
track(arr, "get" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = method.apply(arr, args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return method.apply(arr, args.map(toRaw));
}
else {
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" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = arr[key](...args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return arr[key](...args.map(toRaw));
}
else {
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
instrumentations[key] = function (...args) {
pauseTracking();
const res = toRaw(this)[key].apply(this, args);
resetTracking();
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
pauseTracking();
const res = method.apply(this, args);
enableTracking();
return res;
};
});
};
});
return instrumentations;
}
function createGetter(isReadonly = false, shallow = false) {

@@ -233,14 +400,18 @@ return function get(target, key, receiver) {

else if (key === "__v_raw" /* RAW */ &&
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) {
receiver ===
(isReadonly
? shallow
? shallowReadonlyMap
: readonlyMap
: shallow
? shallowReactiveMap
: reactiveMap).get(target)) {
return target;
}
const targetIsArray = shared.isArray(target);
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
const keyIsSymbol = shared.isSymbol(key);
if (keyIsSymbol
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
if (shared.isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
return res;

@@ -272,5 +443,6 @@ }

return function set(target, key, value, receiver) {
const oldValue = target[key];
let oldValue = target[key];
if (!shallow) {
value = toRaw(value);
oldValue = toRaw(oldValue);
if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) {

@@ -299,3 +471,3 @@ oldValue.value = value;

const hadKey = shared.hasOwn(target, key);
const oldValue = target[key];
target[key];
const result = Reflect.deleteProperty(target, key);

@@ -315,3 +487,3 @@ if (result && hadKey) {

function ownKeys(target) {
track(target, "iterate" /* ITERATE */, ITERATE_KEY);
track(target, "iterate" /* ITERATE */, shared.isArray(target) ? 'length' : ITERATE_KEY);
return Reflect.ownKeys(target);

@@ -335,3 +507,3 @@ }

};
const shallowReactiveHandlers = shared.extend({}, mutableHandlers, {
const shallowReactiveHandlers = /*#__PURE__*/ shared.extend({}, mutableHandlers, {
get: shallowGet,

@@ -343,8 +515,6 @@ set: shallowSet

// retain the reactivity of the normal readonly object.
const shallowReadonlyHandlers = shared.extend({}, readonlyHandlers, {
const shallowReadonlyHandlers = /*#__PURE__*/ shared.extend({}, readonlyHandlers, {
get: shallowReadonlyGet
});
const toReactive = (value) => shared.isObject(value) ? reactive(value) : value;
const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
const toShallow = (value) => value;

@@ -363,3 +533,3 @@ const getProto = (v) => Reflect.getPrototypeOf(v);

const { has } = getProto(rawTarget);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
if (has.call(rawTarget, key)) {

@@ -371,2 +541,7 @@ return wrap(target.get(key));

}
else if (target !== rawTarget) {
// #3602 readonly(reactive(Map))
// ensure that the nested reactive `Map` can do tracking for itself
target.get(key);
}
}

@@ -395,7 +570,7 @@ function has$1(key, isReadonly = false) {

const hadKey = proto.has.call(target, value);
const result = target.add(value);
if (!hadKey) {
target.add(value);
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}

@@ -412,3 +587,3 @@ function set$1(key, value) {

const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {

@@ -420,3 +595,3 @@ trigger(target, "add" /* ADD */, key, value);

}
return result;
return this;
}

@@ -431,3 +606,3 @@ function deleteEntry(key) {

}
const oldValue = get ? get.call(target, key) : undefined;
get ? get.call(target, key) : undefined;
// forward the operation before queueing reactions

@@ -455,3 +630,3 @@ const result = target.delete(key);

const rawTarget = toRaw(target);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);

@@ -474,3 +649,3 @@ return target.forEach((value, key) => {

const innerIterator = target[method](...args);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly &&

@@ -503,55 +678,83 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);

}
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
});
function createInstrumentations() {
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations = {
get(key) {
return get$1(this, key, true, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, true)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
});
return [
mutableInstrumentations,
readonlyInstrumentations,
shallowInstrumentations,
shallowReadonlyInstrumentations
];
}
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
function createInstrumentationGetter(isReadonly, shallow) {
const instrumentations = shallow
? shallowInstrumentations
? isReadonly
? shallowReadonlyInstrumentations
: shallowInstrumentations
: isReadonly

@@ -576,13 +779,18 @@ ? readonlyInstrumentations

const mutableCollectionHandlers = {
get: createInstrumentationGetter(false, false)
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
};
const shallowCollectionHandlers = {
get: createInstrumentationGetter(false, true)
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
};
const readonlyCollectionHandlers = {
get: createInstrumentationGetter(true, false)
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
};
const shallowReadonlyCollectionHandlers = {
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
};
const reactiveMap = new WeakMap();
const shallowReactiveMap = new WeakMap();
const readonlyMap = new WeakMap();
const shallowReadonlyMap = new WeakMap();
function targetTypeMap(rawType) {

@@ -612,21 +820,29 @@ switch (rawType) {

}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
}
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
if (!shared.isObject(target)) {

@@ -642,3 +858,2 @@ return target;

// target already has corresponding Proxy
const proxyMap = isReadonly ? readonlyMap : reactiveMap;
const existingProxy = proxyMap.get(target);

@@ -670,3 +885,4 @@ if (existingProxy) {

function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
const raw = observed && observed["__v_raw" /* RAW */];
return raw ? toRaw(raw) : observed;
}

@@ -677,4 +893,24 @@ function markRaw(value) {

}
const toReactive = (value) => shared.isObject(value) ? reactive(value) : value;
const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value;
const convert = (val) => shared.isObject(val) ? reactive(val) : val;
function trackRefValue(ref) {
if (isTracking()) {
ref = toRaw(ref);
if (!ref.dep) {
ref.dep = createDep();
}
{
trackEffects(ref.dep);
}
}
}
function triggerRefValue(ref, newVal) {
ref = toRaw(ref);
if (ref.dep) {
{
triggerEffects(ref.dep);
}
}
}
function isRef(r) {

@@ -684,3 +920,3 @@ return Boolean(r && r.__v_isRef === true);

function ref(value) {
return createRef(value);
return createRef(value, false);
}

@@ -690,29 +926,31 @@ function shallowRef(value) {

}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
class RefImpl {
constructor(_rawValue, _shallow = false) {
this._rawValue = _rawValue;
constructor(value, _shallow) {
this._shallow = _shallow;
this.dep = undefined;
this.__v_isRef = true;
this._value = _shallow ? _rawValue : convert(_rawValue);
this._rawValue = _shallow ? value : toRaw(value);
this._value = _shallow ? value : toReactive(value);
}
get value() {
track(toRaw(this), "get" /* GET */, 'value');
trackRefValue(this);
return this._value;
}
set value(newVal) {
if (shared.hasChanged(toRaw(newVal), this._rawValue)) {
newVal = this._shallow ? newVal : toRaw(newVal);
if (shared.hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = this._shallow ? newVal : convert(newVal);
trigger(toRaw(this), "set" /* SET */, 'value', newVal);
this._value = this._shallow ? newVal : toReactive(newVal);
triggerRefValue(this);
}
}
}
function createRef(rawValue, shallow = false) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(ref, "set" /* SET */, 'value', void 0);
triggerRefValue(ref);
}

@@ -742,4 +980,5 @@ function unref(ref) {

constructor(factory) {
this.dep = undefined;
this.__v_isRef = true;
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value'));
const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
this._get = get;

@@ -779,5 +1018,4 @@ this._set = set;

function toRef(object, key) {
return isRef(object[key])
? object[key]
: new ObjectRefImpl(object, key);
const val = object[key];
return isRef(val) ? val : new ObjectRefImpl(object, key);
}

@@ -788,11 +1026,9 @@

this._setter = _setter;
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this.effect = effect(getter, {
lazy: true,
scheduler: () => {
if (!this._dirty) {
this._dirty = true;
trigger(toRaw(this), "set" /* SET */, 'value');
}
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}

@@ -803,8 +1039,10 @@ });

get value() {
if (this._dirty) {
this._value = this.effect();
this._dirty = false;
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
const self = toRaw(this);
trackRefValue(self);
if (self._dirty) {
self._dirty = false;
self._value = self.effect.run();
}
track(toRaw(this), "get" /* GET */, 'value');
return this._value;
return self._value;
}

@@ -815,8 +1053,9 @@ set value(newValue) {

}
function computed(getterOrOptions) {
function computed(getterOrOptions, debugOptions) {
let getter;
let setter;
if (shared.isFunction(getterOrOptions)) {
const onlyGetter = shared.isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = shared.NOOP;
setter = shared.NOOP;
}

@@ -827,10 +1066,91 @@ else {

}
return new ComputedRefImpl(getter, setter, shared.isFunction(getterOrOptions) || !getterOrOptions.set);
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
return cRef;
}
var _a;
const tick = Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this[_a] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
}
else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
// chained upstream computeds are notified synchronously to ensure
// value invalidation in case of sync access; normal effects are
// deferred to be triggered in scheduler.
for (const e of this.dep) {
if (e.computed) {
e.scheduler(true /* computedTrigger */);
}
}
}
this._dirty = true;
});
this.effect.computed = true;
}
_get() {
if (this._dirty) {
this._dirty = false;
return (this._value = this.effect.run());
}
return this._value;
}
get value() {
trackRefValue(this);
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
return toRaw(this)._get();
}
}
_a = "__v_isReadonly" /* IS_READONLY */;
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
exports.EffectScope = EffectScope;
exports.ITERATE_KEY = ITERATE_KEY;
exports.ReactiveEffect = ReactiveEffect;
exports.computed = computed;
exports.customRef = customRef;
exports.deferredComputed = deferredComputed;
exports.effect = effect;
exports.effectScope = effectScope;
exports.enableTracking = enableTracking;
exports.getCurrentScope = getCurrentScope;
exports.isProxy = isProxy;

@@ -841,2 +1161,3 @@ exports.isReactive = isReactive;

exports.markRaw = markRaw;
exports.onScopeDispose = onScopeDispose;
exports.pauseTracking = pauseTracking;

@@ -843,0 +1164,0 @@ exports.proxyRefs = proxyRefs;

@@ -1,2 +0,1 @@

declare type BaseTypes = string | number | boolean;

@@ -8,10 +7,13 @@

export declare function computed<T>(getter: ComputedGetter<T>): ComputedRef<T>;
declare const ComoutedRefSymbol: unique symbol;
export declare function computed<T>(options: WritableComputedOptions<T>): WritableComputedRef<T>;
export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
export declare type ComputedGetter<T> = (ctx?: any) => T;
export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
export declare type ComputedGetter<T> = (...args: any[]) => T;
export declare interface ComputedRef<T = any> extends WritableComputedRef<T> {
readonly value: T;
[ComoutedRefSymbol]: true;
}

@@ -30,11 +32,16 @@

effect: ReactiveEffect;
} & DebuggerEventExtraInfo;
export declare type DebuggerEventExtraInfo = {
target: object;
type: TrackOpTypes | TriggerOpTypes;
key: any;
} & DebuggerEventExtraInfo;
declare interface DebuggerEventExtraInfo {
newValue?: any;
oldValue?: any;
oldTarget?: Map<any, any> | Set<any>;
};
export declare interface DebuggerOptions {
onTrack?: (event: DebuggerEvent) => void;
onTrigger?: (event: DebuggerEvent) => void;
}

@@ -46,8 +53,34 @@

declare type Dep = Set<ReactiveEffect>;
export declare function deferredComputed<T>(getter: () => T): ComputedRef<T>;
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffect<T>;
declare type Dep = Set<ReactiveEffect> & TrackedMarkers;
export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner;
export declare type EffectScheduler = (...args: any[]) => any;
export declare class EffectScope {
active: boolean;
effects: ReactiveEffect[];
cleanups: (() => void)[];
parent: EffectScope | undefined;
scopes: EffectScope[] | undefined;
/**
* track a child scope's index in its parent's scopes array for optimized
* removal
*/
private index;
constructor(detached?: boolean);
run<T>(fn: () => T): T | undefined;
on(): void;
off(): void;
stop(fromParent?: boolean): void;
}
export declare function effectScope(detached?: boolean): EffectScope;
export declare function enableTracking(): void;
export declare function getCurrentScope(): EffectScope | undefined;
export declare function isProxy(value: unknown): boolean;

@@ -67,2 +100,4 @@

export declare function onScopeDispose(fn: () => void): void;
export declare function pauseTracking(): void;

@@ -74,23 +109,54 @@

/**
* Creates a reactive copy of the original object.
*
* The reactive conversion is "deep"—it affects all nested properties. In the
* ES2015 Proxy based implementation, the returned proxy is **not** equal to the
* original object. It is recommended to work exclusively with the reactive
* proxy and avoid relying on the original object.
*
* A reactive object also automatically unwraps refs contained in it, so you
* don't need to use `.value` when accessing and mutating their value:
*
* ```js
* const count = ref(0)
* const obj = reactive({
* count
* })
*
* obj.count++
* obj.count // -> 1
* count.value // -> 1
* ```
*/
export declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
export declare interface ReactiveEffect<T = any> {
(): T;
_isEffect: true;
id: number;
export declare class ReactiveEffect<T = any> {
fn: () => T;
scheduler: EffectScheduler | null;
active: boolean;
raw: () => T;
deps: Array<Dep>;
options: ReactiveEffectOptions;
deps: Dep[];
computed?: boolean;
allowRecurse?: boolean;
onStop?: () => void;
onTrack?: (event: DebuggerEvent) => void;
onTrigger?: (event: DebuggerEvent) => void;
constructor(fn: () => T, scheduler?: EffectScheduler | null, scope?: EffectScope | null);
run(): T | undefined;
stop(): void;
}
export declare interface ReactiveEffectOptions {
export declare interface ReactiveEffectOptions extends DebuggerOptions {
lazy?: boolean;
scheduler?: (job: ReactiveEffect) => void;
onTrack?: (event: DebuggerEvent) => void;
onTrigger?: (event: DebuggerEvent) => void;
scheduler?: EffectScheduler;
scope?: EffectScope;
allowRecurse?: boolean;
onStop?: () => void;
allowRecurse?: boolean;
}
export declare interface ReactiveEffectRunner<T = any> {
(): T;
effect: ReactiveEffect;
}
export declare const enum ReactiveFlags {

@@ -103,5 +169,10 @@ SKIP = "__v_skip",

/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
export declare interface Ref<T = any> {
value: T;
/**

@@ -113,6 +184,6 @@ * Type differentiator only.

[RefSymbol]: true;
value: T;
/* Excluded from this release type: _shallow */
}
export declare function ref<T extends object>(value: T): T extends Ref ? T : Ref<UnwrapRef<T>>;
export declare function ref<T extends object>(value: T): ToRef<T>;

@@ -147,4 +218,15 @@ export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;

/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
export declare function shallowReactive<T extends object>(target: T): T;
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
export declare function shallowReadonly<T extends object>(target: T): Readonly<{

@@ -161,68 +243,16 @@ [K in keyof T]: UnwrapNestedRefs<T[K]>;

export declare type ShallowUnwrapRef<T> = {
[K in keyof T]: T[K] extends Ref<infer V> ? V : T[K];
[K in keyof T]: T[K] extends Ref<infer V> ? V : T[K] extends Ref<infer V> | undefined ? unknown extends V ? undefined : V | undefined : T[K];
};
declare function stop_2(effect: ReactiveEffect): void;
declare function stop_2(runner: ReactiveEffectRunner): void;
export { stop_2 as stop }
declare type SymbolExtract<T> = (T extends {
[Symbol.asyncIterator]: infer V;
} ? {
[Symbol.asyncIterator]: V;
} : {}) & (T extends {
[Symbol.hasInstance]: infer V;
} ? {
[Symbol.hasInstance]: V;
} : {}) & (T extends {
[Symbol.isConcatSpreadable]: infer V;
} ? {
[Symbol.isConcatSpreadable]: V;
} : {}) & (T extends {
[Symbol.iterator]: infer V;
} ? {
[Symbol.iterator]: V;
} : {}) & (T extends {
[Symbol.match]: infer V;
} ? {
[Symbol.match]: V;
} : {}) & (T extends {
[Symbol.matchAll]: infer V;
} ? {
[Symbol.matchAll]: V;
} : {}) & (T extends {
[Symbol.replace]: infer V;
} ? {
[Symbol.replace]: V;
} : {}) & (T extends {
[Symbol.search]: infer V;
} ? {
[Symbol.search]: V;
} : {}) & (T extends {
[Symbol.species]: infer V;
} ? {
[Symbol.species]: V;
} : {}) & (T extends {
[Symbol.split]: infer V;
} ? {
[Symbol.split]: V;
} : {}) & (T extends {
[Symbol.toPrimitive]: infer V;
} ? {
[Symbol.toPrimitive]: V;
} : {}) & (T extends {
[Symbol.toStringTag]: infer V;
} ? {
[Symbol.toStringTag]: V;
} : {}) & (T extends {
[Symbol.unscopables]: infer V;
} ? {
[Symbol.unscopables]: V;
} : {});
export declare function toRaw<T>(observed: T): T;
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): Ref<T[K]>;
export declare type ToRef<T> = [T] extends [Ref] ? T : Ref<UnwrapRef<T>>;
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
export declare type ToRefs<T = any> = {
[K in keyof T]: Ref<T[K]>;
[K in keyof T]: T[K] extends Ref ? T[K] : Ref<UnwrapRef<T[K]>>;
};

@@ -234,2 +264,18 @@

/**
* wasTracked and newTracked maintain the status for several levels of effect
* tracking recursion. One bit per level is used to define whether the dependency
* was/is tracked.
*/
declare type TrackedMarkers = {
/**
* wasTracked
*/
w: number;
/**
* newTracked
*/
n: number;
};
export declare const enum TrackOpTypes {

@@ -252,10 +298,6 @@ GET = "get",

export declare function unref<T>(ref: T): T extends Ref<infer V> ? V : T;
export declare function unref<T>(ref: T | Ref<T>): T;
declare type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRef<T>;
export declare type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;
declare type UnwrappedObject<T> = {
[P in keyof T]: UnwrapRef<T[P]>;
} & SymbolExtract<T>;
export declare type UnwrapRef<T> = T extends Ref<infer V> ? UnwrapRefSimple<V> : UnwrapRefSimple<T>;

@@ -265,3 +307,5 @@

[K in keyof T]: UnwrapRefSimple<T[K]>;
} : T extends object ? UnwrappedObject<T> : T;
} : T extends object ? {
[P in keyof T]: P extends symbol ? T[P] : UnwrapRef<T[P]>;
} : T;

@@ -268,0 +312,0 @@ declare type WeakCollections = WeakMap<any, any> | WeakSet<any>;

@@ -1,3 +0,20 @@

const EMPTY_OBJ = Object.freeze({})
/**
* Make a map and return a function for checking if a key
* is in that map.
* IMPORTANT: all calls of this function must be prefixed with
* \/\*#\_\_PURE\_\_\*\/
* So that rollup can tree-shake them if necessary.
*/
function makeMap(str, expectsLowerCase) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
Object.freeze({})
;
Object.freeze([]) ;
const extend = Object.assign;

@@ -15,2 +32,3 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;

const toRawType = (value) => {
// extract "RawType" from strings like "[object RawType]"
return toTypeString(value).slice(8, -1);

@@ -32,7 +50,5 @@ };

*/
const capitalize = cacheStringFunction((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
// compare whether a value has changed, accounting for NaN.
const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
const def = (obj, key, value) => {

@@ -46,59 +62,184 @@ Object.defineProperty(obj, key, {

const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
function warn(msg, ...args) {
console.warn(`[Vue warn] ${msg}`, ...args);
}
function effect(fn, options = EMPTY_OBJ) {
if (isEffect(fn)) {
fn = fn.raw;
let activeEffectScope;
const effectScopeStack = [];
class EffectScope {
constructor(detached = false) {
this.active = true;
this.effects = [];
this.cleanups = [];
if (!detached && activeEffectScope) {
this.parent = activeEffectScope;
this.index =
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
}
}
const effect = createReactiveEffect(fn, options);
if (!options.lazy) {
effect();
run(fn) {
if (this.active) {
try {
this.on();
return fn();
}
finally {
this.off();
}
}
else {
warn(`cannot run an inactive effect scope.`);
}
}
return effect;
}
function stop(effect) {
if (effect.active) {
cleanup(effect);
if (effect.options.onStop) {
effect.options.onStop();
on() {
if (this.active) {
effectScopeStack.push(this);
activeEffectScope = this;
}
effect.active = false;
}
off() {
if (this.active) {
effectScopeStack.pop();
activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
}
}
stop(fromParent) {
if (this.active) {
this.effects.forEach(e => e.stop());
this.cleanups.forEach(cleanup => cleanup());
if (this.scopes) {
this.scopes.forEach(e => e.stop(true));
}
// nested scope, dereference from parent to avoid memory leaks
if (this.parent && !fromParent) {
// optimized O(1) removal
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.active = false;
}
}
}
let uid = 0;
function createReactiveEffect(fn, options) {
const effect = function reactiveEffect() {
if (!effect.active) {
return options.scheduler ? undefined : fn();
function effectScope(detached) {
return new EffectScope(detached);
}
function recordEffectScope(effect, scope) {
scope = scope || activeEffectScope;
if (scope && scope.active) {
scope.effects.push(effect);
}
}
function getCurrentScope() {
return activeEffectScope;
}
function onScopeDispose(fn) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn);
}
else {
warn(`onScopeDispose() is called when there is no active effect scope` +
` to be associated with.`);
}
}
const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit; // set was tracked
}
if (!effectStack.includes(effect)) {
cleanup(effect);
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
}
else {
deps[ptr++] = dep;
}
// clear bits
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = new WeakMap();
// The number of effects currently being tracked recursively.
let effectTrackDepth = 0;
let trackOpBit = 1;
/**
* The bitwise track markers support at most 30 levels op recursion.
* This value is chosen to enable modern JS engines to use a SMI on all platforms.
* When recursion depth is greater, fall back to using a full cleanup.
*/
const maxMarkerBits = 30;
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
this.fn = fn;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
recordEffectScope(this, scope);
}
run() {
if (!this.active) {
return this.fn();
}
if (!effectStack.includes(this)) {
try {
effectStack.push((activeEffect = this));
enableTracking();
effectStack.push(effect);
activeEffect = effect;
return fn();
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
}
else {
cleanupEffect(this);
}
return this.fn();
}
finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
resetTracking();
effectStack.pop();
resetTracking();
activeEffect = effectStack[effectStack.length - 1];
const n = effectStack.length;
activeEffect = n > 0 ? effectStack[n - 1] : undefined;
}
}
};
effect.id = uid++;
effect._isEffect = true;
effect.active = true;
effect.raw = fn;
effect.deps = [];
effect.options = options;
return effect;
}
stop() {
if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
this.active = false;
}
}
}
function cleanup(effect) {
function cleanupEffect(effect) {
const { deps } = effect;

@@ -112,2 +253,22 @@ if (deps.length) {

}
function effect(fn, options) {
if (fn.effect) {
fn = fn.effect.fn;
}
const _effect = new ReactiveEffect(fn);
if (options) {
extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
}
if (!options || !options.lazy) {
_effect.run();
}
const runner = _effect.run.bind(_effect);
runner.effect = _effect;
return runner;
}
function stop(runner) {
runner.effect.stop();
}
let shouldTrack = true;

@@ -128,3 +289,3 @@ const trackStack = [];

function track(target, type, key) {
if (!shouldTrack || activeEffect === undefined) {
if (!isTracking()) {
return;

@@ -138,14 +299,30 @@ }

if (!dep) {
depsMap.set(key, (dep = new Set()));
depsMap.set(key, (dep = createDep()));
}
if (!dep.has(activeEffect)) {
const eventInfo = { effect: activeEffect, target, type, key }
;
trackEffects(dep, eventInfo);
}
function isTracking() {
return shouldTrack && activeEffect !== undefined;
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit; // set newly tracked
shouldTrack = !wasTracked(dep);
}
}
else {
// Full cleanup mode.
shouldTrack = !dep.has(activeEffect);
}
if (shouldTrack) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
type,
key
});
if (activeEffect.onTrack) {
activeEffect.onTrack(Object.assign({
effect: activeEffect
}, debuggerEventExtraInfo));
}

@@ -160,16 +337,7 @@ }

}
const effects = new Set();
const add = (effectsToAdd) => {
if (effectsToAdd) {
effectsToAdd.forEach(effect => {
if (effect !== activeEffect || effect.options.allowRecurse) {
effects.add(effect);
}
});
}
};
let deps = [];
if (type === "clear" /* CLEAR */) {
// collection being cleared
// trigger all effects for target
depsMap.forEach(add);
deps = [...depsMap.values()];
}

@@ -179,3 +347,3 @@ else if (key === 'length' && isArray(target)) {

if (key === 'length' || key >= newValue) {
add(dep);
deps.push(dep);
}

@@ -187,3 +355,3 @@ });

if (key !== void 0) {
add(depsMap.get(key));
deps.push(depsMap.get(key));
}

@@ -194,5 +362,5 @@ // also run for iteration key on ADD | DELETE | Map.SET

if (!isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -202,3 +370,3 @@ }

// new index added to array -> length changes
add(depsMap.get('length'));
deps.push(depsMap.get('length'));
}

@@ -208,5 +376,5 @@ break;

if (!isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -217,3 +385,3 @@ }

if (isMap(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
}

@@ -223,24 +391,41 @@ break;

}
const run = (effect) => {
if ( effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
key,
type,
newValue,
oldValue,
oldTarget
});
const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
;
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0], eventInfo);
}
}
if (effect.options.scheduler) {
effect.options.scheduler(effect);
}
else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
else {
effect();
{
triggerEffects(createDep(effects), eventInfo);
}
};
effects.forEach(run);
}
}
function triggerEffects(dep, debuggerEventExtraInfo) {
// spread into array for stabilization
for (const effect of isArray(dep) ? dep : [...dep]) {
if (effect !== activeEffect || effect.allowRecurse) {
if (effect.onTrigger) {
effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
}
if (effect.scheduler) {
effect.scheduler();
}
else {
effect.run();
}
}
}
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)

@@ -253,30 +438,32 @@ .map(key => Symbol[key])

const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
const arrayInstrumentations = {};
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
const arr = toRaw(this);
for (let i = 0, l = this.length; i < l; i++) {
track(arr, "get" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = method.apply(arr, args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return method.apply(arr, args.map(toRaw));
}
else {
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" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = arr[key](...args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return arr[key](...args.map(toRaw));
}
else {
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
instrumentations[key] = function (...args) {
pauseTracking();
const res = toRaw(this)[key].apply(this, args);
resetTracking();
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
pauseTracking();
const res = method.apply(this, args);
enableTracking();
return res;
};
});
};
});
return instrumentations;
}
function createGetter(isReadonly = false, shallow = false) {

@@ -291,14 +478,18 @@ return function get(target, key, receiver) {

else if (key === "__v_raw" /* RAW */ &&
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) {
receiver ===
(isReadonly
? shallow
? shallowReadonlyMap
: readonlyMap
: shallow
? shallowReactiveMap
: reactiveMap).get(target)) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
const keyIsSymbol = isSymbol(key);
if (keyIsSymbol
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
return res;

@@ -330,5 +521,6 @@ }

return function set(target, key, value, receiver) {
const oldValue = target[key];
let oldValue = target[key];
if (!shallow) {
value = toRaw(value);
oldValue = toRaw(oldValue);
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {

@@ -372,3 +564,3 @@ oldValue.value = value;

function ownKeys(target) {
track(target, "iterate" /* ITERATE */, ITERATE_KEY);
track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
return Reflect.ownKeys(target);

@@ -398,3 +590,3 @@ }

};
const shallowReactiveHandlers = extend({}, mutableHandlers, {
const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
get: shallowGet,

@@ -406,8 +598,6 @@ set: shallowSet

// retain the reactivity of the normal readonly object.
const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
get: shallowReadonlyGet
});
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
const toShallow = (value) => value;

@@ -426,3 +616,3 @@ const getProto = (v) => Reflect.getPrototypeOf(v);

const { has } = getProto(rawTarget);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
if (has.call(rawTarget, key)) {

@@ -434,2 +624,7 @@ return wrap(target.get(key));

}
else if (target !== rawTarget) {
// #3602 readonly(reactive(Map))
// ensure that the nested reactive `Map` can do tracking for itself
target.get(key);
}
}

@@ -458,7 +653,7 @@ function has$1(key, isReadonly = false) {

const hadKey = proto.has.call(target, value);
const result = target.add(value);
if (!hadKey) {
target.add(value);
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}

@@ -478,3 +673,3 @@ function set$1(key, value) {

const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {

@@ -486,3 +681,3 @@ trigger(target, "add" /* ADD */, key, value);

}
return result;
return this;
}

@@ -511,3 +706,3 @@ function deleteEntry(key) {

const hadItems = target.size !== 0;
const oldTarget = isMap(target)
const oldTarget = isMap(target)
? new Map(target)

@@ -528,3 +723,3 @@ : new Set(target)

const rawTarget = toRaw(target);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);

@@ -547,3 +742,3 @@ return target.forEach((value, key) => {

const innerIterator = target[method](...args);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly &&

@@ -580,55 +775,83 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);

}
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
});
function createInstrumentations() {
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations = {
get(key) {
return get$1(this, key, true, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, true)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
});
return [
mutableInstrumentations,
readonlyInstrumentations,
shallowInstrumentations,
shallowReadonlyInstrumentations
];
}
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
function createInstrumentationGetter(isReadonly, shallow) {
const instrumentations = shallow
? shallowInstrumentations
? isReadonly
? shallowReadonlyInstrumentations
: shallowInstrumentations
: isReadonly

@@ -653,10 +876,13 @@ ? readonlyInstrumentations

const mutableCollectionHandlers = {
get: createInstrumentationGetter(false, false)
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
};
const shallowCollectionHandlers = {
get: createInstrumentationGetter(false, true)
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
};
const readonlyCollectionHandlers = {
get: createInstrumentationGetter(true, false)
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
};
const shallowReadonlyCollectionHandlers = {
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
};
function checkIdentityKeys(target, has, key) {

@@ -667,3 +893,3 @@ const rawKey = toRaw(key);

console.warn(`Reactive ${type} contains both the raw and reactive ` +
`versions of the same object${type === `Map` ? `as keys` : ``}, ` +
`versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
`which can lead to inconsistencies. ` +

@@ -676,3 +902,5 @@ `Avoid differentiating between the raw and reactive versions ` +

const reactiveMap = new WeakMap();
const shallowReactiveMap = new WeakMap();
const readonlyMap = new WeakMap();
const shallowReadonlyMap = new WeakMap();
function targetTypeMap(rawType) {

@@ -702,21 +930,29 @@ switch (rawType) {

}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
}
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
if (!isObject(target)) {

@@ -735,3 +971,2 @@ {

// target already has corresponding Proxy
const proxyMap = isReadonly ? readonlyMap : reactiveMap;
const existingProxy = proxyMap.get(target);

@@ -763,3 +998,4 @@ if (existingProxy) {

function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
const raw = observed && observed["__v_raw" /* RAW */];
return raw ? toRaw(raw) : observed;
}

@@ -770,4 +1006,33 @@ function markRaw(value) {

}
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
const convert = (val) => isObject(val) ? reactive(val) : val;
function trackRefValue(ref) {
if (isTracking()) {
ref = toRaw(ref);
if (!ref.dep) {
ref.dep = createDep();
}
{
trackEffects(ref.dep, {
target: ref,
type: "get" /* GET */,
key: 'value'
});
}
}
}
function triggerRefValue(ref, newVal) {
ref = toRaw(ref);
if (ref.dep) {
{
triggerEffects(ref.dep, {
target: ref,
type: "set" /* SET */,
key: 'value',
newValue: newVal
});
}
}
}
function isRef(r) {

@@ -777,3 +1042,3 @@ return Boolean(r && r.__v_isRef === true);

function ref(value) {
return createRef(value);
return createRef(value, false);
}

@@ -783,29 +1048,31 @@ function shallowRef(value) {

}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
class RefImpl {
constructor(_rawValue, _shallow = false) {
this._rawValue = _rawValue;
constructor(value, _shallow) {
this._shallow = _shallow;
this.dep = undefined;
this.__v_isRef = true;
this._value = _shallow ? _rawValue : convert(_rawValue);
this._rawValue = _shallow ? value : toRaw(value);
this._value = _shallow ? value : toReactive(value);
}
get value() {
track(toRaw(this), "get" /* GET */, 'value');
trackRefValue(this);
return this._value;
}
set value(newVal) {
if (hasChanged(toRaw(newVal), this._rawValue)) {
newVal = this._shallow ? newVal : toRaw(newVal);
if (hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = this._shallow ? newVal : convert(newVal);
trigger(toRaw(this), "set" /* SET */, 'value', newVal);
this._value = this._shallow ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
}
}
}
function createRef(rawValue, shallow = false) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(ref, "set" /* SET */, 'value', ref.value );
triggerRefValue(ref, ref.value );
}

@@ -835,4 +1102,5 @@ function unref(ref) {

constructor(factory) {
this.dep = undefined;
this.__v_isRef = true;
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value'));
const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
this._get = get;

@@ -852,3 +1120,3 @@ this._set = set;

function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);

@@ -876,5 +1144,4 @@ }

function toRef(object, key) {
return isRef(object[key])
? object[key]
: new ObjectRefImpl(object, key);
const val = object[key];
return isRef(val) ? val : new ObjectRefImpl(object, key);
}

@@ -885,11 +1152,9 @@

this._setter = _setter;
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this.effect = effect(getter, {
lazy: true,
scheduler: () => {
if (!this._dirty) {
this._dirty = true;
trigger(toRaw(this), "set" /* SET */, 'value');
}
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}

@@ -900,8 +1165,10 @@ });

get value() {
if (this._dirty) {
this._value = this.effect();
this._dirty = false;
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
const self = toRaw(this);
trackRefValue(self);
if (self._dirty) {
self._dirty = false;
self._value = self.effect.run();
}
track(toRaw(this), "get" /* GET */, 'value');
return this._value;
return self._value;
}

@@ -912,8 +1179,9 @@ set value(newValue) {

}
function computed(getterOrOptions) {
function computed(getterOrOptions, debugOptions) {
let getter;
let setter;
if (isFunction(getterOrOptions)) {
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');

@@ -927,5 +1195,85 @@ }

}
return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
if (debugOptions) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
export { ITERATE_KEY, computed, customRef, effect, enableTracking, isProxy, isReactive, isReadonly, isRef, markRaw, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref };
var _a;
const tick = Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this[_a] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
}
else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
// chained upstream computeds are notified synchronously to ensure
// value invalidation in case of sync access; normal effects are
// deferred to be triggered in scheduler.
for (const e of this.dep) {
if (e.computed) {
e.scheduler(true /* computedTrigger */);
}
}
}
this._dirty = true;
});
this.effect.computed = true;
}
_get() {
if (this._dirty) {
this._dirty = false;
return (this._value = this.effect.run());
}
return this._value;
}
get value() {
trackRefValue(this);
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
return toRaw(this)._get();
}
}
_a = "__v_isReadonly" /* IS_READONLY */;
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
export { EffectScope, ITERATE_KEY, ReactiveEffect, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, markRaw, onScopeDispose, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref };

@@ -1,1 +0,1 @@

const t={},e=()=>{},n=Object.assign,r=Object.prototype.hasOwnProperty,s=(t,e)=>r.call(t,e),i=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),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,h=(t,e)=>t!==e&&(t==t||e==e),v=new WeakMap,d=[];let p;const g=Symbol(""),y=Symbol("");function w(e,n=t){(function(t){return t&&!0===t._isEffect})(e)&&(e=e.raw);const r=function(t,e){const n=function(){if(!n.active)return e.scheduler?void 0:t();if(!d.includes(n)){S(n);try{return j(),d.push(n),p=n,t()}finally{d.pop(),O(),p=d[d.length-1]}}};return n.id=b++,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(e,n);return n.lazy||r(),r}function R(t){t.active&&(S(t),t.options.onStop&&t.options.onStop(),t.active=!1)}let b=0;function S(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let k=!0;const E=[];function m(){E.push(k),k=!1}function j(){E.push(k),k=!0}function O(){const t=E.pop();k=void 0===t||t}function P(t,e,n){if(!k||void 0===p)return;let r=v.get(t);r||v.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(p)||(s.add(p),p.deps.push(s))}function x(t,e,n,r,s,c){const u=v.get(t);if(!u)return;const a=new Set,l=t=>{t&&t.forEach(t=>{(t!==p||t.options.allowRecurse)&&a.add(t)})};if("clear"===e)u.forEach(l);else if("length"===n&&i(t))u.forEach((t,e)=>{("length"===e||e>=r)&&l(t)});else switch(void 0!==n&&l(u.get(n)),e){case"add":i(t)?_(n)&&l(u.get("length")):(l(u.get(g)),o(t)&&l(u.get(y)));break;case"delete":i(t)||(l(u.get(g)),o(t)&&l(u.get(y)));break;case"set":o(t)&&l(u.get(g))}a.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const z=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(u)),M=I(),A=I(!1,!0),W=I(!0),N=I(!0,!0),V={};function I(t=!1,e=!1){return function(n,r,o){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&o===(t?lt:at).get(n))return n;const c=i(n);if(c&&s(V,r))return Reflect.get(V,r,o);const l=Reflect.get(n,r,o);if(u(r)?z.has(r):"__proto__"===r||"__v_isRef"===r)return l;if(t||P(n,0,r),e)return l;if(kt(l)){return!c||!_(r)?l.value:l}return a(l)?t?vt(l):_t(l):l}}["includes","indexOf","lastIndexOf"].forEach(t=>{const e=Array.prototype[t];V[t]=function(...t){const n=Rt(this);for(let t=0,e=this.length;t<e;t++)P(n,0,t+"");const r=e.apply(n,t);return-1===r||!1===r?e.apply(n,t.map(Rt)):r}}),["push","pop","shift","unshift","splice"].forEach(t=>{const e=Array.prototype[t];V[t]=function(...t){m();const n=e.apply(this,t);return j(),n}});function K(t=!1){return function(e,n,r,o){const c=e[n];if(!t&&(r=Rt(r),!i(e)&&kt(c)&&!kt(r)))return c.value=r,!0;const u=i(e)&&_(n)?Number(n)<e.length:s(e,n),a=Reflect.set(e,n,r,o);return e===Rt(o)&&(u?h(r,c)&&x(e,"set",n,r):x(e,"add",n,r)),a}}const B={get:M,set:K(),deleteProperty:function(t,e){const n=s(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&x(t,"delete",e,void 0),r},has:function(t,e){const n=Reflect.has(t,e);return u(e)&&z.has(e)||P(t,0,e),n},ownKeys:function(t){return P(t,0,g),Reflect.ownKeys(t)}},q={get:W,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},C=n({},B,{get:A,set:K(!0)}),D=n({},q,{get:N}),F=t=>a(t)?_t(t):t,G=t=>a(t)?vt(t):t,H=t=>t,J=t=>Reflect.getPrototypeOf(t);function L(t,e,n=!1,r=!1){const s=Rt(t=t.__v_raw),i=Rt(e);e!==i&&!n&&P(s,0,e),!n&&P(s,0,i);const{has:o}=J(s),c=n?G:r?H:F;return o.call(s,e)?c(t.get(e)):o.call(s,i)?c(t.get(i)):void 0}function Q(t,e=!1){const n=this.__v_raw,r=Rt(n),s=Rt(t);return t!==s&&!e&&P(r,0,t),!e&&P(r,0,s),t===s?n.has(t):n.has(t)||n.has(s)}function T(t,e=!1){return t=t.__v_raw,!e&&P(Rt(t),0,g),Reflect.get(t,"size",t)}function U(t){t=Rt(t);const e=Rt(this),n=J(e).has.call(e,t),r=e.add(t);return n||x(e,"add",t,t),r}function X(t,e){e=Rt(e);const n=Rt(this),{has:r,get:s}=J(n);let i=r.call(n,t);i||(t=Rt(t),i=r.call(n,t));const o=s.call(n,t),c=n.set(t,e);return i?h(e,o)&&x(n,"set",t,e):x(n,"add",t,e),c}function Y(t){const e=Rt(this),{has:n,get:r}=J(e);let s=n.call(e,t);s||(t=Rt(t),s=n.call(e,t));r&&r.call(e,t);const i=e.delete(t);return s&&x(e,"delete",t,void 0),i}function Z(){const t=Rt(this),e=0!==t.size,n=t.clear();return e&&x(t,"clear",void 0,void 0),n}function $(t,e){return function(n,r){const s=this,i=s.__v_raw,o=Rt(i),c=t?G:e?H:F;return!t&&P(o,0,g),i.forEach((t,e)=>n.call(r,c(t),c(e),s))}}function tt(t,e,n){return function(...r){const s=this.__v_raw,i=Rt(s),c=o(i),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,l=s[t](...r),f=e?G:n?H:F;return!e&&P(i,0,a?y:g),{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 et(t){return function(...e){return"delete"!==t&&this}}const nt={get(t){return L(this,t)},get size(){return T(this)},has:Q,add:U,set:X,delete:Y,clear:Z,forEach:$(!1,!1)},rt={get(t){return L(this,t,!1,!0)},get size(){return T(this)},has:Q,add:U,set:X,delete:Y,clear:Z,forEach:$(!1,!0)},st={get(t){return L(this,t,!0)},get size(){return T(this,!0)},has(t){return Q.call(this,t,!0)},add:et("add"),set:et("set"),delete:et("delete"),clear:et("clear"),forEach:$(!0,!1)};function it(t,e){const n=e?rt:t?st:nt;return(e,r,i)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(s(n,r)&&r in e?n:e,r,i)}["keys","values","entries",Symbol.iterator].forEach(t=>{nt[t]=tt(t,!1,!1),st[t]=tt(t,!0,!1),rt[t]=tt(t,!1,!0)});const ot={get:it(!1,!1)},ct={get:it(!1,!0)},ut={get:it(!0,!1)},at=new WeakMap,lt=new WeakMap;function ft(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>f(t).slice(8,-1))(t))}function _t(t){return t&&t.__v_isReadonly?t:pt(t,!1,B,ot)}function ht(t){return pt(t,!1,C,ct)}function vt(t){return pt(t,!0,q,ut)}function dt(t){return pt(t,!0,D,ut)}function pt(t,e,n,r){if(!a(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?lt:at,i=s.get(t);if(i)return i;const o=ft(t);if(0===o)return t;const c=new Proxy(t,2===o?r:n);return s.set(t,c),c}function gt(t){return yt(t)?gt(t.__v_raw):!(!t||!t.__v_isReactive)}function yt(t){return!(!t||!t.__v_isReadonly)}function wt(t){return gt(t)||yt(t)}function Rt(t){return t&&Rt(t.__v_raw)||t}function bt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const St=t=>a(t)?_t(t):t;function kt(t){return Boolean(t&&!0===t.__v_isRef)}function Et(t){return Ot(t)}function mt(t){return Ot(t,!0)}class jt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:St(t)}get value(){return P(Rt(this),0,"value"),this._value}set value(t){h(Rt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:St(t),x(Rt(this),"set","value",t))}}function Ot(t,e=!1){return kt(t)?t:new jt(t,e)}function Pt(t){x(t,"set","value",void 0)}function xt(t){return kt(t)?t.value:t}const zt={get:(t,e,n)=>xt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return kt(s)&&!kt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};function Mt(t){return gt(t)?t:new Proxy(t,zt)}class At{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>P(this,0,"value"),()=>x(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function Wt(t){return new At(t)}function Nt(t){const e=i(t)?new Array(t.length):{};for(const n in t)e[n]=It(t,n);return e}class Vt{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function It(t,e){return kt(t[e])?t[e]:new Vt(t,e)}class Kt{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=w(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,x(Rt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),P(Rt(this),0,"value"),this._value}set value(t){this._setter(t)}}function Bt(t){let n,r;return c(t)?(n=t,r=e):(n=t.get,r=t.set),new Kt(n,r,c(t)||!t.set)}export{g as ITERATE_KEY,Bt as computed,Wt as customRef,w as effect,j as enableTracking,wt as isProxy,gt as isReactive,yt as isReadonly,kt as isRef,bt as markRaw,m as pauseTracking,Mt as proxyRefs,_t as reactive,vt as readonly,Et as ref,O as resetTracking,ht as shallowReactive,dt as shallowReadonly,mt as shallowRef,R as stop,Rt as toRaw,It as toRef,Nt as toRefs,P as track,x as trigger,Pt as triggerRef,xt as unref};
function t(t,e){const n=Object.create(null),s=t.split(",");for(let i=0;i<s.length;i++)n[s[i]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e=()=>{},n=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),r=Array.isArray,c=t=>"[object Map]"===l(t),o=t=>"symbol"==typeof t,u=t=>null!==t&&"object"==typeof t,h=Object.prototype.toString,l=t=>h.call(t),a=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,f=(t,e)=>!Object.is(t,e);let _;const d=[];class p{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&_&&(this.parent=_,this.index=(_.scopes||(_.scopes=[])).push(this)-1)}run(t){if(this.active)try{return this.on(),t()}finally{this.off()}}on(){this.active&&(d.push(this),_=this)}off(){this.active&&(d.pop(),_=d[d.length-1])}stop(t){if(this.active){if(this.effects.forEach(t=>t.stop()),this.cleanups.forEach(t=>t()),this.scopes&&this.scopes.forEach(t=>t.stop(!0)),this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.active=!1}}}function v(t){return new p(t)}function g(t,e){(e=e||_)&&e.active&&e.effects.push(t)}function y(){return _}function w(t){_&&_.cleanups.push(t)}const b=t=>{const e=new Set(t);return e.w=0,e.n=0,e},R=t=>(t.w&O)>0,k=t=>(t.n&O)>0,m=new WeakMap;let j=0,O=1;const S=[];let E;const x=Symbol(""),P=Symbol("");class M{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],g(this,n)}run(){if(!this.active)return this.fn();if(!S.includes(this))try{return S.push(E=this),K(),O=1<<++j,j<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=O})(this):z(this),this.fn()}finally{j<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];R(i)&&!k(i)?i.delete(t):e[n++]=i,i.w&=~O,i.n&=~O}e.length=n}})(this),O=1<<--j,B(),S.pop();const t=S.length;E=t>0?S[t-1]:void 0}}stop(){this.active&&(z(this),this.onStop&&this.onStop(),this.active=!1)}}function z(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}function W(t,e){t.effect&&(t=t.effect.fn);const s=new M(t);e&&(n(s,e),e.scope&&g(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i}function A(t){t.effect.stop()}let N=!0;const V=[];function I(){V.push(N),N=!1}function K(){V.push(N),N=!0}function B(){const t=V.pop();N=void 0===t||t}function C(t,e,n){if(!L())return;let s=m.get(t);s||m.set(t,s=new Map);let i=s.get(n);i||s.set(n,i=b()),q(i)}function L(){return N&&void 0!==E}function q(t,e){let n=!1;j<=30?k(t)||(t.n|=O,n=!R(t)):n=!t.has(E),n&&(t.add(E),E.deps.push(t))}function D(t,e,n,s,i,o){const u=m.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===n&&r(t))u.forEach((t,e)=>{("length"===e||e>=s)&&h.push(t)});else switch(void 0!==n&&h.push(u.get(n)),e){case"add":r(t)?a(n)&&h.push(u.get("length")):(h.push(u.get(x)),c(t)&&h.push(u.get(P)));break;case"delete":r(t)||(h.push(u.get(x)),c(t)&&h.push(u.get(P)));break;case"set":c(t)&&h.push(u.get(x))}if(1===h.length)h[0]&&F(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);F(b(t))}}function F(t,e){for(const n of r(t)?t:[...t])(n!==E||n.allowRecurse)&&(n.scheduler?n.scheduler():n.run())}const G=t("__proto__,__v_isRef,__isVue"),H=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(o)),J=Z(),Q=Z(!1,!0),T=Z(!0),U=Z(!0,!0),X=Y();function Y(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...t){const n=Ct(this);for(let e=0,i=this.length;e<i;e++)C(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(Ct)):s}}),["push","pop","shift","unshift","splice"].forEach(e=>{t[e]=function(...t){I();const n=Ct(this)[e].apply(this,t);return B(),n}}),t}function Z(t=!1,e=!1){return function(n,s,c){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_raw"===s&&c===(t?e?Pt:xt:e?Et:St).get(n))return n;const h=r(n);if(!t&&h&&i(X,s))return Reflect.get(X,s,c);const l=Reflect.get(n,s,c);if(o(s)?H.has(s):G(s))return l;if(t||C(n,0,s),e)return l;if(Ht(l)){return!h||!a(s)?l.value:l}return u(l)?t?At(l):zt(l):l}}function $(t=!1){return function(e,n,s,c){let o=e[n];if(!t&&(s=Ct(s),o=Ct(o),!r(e)&&Ht(o)&&!Ht(s)))return o.value=s,!0;const u=r(e)&&a(n)?Number(n)<e.length:i(e,n),h=Reflect.set(e,n,s,c);return e===Ct(c)&&(u?f(s,o)&&D(e,"set",n,s):D(e,"add",n,s)),h}}const tt={get:J,set:$(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&D(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return o(e)&&H.has(e)||C(t,0,e),n},ownKeys:function(t){return C(t,0,r(t)?"length":x),Reflect.ownKeys(t)}},et={get:T,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},nt=n({},tt,{get:Q,set:$(!0)}),st=n({},et,{get:U}),it=t=>t,rt=t=>Reflect.getPrototypeOf(t);function ct(t,e,n=!1,s=!1){const i=Ct(t=t.__v_raw),r=Ct(e);e!==r&&!n&&C(i,0,e),!n&&C(i,0,r);const{has:c}=rt(i),o=s?it:n?Dt:qt;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 n=this.__v_raw,s=Ct(n),i=Ct(t);return t!==i&&!e&&C(s,0,t),!e&&C(s,0,i),t===i?n.has(t):n.has(t)||n.has(i)}function ut(t,e=!1){return t=t.__v_raw,!e&&C(Ct(t),0,x),Reflect.get(t,"size",t)}function ht(t){t=Ct(t);const e=Ct(this);return rt(e).has.call(e,t)||(e.add(t),D(e,"add",t,t)),this}function lt(t,e){e=Ct(e);const n=Ct(this),{has:s,get:i}=rt(n);let r=s.call(n,t);r||(t=Ct(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?f(e,c)&&D(n,"set",t,e):D(n,"add",t,e),this}function at(t){const e=Ct(this),{has:n,get:s}=rt(e);let i=n.call(e,t);i||(t=Ct(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&D(e,"delete",t,void 0),r}function ft(){const t=Ct(this),e=0!==t.size,n=t.clear();return e&&D(t,"clear",void 0,void 0),n}function _t(t,e){return function(n,s){const i=this,r=i.__v_raw,c=Ct(r),o=e?it:t?Dt:qt;return!t&&C(c,0,x),r.forEach((t,e)=>n.call(s,o(t),o(e),i))}}function dt(t,e,n){return function(...s){const i=this.__v_raw,r=Ct(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,l=i[t](...s),a=n?it:e?Dt:qt;return!e&&C(r,0,h?P:x),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[a(t[0]),a(t[1])]:a(t),done:e}},[Symbol.iterator](){return this}}}}function pt(t){return function(...e){return"delete"!==t&&this}}function vt(){const t={get(t){return ct(this,t)},get size(){return ut(this)},has:ot,add:ht,set:lt,delete:at,clear:ft,forEach:_t(!1,!1)},e={get(t){return ct(this,t,!1,!0)},get size(){return ut(this)},has:ot,add:ht,set:lt,delete:at,clear:ft,forEach:_t(!1,!0)},n={get(t){return ct(this,t,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:_t(!0,!1)},s={get(t){return ct(this,t,!0,!0)},get size(){return ut(this,!0)},has(t){return ot.call(this,t,!0)},add:pt("add"),set:pt("set"),delete:pt("delete"),clear:pt("clear"),forEach:_t(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(i=>{t[i]=dt(i,!1,!1),n[i]=dt(i,!0,!1),e[i]=dt(i,!1,!0),s[i]=dt(i,!0,!0)}),[t,n,e,s]}const[gt,yt,wt,bt]=vt();function Rt(t,e){const n=e?t?bt:wt:t?yt:gt;return(e,s,r)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(i(n,s)&&s in e?n:e,s,r)}const kt={get:Rt(!1,!1)},mt={get:Rt(!1,!0)},jt={get:Rt(!0,!1)},Ot={get:Rt(!0,!0)},St=new WeakMap,Et=new WeakMap,xt=new WeakMap,Pt=new WeakMap;function Mt(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>l(t).slice(8,-1))(t))}function zt(t){return t&&t.__v_isReadonly?t:Vt(t,!1,tt,kt,St)}function Wt(t){return Vt(t,!1,nt,mt,Et)}function At(t){return Vt(t,!0,et,jt,xt)}function Nt(t){return Vt(t,!0,st,Ot,Pt)}function Vt(t,e,n,s,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 c=Mt(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function It(t){return Kt(t)?It(t.__v_raw):!(!t||!t.__v_isReactive)}function Kt(t){return!(!t||!t.__v_isReadonly)}function Bt(t){return It(t)||Kt(t)}function Ct(t){const e=t&&t.__v_raw;return e?Ct(e):t}function Lt(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}const qt=t=>u(t)?zt(t):t,Dt=t=>u(t)?At(t):t;function Ft(t){L()&&((t=Ct(t)).dep||(t.dep=b()),q(t.dep))}function Gt(t,e){(t=Ct(t)).dep&&F(t.dep)}function Ht(t){return Boolean(t&&!0===t.__v_isRef)}function Jt(t){return Tt(t,!1)}function Qt(t){return Tt(t,!0)}function Tt(t,e){return Ht(t)?t:new Ut(t,e)}class Ut{constructor(t,e){this._shallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Ct(t),this._value=e?t:qt(t)}get value(){return Ft(this),this._value}set value(t){t=this._shallow?t:Ct(t),f(t,this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:qt(t),Gt(this))}}function Xt(t){Gt(t)}function Yt(t){return Ht(t)?t.value:t}const Zt={get:(t,e,n)=>Yt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Ht(i)&&!Ht(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};function $t(t){return It(t)?t:new Proxy(t,Zt)}class te{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t(()=>Ft(this),()=>Gt(this));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function ee(t){return new te(t)}function ne(t){const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=ie(t,n);return e}class se{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function ie(t,e){const n=t[e];return Ht(n)?n:new se(t,e)}class re{constructor(t,e,n){this._setter=e,this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.effect=new M(t,()=>{this._dirty||(this._dirty=!0,Gt(this))}),this.__v_isReadonly=n}get value(){const t=Ct(this);return Ft(t),t._dirty&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ce(t,n){let s,i;const r="function"==typeof t;r?(s=t,i=e):(s=t.get,i=t.set);return new re(s,i,r||!i)}var oe;const ue=Promise.resolve(),he=[];let le=!1;const ae=()=>{for(let t=0;t<he.length;t++)he[t]();he.length=0,le=!1};class fe{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this[oe]=!0;let n=!1,s=!1;this.effect=new M(t,t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,he.push(()=>{this.effect.active&&this._get()!==t&&Gt(this),s=!1}),le||(le=!0,ue.then(ae))}for(const t of this.dep)t.computed&&t.scheduler(!0)}this._dirty=!0}),this.effect.computed=!0}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Ft(this),Ct(this)._get()}}function _e(t){return new fe(t)}oe="__v_isReadonly";export{p as EffectScope,x as ITERATE_KEY,M as ReactiveEffect,ce as computed,ee as customRef,_e as deferredComputed,W as effect,v as effectScope,K as enableTracking,y as getCurrentScope,Bt as isProxy,It as isReactive,Kt as isReadonly,Ht as isRef,Lt as markRaw,w as onScopeDispose,I as pauseTracking,$t as proxyRefs,zt as reactive,At as readonly,Jt as ref,B as resetTracking,Wt as shallowReactive,Nt as shallowReadonly,Qt as shallowRef,A as stop,Ct as toRaw,ie as toRef,ne as toRefs,C as track,D as trigger,Xt as triggerRef,Yt as unref};

@@ -1,4 +0,133 @@

import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, isFunction, NOOP } from '@atom-vue/shared';
import { extend, isArray, isMap, isIntegerKey, isSymbol, hasOwn, isObject, hasChanged, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@atom-vue/shared';
function warn(msg, ...args) {
console.warn(`[Vue warn] ${msg}`, ...args);
}
let activeEffectScope;
const effectScopeStack = [];
class EffectScope {
constructor(detached = false) {
this.active = true;
this.effects = [];
this.cleanups = [];
if (!detached && activeEffectScope) {
this.parent = activeEffectScope;
this.index =
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
}
}
run(fn) {
if (this.active) {
try {
this.on();
return fn();
}
finally {
this.off();
}
}
else if ((process.env.NODE_ENV !== 'production')) {
warn(`cannot run an inactive effect scope.`);
}
}
on() {
if (this.active) {
effectScopeStack.push(this);
activeEffectScope = this;
}
}
off() {
if (this.active) {
effectScopeStack.pop();
activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
}
}
stop(fromParent) {
if (this.active) {
this.effects.forEach(e => e.stop());
this.cleanups.forEach(cleanup => cleanup());
if (this.scopes) {
this.scopes.forEach(e => e.stop(true));
}
// nested scope, dereference from parent to avoid memory leaks
if (this.parent && !fromParent) {
// optimized O(1) removal
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.active = false;
}
}
}
function effectScope(detached) {
return new EffectScope(detached);
}
function recordEffectScope(effect, scope) {
scope = scope || activeEffectScope;
if (scope && scope.active) {
scope.effects.push(effect);
}
}
function getCurrentScope() {
return activeEffectScope;
}
function onScopeDispose(fn) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn);
}
else if ((process.env.NODE_ENV !== 'production')) {
warn(`onScopeDispose() is called when there is no active effect scope` +
` to be associated with.`);
}
}
const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit; // set was tracked
}
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
}
else {
deps[ptr++] = dep;
}
// clear bits
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = new WeakMap();
// The number of effects currently being tracked recursively.
let effectTrackDepth = 0;
let trackOpBit = 1;
/**
* The bitwise track markers support at most 30 levels op recursion.
* This value is chosen to enable modern JS engines to use a SMI on all platforms.
* When recursion depth is greater, fall back to using a full cleanup.
*/
const maxMarkerBits = 30;
const effectStack = [];

@@ -8,54 +137,50 @@ let activeEffect;

const MAP_KEY_ITERATE_KEY = Symbol((process.env.NODE_ENV !== 'production') ? 'Map key iterate' : '');
function isEffect(fn) {
return fn && fn._isEffect === true;
}
function effect(fn, options = EMPTY_OBJ) {
if (isEffect(fn)) {
fn = fn.raw;
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
this.fn = fn;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
recordEffectScope(this, scope);
}
const effect = createReactiveEffect(fn, options);
if (!options.lazy) {
effect();
}
return effect;
}
function stop(effect) {
if (effect.active) {
cleanup(effect);
if (effect.options.onStop) {
effect.options.onStop();
run() {
if (!this.active) {
return this.fn();
}
effect.active = false;
}
}
let uid = 0;
function createReactiveEffect(fn, options) {
const effect = function reactiveEffect() {
if (!effect.active) {
return options.scheduler ? undefined : fn();
}
if (!effectStack.includes(effect)) {
cleanup(effect);
if (!effectStack.includes(this)) {
try {
effectStack.push((activeEffect = this));
enableTracking();
effectStack.push(effect);
activeEffect = effect;
return fn();
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
}
else {
cleanupEffect(this);
}
return this.fn();
}
finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
resetTracking();
effectStack.pop();
resetTracking();
activeEffect = effectStack[effectStack.length - 1];
const n = effectStack.length;
activeEffect = n > 0 ? effectStack[n - 1] : undefined;
}
}
};
effect.id = uid++;
effect._isEffect = true;
effect.active = true;
effect.raw = fn;
effect.deps = [];
effect.options = options;
return effect;
}
stop() {
if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
this.active = false;
}
}
}
function cleanup(effect) {
function cleanupEffect(effect) {
const { deps } = effect;

@@ -69,2 +194,22 @@ if (deps.length) {

}
function effect(fn, options) {
if (fn.effect) {
fn = fn.effect.fn;
}
const _effect = new ReactiveEffect(fn);
if (options) {
extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
}
if (!options || !options.lazy) {
_effect.run();
}
const runner = _effect.run.bind(_effect);
runner.effect = _effect;
return runner;
}
function stop(runner) {
runner.effect.stop();
}
let shouldTrack = true;

@@ -85,3 +230,3 @@ const trackStack = [];

function track(target, type, key) {
if (!shouldTrack || activeEffect === undefined) {
if (!isTracking()) {
return;

@@ -95,14 +240,31 @@ }

if (!dep) {
depsMap.set(key, (dep = new Set()));
depsMap.set(key, (dep = createDep()));
}
if (!dep.has(activeEffect)) {
const eventInfo = (process.env.NODE_ENV !== 'production')
? { effect: activeEffect, target, type, key }
: undefined;
trackEffects(dep, eventInfo);
}
function isTracking() {
return shouldTrack && activeEffect !== undefined;
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit; // set newly tracked
shouldTrack = !wasTracked(dep);
}
}
else {
// Full cleanup mode.
shouldTrack = !dep.has(activeEffect);
}
if (shouldTrack) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ((process.env.NODE_ENV !== 'production') && activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
type,
key
});
if ((process.env.NODE_ENV !== 'production') && activeEffect.onTrack) {
activeEffect.onTrack(Object.assign({
effect: activeEffect
}, debuggerEventExtraInfo));
}

@@ -117,16 +279,7 @@ }

}
const effects = new Set();
const add = (effectsToAdd) => {
if (effectsToAdd) {
effectsToAdd.forEach(effect => {
if (effect !== activeEffect || effect.options.allowRecurse) {
effects.add(effect);
}
});
}
};
let deps = [];
if (type === "clear" /* CLEAR */) {
// collection being cleared
// trigger all effects for target
depsMap.forEach(add);
deps = [...depsMap.values()];
}

@@ -136,3 +289,3 @@ else if (key === 'length' && isArray(target)) {

if (key === 'length' || key >= newValue) {
add(dep);
deps.push(dep);
}

@@ -144,3 +297,3 @@ });

if (key !== void 0) {
add(depsMap.get(key));
deps.push(depsMap.get(key));
}

@@ -151,5 +304,5 @@ // also run for iteration key on ADD | DELETE | Map.SET

if (!isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -159,3 +312,3 @@ }

// new index added to array -> length changes
add(depsMap.get('length'));
deps.push(depsMap.get('length'));
}

@@ -165,5 +318,5 @@ break;

if (!isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -174,3 +327,3 @@ }

if (isMap(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
}

@@ -180,24 +333,48 @@ break;

}
const run = (effect) => {
if ((process.env.NODE_ENV !== 'production') && effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
key,
type,
newValue,
oldValue,
oldTarget
});
const eventInfo = (process.env.NODE_ENV !== 'production')
? { target, type, key, newValue, oldValue, oldTarget }
: undefined;
if (deps.length === 1) {
if (deps[0]) {
if ((process.env.NODE_ENV !== 'production')) {
triggerEffects(deps[0], eventInfo);
}
else {
triggerEffects(deps[0]);
}
}
if (effect.options.scheduler) {
effect.options.scheduler(effect);
}
else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
if ((process.env.NODE_ENV !== 'production')) {
triggerEffects(createDep(effects), eventInfo);
}
else {
effect();
triggerEffects(createDep(effects));
}
};
effects.forEach(run);
}
}
function triggerEffects(dep, debuggerEventExtraInfo) {
// spread into array for stabilization
for (const effect of isArray(dep) ? dep : [...dep]) {
if (effect !== activeEffect || effect.allowRecurse) {
if ((process.env.NODE_ENV !== 'production') && effect.onTrigger) {
effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
}
if (effect.scheduler) {
effect.scheduler();
}
else {
effect.run();
}
}
}
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)

@@ -210,30 +387,32 @@ .map(key => Symbol[key])

const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
const arrayInstrumentations = {};
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
const arr = toRaw(this);
for (let i = 0, l = this.length; i < l; i++) {
track(arr, "get" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = method.apply(arr, args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return method.apply(arr, args.map(toRaw));
}
else {
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" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = arr[key](...args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return arr[key](...args.map(toRaw));
}
else {
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
instrumentations[key] = function (...args) {
pauseTracking();
const res = toRaw(this)[key].apply(this, args);
resetTracking();
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
pauseTracking();
const res = method.apply(this, args);
enableTracking();
return res;
};
});
};
});
return instrumentations;
}
function createGetter(isReadonly = false, shallow = false) {

@@ -248,14 +427,18 @@ return function get(target, key, receiver) {

else if (key === "__v_raw" /* RAW */ &&
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) {
receiver ===
(isReadonly
? shallow
? shallowReadonlyMap
: readonlyMap
: shallow
? shallowReactiveMap
: reactiveMap).get(target)) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
const keyIsSymbol = isSymbol(key);
if (keyIsSymbol
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
return res;

@@ -287,5 +470,6 @@ }

return function set(target, key, value, receiver) {
const oldValue = target[key];
let oldValue = target[key];
if (!shallow) {
value = toRaw(value);
oldValue = toRaw(oldValue);
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {

@@ -329,3 +513,3 @@ oldValue.value = value;

function ownKeys(target) {
track(target, "iterate" /* ITERATE */, ITERATE_KEY);
track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
return Reflect.ownKeys(target);

@@ -355,3 +539,3 @@ }

};
const shallowReactiveHandlers = extend({}, mutableHandlers, {
const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
get: shallowGet,

@@ -363,8 +547,6 @@ set: shallowSet

// retain the reactivity of the normal readonly object.
const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
get: shallowReadonlyGet
});
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
const toShallow = (value) => value;

@@ -383,3 +565,3 @@ const getProto = (v) => Reflect.getPrototypeOf(v);

const { has } = getProto(rawTarget);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
if (has.call(rawTarget, key)) {

@@ -391,2 +573,7 @@ return wrap(target.get(key));

}
else if (target !== rawTarget) {
// #3602 readonly(reactive(Map))
// ensure that the nested reactive `Map` can do tracking for itself
target.get(key);
}
}

@@ -415,7 +602,7 @@ function has$1(key, isReadonly = false) {

const hadKey = proto.has.call(target, value);
const result = target.add(value);
if (!hadKey) {
target.add(value);
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}

@@ -435,3 +622,3 @@ function set$1(key, value) {

const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {

@@ -443,3 +630,3 @@ trigger(target, "add" /* ADD */, key, value);

}
return result;
return this;
}

@@ -485,3 +672,3 @@ function deleteEntry(key) {

const rawTarget = toRaw(target);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);

@@ -504,3 +691,3 @@ return target.forEach((value, key) => {

const innerIterator = target[method](...args);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly &&

@@ -537,55 +724,83 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);

}
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
});
function createInstrumentations() {
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations = {
get(key) {
return get$1(this, key, true, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, true)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
});
return [
mutableInstrumentations,
readonlyInstrumentations,
shallowInstrumentations,
shallowReadonlyInstrumentations
];
}
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
function createInstrumentationGetter(isReadonly, shallow) {
const instrumentations = shallow
? shallowInstrumentations
? isReadonly
? shallowReadonlyInstrumentations
: shallowInstrumentations
: isReadonly

@@ -610,10 +825,13 @@ ? readonlyInstrumentations

const mutableCollectionHandlers = {
get: createInstrumentationGetter(false, false)
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
};
const shallowCollectionHandlers = {
get: createInstrumentationGetter(false, true)
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
};
const readonlyCollectionHandlers = {
get: createInstrumentationGetter(true, false)
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
};
const shallowReadonlyCollectionHandlers = {
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
};
function checkIdentityKeys(target, has, key) {

@@ -624,3 +842,3 @@ const rawKey = toRaw(key);

console.warn(`Reactive ${type} contains both the raw and reactive ` +
`versions of the same object${type === `Map` ? `as keys` : ``}, ` +
`versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
`which can lead to inconsistencies. ` +

@@ -633,3 +851,5 @@ `Avoid differentiating between the raw and reactive versions ` +

const reactiveMap = new WeakMap();
const shallowReactiveMap = new WeakMap();
const readonlyMap = new WeakMap();
const shallowReadonlyMap = new WeakMap();
function targetTypeMap(rawType) {

@@ -659,21 +879,29 @@ switch (rawType) {

}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
}
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
if (!isObject(target)) {

@@ -692,3 +920,2 @@ if ((process.env.NODE_ENV !== 'production')) {

// target already has corresponding Proxy
const proxyMap = isReadonly ? readonlyMap : reactiveMap;
const existingProxy = proxyMap.get(target);

@@ -720,3 +947,4 @@ if (existingProxy) {

function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
const raw = observed && observed["__v_raw" /* RAW */];
return raw ? toRaw(raw) : observed;
}

@@ -727,4 +955,39 @@ function markRaw(value) {

}
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
const convert = (val) => isObject(val) ? reactive(val) : val;
function trackRefValue(ref) {
if (isTracking()) {
ref = toRaw(ref);
if (!ref.dep) {
ref.dep = createDep();
}
if ((process.env.NODE_ENV !== 'production')) {
trackEffects(ref.dep, {
target: ref,
type: "get" /* GET */,
key: 'value'
});
}
else {
trackEffects(ref.dep);
}
}
}
function triggerRefValue(ref, newVal) {
ref = toRaw(ref);
if (ref.dep) {
if ((process.env.NODE_ENV !== 'production')) {
triggerEffects(ref.dep, {
target: ref,
type: "set" /* SET */,
key: 'value',
newValue: newVal
});
}
else {
triggerEffects(ref.dep);
}
}
}
function isRef(r) {

@@ -734,3 +997,3 @@ return Boolean(r && r.__v_isRef === true);

function ref(value) {
return createRef(value);
return createRef(value, false);
}

@@ -740,29 +1003,31 @@ function shallowRef(value) {

}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
class RefImpl {
constructor(_rawValue, _shallow = false) {
this._rawValue = _rawValue;
constructor(value, _shallow) {
this._shallow = _shallow;
this.dep = undefined;
this.__v_isRef = true;
this._value = _shallow ? _rawValue : convert(_rawValue);
this._rawValue = _shallow ? value : toRaw(value);
this._value = _shallow ? value : toReactive(value);
}
get value() {
track(toRaw(this), "get" /* GET */, 'value');
trackRefValue(this);
return this._value;
}
set value(newVal) {
if (hasChanged(toRaw(newVal), this._rawValue)) {
newVal = this._shallow ? newVal : toRaw(newVal);
if (hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = this._shallow ? newVal : convert(newVal);
trigger(toRaw(this), "set" /* SET */, 'value', newVal);
this._value = this._shallow ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
}
}
}
function createRef(rawValue, shallow = false) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(ref, "set" /* SET */, 'value', (process.env.NODE_ENV !== 'production') ? ref.value : void 0);
triggerRefValue(ref, (process.env.NODE_ENV !== 'production') ? ref.value : void 0);
}

@@ -792,4 +1057,5 @@ function unref(ref) {

constructor(factory) {
this.dep = undefined;
this.__v_isRef = true;
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value'));
const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
this._get = get;

@@ -832,5 +1098,4 @@ this._set = set;

function toRef(object, key) {
return isRef(object[key])
? object[key]
: new ObjectRefImpl(object, key);
const val = object[key];
return isRef(val) ? val : new ObjectRefImpl(object, key);
}

@@ -841,11 +1106,9 @@

this._setter = _setter;
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this.effect = effect(getter, {
lazy: true,
scheduler: () => {
if (!this._dirty) {
this._dirty = true;
trigger(toRaw(this), "set" /* SET */, 'value');
}
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}

@@ -856,8 +1119,10 @@ });

get value() {
if (this._dirty) {
this._value = this.effect();
this._dirty = false;
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
const self = toRaw(this);
trackRefValue(self);
if (self._dirty) {
self._dirty = false;
self._value = self.effect.run();
}
track(toRaw(this), "get" /* GET */, 'value');
return this._value;
return self._value;
}

@@ -868,6 +1133,7 @@ set value(newValue) {

}
function computed(getterOrOptions) {
function computed(getterOrOptions, debugOptions) {
let getter;
let setter;
if (isFunction(getterOrOptions)) {
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;

@@ -884,5 +1150,85 @@ setter = (process.env.NODE_ENV !== 'production')

}
return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
if ((process.env.NODE_ENV !== 'production') && debugOptions) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
export { ITERATE_KEY, computed, customRef, effect, enableTracking, isProxy, isReactive, isReadonly, isRef, markRaw, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref };
var _a;
const tick = Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this[_a] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
}
else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
// chained upstream computeds are notified synchronously to ensure
// value invalidation in case of sync access; normal effects are
// deferred to be triggered in scheduler.
for (const e of this.dep) {
if (e.computed) {
e.scheduler(true /* computedTrigger */);
}
}
}
this._dirty = true;
});
this.effect.computed = true;
}
_get() {
if (this._dirty) {
this._dirty = false;
return (this._value = this.effect.run());
}
return this._value;
}
get value() {
trackRefValue(this);
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
return toRaw(this)._get();
}
}
_a = "__v_isReadonly" /* IS_READONLY */;
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
export { EffectScope, ITERATE_KEY, ReactiveEffect, computed, customRef, deferredComputed, effect, effectScope, enableTracking, getCurrentScope, isProxy, isReactive, isReadonly, isRef, markRaw, onScopeDispose, pauseTracking, proxyRefs, reactive, readonly, ref, resetTracking, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, track, trigger, triggerRef, unref };
var VueReactivity = (function (exports) {
'use strict';
const EMPTY_OBJ = Object.freeze({})
/**
* Make a map and return a function for checking if a key
* is in that map.
* IMPORTANT: all calls of this function must be prefixed with
* \/\*#\_\_PURE\_\_\*\/
* So that rollup can tree-shake them if necessary.
*/
function makeMap(str, expectsLowerCase) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
Object.freeze({})
;
Object.freeze([]) ;
const extend = Object.assign;

@@ -18,2 +35,3 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;

const toRawType = (value) => {
// extract "RawType" from strings like "[object RawType]"
return toTypeString(value).slice(8, -1);

@@ -35,7 +53,5 @@ };

*/
const capitalize = cacheStringFunction((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
// compare whether a value has changed, accounting for NaN.
const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
const def = (obj, key, value) => {

@@ -49,59 +65,184 @@ Object.defineProperty(obj, key, {

const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
function warn(msg, ...args) {
console.warn(`[Vue warn] ${msg}`, ...args);
}
function effect(fn, options = EMPTY_OBJ) {
if (isEffect(fn)) {
fn = fn.raw;
let activeEffectScope;
const effectScopeStack = [];
class EffectScope {
constructor(detached = false) {
this.active = true;
this.effects = [];
this.cleanups = [];
if (!detached && activeEffectScope) {
this.parent = activeEffectScope;
this.index =
(activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
}
}
const effect = createReactiveEffect(fn, options);
if (!options.lazy) {
effect();
run(fn) {
if (this.active) {
try {
this.on();
return fn();
}
finally {
this.off();
}
}
else {
warn(`cannot run an inactive effect scope.`);
}
}
return effect;
}
function stop(effect) {
if (effect.active) {
cleanup(effect);
if (effect.options.onStop) {
effect.options.onStop();
on() {
if (this.active) {
effectScopeStack.push(this);
activeEffectScope = this;
}
effect.active = false;
}
off() {
if (this.active) {
effectScopeStack.pop();
activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
}
}
stop(fromParent) {
if (this.active) {
this.effects.forEach(e => e.stop());
this.cleanups.forEach(cleanup => cleanup());
if (this.scopes) {
this.scopes.forEach(e => e.stop(true));
}
// nested scope, dereference from parent to avoid memory leaks
if (this.parent && !fromParent) {
// optimized O(1) removal
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.active = false;
}
}
}
let uid = 0;
function createReactiveEffect(fn, options) {
const effect = function reactiveEffect() {
if (!effect.active) {
return options.scheduler ? undefined : fn();
function effectScope(detached) {
return new EffectScope(detached);
}
function recordEffectScope(effect, scope) {
scope = scope || activeEffectScope;
if (scope && scope.active) {
scope.effects.push(effect);
}
}
function getCurrentScope() {
return activeEffectScope;
}
function onScopeDispose(fn) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn);
}
else {
warn(`onScopeDispose() is called when there is no active effect scope` +
` to be associated with.`);
}
}
const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit; // set was tracked
}
if (!effectStack.includes(effect)) {
cleanup(effect);
}
};
const finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
}
else {
deps[ptr++] = dep;
}
// clear bits
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = new WeakMap();
// The number of effects currently being tracked recursively.
let effectTrackDepth = 0;
let trackOpBit = 1;
/**
* The bitwise track markers support at most 30 levels op recursion.
* This value is chosen to enable modern JS engines to use a SMI on all platforms.
* When recursion depth is greater, fall back to using a full cleanup.
*/
const maxMarkerBits = 30;
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
class ReactiveEffect {
constructor(fn, scheduler = null, scope) {
this.fn = fn;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
recordEffectScope(this, scope);
}
run() {
if (!this.active) {
return this.fn();
}
if (!effectStack.includes(this)) {
try {
effectStack.push((activeEffect = this));
enableTracking();
effectStack.push(effect);
activeEffect = effect;
return fn();
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
}
else {
cleanupEffect(this);
}
return this.fn();
}
finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
resetTracking();
effectStack.pop();
resetTracking();
activeEffect = effectStack[effectStack.length - 1];
const n = effectStack.length;
activeEffect = n > 0 ? effectStack[n - 1] : undefined;
}
}
};
effect.id = uid++;
effect._isEffect = true;
effect.active = true;
effect.raw = fn;
effect.deps = [];
effect.options = options;
return effect;
}
stop() {
if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
this.active = false;
}
}
}
function cleanup(effect) {
function cleanupEffect(effect) {
const { deps } = effect;

@@ -115,2 +256,22 @@ if (deps.length) {

}
function effect(fn, options) {
if (fn.effect) {
fn = fn.effect.fn;
}
const _effect = new ReactiveEffect(fn);
if (options) {
extend(_effect, options);
if (options.scope)
recordEffectScope(_effect, options.scope);
}
if (!options || !options.lazy) {
_effect.run();
}
const runner = _effect.run.bind(_effect);
runner.effect = _effect;
return runner;
}
function stop(runner) {
runner.effect.stop();
}
let shouldTrack = true;

@@ -131,3 +292,3 @@ const trackStack = [];

function track(target, type, key) {
if (!shouldTrack || activeEffect === undefined) {
if (!isTracking()) {
return;

@@ -141,14 +302,30 @@ }

if (!dep) {
depsMap.set(key, (dep = new Set()));
depsMap.set(key, (dep = createDep()));
}
if (!dep.has(activeEffect)) {
const eventInfo = { effect: activeEffect, target, type, key }
;
trackEffects(dep, eventInfo);
}
function isTracking() {
return shouldTrack && activeEffect !== undefined;
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit; // set newly tracked
shouldTrack = !wasTracked(dep);
}
}
else {
// Full cleanup mode.
shouldTrack = !dep.has(activeEffect);
}
if (shouldTrack) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
type,
key
});
if (activeEffect.onTrack) {
activeEffect.onTrack(Object.assign({
effect: activeEffect
}, debuggerEventExtraInfo));
}

@@ -163,16 +340,7 @@ }

}
const effects = new Set();
const add = (effectsToAdd) => {
if (effectsToAdd) {
effectsToAdd.forEach(effect => {
if (effect !== activeEffect || effect.options.allowRecurse) {
effects.add(effect);
}
});
}
};
let deps = [];
if (type === "clear" /* CLEAR */) {
// collection being cleared
// trigger all effects for target
depsMap.forEach(add);
deps = [...depsMap.values()];
}

@@ -182,3 +350,3 @@ else if (key === 'length' && isArray(target)) {

if (key === 'length' || key >= newValue) {
add(dep);
deps.push(dep);
}

@@ -190,3 +358,3 @@ });

if (key !== void 0) {
add(depsMap.get(key));
deps.push(depsMap.get(key));
}

@@ -197,5 +365,5 @@ // also run for iteration key on ADD | DELETE | Map.SET

if (!isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -205,3 +373,3 @@ }

// new index added to array -> length changes
add(depsMap.get('length'));
deps.push(depsMap.get('length'));
}

@@ -211,5 +379,5 @@ break;

if (!isArray(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
add(depsMap.get(MAP_KEY_ITERATE_KEY));
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}

@@ -220,3 +388,3 @@ }

if (isMap(target)) {
add(depsMap.get(ITERATE_KEY));
deps.push(depsMap.get(ITERATE_KEY));
}

@@ -226,24 +394,41 @@ break;

}
const run = (effect) => {
if ( effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
key,
type,
newValue,
oldValue,
oldTarget
});
const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
;
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0], eventInfo);
}
}
if (effect.options.scheduler) {
effect.options.scheduler(effect);
}
else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
else {
effect();
{
triggerEffects(createDep(effects), eventInfo);
}
};
effects.forEach(run);
}
}
function triggerEffects(dep, debuggerEventExtraInfo) {
// spread into array for stabilization
for (const effect of isArray(dep) ? dep : [...dep]) {
if (effect !== activeEffect || effect.allowRecurse) {
if (effect.onTrigger) {
effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
}
if (effect.scheduler) {
effect.scheduler();
}
else {
effect.run();
}
}
}
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)

@@ -256,30 +441,32 @@ .map(key => Symbol[key])

const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
const arrayInstrumentations = {};
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
const arr = toRaw(this);
for (let i = 0, l = this.length; i < l; i++) {
track(arr, "get" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = method.apply(arr, args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return method.apply(arr, args.map(toRaw));
}
else {
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" /* GET */, i + '');
}
// we run the method using the original args first (which may be reactive)
const res = arr[key](...args);
if (res === -1 || res === false) {
// if that didn't work, run it again using raw values.
return arr[key](...args.map(toRaw));
}
else {
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
instrumentations[key] = function (...args) {
pauseTracking();
const res = toRaw(this)[key].apply(this, args);
resetTracking();
return res;
}
};
});
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
const method = Array.prototype[key];
arrayInstrumentations[key] = function (...args) {
pauseTracking();
const res = method.apply(this, args);
enableTracking();
return res;
};
});
};
});
return instrumentations;
}
function createGetter(isReadonly = false, shallow = false) {

@@ -294,14 +481,18 @@ return function get(target, key, receiver) {

else if (key === "__v_raw" /* RAW */ &&
receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) {
receiver ===
(isReadonly
? shallow
? shallowReadonlyMap
: readonlyMap
: shallow
? shallowReactiveMap
: reactiveMap).get(target)) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
const keyIsSymbol = isSymbol(key);
if (keyIsSymbol
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
return res;

@@ -333,5 +524,6 @@ }

return function set(target, key, value, receiver) {
const oldValue = target[key];
let oldValue = target[key];
if (!shallow) {
value = toRaw(value);
oldValue = toRaw(oldValue);
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {

@@ -375,3 +567,3 @@ oldValue.value = value;

function ownKeys(target) {
track(target, "iterate" /* ITERATE */, ITERATE_KEY);
track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
return Reflect.ownKeys(target);

@@ -401,3 +593,3 @@ }

};
const shallowReactiveHandlers = extend({}, mutableHandlers, {
const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
get: shallowGet,

@@ -409,8 +601,6 @@ set: shallowSet

// retain the reactivity of the normal readonly object.
const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
get: shallowReadonlyGet
});
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
const toShallow = (value) => value;

@@ -429,3 +619,3 @@ const getProto = (v) => Reflect.getPrototypeOf(v);

const { has } = getProto(rawTarget);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
if (has.call(rawTarget, key)) {

@@ -437,2 +627,7 @@ return wrap(target.get(key));

}
else if (target !== rawTarget) {
// #3602 readonly(reactive(Map))
// ensure that the nested reactive `Map` can do tracking for itself
target.get(key);
}
}

@@ -461,7 +656,7 @@ function has$1(key, isReadonly = false) {

const hadKey = proto.has.call(target, value);
const result = target.add(value);
if (!hadKey) {
target.add(value);
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}

@@ -481,3 +676,3 @@ function set$1(key, value) {

const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {

@@ -489,3 +684,3 @@ trigger(target, "add" /* ADD */, key, value);

}
return result;
return this;
}

@@ -514,3 +709,3 @@ function deleteEntry(key) {

const hadItems = target.size !== 0;
const oldTarget = isMap(target)
const oldTarget = isMap(target)
? new Map(target)

@@ -531,3 +726,3 @@ : new Set(target)

const rawTarget = toRaw(target);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);

@@ -550,3 +745,3 @@ return target.forEach((value, key) => {

const innerIterator = target[method](...args);
const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
!isReadonly &&

@@ -583,55 +778,83 @@ track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);

}
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
});
function createInstrumentations() {
const mutableInstrumentations = {
get(key) {
return get$1(this, key);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations = {
get(key) {
return get$1(this, key, false, true);
},
get size() {
return size(this);
},
has: has$1,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations = {
get(key) {
return get$1(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations = {
get(key) {
return get$1(this, key, true, true);
},
get size() {
return size(this, true);
},
has(key) {
return has$1.call(this, key, true);
},
add: createReadonlyMethod("add" /* ADD */),
set: createReadonlyMethod("set" /* SET */),
delete: createReadonlyMethod("delete" /* DELETE */),
clear: createReadonlyMethod("clear" /* CLEAR */),
forEach: createForEach(true, true)
};
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
iteratorMethods.forEach(method => {
mutableInstrumentations[method] = createIterableMethod(method, false, false);
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
shallowInstrumentations[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
});
return [
mutableInstrumentations,
readonlyInstrumentations,
shallowInstrumentations,
shallowReadonlyInstrumentations
];
}
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
function createInstrumentationGetter(isReadonly, shallow) {
const instrumentations = shallow
? shallowInstrumentations
? isReadonly
? shallowReadonlyInstrumentations
: shallowInstrumentations
: isReadonly

@@ -656,10 +879,13 @@ ? readonlyInstrumentations

const mutableCollectionHandlers = {
get: createInstrumentationGetter(false, false)
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
};
const shallowCollectionHandlers = {
get: createInstrumentationGetter(false, true)
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
};
const readonlyCollectionHandlers = {
get: createInstrumentationGetter(true, false)
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
};
const shallowReadonlyCollectionHandlers = {
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
};
function checkIdentityKeys(target, has, key) {

@@ -670,3 +896,3 @@ const rawKey = toRaw(key);

console.warn(`Reactive ${type} contains both the raw and reactive ` +
`versions of the same object${type === `Map` ? `as keys` : ``}, ` +
`versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
`which can lead to inconsistencies. ` +

@@ -679,3 +905,5 @@ `Avoid differentiating between the raw and reactive versions ` +

const reactiveMap = new WeakMap();
const shallowReactiveMap = new WeakMap();
const readonlyMap = new WeakMap();
const shallowReadonlyMap = new WeakMap();
function targetTypeMap(rawType) {

@@ -705,21 +933,29 @@ switch (rawType) {

}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
}
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {
function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
if (!isObject(target)) {

@@ -738,3 +974,2 @@ {

// target already has corresponding Proxy
const proxyMap = isReadonly ? readonlyMap : reactiveMap;
const existingProxy = proxyMap.get(target);

@@ -766,3 +1001,4 @@ if (existingProxy) {

function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
const raw = observed && observed["__v_raw" /* RAW */];
return raw ? toRaw(raw) : observed;
}

@@ -773,4 +1009,33 @@ function markRaw(value) {

}
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
const convert = (val) => isObject(val) ? reactive(val) : val;
function trackRefValue(ref) {
if (isTracking()) {
ref = toRaw(ref);
if (!ref.dep) {
ref.dep = createDep();
}
{
trackEffects(ref.dep, {
target: ref,
type: "get" /* GET */,
key: 'value'
});
}
}
}
function triggerRefValue(ref, newVal) {
ref = toRaw(ref);
if (ref.dep) {
{
triggerEffects(ref.dep, {
target: ref,
type: "set" /* SET */,
key: 'value',
newValue: newVal
});
}
}
}
function isRef(r) {

@@ -780,3 +1045,3 @@ return Boolean(r && r.__v_isRef === true);

function ref(value) {
return createRef(value);
return createRef(value, false);
}

@@ -786,29 +1051,31 @@ function shallowRef(value) {

}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
class RefImpl {
constructor(_rawValue, _shallow = false) {
this._rawValue = _rawValue;
constructor(value, _shallow) {
this._shallow = _shallow;
this.dep = undefined;
this.__v_isRef = true;
this._value = _shallow ? _rawValue : convert(_rawValue);
this._rawValue = _shallow ? value : toRaw(value);
this._value = _shallow ? value : toReactive(value);
}
get value() {
track(toRaw(this), "get" /* GET */, 'value');
trackRefValue(this);
return this._value;
}
set value(newVal) {
if (hasChanged(toRaw(newVal), this._rawValue)) {
newVal = this._shallow ? newVal : toRaw(newVal);
if (hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = this._shallow ? newVal : convert(newVal);
trigger(toRaw(this), "set" /* SET */, 'value', newVal);
this._value = this._shallow ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
}
}
}
function createRef(rawValue, shallow = false) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(ref, "set" /* SET */, 'value', ref.value );
triggerRefValue(ref, ref.value );
}

@@ -838,4 +1105,5 @@ function unref(ref) {

constructor(factory) {
this.dep = undefined;
this.__v_isRef = true;
const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value'));
const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
this._get = get;

@@ -855,3 +1123,3 @@ this._set = set;

function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);

@@ -879,5 +1147,4 @@ }

function toRef(object, key) {
return isRef(object[key])
? object[key]
: new ObjectRefImpl(object, key);
const val = object[key];
return isRef(val) ? val : new ObjectRefImpl(object, key);
}

@@ -888,11 +1155,9 @@

this._setter = _setter;
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this.effect = effect(getter, {
lazy: true,
scheduler: () => {
if (!this._dirty) {
this._dirty = true;
trigger(toRaw(this), "set" /* SET */, 'value');
}
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}

@@ -903,8 +1168,10 @@ });

get value() {
if (this._dirty) {
this._value = this.effect();
this._dirty = false;
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
const self = toRaw(this);
trackRefValue(self);
if (self._dirty) {
self._dirty = false;
self._value = self.effect.run();
}
track(toRaw(this), "get" /* GET */, 'value');
return this._value;
return self._value;
}

@@ -915,8 +1182,9 @@ set value(newValue) {

}
function computed(getterOrOptions) {
function computed(getterOrOptions, debugOptions) {
let getter;
let setter;
if (isFunction(getterOrOptions)) {
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');

@@ -930,10 +1198,95 @@ }

}
return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
if (debugOptions) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
var _a;
const tick = Promise.resolve();
const queue = [];
let queued = false;
const scheduler = (fn) => {
queue.push(fn);
if (!queued) {
queued = true;
tick.then(flush);
}
};
const flush = () => {
for (let i = 0; i < queue.length; i++) {
queue[i]();
}
queue.length = 0;
queued = false;
};
class DeferredComputedRefImpl {
constructor(getter) {
this.dep = undefined;
this._dirty = true;
this.__v_isRef = true;
this[_a] = true;
let compareTarget;
let hasCompareTarget = false;
let scheduled = false;
this.effect = new ReactiveEffect(getter, (computedTrigger) => {
if (this.dep) {
if (computedTrigger) {
compareTarget = this._value;
hasCompareTarget = true;
}
else if (!scheduled) {
const valueToCompare = hasCompareTarget ? compareTarget : this._value;
scheduled = true;
hasCompareTarget = false;
scheduler(() => {
if (this.effect.active && this._get() !== valueToCompare) {
triggerRefValue(this);
}
scheduled = false;
});
}
// chained upstream computeds are notified synchronously to ensure
// value invalidation in case of sync access; normal effects are
// deferred to be triggered in scheduler.
for (const e of this.dep) {
if (e.computed) {
e.scheduler(true /* computedTrigger */);
}
}
}
this._dirty = true;
});
this.effect.computed = true;
}
_get() {
if (this._dirty) {
this._dirty = false;
return (this._value = this.effect.run());
}
return this._value;
}
get value() {
trackRefValue(this);
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
return toRaw(this)._get();
}
}
_a = "__v_isReadonly" /* IS_READONLY */;
function deferredComputed(getter) {
return new DeferredComputedRefImpl(getter);
}
exports.EffectScope = EffectScope;
exports.ITERATE_KEY = ITERATE_KEY;
exports.ReactiveEffect = ReactiveEffect;
exports.computed = computed;
exports.customRef = customRef;
exports.deferredComputed = deferredComputed;
exports.effect = effect;
exports.effectScope = effectScope;
exports.enableTracking = enableTracking;
exports.getCurrentScope = getCurrentScope;
exports.isProxy = isProxy;

@@ -944,2 +1297,3 @@ exports.isReactive = isReactive;

exports.markRaw = markRaw;
exports.onScopeDispose = onScopeDispose;
exports.pauseTracking = pauseTracking;

@@ -963,4 +1317,6 @@ exports.proxyRefs = proxyRefs;

Object.defineProperty(exports, '__esModule', { value: true });
return exports;
}({}));

@@ -1,1 +0,1 @@

var VueReactivity=function(t){"use strict";const e={},n=()=>{},r=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),o=Array.isArray,c=t=>"[object Map]"===_(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,l=t=>null!==t&&"object"==typeof t,f=Object.prototype.toString,_=t=>f.call(t),h=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,v=(t,e)=>t!==e&&(t==t||e==e),d=new WeakMap,g=[];let p;const y=Symbol(""),w=Symbol("");function R(t,n=e){(function(t){return t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(){if(!n.active)return e.scheduler?void 0:t();if(!g.includes(n)){k(n);try{return j(),g.push(n),p=n,t()}finally{g.pop(),O(),p=g[g.length-1]}}};return n.id=b++,n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}let b=0;function k(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let E=!0;const m=[];function S(){m.push(E),E=!1}function j(){m.push(E),E=!0}function O(){const t=m.pop();E=void 0===t||t}function P(t,e,n){if(!E||void 0===p)return;let r=d.get(t);r||d.set(t,r=new Map);let s=r.get(n);s||r.set(n,s=new Set),s.has(p)||(s.add(p),p.deps.push(s))}function x(t,e,n,r,s,i){const u=d.get(t);if(!u)return;const a=new Set,l=t=>{t&&t.forEach(t=>{(t!==p||t.options.allowRecurse)&&a.add(t)})};if("clear"===e)u.forEach(l);else if("length"===n&&o(t))u.forEach((t,e)=>{("length"===e||e>=r)&&l(t)});else switch(void 0!==n&&l(u.get(n)),e){case"add":o(t)?h(n)&&l(u.get("length")):(l(u.get(y)),c(t)&&l(u.get(w)));break;case"delete":o(t)||(l(u.get(y)),c(t)&&l(u.get(w)));break;case"set":c(t)&&l(u.get(y))}a.forEach(t=>{t.options.scheduler?t.options.scheduler(t):t()})}const z=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(a)),A=V(),M=V(!1,!0),T=V(!0),W=V(!0,!0),N={};function V(t=!1,e=!1){return function(n,r,s){if("__v_isReactive"===r)return!t;if("__v_isReadonly"===r)return t;if("__v_raw"===r&&s===(t?lt:at).get(n))return n;const c=o(n);if(c&&i(N,r))return Reflect.get(N,r,s);const u=Reflect.get(n,r,s);if(a(r)?z.has(r):"__proto__"===r||"__v_isRef"===r)return u;if(t||P(n,0,r),e)return u;if(wt(u)){return!c||!h(r)?u.value:u}return l(u)?t?ht(u):_t(u):u}}["includes","indexOf","lastIndexOf"].forEach(t=>{const e=Array.prototype[t];N[t]=function(...t){const n=pt(this);for(let t=0,e=this.length;t<e;t++)P(n,0,t+"");const r=e.apply(n,t);return-1===r||!1===r?e.apply(n,t.map(pt)):r}}),["push","pop","shift","unshift","splice"].forEach(t=>{const e=Array.prototype[t];N[t]=function(...t){S();const n=e.apply(this,t);return j(),n}});function I(t=!1){return function(e,n,r,s){const c=e[n];if(!t&&(r=pt(r),!o(e)&&wt(c)&&!wt(r)))return c.value=r,!0;const u=o(e)&&h(n)?Number(n)<e.length:i(e,n),a=Reflect.set(e,n,r,s);return e===pt(s)&&(u?v(r,c)&&x(e,"set",n,r):x(e,"add",n,r)),a}}const K={get:A,set:I(),deleteProperty:function(t,e){const n=i(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&x(t,"delete",e,void 0),r},has:function(t,e){const n=Reflect.has(t,e);return a(e)&&z.has(e)||P(t,0,e),n},ownKeys:function(t){return P(t,0,y),Reflect.ownKeys(t)}},B={get:T,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},Y=r({},K,{get:M,set:I(!0)}),q=r({},B,{get:W}),C=t=>l(t)?_t(t):t,D=t=>l(t)?ht(t):t,F=t=>t,G=t=>Reflect.getPrototypeOf(t);function H(t,e,n=!1,r=!1){const s=pt(t=t.__v_raw),i=pt(e);e!==i&&!n&&P(s,0,e),!n&&P(s,0,i);const{has:o}=G(s),c=n?D:r?F:C;return o.call(s,e)?c(t.get(e)):o.call(s,i)?c(t.get(i)):void 0}function J(t,e=!1){const n=this.__v_raw,r=pt(n),s=pt(t);return t!==s&&!e&&P(r,0,t),!e&&P(r,0,s),t===s?n.has(t):n.has(t)||n.has(s)}function L(t,e=!1){return t=t.__v_raw,!e&&P(pt(t),0,y),Reflect.get(t,"size",t)}function Q(t){t=pt(t);const e=pt(this),n=G(e).has.call(e,t),r=e.add(t);return n||x(e,"add",t,t),r}function U(t,e){e=pt(e);const n=pt(this),{has:r,get:s}=G(n);let i=r.call(n,t);i||(t=pt(t),i=r.call(n,t));const o=s.call(n,t),c=n.set(t,e);return i?v(e,o)&&x(n,"set",t,e):x(n,"add",t,e),c}function X(t){const e=pt(this),{has:n,get:r}=G(e);let s=n.call(e,t);s||(t=pt(t),s=n.call(e,t));r&&r.call(e,t);const i=e.delete(t);return s&&x(e,"delete",t,void 0),i}function Z(){const t=pt(this),e=0!==t.size,n=t.clear();return e&&x(t,"clear",void 0,void 0),n}function $(t,e){return function(n,r){const s=this,i=s.__v_raw,o=pt(i),c=t?D:e?F:C;return!t&&P(o,0,y),i.forEach((t,e)=>n.call(r,c(t),c(e),s))}}function tt(t,e,n){return function(...r){const s=this.__v_raw,i=pt(s),o=c(i),u="entries"===t||t===Symbol.iterator&&o,a="keys"===t&&o,l=s[t](...r),f=e?D:n?F:C;return!e&&P(i,0,a?w:y),{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 et(t){return function(...e){return"delete"!==t&&this}}const nt={get(t){return H(this,t)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!1)},rt={get(t){return H(this,t,!1,!0)},get size(){return L(this)},has:J,add:Q,set:U,delete:X,clear:Z,forEach:$(!1,!0)},st={get(t){return H(this,t,!0)},get size(){return L(this,!0)},has(t){return J.call(this,t,!0)},add:et("add"),set:et("set"),delete:et("delete"),clear:et("clear"),forEach:$(!0,!1)};function it(t,e){const n=e?rt:t?st:nt;return(e,r,s)=>"__v_isReactive"===r?!t:"__v_isReadonly"===r?t:"__v_raw"===r?e:Reflect.get(i(n,r)&&r in e?n:e,r,s)}["keys","values","entries",Symbol.iterator].forEach(t=>{nt[t]=tt(t,!1,!1),st[t]=tt(t,!0,!1),rt[t]=tt(t,!1,!0)});const ot={get:it(!1,!1)},ct={get:it(!1,!0)},ut={get:it(!0,!1)},at=new WeakMap,lt=new WeakMap;function ft(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>_(t).slice(8,-1))(t))}function _t(t){return t&&t.__v_isReadonly?t:vt(t,!1,K,ot)}function ht(t){return vt(t,!0,B,ut)}function vt(t,e,n,r){if(!l(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const s=e?lt:at,i=s.get(t);if(i)return i;const o=ft(t);if(0===o)return t;const c=new Proxy(t,2===o?r:n);return s.set(t,c),c}function dt(t){return gt(t)?dt(t.__v_raw):!(!t||!t.__v_isReactive)}function gt(t){return!(!t||!t.__v_isReadonly)}function pt(t){return t&&pt(t.__v_raw)||t}const yt=t=>l(t)?_t(t):t;function wt(t){return Boolean(t&&!0===t.__v_isRef)}class Rt{constructor(t,e=!1){this._rawValue=t,this._shallow=e,this.__v_isRef=!0,this._value=e?t:yt(t)}get value(){return P(pt(this),0,"value"),this._value}set value(t){v(pt(t),this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:yt(t),x(pt(this),"set","value",t))}}function bt(t,e=!1){return wt(t)?t:new Rt(t,e)}function kt(t){return wt(t)?t.value:t}const Et={get:(t,e,n)=>kt(Reflect.get(t,e,n)),set:(t,e,n,r)=>{const s=t[e];return wt(s)&&!wt(n)?(s.value=n,!0):Reflect.set(t,e,n,r)}};class mt{constructor(t){this.__v_isRef=!0;const{get:e,set:n}=t(()=>P(this,0,"value"),()=>x(this,"set","value"));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class St{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function jt(t,e){return wt(t[e])?t[e]:new St(t,e)}class Ot{constructor(t,e,n){this._setter=e,this._dirty=!0,this.__v_isRef=!0,this.effect=R(t,{lazy:!0,scheduler:()=>{this._dirty||(this._dirty=!0,x(pt(this),"set","value"))}}),this.__v_isReadonly=n}get value(){return this._dirty&&(this._value=this.effect(),this._dirty=!1),P(pt(this),0,"value"),this._value}set value(t){this._setter(t)}}return t.ITERATE_KEY=y,t.computed=function(t){let e,r;return u(t)?(e=t,r=n):(e=t.get,r=t.set),new Ot(e,r,u(t)||!t.set)},t.customRef=function(t){return new mt(t)},t.effect=R,t.enableTracking=j,t.isProxy=function(t){return dt(t)||gt(t)},t.isReactive=dt,t.isReadonly=gt,t.isRef=wt,t.markRaw=function(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t},t.pauseTracking=S,t.proxyRefs=function(t){return dt(t)?t:new Proxy(t,Et)},t.reactive=_t,t.readonly=ht,t.ref=function(t){return bt(t)},t.resetTracking=O,t.shallowReactive=function(t){return vt(t,!1,Y,ct)},t.shallowReadonly=function(t){return vt(t,!0,q,ut)},t.shallowRef=function(t){return bt(t,!0)},t.stop=function(t){t.active&&(k(t),t.options.onStop&&t.options.onStop(),t.active=!1)},t.toRaw=pt,t.toRef=jt,t.toRefs=function(t){const e=o(t)?new Array(t.length):{};for(const n in t)e[n]=jt(t,n);return e},t.track=P,t.trigger=x,t.triggerRef=function(t){x(t,"set","value",void 0)},t.unref=kt,t}({});
var VueReactivity=function(t){"use strict";function e(t,e){const n=Object.create(null),s=t.split(",");for(let r=0;r<s.length;r++)n[s[r]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const n=()=>{},s=Object.assign,r=Object.prototype.hasOwnProperty,i=(t,e)=>r.call(t,e),c=Array.isArray,o=t=>"[object Map]"===h(t),u=t=>"symbol"==typeof t,a=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,h=t=>l.call(t),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,_=(t,e)=>!Object.is(t,e);let p;const d=[];class v{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&p&&(this.parent=p,this.index=(p.scopes||(p.scopes=[])).push(this)-1)}run(t){if(this.active)try{return this.on(),t()}finally{this.off()}}on(){this.active&&(d.push(this),p=this)}off(){this.active&&(d.pop(),p=d[d.length-1])}stop(t){if(this.active){if(this.effects.forEach(t=>t.stop()),this.cleanups.forEach(t=>t()),this.scopes&&this.scopes.forEach(t=>t.stop(!0)),this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.active=!1}}}function g(t,e){(e=e||p)&&e.active&&e.effects.push(t)}const y=t=>{const e=new Set(t);return e.w=0,e.n=0,e},w=t=>(t.w&m)>0,R=t=>(t.n&m)>0,b=new WeakMap;let k=0,m=1;const E=[];let S;const j=Symbol(""),O=Symbol("");class x{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],g(this,n)}run(){if(!this.active)return this.fn();if(!E.includes(this))try{return E.push(S=this),A(),m=1<<++k,k<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=m})(this):P(this),this.fn()}finally{k<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const r=e[s];w(r)&&!R(r)?r.delete(t):e[n++]=r,r.w&=~m,r.n&=~m}e.length=n}})(this),m=1<<--k,T(),E.pop();const t=E.length;S=t>0?E[t-1]:void 0}}stop(){this.active&&(P(this),this.onStop&&this.onStop(),this.active=!1)}}function P(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let M=!0;const z=[];function W(){z.push(M),M=!1}function A(){z.push(M),M=!0}function T(){const t=z.pop();M=void 0===t||t}function V(t,e,n){if(!N())return;let s=b.get(t);s||b.set(t,s=new Map);let r=s.get(n);r||s.set(n,r=y()),C(r)}function N(){return M&&void 0!==S}function C(t,e){let n=!1;k<=30?R(t)||(t.n|=m,n=!w(t)):n=!t.has(S),n&&(t.add(S),S.deps.push(t))}function I(t,e,n,s,r,i){const u=b.get(t);if(!u)return;let a=[];if("clear"===e)a=[...u.values()];else if("length"===n&&c(t))u.forEach((t,e)=>{("length"===e||e>=s)&&a.push(t)});else switch(void 0!==n&&a.push(u.get(n)),e){case"add":c(t)?f(n)&&a.push(u.get("length")):(a.push(u.get(j)),o(t)&&a.push(u.get(O)));break;case"delete":c(t)||(a.push(u.get(j)),o(t)&&a.push(u.get(O)));break;case"set":o(t)&&a.push(u.get(j))}if(1===a.length)a[0]&&K(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);K(y(t))}}function K(t,e){for(const n of c(t)?t:[...t])(n!==S||n.allowRecurse)&&(n.scheduler?n.scheduler():n.run())}const B=e("__proto__,__v_isRef,__isVue"),D=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(u)),L=J(),Y=J(!1,!0),q=J(!0),F=J(!0,!0),G=H();function H(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...t){const n=Wt(this);for(let e=0,r=this.length;e<r;e++)V(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(Wt)):s}}),["push","pop","shift","unshift","splice"].forEach(e=>{t[e]=function(...t){W();const n=Wt(this)[e].apply(this,t);return T(),n}}),t}function J(t=!1,e=!1){return function(n,s,r){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_raw"===s&&r===(t?e?St:Et:e?mt:kt).get(n))return n;const o=c(n);if(!t&&o&&i(G,s))return Reflect.get(G,s,r);const l=Reflect.get(n,s,r);if(u(s)?D.has(s):B(s))return l;if(t||V(n,0,s),e)return l;if(Ct(l)){return!o||!f(s)?l.value:l}return a(l)?t?xt(l):Ot(l):l}}function Q(t=!1){return function(e,n,s,r){let o=e[n];if(!t&&(s=Wt(s),o=Wt(o),!c(e)&&Ct(o)&&!Ct(s)))return o.value=s,!0;const u=c(e)&&f(n)?Number(n)<e.length:i(e,n),a=Reflect.set(e,n,s,r);return e===Wt(r)&&(u?_(s,o)&&I(e,"set",n,s):I(e,"add",n,s)),a}}const U={get:L,set:Q(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&I(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return u(e)&&D.has(e)||V(t,0,e),n},ownKeys:function(t){return V(t,0,c(t)?"length":j),Reflect.ownKeys(t)}},X={get:q,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},Z=s({},U,{get:Y,set:Q(!0)}),$=s({},X,{get:F}),tt=t=>t,et=t=>Reflect.getPrototypeOf(t);function nt(t,e,n=!1,s=!1){const r=Wt(t=t.__v_raw),i=Wt(e);e!==i&&!n&&V(r,0,e),!n&&V(r,0,i);const{has:c}=et(r),o=s?tt:n?Tt:At;return c.call(r,e)?o(t.get(e)):c.call(r,i)?o(t.get(i)):void(t!==r&&t.get(e))}function st(t,e=!1){const n=this.__v_raw,s=Wt(n),r=Wt(t);return t!==r&&!e&&V(s,0,t),!e&&V(s,0,r),t===r?n.has(t):n.has(t)||n.has(r)}function rt(t,e=!1){return t=t.__v_raw,!e&&V(Wt(t),0,j),Reflect.get(t,"size",t)}function it(t){t=Wt(t);const e=Wt(this);return et(e).has.call(e,t)||(e.add(t),I(e,"add",t,t)),this}function ct(t,e){e=Wt(e);const n=Wt(this),{has:s,get:r}=et(n);let i=s.call(n,t);i||(t=Wt(t),i=s.call(n,t));const c=r.call(n,t);return n.set(t,e),i?_(e,c)&&I(n,"set",t,e):I(n,"add",t,e),this}function ot(t){const e=Wt(this),{has:n,get:s}=et(e);let r=n.call(e,t);r||(t=Wt(t),r=n.call(e,t)),s&&s.call(e,t);const i=e.delete(t);return r&&I(e,"delete",t,void 0),i}function ut(){const t=Wt(this),e=0!==t.size,n=t.clear();return e&&I(t,"clear",void 0,void 0),n}function at(t,e){return function(n,s){const r=this,i=r.__v_raw,c=Wt(i),o=e?tt:t?Tt:At;return!t&&V(c,0,j),i.forEach((t,e)=>n.call(s,o(t),o(e),r))}}function lt(t,e,n){return function(...s){const r=this.__v_raw,i=Wt(r),c=o(i),u="entries"===t||t===Symbol.iterator&&c,a="keys"===t&&c,l=r[t](...s),h=n?tt:e?Tt:At;return!e&&V(i,0,a?O:j),{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 ht(t){return function(...e){return"delete"!==t&&this}}function ft(){const t={get(t){return nt(this,t)},get size(){return rt(this)},has:st,add:it,set:ct,delete:ot,clear:ut,forEach:at(!1,!1)},e={get(t){return nt(this,t,!1,!0)},get size(){return rt(this)},has:st,add:it,set:ct,delete:ot,clear:ut,forEach:at(!1,!0)},n={get(t){return nt(this,t,!0)},get size(){return rt(this,!0)},has(t){return st.call(this,t,!0)},add:ht("add"),set:ht("set"),delete:ht("delete"),clear:ht("clear"),forEach:at(!0,!1)},s={get(t){return nt(this,t,!0,!0)},get size(){return rt(this,!0)},has(t){return st.call(this,t,!0)},add:ht("add"),set:ht("set"),delete:ht("delete"),clear:ht("clear"),forEach:at(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(r=>{t[r]=lt(r,!1,!1),n[r]=lt(r,!0,!1),e[r]=lt(r,!1,!0),s[r]=lt(r,!0,!0)}),[t,n,e,s]}const[_t,pt,dt,vt]=ft();function gt(t,e){const n=e?t?vt:dt:t?pt:_t;return(e,s,r)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(i(n,s)&&s in e?n:e,s,r)}const yt={get:gt(!1,!1)},wt={get:gt(!1,!0)},Rt={get:gt(!0,!1)},bt={get:gt(!0,!0)},kt=new WeakMap,mt=new WeakMap,Et=new WeakMap,St=new WeakMap;function jt(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>h(t).slice(8,-1))(t))}function Ot(t){return t&&t.__v_isReadonly?t:Pt(t,!1,U,yt,kt)}function xt(t){return Pt(t,!0,X,Rt,Et)}function Pt(t,e,n,s,r){if(!a(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const i=r.get(t);if(i)return i;const c=jt(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return r.set(t,o),o}function Mt(t){return zt(t)?Mt(t.__v_raw):!(!t||!t.__v_isReactive)}function zt(t){return!(!t||!t.__v_isReadonly)}function Wt(t){const e=t&&t.__v_raw;return e?Wt(e):t}const At=t=>a(t)?Ot(t):t,Tt=t=>a(t)?xt(t):t;function Vt(t){N()&&((t=Wt(t)).dep||(t.dep=y()),C(t.dep))}function Nt(t,e){(t=Wt(t)).dep&&K(t.dep)}function Ct(t){return Boolean(t&&!0===t.__v_isRef)}function It(t,e){return Ct(t)?t:new Kt(t,e)}class Kt{constructor(t,e){this._shallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Wt(t),this._value=e?t:At(t)}get value(){return Vt(this),this._value}set value(t){t=this._shallow?t:Wt(t),_(t,this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:At(t),Nt(this))}}function Bt(t){return Ct(t)?t.value:t}const Dt={get:(t,e,n)=>Bt(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const r=t[e];return Ct(r)&&!Ct(n)?(r.value=n,!0):Reflect.set(t,e,n,s)}};class Lt{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t(()=>Vt(this),()=>Nt(this));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}class Yt{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function qt(t,e){const n=t[e];return Ct(n)?n:new Yt(t,e)}class Ft{constructor(t,e,n){this._setter=e,this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.effect=new x(t,()=>{this._dirty||(this._dirty=!0,Nt(this))}),this.__v_isReadonly=n}get value(){const t=Wt(this);return Vt(t),t._dirty&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}var Gt;const Ht=Promise.resolve(),Jt=[];let Qt=!1;const Ut=()=>{for(let t=0;t<Jt.length;t++)Jt[t]();Jt.length=0,Qt=!1};class Xt{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this[Gt]=!0;let n=!1,s=!1;this.effect=new x(t,t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,Jt.push(()=>{this.effect.active&&this._get()!==t&&Nt(this),s=!1}),Qt||(Qt=!0,Ht.then(Ut))}for(const t of this.dep)t.computed&&t.scheduler(!0)}this._dirty=!0}),this.effect.computed=!0}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Vt(this),Wt(this)._get()}}return Gt="__v_isReadonly",t.EffectScope=v,t.ITERATE_KEY=j,t.ReactiveEffect=x,t.computed=function(t,e){let s,r;const i="function"==typeof t;return i?(s=t,r=n):(s=t.get,r=t.set),new Ft(s,r,i||!r)},t.customRef=function(t){return new Lt(t)},t.deferredComputed=function(t){return new Xt(t)},t.effect=function(t,e){t.effect&&(t=t.effect.fn);const n=new x(t);e&&(s(n,e),e.scope&&g(n,e.scope)),e&&e.lazy||n.run();const r=n.run.bind(n);return r.effect=n,r},t.effectScope=function(t){return new v(t)},t.enableTracking=A,t.getCurrentScope=function(){return p},t.isProxy=function(t){return Mt(t)||zt(t)},t.isReactive=Mt,t.isReadonly=zt,t.isRef=Ct,t.markRaw=function(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t},t.onScopeDispose=function(t){p&&p.cleanups.push(t)},t.pauseTracking=W,t.proxyRefs=function(t){return Mt(t)?t:new Proxy(t,Dt)},t.reactive=Ot,t.readonly=xt,t.ref=function(t){return It(t,!1)},t.resetTracking=T,t.shallowReactive=function(t){return Pt(t,!1,Z,wt,mt)},t.shallowReadonly=function(t){return Pt(t,!0,$,bt,St)},t.shallowRef=function(t){return It(t,!0)},t.stop=function(t){t.effect.stop()},t.toRaw=Wt,t.toRef=qt,t.toRefs=function(t){const e=c(t)?new Array(t.length):{};for(const n in t)e[n]=qt(t,n);return e},t.track=V,t.trigger=I,t.triggerRef=function(t){Nt(t)},t.unref=Bt,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
{
"name": "@atom-vue/reactivity",
"version": "3.0.0-beta.47",
"version": "3.0.0-beta.48",
"description": "@vue/reactivity",

@@ -39,4 +39,4 @@ "main": "index.js",

"dependencies": {
"@atom-vue/shared": "3.0.0-beta.47"
"@atom-vue/shared": "3.0.0-beta.48"
}
}