@vue/reactivity
Advanced tools
Comparing version 3.0.0-alpha.7 to 3.0.0-alpha.8
@@ -5,48 +5,4 @@ 'use strict'; | ||
// 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]; | ||
} | ||
var shared = require('@vue/shared'); | ||
const EMPTY_OBJ = Object.freeze({}) | ||
; | ||
const extend = (a, b) => { | ||
for (const key in b) { | ||
a[key] = b[key]; | ||
} | ||
return a; | ||
}; | ||
const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
const hasOwn = (val, key) => hasOwnProperty.call(val, key); | ||
const isArray = Array.isArray; | ||
const isFunction = (val) => typeof val === 'function'; | ||
const isSymbol = (val) => typeof val === 'symbol'; | ||
const isObject = (val) => val !== null && typeof val === 'object'; | ||
const objectToString = Object.prototype.toString; | ||
const toTypeString = (value) => objectToString.call(value); | ||
const toRawType = (value) => { | ||
return toTypeString(value).slice(8, -1); | ||
}; | ||
const cacheStringFunction = (fn) => { | ||
const cache = Object.create(null); | ||
return ((str) => { | ||
const hit = cache[str]; | ||
return hit || (cache[str] = fn(str)); | ||
}); | ||
}; | ||
const capitalize = cacheStringFunction((str) => { | ||
return 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 targetMap = new WeakMap(); | ||
@@ -59,3 +15,3 @@ const effectStack = []; | ||
} | ||
function effect(fn, options = EMPTY_OBJ) { | ||
function effect(fn, options = shared.EMPTY_OBJ) { | ||
if (isEffect(fn)) { | ||
@@ -172,3 +128,3 @@ fn = fn.raw; | ||
} | ||
else if (key === 'length' && isArray(target)) { | ||
else if (key === 'length' && shared.isArray(target)) { | ||
depsMap.forEach((dep, key) => { | ||
@@ -187,5 +143,5 @@ if (key === 'length' || key >= newValue) { | ||
if (type === "add" /* ADD */ || | ||
type === "delete" /* DELETE */ || | ||
(type === "delete" /* DELETE */ && !shared.isArray(target)) || | ||
(type === "set" /* SET */ && target instanceof Map)) { | ||
const iterationKey = isArray(target) ? 'length' : ITERATE_KEY; | ||
const iterationKey = shared.isArray(target) ? 'length' : ITERATE_KEY; | ||
addRunners(effects, computedRunners, depsMap.get(iterationKey)); | ||
@@ -210,3 +166,3 @@ } | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
if (effect !== activeEffect || !shouldTrack) { | ||
if (effect.options.computed) { | ||
@@ -230,3 +186,3 @@ computedRunners.add(effect); | ||
}; | ||
effect.options.onTrigger(extraInfo ? extend(event, extraInfo) : event); | ||
effect.options.onTrigger(extraInfo ? shared.extend(event, extraInfo) : event); | ||
} | ||
@@ -252,3 +208,3 @@ if (effect.options.scheduler !== void 0) { | ||
.map(key => Symbol[key]) | ||
.filter(isSymbol)); | ||
.filter(shared.isSymbol)); | ||
const get = /*#__PURE__*/ createGetter(); | ||
@@ -265,3 +221,11 @@ const shallowReactiveGet = /*#__PURE__*/ createGetter(false, true); | ||
} | ||
return arr[key](...args.map(toRaw)); | ||
// we run the method using the orignal 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; | ||
} | ||
}; | ||
@@ -271,7 +235,7 @@ }); | ||
return function get(target, key, receiver) { | ||
if (isArray(target) && hasOwn(arrayInstrumentations, key)) { | ||
if (shared.isArray(target) && shared.hasOwn(arrayInstrumentations, key)) { | ||
return Reflect.get(arrayInstrumentations, key, receiver); | ||
} | ||
const res = Reflect.get(target, key, receiver); | ||
if (isSymbol(key) && builtInSymbols.has(key)) { | ||
if (shared.isSymbol(key) && builtInSymbols.has(key)) { | ||
return res; | ||
@@ -285,7 +249,7 @@ } | ||
// ref unwrapping, only for Objects, not for Arrays. | ||
if (isRef(res) && !isArray(target)) { | ||
if (isRef(res) && !shared.isArray(target)) { | ||
return res.value; | ||
} | ||
track(target, "get" /* GET */, key); | ||
return isObject(res) | ||
return shared.isObject(res) | ||
? isReadonly | ||
@@ -314,3 +278,3 @@ ? // need to lazy access readonly and reactive here to avoid | ||
value = toRaw(value); | ||
if (!isArray(target) && isRef(oldValue) && !isRef(value)) { | ||
if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) { | ||
oldValue.value = value; | ||
@@ -320,3 +284,3 @@ return true; | ||
} | ||
const hadKey = hasOwn(target, key); | ||
const hadKey = shared.hasOwn(target, key); | ||
const result = Reflect.set(target, key, value, receiver); | ||
@@ -328,3 +292,3 @@ // don't trigger if target is something up in the prototype chain of original | ||
} | ||
else if (hasChanged(value, oldValue)) { | ||
else if (shared.hasChanged(value, oldValue)) { | ||
trigger(target, "set" /* SET */, key, value, oldValue); | ||
@@ -337,3 +301,3 @@ } | ||
function deleteProperty(target, key) { | ||
const hadKey = hasOwn(target, key); | ||
const hadKey = shared.hasOwn(target, key); | ||
const oldValue = target[key]; | ||
@@ -393,16 +357,23 @@ const result = Reflect.deleteProperty(target, key); | ||
const toReactive = (value) => isObject(value) ? reactive(value) : value; | ||
const toReadonly = (value) => isObject(value) ? readonly(value) : value; | ||
const toReactive = (value) => shared.isObject(value) ? reactive(value) : value; | ||
const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value; | ||
const getProto = (v) => Reflect.getPrototypeOf(v); | ||
function get$1(target, key, wrap) { | ||
target = toRaw(target); | ||
key = toRaw(key); | ||
track(target, "get" /* GET */, key); | ||
return wrap(getProto(target).get.call(target, key)); | ||
const rawKey = toRaw(key); | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
key = toRaw(key); | ||
track(target, "has" /* HAS */, key); | ||
return getProto(target).has.call(target, key); | ||
const rawKey = toRaw(key); | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
} | ||
@@ -436,3 +407,3 @@ function size(target) { | ||
} | ||
else if (hasChanged(value, oldValue)) { | ||
else if (shared.hasChanged(value, oldValue)) { | ||
trigger(target, "set" /* SET */, key, value, oldValue); | ||
@@ -443,9 +414,12 @@ } | ||
function deleteEntry(key) { | ||
key = toRaw(key); | ||
const target = toRaw(this); | ||
const proto = getProto(target); | ||
const hadKey = proto.has.call(target, key); | ||
const oldValue = proto.get ? proto.get.call(target, key) : undefined; | ||
const { has, get, delete: del } = getProto(target); | ||
let hadKey = has.call(target, key); | ||
if (!hadKey) { | ||
key = toRaw(key); | ||
hadKey = has.call(target, key); | ||
} | ||
const oldValue = get ? get.call(target, key) : undefined; | ||
// forward the operation before queueing reactions | ||
const result = proto.delete.call(target, key); | ||
const result = del.call(target, key); | ||
if (hadKey) { | ||
@@ -518,3 +492,3 @@ trigger(target, "delete" /* DELETE */, key, undefined, oldValue); | ||
const key = args[0] ? `on key "${args[0]}" ` : ``; | ||
console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); | ||
console.warn(`${shared.capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); | ||
} | ||
@@ -562,3 +536,3 @@ return type === "delete" /* DELETE */ ? false : this; | ||
function createInstrumentationGetter(instrumentations) { | ||
return (target, key, receiver) => Reflect.get(hasOwn(instrumentations, key) && key in target | ||
return (target, key, receiver) => Reflect.get(shared.hasOwn(instrumentations, key) && key in target | ||
? instrumentations | ||
@@ -584,7 +558,7 @@ : target, key, receiver); | ||
const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]); | ||
const isObservableType = /*#__PURE__*/ makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const isObservableType = /*#__PURE__*/ shared.makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const canObserve = (value) => { | ||
return (!value._isVue && | ||
!value._isVNode && | ||
isObservableType(toRawType(value)) && | ||
isObservableType(shared.toRawType(value)) && | ||
!nonReactiveValues.has(value)); | ||
@@ -628,3 +602,3 @@ }; | ||
function createReactiveObject(target, toProxy, toRaw, baseHandlers, collectionHandlers) { | ||
if (!isObject(target)) { | ||
if (!shared.isObject(target)) { | ||
{ | ||
@@ -674,3 +648,3 @@ console.warn(`value cannot be made reactive: ${String(target)}`); | ||
const convert = (val) => isObject(val) ? reactive(val) : val; | ||
const convert = (val) => shared.isObject(val) ? reactive(val) : val; | ||
function isRef(r) { | ||
@@ -733,3 +707,3 @@ return r ? r._isRef === true : false; | ||
let setter; | ||
if (isFunction(getterOrOptions)) { | ||
if (shared.isFunction(getterOrOptions)) { | ||
getter = getterOrOptions; | ||
@@ -736,0 +710,0 @@ setter = () => { |
@@ -5,32 +5,4 @@ 'use strict'; | ||
// 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]; | ||
} | ||
var shared = require('@vue/shared'); | ||
const EMPTY_OBJ = {}; | ||
const NOOP = () => { }; | ||
const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
const hasOwn = (val, key) => hasOwnProperty.call(val, key); | ||
const isArray = Array.isArray; | ||
const isFunction = (val) => typeof val === 'function'; | ||
const isSymbol = (val) => typeof val === 'symbol'; | ||
const isObject = (val) => val !== null && typeof val === 'object'; | ||
const objectToString = Object.prototype.toString; | ||
const toTypeString = (value) => objectToString.call(value); | ||
const toRawType = (value) => { | ||
return toTypeString(value).slice(8, -1); | ||
}; | ||
// compare whether a value has changed, accounting for NaN. | ||
const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); | ||
const targetMap = new WeakMap(); | ||
@@ -43,3 +15,3 @@ const effectStack = []; | ||
} | ||
function effect(fn, options = EMPTY_OBJ) { | ||
function effect(fn, options = shared.EMPTY_OBJ) { | ||
if (isEffect(fn)) { | ||
@@ -148,3 +120,3 @@ fn = fn.raw; | ||
} | ||
else if (key === 'length' && isArray(target)) { | ||
else if (key === 'length' && shared.isArray(target)) { | ||
depsMap.forEach((dep, key) => { | ||
@@ -163,5 +135,5 @@ if (key === 'length' || key >= newValue) { | ||
if (type === "add" /* ADD */ || | ||
type === "delete" /* DELETE */ || | ||
(type === "delete" /* DELETE */ && !shared.isArray(target)) || | ||
(type === "set" /* SET */ && target instanceof Map)) { | ||
const iterationKey = isArray(target) ? 'length' : ITERATE_KEY; | ||
const iterationKey = shared.isArray(target) ? 'length' : ITERATE_KEY; | ||
addRunners(effects, computedRunners, depsMap.get(iterationKey)); | ||
@@ -181,3 +153,3 @@ } | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
if (effect !== activeEffect || !shouldTrack) { | ||
if (effect.options.computed) { | ||
@@ -213,3 +185,3 @@ computedRunners.add(effect); | ||
.map(key => Symbol[key]) | ||
.filter(isSymbol)); | ||
.filter(shared.isSymbol)); | ||
const get = /*#__PURE__*/ createGetter(); | ||
@@ -226,3 +198,11 @@ const shallowReactiveGet = /*#__PURE__*/ createGetter(false, true); | ||
} | ||
return arr[key](...args.map(toRaw)); | ||
// we run the method using the orignal 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; | ||
} | ||
}; | ||
@@ -232,7 +212,7 @@ }); | ||
return function get(target, key, receiver) { | ||
if (isArray(target) && hasOwn(arrayInstrumentations, key)) { | ||
if (shared.isArray(target) && shared.hasOwn(arrayInstrumentations, key)) { | ||
return Reflect.get(arrayInstrumentations, key, receiver); | ||
} | ||
const res = Reflect.get(target, key, receiver); | ||
if (isSymbol(key) && builtInSymbols.has(key)) { | ||
if (shared.isSymbol(key) && builtInSymbols.has(key)) { | ||
return res; | ||
@@ -246,7 +226,7 @@ } | ||
// ref unwrapping, only for Objects, not for Arrays. | ||
if (isRef(res) && !isArray(target)) { | ||
if (isRef(res) && !shared.isArray(target)) { | ||
return res.value; | ||
} | ||
track(target, "get" /* GET */, key); | ||
return isObject(res) | ||
return shared.isObject(res) | ||
? isReadonly | ||
@@ -272,3 +252,3 @@ ? // need to lazy access readonly and reactive here to avoid | ||
value = toRaw(value); | ||
if (!isArray(target) && isRef(oldValue) && !isRef(value)) { | ||
if (!shared.isArray(target) && isRef(oldValue) && !isRef(value)) { | ||
oldValue.value = value; | ||
@@ -278,3 +258,3 @@ return true; | ||
} | ||
const hadKey = hasOwn(target, key); | ||
const hadKey = shared.hasOwn(target, key); | ||
const result = Reflect.set(target, key, value, receiver); | ||
@@ -286,3 +266,3 @@ // don't trigger if target is something up in the prototype chain of original | ||
} | ||
else if (hasChanged(value, oldValue)) { | ||
else if (shared.hasChanged(value, oldValue)) { | ||
trigger(target, "set" /* SET */, key, value); | ||
@@ -295,3 +275,3 @@ } | ||
function deleteProperty(target, key) { | ||
const hadKey = hasOwn(target, key); | ||
const hadKey = shared.hasOwn(target, key); | ||
const oldValue = target[key]; | ||
@@ -348,16 +328,23 @@ const result = Reflect.deleteProperty(target, key); | ||
const toReactive = (value) => isObject(value) ? reactive(value) : value; | ||
const toReadonly = (value) => isObject(value) ? readonly(value) : value; | ||
const toReactive = (value) => shared.isObject(value) ? reactive(value) : value; | ||
const toReadonly = (value) => shared.isObject(value) ? readonly(value) : value; | ||
const getProto = (v) => Reflect.getPrototypeOf(v); | ||
function get$1(target, key, wrap) { | ||
target = toRaw(target); | ||
key = toRaw(key); | ||
track(target, "get" /* GET */, key); | ||
return wrap(getProto(target).get.call(target, key)); | ||
const rawKey = toRaw(key); | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
key = toRaw(key); | ||
track(target, "has" /* HAS */, key); | ||
return getProto(target).has.call(target, key); | ||
const rawKey = toRaw(key); | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
} | ||
@@ -391,3 +378,3 @@ function size(target) { | ||
} | ||
else if (hasChanged(value, oldValue)) { | ||
else if (shared.hasChanged(value, oldValue)) { | ||
trigger(target, "set" /* SET */, key, value); | ||
@@ -398,9 +385,12 @@ } | ||
function deleteEntry(key) { | ||
key = toRaw(key); | ||
const target = toRaw(this); | ||
const proto = getProto(target); | ||
const hadKey = proto.has.call(target, key); | ||
const oldValue = proto.get ? proto.get.call(target, key) : undefined; | ||
const { has, get, delete: del } = getProto(target); | ||
let hadKey = has.call(target, key); | ||
if (!hadKey) { | ||
key = toRaw(key); | ||
hadKey = has.call(target, key); | ||
} | ||
const oldValue = get ? get.call(target, key) : undefined; | ||
// forward the operation before queueing reactions | ||
const result = proto.delete.call(target, key); | ||
const result = del.call(target, key); | ||
if (hadKey) { | ||
@@ -508,3 +498,3 @@ trigger(target, "delete" /* DELETE */, key, undefined); | ||
function createInstrumentationGetter(instrumentations) { | ||
return (target, key, receiver) => Reflect.get(hasOwn(instrumentations, key) && key in target | ||
return (target, key, receiver) => Reflect.get(shared.hasOwn(instrumentations, key) && key in target | ||
? instrumentations | ||
@@ -530,7 +520,7 @@ : target, key, receiver); | ||
const collectionTypes = new Set([Set, Map, WeakMap, WeakSet]); | ||
const isObservableType = /*#__PURE__*/ makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const isObservableType = /*#__PURE__*/ shared.makeMap('Object,Array,Map,Set,WeakMap,WeakSet'); | ||
const canObserve = (value) => { | ||
return (!value._isVue && | ||
!value._isVNode && | ||
isObservableType(toRawType(value)) && | ||
isObservableType(shared.toRawType(value)) && | ||
!nonReactiveValues.has(value)); | ||
@@ -574,3 +564,3 @@ }; | ||
function createReactiveObject(target, toProxy, toRaw, baseHandlers, collectionHandlers) { | ||
if (!isObject(target)) { | ||
if (!shared.isObject(target)) { | ||
return target; | ||
@@ -617,3 +607,3 @@ } | ||
const convert = (val) => isObject(val) ? reactive(val) : val; | ||
const convert = (val) => shared.isObject(val) ? reactive(val) : val; | ||
function isRef(r) { | ||
@@ -673,5 +663,5 @@ return r ? r._isRef === true : false; | ||
let setter; | ||
if (isFunction(getterOrOptions)) { | ||
if (shared.isFunction(getterOrOptions)) { | ||
getter = getterOrOptions; | ||
setter = NOOP; | ||
setter = shared.NOOP; | ||
} | ||
@@ -678,0 +668,0 @@ else { |
@@ -86,3 +86,3 @@ | ||
export declare function ref<T = any>(): Ref<T>; | ||
export declare function ref<T = any>(): Ref<T | undefined>; | ||
@@ -99,3 +99,3 @@ export declare function resetTracking(): void; | ||
export declare function shallowRef<T = any>(): Ref<T>; | ||
export declare function shallowRef<T = any>(): Ref<T | undefined>; | ||
@@ -102,0 +102,0 @@ export declare function stop(effect: ReactiveEffect): void; |
@@ -1,49 +0,3 @@ | ||
// 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]; | ||
} | ||
import { EMPTY_OBJ, isArray, extend, isSymbol, hasOwn, isObject, hasChanged, capitalize, toRawType, makeMap, isFunction, NOOP } from '@vue/shared'; | ||
const EMPTY_OBJ = (process.env.NODE_ENV !== 'production') | ||
? Object.freeze({}) | ||
: {}; | ||
const NOOP = () => { }; | ||
const extend = (a, b) => { | ||
for (const key in b) { | ||
a[key] = b[key]; | ||
} | ||
return a; | ||
}; | ||
const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
const hasOwn = (val, key) => hasOwnProperty.call(val, key); | ||
const isArray = Array.isArray; | ||
const isFunction = (val) => typeof val === 'function'; | ||
const isSymbol = (val) => typeof val === 'symbol'; | ||
const isObject = (val) => val !== null && typeof val === 'object'; | ||
const objectToString = Object.prototype.toString; | ||
const toTypeString = (value) => objectToString.call(value); | ||
const toRawType = (value) => { | ||
return toTypeString(value).slice(8, -1); | ||
}; | ||
const cacheStringFunction = (fn) => { | ||
const cache = Object.create(null); | ||
return ((str) => { | ||
const hit = cache[str]; | ||
return hit || (cache[str] = fn(str)); | ||
}); | ||
}; | ||
const capitalize = cacheStringFunction((str) => { | ||
return 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 targetMap = new WeakMap(); | ||
@@ -182,3 +136,3 @@ const effectStack = []; | ||
if (type === "add" /* ADD */ || | ||
type === "delete" /* DELETE */ || | ||
(type === "delete" /* DELETE */ && !isArray(target)) || | ||
(type === "set" /* SET */ && target instanceof Map)) { | ||
@@ -206,3 +160,3 @@ const iterationKey = isArray(target) ? 'length' : ITERATE_KEY; | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
if (effect !== activeEffect || !shouldTrack) { | ||
if (effect.options.computed) { | ||
@@ -259,3 +213,11 @@ computedRunners.add(effect); | ||
} | ||
return arr[key](...args.map(toRaw)); | ||
// we run the method using the orignal 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; | ||
} | ||
}; | ||
@@ -386,11 +348,18 @@ }); | ||
target = toRaw(target); | ||
key = toRaw(key); | ||
track(target, "get" /* GET */, key); | ||
return wrap(getProto(target).get.call(target, key)); | ||
const rawKey = toRaw(key); | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
key = toRaw(key); | ||
track(target, "has" /* HAS */, key); | ||
return getProto(target).has.call(target, key); | ||
const rawKey = toRaw(key); | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
} | ||
@@ -430,9 +399,12 @@ function size(target) { | ||
function deleteEntry(key) { | ||
key = toRaw(key); | ||
const target = toRaw(this); | ||
const proto = getProto(target); | ||
const hadKey = proto.has.call(target, key); | ||
const oldValue = proto.get ? proto.get.call(target, key) : undefined; | ||
const { has, get, delete: del } = getProto(target); | ||
let hadKey = has.call(target, key); | ||
if (!hadKey) { | ||
key = toRaw(key); | ||
hadKey = has.call(target, key); | ||
} | ||
const oldValue = get ? get.call(target, key) : undefined; | ||
// forward the operation before queueing reactions | ||
const result = proto.delete.call(target, key); | ||
const result = del.call(target, key); | ||
if (hadKey) { | ||
@@ -439,0 +411,0 @@ trigger(target, "delete" /* DELETE */, key, undefined, oldValue); |
@@ -180,3 +180,3 @@ // Make a map and return a function for checking if a key | ||
if (type === "add" /* ADD */ || | ||
type === "delete" /* DELETE */ || | ||
(type === "delete" /* DELETE */ && !isArray(target)) || | ||
(type === "set" /* SET */ && target instanceof Map)) { | ||
@@ -203,3 +203,3 @@ const iterationKey = isArray(target) ? 'length' : ITERATE_KEY; | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
if (effect !== activeEffect || !shouldTrack) { | ||
if (effect.options.computed) { | ||
@@ -256,3 +256,11 @@ computedRunners.add(effect); | ||
} | ||
return arr[key](...args.map(toRaw)); | ||
// we run the method using the orignal 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; | ||
} | ||
}; | ||
@@ -383,11 +391,18 @@ }); | ||
target = toRaw(target); | ||
key = toRaw(key); | ||
track(target, "get" /* GET */, key); | ||
return wrap(getProto(target).get.call(target, key)); | ||
const rawKey = toRaw(key); | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
key = toRaw(key); | ||
track(target, "has" /* HAS */, key); | ||
return getProto(target).has.call(target, key); | ||
const rawKey = toRaw(key); | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
} | ||
@@ -427,9 +442,12 @@ function size(target) { | ||
function deleteEntry(key) { | ||
key = toRaw(key); | ||
const target = toRaw(this); | ||
const proto = getProto(target); | ||
const hadKey = proto.has.call(target, key); | ||
const oldValue = proto.get ? proto.get.call(target, key) : undefined; | ||
const { has, get, delete: del } = getProto(target); | ||
let hadKey = has.call(target, key); | ||
if (!hadKey) { | ||
key = toRaw(key); | ||
hadKey = has.call(target, key); | ||
} | ||
const oldValue = get ? get.call(target, key) : undefined; | ||
// forward the operation before queueing reactions | ||
const result = proto.delete.call(target, key); | ||
const result = del.call(target, key); | ||
if (hadKey) { | ||
@@ -436,0 +454,0 @@ trigger(target, "delete" /* DELETE */, key, undefined, oldValue); |
@@ -1,1 +0,1 @@ | ||
function t(t,e){const n=Object.create(null),r=t.split(",");for(let t=0;t<r.length;t++)n[r[t]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e={},n=()=>{},r=Object.prototype.hasOwnProperty,o=(t,e)=>r.call(t,e),c=Array.isArray,u=t=>"symbol"==typeof t,i=t=>null!==t&&"object"==typeof t,s=Object.prototype.toString,a=t=>(t=>s.call(t))(t).slice(8,-1),l=(t,e)=>t!==e&&(t==t||e==e),f=new WeakMap,d=[];let h;const p=Symbol("iterate");function g(t,n=e){(function(t){return null!=t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(...e){return function(t,e,n){if(!t.active)return e(...n);if(!d.includes(t)){y(t);try{return R(),d.push(t),h=t,e(...n)}finally{d.pop(),k(),h=d[d.length-1]}}}(n,t,e)};return n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}function v(t){t.active&&(y(t),t.options.onStop&&t.options.onStop(),t.active=!1)}function y(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let w=!0;const S=[];function b(){S.push(w),w=!1}function R(){S.push(w),w=!0}function k(){const t=S.pop();w=void 0===t||t}function m(t,e,n){if(!w||void 0===h)return;let r=f.get(t);void 0===r&&f.set(t,r=new Map);let o=r.get(n);void 0===o&&r.set(n,o=new Set),o.has(h)||(o.add(h),h.deps.push(o))}function E(t,e,n,r,o,u){const i=f.get(t);if(void 0===i)return;const s=new Set,a=new Set;if("clear"===e)i.forEach(t=>{M(s,a,t)});else if("length"===n&&c(t))i.forEach((t,e)=>{("length"===e||e>=r)&&M(s,a,t)});else if(void 0!==n&&M(s,a,i.get(n)),"add"===e||"delete"===e||"set"===e&&t instanceof Map){const e=c(t)?"length":p;M(s,a,i.get(e))}const l=t=>{!function(t,e,n,r,o){void 0!==t.options.scheduler?t.options.scheduler(t):t()}(t)};a.forEach(l),s.forEach(l)}function M(t,e,n){void 0!==n&&n.forEach(n=>{n!==h&&(n.options.computed?e.add(n):t.add(n))})}let W=!0;function O(){W=!0}function _(){W=!1}const P=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(u)),j=N(),x=N(!1,!0),z=N(!0),A=N(!0,!0),K={};function N(t=!1,e=!1){return function(n,r,s){if(c(n)&&o(K,r))return Reflect.get(K,r,s);const a=Reflect.get(n,r,s);return u(r)&&P.has(r)?a:e?(m(n,0,r),a):xt(a)&&!c(n)?a.value:(m(n,0,r),i(a)?t?Rt(a):bt(a):a)}}["includes","indexOf","lastIndexOf"].forEach(t=>{K[t]=function(...e){const n=Ot(this);for(let t=0,e=this.length;t<e;t++)m(n,0,t+"");return n[t](...e.map(Ot))}});const V=q(),C=q(!1,!0),I=q(!0),L=q(!0,!0);function q(t=!1,e=!1){return function(n,r,u,i){if(t&&W)return!0;const s=n[r];if(!e&&(u=Ot(u),!c(n)&&xt(s)&&!xt(u)))return s.value=u,!0;const a=o(n,r),f=Reflect.set(n,r,u,i);return n===Ot(i)&&(a?l(u,s)&&E(n,"set",r,u):E(n,"add",r,u)),f}}function B(t,e){const n=o(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&E(t,"delete",e,void 0),r}function D(t,e){const n=Reflect.has(t,e);return m(t,0,e),n}function F(t){return m(t,0,p),Reflect.ownKeys(t)}const G={get:j,set:V,deleteProperty:B,has:D,ownKeys:F},H={get:z,set:I,has:D,ownKeys:F,deleteProperty:(t,e)=>!!W||B(t,e)},J={...G,get:x,set:C},Q={...H,get:A,set:L},T=t=>i(t)?bt(t):t,U=t=>i(t)?Rt(t):t,X=t=>Reflect.getPrototypeOf(t);function Y(t,e,n){return m(t=Ot(t),0,e=Ot(e)),n(X(t).get.call(t,e))}function Z(t){const e=Ot(this);return m(e,0,t=Ot(t)),X(e).has.call(e,t)}function $(t){return m(t=Ot(t),0,p),Reflect.get(X(t),"size",t)}function tt(t){t=Ot(t);const e=Ot(this),n=X(e),r=n.has.call(e,t),o=n.add.call(e,t);return r||E(e,"add",t,t),o}function et(t,e){e=Ot(e),t=Ot(t);const n=Ot(this),r=X(n),o=r.has.call(n,t),c=r.get.call(n,t),u=r.set.call(n,t,e);return o?l(e,c)&&E(n,"set",t,e):E(n,"add",t,e),u}function nt(t){t=Ot(t);const e=Ot(this),n=X(e),r=n.has.call(e,t),o=(n.get&&n.get.call(e,t),n.delete.call(e,t));return r&&E(e,"delete",t,void 0),o}function rt(){const t=Ot(this),e=0!==t.size,n=X(t).clear.call(t);return e&&E(t,"clear",void 0,void 0),n}function ot(t){return function(e,n){const r=this,o=Ot(r),c=t?U:T;return m(o,0,p),X(o).forEach.call(o,(function(t,n){return e.call(r,c(t),c(n),r)}),n)}}function ct(t,e){return function(...n){const r=Ot(this),o="entries"===t||t===Symbol.iterator&&r instanceof Map,c=X(r)[t].apply(r,n),u=e?U:T;return m(r,0,p),{next(){const{value:t,done:e}=c.next();return e?{value:t,done:e}:{value:o?[u(t[0]),u(t[1])]:u(t),done:e}},[Symbol.iterator](){return this}}}}function ut(t,e){return function(...n){return W?"delete"!==e&&this:t.apply(this,n)}}const it={get(t){return Y(this,t,T)},get size(){return $(this)},has:Z,add:tt,set:et,delete:nt,clear:rt,forEach:ot(!1)},st={get(t){return Y(this,t,U)},get size(){return $(this)},has:Z,add:ut(tt,"add"),set:ut(et,"set"),delete:ut(nt,"delete"),clear:ut(rt,"clear"),forEach:ot(!0)};function at(t){return(e,n,r)=>Reflect.get(o(t,n)&&n in e?t:e,n,r)}["keys","values","entries",Symbol.iterator].forEach(t=>{it[t]=ct(t,!1),st[t]=ct(t,!0)});const lt={get:at(it)},ft={get:at(st)},dt=new WeakMap,ht=new WeakMap,pt=new WeakMap,gt=new WeakMap,vt=new WeakSet,yt=new WeakSet,wt=new Set([Set,Map,WeakMap,WeakSet]),St=t("Object,Array,Map,Set,WeakMap,WeakSet");function bt(t){return gt.has(t)?t:vt.has(t)?Rt(t):xt(t)?t:Et(t,dt,ht,G,lt)}function Rt(t){return ht.has(t)&&(t=ht.get(t)),Et(t,pt,gt,H,ft)}function kt(t){return Et(t,pt,gt,Q,ft)}function mt(t){return Et(t,dt,ht,J,lt)}function Et(t,e,n,r,o){if(!i(t))return t;let c=e.get(t);if(void 0!==c)return c;if(n.has(t))return t;if((u=t)._isVue||u._isVNode||!St(a(u))||yt.has(u))return t;var u;const s=wt.has(t.constructor)?o:r;return c=new Proxy(t,s),e.set(t,c),n.set(c,t),c}function Mt(t){return ht.has(t)||gt.has(t)}function Wt(t){return gt.has(t)}function Ot(t){return ht.get(t)||gt.get(t)||t}function _t(t){return vt.add(t),t}function Pt(t){return yt.add(t),t}const jt=t=>i(t)?bt(t):t;function xt(t){return!!t&&!0===t._isRef}function zt(t){return Kt(t)}function At(t){return Kt(t,!0)}function Kt(t,e=!1){if(xt(t))return t;e||(t=jt(t));const n={_isRef:!0,get value(){return m(n,0,"value"),t},set value(r){t=e?r:jt(r),E(n,"set","value",void 0)}};return n}function Nt(t){return xt(t)?t.value:t}function Vt(t){const e={};for(const n in t)e[n]=Ct(t,n);return e}function Ct(t,e){return{_isRef:!0,get value(){return t[e]},set value(n){t[e]=n}}}function It(t){let e,r;"function"==typeof t?(e=t,r=n):(e=t.get,r=t.set);let o,c,u=!0;const i=g(e,{lazy:!0,computed:!0,scheduler:()=>{u||(u=!0,E(c,"set","value"))}});return c={_isRef:!0,effect:i,get value(){return u&&(o=i(),u=!1),m(c,0,"value"),o},set value(t){r(t)}},c}export{p as ITERATE_KEY,It as computed,g as effect,R as enableTracking,Mt as isReactive,Wt as isReadonly,xt as isRef,O as lock,Pt as markNonReactive,_t as markReadonly,b as pauseTracking,bt as reactive,Rt as readonly,zt as ref,k as resetTracking,mt as shallowReactive,kt as shallowReadonly,At as shallowRef,v as stop,Ot as toRaw,Vt as toRefs,m as track,E as trigger,_ as unlock,Nt as unref}; | ||
function t(t,e){const n=Object.create(null),r=t.split(",");for(let t=0;t<r.length;t++)n[r[t]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e={},n=()=>{},r=Object.prototype.hasOwnProperty,o=(t,e)=>r.call(t,e),c=Array.isArray,u=t=>"symbol"==typeof t,s=t=>null!==t&&"object"==typeof t,i=Object.prototype.toString,a=t=>(t=>i.call(t))(t).slice(8,-1),l=(t,e)=>t!==e&&(t==t||e==e),f=new WeakMap,d=[];let h;const p=Symbol("iterate");function g(t,n=e){(function(t){return null!=t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(...e){return function(t,e,n){if(!t.active)return e(...n);if(!d.includes(t)){y(t);try{return R(),d.push(t),h=t,e(...n)}finally{d.pop(),k(),h=d[d.length-1]}}}(n,t,e)};return n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,n);return n.lazy||r(),r}function v(t){t.active&&(y(t),t.options.onStop&&t.options.onStop(),t.active=!1)}function y(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let w=!0;const S=[];function b(){S.push(w),w=!1}function R(){S.push(w),w=!0}function k(){const t=S.pop();w=void 0===t||t}function m(t,e,n){if(!w||void 0===h)return;let r=f.get(t);void 0===r&&f.set(t,r=new Map);let o=r.get(n);void 0===o&&r.set(n,o=new Set),o.has(h)||(o.add(h),h.deps.push(o))}function E(t,e,n,r,o,u){const s=f.get(t);if(void 0===s)return;const i=new Set,a=new Set;if("clear"===e)s.forEach(t=>{M(i,a,t)});else if("length"===n&&c(t))s.forEach((t,e)=>{("length"===e||e>=r)&&M(i,a,t)});else if(void 0!==n&&M(i,a,s.get(n)),"add"===e||"delete"===e&&!c(t)||"set"===e&&t instanceof Map){const e=c(t)?"length":p;M(i,a,s.get(e))}const l=t=>{!function(t,e,n,r,o){void 0!==t.options.scheduler?t.options.scheduler(t):t()}(t)};a.forEach(l),i.forEach(l)}function M(t,e,n){void 0!==n&&n.forEach(n=>{n===h&&w||(n.options.computed?e.add(n):t.add(n))})}let W=!0;function O(){W=!0}function _(){W=!1}const P=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(u)),j=N(),x=N(!1,!0),z=N(!0),A=N(!0,!0),K={};function N(t=!1,e=!1){return function(n,r,i){if(c(n)&&o(K,r))return Reflect.get(K,r,i);const a=Reflect.get(n,r,i);return u(r)&&P.has(r)?a:e?(m(n,0,r),a):xt(a)&&!c(n)?a.value:(m(n,0,r),s(a)?t?Rt(a):bt(a):a)}}["includes","indexOf","lastIndexOf"].forEach(t=>{K[t]=function(...e){const n=Ot(this);for(let t=0,e=this.length;t<e;t++)m(n,0,t+"");const r=n[t](...e);return-1===r||!1===r?n[t](...e.map(Ot)):r}});const V=q(),C=q(!1,!0),I=q(!0),L=q(!0,!0);function q(t=!1,e=!1){return function(n,r,u,s){if(t&&W)return!0;const i=n[r];if(!e&&(u=Ot(u),!c(n)&&xt(i)&&!xt(u)))return i.value=u,!0;const a=o(n,r),f=Reflect.set(n,r,u,s);return n===Ot(s)&&(a?l(u,i)&&E(n,"set",r,u):E(n,"add",r,u)),f}}function B(t,e){const n=o(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&E(t,"delete",e,void 0),r}function D(t,e){const n=Reflect.has(t,e);return m(t,0,e),n}function F(t){return m(t,0,p),Reflect.ownKeys(t)}const G={get:j,set:V,deleteProperty:B,has:D,ownKeys:F},H={get:z,set:I,has:D,ownKeys:F,deleteProperty:(t,e)=>!!W||B(t,e)},J={...G,get:x,set:C},Q={...H,get:A,set:L},T=t=>s(t)?bt(t):t,U=t=>s(t)?Rt(t):t,X=t=>Reflect.getPrototypeOf(t);function Y(t,e,n){t=Ot(t);const r=Ot(e);m(t,0,r);const{has:o,get:c}=X(t);return o.call(t,e)?n(c.call(t,e)):o.call(t,r)?n(c.call(t,r)):void 0}function Z(t){const e=Ot(this),n=Ot(t);m(e,0,n);const r=X(e).has;return r.call(e,t)||r.call(e,n)}function $(t){return m(t=Ot(t),0,p),Reflect.get(X(t),"size",t)}function tt(t){t=Ot(t);const e=Ot(this),n=X(e),r=n.has.call(e,t),o=n.add.call(e,t);return r||E(e,"add",t,t),o}function et(t,e){e=Ot(e),t=Ot(t);const n=Ot(this),r=X(n),o=r.has.call(n,t),c=r.get.call(n,t),u=r.set.call(n,t,e);return o?l(e,c)&&E(n,"set",t,e):E(n,"add",t,e),u}function nt(t){const e=Ot(this),{has:n,get:r,delete:o}=X(e);let c=n.call(e,t);c||(t=Ot(t),c=n.call(e,t));r&&r.call(e,t);const u=o.call(e,t);return c&&E(e,"delete",t,void 0),u}function rt(){const t=Ot(this),e=0!==t.size,n=X(t).clear.call(t);return e&&E(t,"clear",void 0,void 0),n}function ot(t){return function(e,n){const r=this,o=Ot(r),c=t?U:T;return m(o,0,p),X(o).forEach.call(o,(function(t,n){return e.call(r,c(t),c(n),r)}),n)}}function ct(t,e){return function(...n){const r=Ot(this),o="entries"===t||t===Symbol.iterator&&r instanceof Map,c=X(r)[t].apply(r,n),u=e?U:T;return m(r,0,p),{next(){const{value:t,done:e}=c.next();return e?{value:t,done:e}:{value:o?[u(t[0]),u(t[1])]:u(t),done:e}},[Symbol.iterator](){return this}}}}function ut(t,e){return function(...n){return W?"delete"!==e&&this:t.apply(this,n)}}const st={get(t){return Y(this,t,T)},get size(){return $(this)},has:Z,add:tt,set:et,delete:nt,clear:rt,forEach:ot(!1)},it={get(t){return Y(this,t,U)},get size(){return $(this)},has:Z,add:ut(tt,"add"),set:ut(et,"set"),delete:ut(nt,"delete"),clear:ut(rt,"clear"),forEach:ot(!0)};function at(t){return(e,n,r)=>Reflect.get(o(t,n)&&n in e?t:e,n,r)}["keys","values","entries",Symbol.iterator].forEach(t=>{st[t]=ct(t,!1),it[t]=ct(t,!0)});const lt={get:at(st)},ft={get:at(it)},dt=new WeakMap,ht=new WeakMap,pt=new WeakMap,gt=new WeakMap,vt=new WeakSet,yt=new WeakSet,wt=new Set([Set,Map,WeakMap,WeakSet]),St=t("Object,Array,Map,Set,WeakMap,WeakSet");function bt(t){return gt.has(t)?t:vt.has(t)?Rt(t):xt(t)?t:Et(t,dt,ht,G,lt)}function Rt(t){return ht.has(t)&&(t=ht.get(t)),Et(t,pt,gt,H,ft)}function kt(t){return Et(t,pt,gt,Q,ft)}function mt(t){return Et(t,dt,ht,J,lt)}function Et(t,e,n,r,o){if(!s(t))return t;let c=e.get(t);if(void 0!==c)return c;if(n.has(t))return t;if((u=t)._isVue||u._isVNode||!St(a(u))||yt.has(u))return t;var u;const i=wt.has(t.constructor)?o:r;return c=new Proxy(t,i),e.set(t,c),n.set(c,t),c}function Mt(t){return ht.has(t)||gt.has(t)}function Wt(t){return gt.has(t)}function Ot(t){return ht.get(t)||gt.get(t)||t}function _t(t){return vt.add(t),t}function Pt(t){return yt.add(t),t}const jt=t=>s(t)?bt(t):t;function xt(t){return!!t&&!0===t._isRef}function zt(t){return Kt(t)}function At(t){return Kt(t,!0)}function Kt(t,e=!1){if(xt(t))return t;e||(t=jt(t));const n={_isRef:!0,get value(){return m(n,0,"value"),t},set value(r){t=e?r:jt(r),E(n,"set","value",void 0)}};return n}function Nt(t){return xt(t)?t.value:t}function Vt(t){const e={};for(const n in t)e[n]=Ct(t,n);return e}function Ct(t,e){return{_isRef:!0,get value(){return t[e]},set value(n){t[e]=n}}}function It(t){let e,r;"function"==typeof t?(e=t,r=n):(e=t.get,r=t.set);let o,c,u=!0;const s=g(e,{lazy:!0,computed:!0,scheduler:()=>{u||(u=!0,E(c,"set","value"))}});return c={_isRef:!0,effect:s,get value(){return u&&(o=s(),u=!1),m(c,0,"value"),o},set value(t){r(t)}},c}export{p as ITERATE_KEY,It as computed,g as effect,R as enableTracking,Mt as isReactive,Wt as isReadonly,xt as isRef,O as lock,Pt as markNonReactive,_t as markReadonly,b as pauseTracking,bt as reactive,Rt as readonly,zt as ref,k as resetTracking,mt as shallowReactive,kt as shallowReadonly,At as shallowRef,v as stop,Ot as toRaw,Vt as toRefs,m as track,E as trigger,_ as unlock,Nt as unref}; |
@@ -183,3 +183,3 @@ var VueReactivity = (function (exports) { | ||
if (type === "add" /* ADD */ || | ||
type === "delete" /* DELETE */ || | ||
(type === "delete" /* DELETE */ && !isArray(target)) || | ||
(type === "set" /* SET */ && target instanceof Map)) { | ||
@@ -206,3 +206,3 @@ const iterationKey = isArray(target) ? 'length' : ITERATE_KEY; | ||
effectsToAdd.forEach(effect => { | ||
if (effect !== activeEffect) { | ||
if (effect !== activeEffect || !shouldTrack) { | ||
if (effect.options.computed) { | ||
@@ -259,3 +259,11 @@ computedRunners.add(effect); | ||
} | ||
return arr[key](...args.map(toRaw)); | ||
// we run the method using the orignal 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; | ||
} | ||
}; | ||
@@ -386,11 +394,18 @@ }); | ||
target = toRaw(target); | ||
key = toRaw(key); | ||
track(target, "get" /* GET */, key); | ||
return wrap(getProto(target).get.call(target, key)); | ||
const rawKey = toRaw(key); | ||
track(target, "get" /* GET */, rawKey); | ||
const { has, get } = getProto(target); | ||
if (has.call(target, key)) { | ||
return wrap(get.call(target, key)); | ||
} | ||
else if (has.call(target, rawKey)) { | ||
return wrap(get.call(target, rawKey)); | ||
} | ||
} | ||
function has$1(key) { | ||
const target = toRaw(this); | ||
key = toRaw(key); | ||
track(target, "has" /* HAS */, key); | ||
return getProto(target).has.call(target, key); | ||
const rawKey = toRaw(key); | ||
track(target, "has" /* HAS */, rawKey); | ||
const has = getProto(target).has; | ||
return has.call(target, key) || has.call(target, rawKey); | ||
} | ||
@@ -430,9 +445,12 @@ function size(target) { | ||
function deleteEntry(key) { | ||
key = toRaw(key); | ||
const target = toRaw(this); | ||
const proto = getProto(target); | ||
const hadKey = proto.has.call(target, key); | ||
const oldValue = proto.get ? proto.get.call(target, key) : undefined; | ||
const { has, get, delete: del } = getProto(target); | ||
let hadKey = has.call(target, key); | ||
if (!hadKey) { | ||
key = toRaw(key); | ||
hadKey = has.call(target, key); | ||
} | ||
const oldValue = get ? get.call(target, key) : undefined; | ||
// forward the operation before queueing reactions | ||
const result = proto.delete.call(target, key); | ||
const result = del.call(target, key); | ||
if (hadKey) { | ||
@@ -439,0 +457,0 @@ trigger(target, "delete" /* DELETE */, key, undefined, oldValue); |
@@ -1,1 +0,1 @@ | ||
var VueReactivity=function(e){"use strict";function t(e,t){const n=Object.create(null),r=e.split(",");for(let e=0;e<r.length;e++)n[r[e]]=!0;return t?e=>!!n[e.toLowerCase()]:e=>!!n[e]}const n={},r=()=>{},o=Object.prototype.hasOwnProperty,c=(e,t)=>o.call(e,t),u=Array.isArray,i=e=>"symbol"==typeof e,s=e=>null!==e&&"object"==typeof e,a=Object.prototype.toString,l=e=>(e=>a.call(e))(e).slice(8,-1),f=(e,t)=>e!==t&&(e==e||t==t),d=new WeakMap,h=[];let p;const g=Symbol("iterate");function v(e,t=n){(function(e){return null!=e&&!0===e._isEffect})(e)&&(e=e.raw);const r=function(e,t){const n=function(...t){return function(e,t,n){if(!e.active)return t(...n);if(!h.includes(e)){y(e);try{return k(),h.push(e),p=e,t(...n)}finally{h.pop(),S(),p=h[h.length-1]}}}(n,e,t)};return n._isEffect=!0,n.active=!0,n.raw=e,n.deps=[],n.options=t,n}(e,t);return t.lazy||r(),r}function y(e){const{deps:t}=e;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0}}let w=!0;const R=[];function k(){R.push(w),w=!0}function S(){const e=R.pop();w=void 0===e||e}function m(e,t,n){if(!w||void 0===p)return;let r=d.get(e);void 0===r&&d.set(e,r=new Map);let o=r.get(n);void 0===o&&r.set(n,o=new Set),o.has(p)||(o.add(p),p.deps.push(o))}function E(e,t,n,r,o,c){const i=d.get(e);if(void 0===i)return;const s=new Set,a=new Set;if("clear"===t)i.forEach(e=>{b(s,a,e)});else if("length"===n&&u(e))i.forEach((e,t)=>{("length"===t||t>=r)&&b(s,a,e)});else if(void 0!==n&&b(s,a,i.get(n)),"add"===t||"delete"===t||"set"===t&&e instanceof Map){const t=u(e)?"length":g;b(s,a,i.get(t))}const l=e=>{!function(e,t,n,r,o){void 0!==e.options.scheduler?e.options.scheduler(e):e()}(e)};a.forEach(l),s.forEach(l)}function b(e,t,n){void 0!==n&&n.forEach(n=>{n!==p&&(n.options.computed?t.add(n):e.add(n))})}let M=!0;const W=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(i)),O=x(),_=x(!1,!0),P=x(!0),j=x(!0,!0),z={};function x(e=!1,t=!1){return function(n,r,o){if(u(n)&&c(z,r))return Reflect.get(z,r,o);const a=Reflect.get(n,r,o);return i(r)&&W.has(r)?a:t?(m(n,0,r),a):me(a)&&!u(n)?a.value:(m(n,0,r),s(a)?e?we(a):ye(a):a)}}["includes","indexOf","lastIndexOf"].forEach(e=>{z[e]=function(...t){const n=ke(this);for(let e=0,t=this.length;e<t;e++)m(n,0,e+"");return n[e](...t.map(ke))}});const T=V(),A=V(!1,!0),K=V(!0),N=V(!0,!0);function V(e=!1,t=!1){return function(n,r,o,i){if(e&&M)return!0;const s=n[r];if(!t&&(o=ke(o),!u(n)&&me(s)&&!me(o)))return s.value=o,!0;const a=c(n,r),l=Reflect.set(n,r,o,i);return n===ke(i)&&(a?f(o,s)&&E(n,"set",r,o):E(n,"add",r,o)),l}}function I(e,t){const n=c(e,t),r=Reflect.deleteProperty(e,t);return r&&n&&E(e,"delete",t,void 0),r}function C(e,t){const n=Reflect.has(e,t);return m(e,0,t),n}function L(e){return m(e,0,g),Reflect.ownKeys(e)}const Y={get:O,set:T,deleteProperty:I,has:C,ownKeys:L},q={get:P,set:K,has:C,ownKeys:L,deleteProperty:(e,t)=>!!M||I(e,t)},B={...Y,get:_,set:A},D={...q,get:j,set:N},F=e=>s(e)?ye(e):e,G=e=>s(e)?we(e):e,H=e=>Reflect.getPrototypeOf(e);function J(e,t,n){return m(e=ke(e),0,t=ke(t)),n(H(e).get.call(e,t))}function Q(e){const t=ke(this);return m(t,0,e=ke(e)),H(t).has.call(t,e)}function U(e){return m(e=ke(e),0,g),Reflect.get(H(e),"size",e)}function X(e){e=ke(e);const t=ke(this),n=H(t),r=n.has.call(t,e),o=n.add.call(t,e);return r||E(t,"add",e,e),o}function Z(e,t){t=ke(t),e=ke(e);const n=ke(this),r=H(n),o=r.has.call(n,e),c=r.get.call(n,e),u=r.set.call(n,e,t);return o?f(t,c)&&E(n,"set",e,t):E(n,"add",e,t),u}function $(e){e=ke(e);const t=ke(this),n=H(t),r=n.has.call(t,e),o=(n.get&&n.get.call(t,e),n.delete.call(t,e));return r&&E(t,"delete",e,void 0),o}function ee(){const e=ke(this),t=0!==e.size,n=H(e).clear.call(e);return t&&E(e,"clear",void 0,void 0),n}function te(e){return function(t,n){const r=this,o=ke(r),c=e?G:F;return m(o,0,g),H(o).forEach.call(o,(function(e,n){return t.call(r,c(e),c(n),r)}),n)}}function ne(e,t){return function(...n){const r=ke(this),o="entries"===e||e===Symbol.iterator&&r instanceof Map,c=H(r)[e].apply(r,n),u=t?G:F;return m(r,0,g),{next(){const{value:e,done:t}=c.next();return t?{value:e,done:t}:{value:o?[u(e[0]),u(e[1])]:u(e),done:t}},[Symbol.iterator](){return this}}}}function re(e,t){return function(...n){return M?"delete"!==t&&this:e.apply(this,n)}}const oe={get(e){return J(this,e,F)},get size(){return U(this)},has:Q,add:X,set:Z,delete:$,clear:ee,forEach:te(!1)},ce={get(e){return J(this,e,G)},get size(){return U(this)},has:Q,add:re(X,"add"),set:re(Z,"set"),delete:re($,"delete"),clear:re(ee,"clear"),forEach:te(!0)};function ue(e){return(t,n,r)=>Reflect.get(c(e,n)&&n in t?e:t,n,r)}["keys","values","entries",Symbol.iterator].forEach(e=>{oe[e]=ne(e,!1),ce[e]=ne(e,!0)});const ie={get:ue(oe)},se={get:ue(ce)},ae=new WeakMap,le=new WeakMap,fe=new WeakMap,de=new WeakMap,he=new WeakSet,pe=new WeakSet,ge=new Set([Set,Map,WeakMap,WeakSet]),ve=t("Object,Array,Map,Set,WeakMap,WeakSet");function ye(e){return de.has(e)?e:he.has(e)?we(e):me(e)?e:Re(e,ae,le,Y,ie)}function we(e){return le.has(e)&&(e=le.get(e)),Re(e,fe,de,q,se)}function Re(e,t,n,r,o){if(!s(e))return e;let c=t.get(e);if(void 0!==c)return c;if(n.has(e))return e;if((u=e)._isVue||u._isVNode||!ve(l(u))||pe.has(u))return e;var u;const i=ge.has(e.constructor)?o:r;return c=new Proxy(e,i),t.set(e,c),n.set(c,e),c}function ke(e){return le.get(e)||de.get(e)||e}const Se=e=>s(e)?ye(e):e;function me(e){return!!e&&!0===e._isRef}function Ee(e,t=!1){if(me(e))return e;t||(e=Se(e));const n={_isRef:!0,get value(){return m(n,0,"value"),e},set value(r){e=t?r:Se(r),E(n,"set","value",void 0)}};return n}function be(e,t){return{_isRef:!0,get value(){return e[t]},set value(n){e[t]=n}}}return e.ITERATE_KEY=g,e.computed=function(e){let t,n;"function"==typeof e?(t=e,n=r):(t=e.get,n=e.set);let o,c,u=!0;const i=v(t,{lazy:!0,computed:!0,scheduler:()=>{u||(u=!0,E(c,"set","value"))}});return c={_isRef:!0,effect:i,get value(){return u&&(o=i(),u=!1),m(c,0,"value"),o},set value(e){n(e)}},c},e.effect=v,e.enableTracking=k,e.isReactive=function(e){return le.has(e)||de.has(e)},e.isReadonly=function(e){return de.has(e)},e.isRef=me,e.lock=function(){M=!0},e.markNonReactive=function(e){return pe.add(e),e},e.markReadonly=function(e){return he.add(e),e},e.pauseTracking=function(){R.push(w),w=!1},e.reactive=ye,e.readonly=we,e.ref=function(e){return Ee(e)},e.resetTracking=S,e.shallowReactive=function(e){return Re(e,ae,le,B,ie)},e.shallowReadonly=function(e){return Re(e,fe,de,D,se)},e.shallowRef=function(e){return Ee(e,!0)},e.stop=function(e){e.active&&(y(e),e.options.onStop&&e.options.onStop(),e.active=!1)},e.toRaw=ke,e.toRefs=function(e){const t={};for(const n in e)t[n]=be(e,n);return t},e.track=m,e.trigger=E,e.unlock=function(){M=!1},e.unref=function(e){return me(e)?e.value:e},e}({}); | ||
var VueReactivity=function(t){"use strict";function e(t,e){const n=Object.create(null),r=t.split(",");for(let t=0;t<r.length;t++)n[r[t]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const n={},r=()=>{},o=Object.prototype.hasOwnProperty,c=(t,e)=>o.call(t,e),u=Array.isArray,s=t=>"symbol"==typeof t,i=t=>null!==t&&"object"==typeof t,a=Object.prototype.toString,l=t=>(t=>a.call(t))(t).slice(8,-1),f=(t,e)=>t!==e&&(t==t||e==e),d=new WeakMap,h=[];let p;const g=Symbol("iterate");function v(t,e=n){(function(t){return null!=t&&!0===t._isEffect})(t)&&(t=t.raw);const r=function(t,e){const n=function(...e){return function(t,e,n){if(!t.active)return e(...n);if(!h.includes(t)){y(t);try{return k(),h.push(t),p=t,e(...n)}finally{h.pop(),S(),p=h[h.length-1]}}}(n,t,e)};return n._isEffect=!0,n.active=!0,n.raw=t,n.deps=[],n.options=e,n}(t,e);return e.lazy||r(),r}function y(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let w=!0;const R=[];function k(){R.push(w),w=!0}function S(){const t=R.pop();w=void 0===t||t}function m(t,e,n){if(!w||void 0===p)return;let r=d.get(t);void 0===r&&d.set(t,r=new Map);let o=r.get(n);void 0===o&&r.set(n,o=new Set),o.has(p)||(o.add(p),p.deps.push(o))}function E(t,e,n,r,o,c){const s=d.get(t);if(void 0===s)return;const i=new Set,a=new Set;if("clear"===e)s.forEach(t=>{b(i,a,t)});else if("length"===n&&u(t))s.forEach((t,e)=>{("length"===e||e>=r)&&b(i,a,t)});else if(void 0!==n&&b(i,a,s.get(n)),"add"===e||"delete"===e&&!u(t)||"set"===e&&t instanceof Map){const e=u(t)?"length":g;b(i,a,s.get(e))}const l=t=>{!function(t,e,n,r,o){void 0!==t.options.scheduler?t.options.scheduler(t):t()}(t)};a.forEach(l),i.forEach(l)}function b(t,e,n){void 0!==n&&n.forEach(n=>{n===p&&w||(n.options.computed?e.add(n):t.add(n))})}let M=!0;const W=new Set(Object.getOwnPropertyNames(Symbol).map(t=>Symbol[t]).filter(s)),O=x(),_=x(!1,!0),P=x(!0),j=x(!0,!0),z={};function x(t=!1,e=!1){return function(n,r,o){if(u(n)&&c(z,r))return Reflect.get(z,r,o);const a=Reflect.get(n,r,o);return s(r)&&W.has(r)?a:e?(m(n,0,r),a):mt(a)&&!u(n)?a.value:(m(n,0,r),i(a)?t?wt(a):yt(a):a)}}["includes","indexOf","lastIndexOf"].forEach(t=>{z[t]=function(...e){const n=kt(this);for(let t=0,e=this.length;t<e;t++)m(n,0,t+"");const r=n[t](...e);return-1===r||!1===r?n[t](...e.map(kt)):r}});const T=V(),A=V(!1,!0),K=V(!0),N=V(!0,!0);function V(t=!1,e=!1){return function(n,r,o,s){if(t&&M)return!0;const i=n[r];if(!e&&(o=kt(o),!u(n)&&mt(i)&&!mt(o)))return i.value=o,!0;const a=c(n,r),l=Reflect.set(n,r,o,s);return n===kt(s)&&(a?f(o,i)&&E(n,"set",r,o):E(n,"add",r,o)),l}}function I(t,e){const n=c(t,e),r=Reflect.deleteProperty(t,e);return r&&n&&E(t,"delete",e,void 0),r}function C(t,e){const n=Reflect.has(t,e);return m(t,0,e),n}function L(t){return m(t,0,g),Reflect.ownKeys(t)}const Y={get:O,set:T,deleteProperty:I,has:C,ownKeys:L},q={get:P,set:K,has:C,ownKeys:L,deleteProperty:(t,e)=>!!M||I(t,e)},B={...Y,get:_,set:A},D={...q,get:j,set:N},F=t=>i(t)?yt(t):t,G=t=>i(t)?wt(t):t,H=t=>Reflect.getPrototypeOf(t);function J(t,e,n){t=kt(t);const r=kt(e);m(t,0,r);const{has:o,get:c}=H(t);return o.call(t,e)?n(c.call(t,e)):o.call(t,r)?n(c.call(t,r)):void 0}function Q(t){const e=kt(this),n=kt(t);m(e,0,n);const r=H(e).has;return r.call(e,t)||r.call(e,n)}function U(t){return m(t=kt(t),0,g),Reflect.get(H(t),"size",t)}function X(t){t=kt(t);const e=kt(this),n=H(e),r=n.has.call(e,t),o=n.add.call(e,t);return r||E(e,"add",t,t),o}function Z(t,e){e=kt(e),t=kt(t);const n=kt(this),r=H(n),o=r.has.call(n,t),c=r.get.call(n,t),u=r.set.call(n,t,e);return o?f(e,c)&&E(n,"set",t,e):E(n,"add",t,e),u}function $(t){const e=kt(this),{has:n,get:r,delete:o}=H(e);let c=n.call(e,t);c||(t=kt(t),c=n.call(e,t));r&&r.call(e,t);const u=o.call(e,t);return c&&E(e,"delete",t,void 0),u}function tt(){const t=kt(this),e=0!==t.size,n=H(t).clear.call(t);return e&&E(t,"clear",void 0,void 0),n}function et(t){return function(e,n){const r=this,o=kt(r),c=t?G:F;return m(o,0,g),H(o).forEach.call(o,(function(t,n){return e.call(r,c(t),c(n),r)}),n)}}function nt(t,e){return function(...n){const r=kt(this),o="entries"===t||t===Symbol.iterator&&r instanceof Map,c=H(r)[t].apply(r,n),u=e?G:F;return m(r,0,g),{next(){const{value:t,done:e}=c.next();return e?{value:t,done:e}:{value:o?[u(t[0]),u(t[1])]:u(t),done:e}},[Symbol.iterator](){return this}}}}function rt(t,e){return function(...n){return M?"delete"!==e&&this:t.apply(this,n)}}const ot={get(t){return J(this,t,F)},get size(){return U(this)},has:Q,add:X,set:Z,delete:$,clear:tt,forEach:et(!1)},ct={get(t){return J(this,t,G)},get size(){return U(this)},has:Q,add:rt(X,"add"),set:rt(Z,"set"),delete:rt($,"delete"),clear:rt(tt,"clear"),forEach:et(!0)};function ut(t){return(e,n,r)=>Reflect.get(c(t,n)&&n in e?t:e,n,r)}["keys","values","entries",Symbol.iterator].forEach(t=>{ot[t]=nt(t,!1),ct[t]=nt(t,!0)});const st={get:ut(ot)},it={get:ut(ct)},at=new WeakMap,lt=new WeakMap,ft=new WeakMap,dt=new WeakMap,ht=new WeakSet,pt=new WeakSet,gt=new Set([Set,Map,WeakMap,WeakSet]),vt=e("Object,Array,Map,Set,WeakMap,WeakSet");function yt(t){return dt.has(t)?t:ht.has(t)?wt(t):mt(t)?t:Rt(t,at,lt,Y,st)}function wt(t){return lt.has(t)&&(t=lt.get(t)),Rt(t,ft,dt,q,it)}function Rt(t,e,n,r,o){if(!i(t))return t;let c=e.get(t);if(void 0!==c)return c;if(n.has(t))return t;if((u=t)._isVue||u._isVNode||!vt(l(u))||pt.has(u))return t;var u;const s=gt.has(t.constructor)?o:r;return c=new Proxy(t,s),e.set(t,c),n.set(c,t),c}function kt(t){return lt.get(t)||dt.get(t)||t}const St=t=>i(t)?yt(t):t;function mt(t){return!!t&&!0===t._isRef}function Et(t,e=!1){if(mt(t))return t;e||(t=St(t));const n={_isRef:!0,get value(){return m(n,0,"value"),t},set value(r){t=e?r:St(r),E(n,"set","value",void 0)}};return n}function bt(t,e){return{_isRef:!0,get value(){return t[e]},set value(n){t[e]=n}}}return t.ITERATE_KEY=g,t.computed=function(t){let e,n;"function"==typeof t?(e=t,n=r):(e=t.get,n=t.set);let o,c,u=!0;const s=v(e,{lazy:!0,computed:!0,scheduler:()=>{u||(u=!0,E(c,"set","value"))}});return c={_isRef:!0,effect:s,get value(){return u&&(o=s(),u=!1),m(c,0,"value"),o},set value(t){n(t)}},c},t.effect=v,t.enableTracking=k,t.isReactive=function(t){return lt.has(t)||dt.has(t)},t.isReadonly=function(t){return dt.has(t)},t.isRef=mt,t.lock=function(){M=!0},t.markNonReactive=function(t){return pt.add(t),t},t.markReadonly=function(t){return ht.add(t),t},t.pauseTracking=function(){R.push(w),w=!1},t.reactive=yt,t.readonly=wt,t.ref=function(t){return Et(t)},t.resetTracking=S,t.shallowReactive=function(t){return Rt(t,at,lt,B,st)},t.shallowReadonly=function(t){return Rt(t,ft,dt,D,it)},t.shallowRef=function(t){return Et(t,!0)},t.stop=function(t){t.active&&(y(t),t.options.onStop&&t.options.onStop(),t.active=!1)},t.toRaw=kt,t.toRefs=function(t){const e={};for(const n in t)e[n]=bt(t,n);return e},t.track=m,t.trigger=E,t.unlock=function(){M=!1},t.unref=function(t){return mt(t)?t.value:t},t}({}); |
{ | ||
"name": "@vue/reactivity", | ||
"version": "3.0.0-alpha.7", | ||
"version": "3.0.0-alpha.8", | ||
"description": "@vue/reactivity", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/vuejs/vue.git" | ||
"url": "git+https://github.com/vuejs/vue-next.git" | ||
}, | ||
@@ -34,5 +34,8 @@ "buildOptions": { | ||
"bugs": { | ||
"url": "https://github.com/vuejs/vue/issues" | ||
"url": "https://github.com/vuejs/vue-next/issues" | ||
}, | ||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/reactivity#readme" | ||
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/reactivity#readme", | ||
"dependencies": { | ||
"@vue/shared": "3.0.0-alpha.8" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1
145423
1
3871
12
+ Added@vue/shared@3.0.0-alpha.8
+ Added@vue/shared@3.0.0-alpha.8(transitive)