Comparing version 1.11.0 to 1.11.1
@@ -33,7 +33,7 @@ type AnyFunction = (...args: any[]) => any; | ||
export declare function ref<T extends object>(obj: T): T & AsRef; | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, shouldTrapDefineProperty?: (desc: PropertyDescriptor) => boolean | undefined, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
status?: 'pending' | 'fulfilled' | 'rejected'; | ||
value?: Awaited<P>; | ||
reason?: unknown; | ||
}) => Awaited<P>, snapCache?: WeakMap<object, [version: number, snap: unknown]>, createSnapshot?: CreateSnapshot, proxyCache?: WeakMap<object, object>, versionHolder?: [number, number], proxyFunction?: <T_1 extends object>(initialObject: T_1) => T_1) => readonly [<T_1 extends object>(initialObject: T_1) => T_1, WeakMap<object, ProxyState>, WeakSet<object>, (value1: any, value2: any) => boolean, <T extends object>(target: T, handler: ProxyHandler<T>) => T, (x: unknown) => boolean, (desc: PropertyDescriptor) => boolean | undefined, <P extends Promise<any>>(promise: P & { | ||
}) => Awaited<P>, snapCache?: WeakMap<object, [version: number, snap: unknown]>, createSnapshot?: CreateSnapshot, proxyCache?: WeakMap<object, object>, versionHolder?: [number, number], proxyFunction?: <T_1 extends object>(initialObject: T_1) => T_1) => readonly [<T_1 extends object>(initialObject: T_1) => T_1, WeakMap<object, ProxyState>, WeakSet<object>, (value1: any, value2: any) => boolean, <T extends object>(target: T, handler: ProxyHandler<T>) => T, (x: unknown) => boolean, <P extends Promise<any>>(promise: P & { | ||
status?: 'pending' | 'fulfilled' | 'rejected'; | ||
@@ -40,0 +40,0 @@ value?: Awaited<P>; |
@@ -6,3 +6,3 @@ import { markToTrack, getUntracked } from 'proxy-compare'; | ||
const refSet = /* @__PURE__ */ new WeakSet(); | ||
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), shouldTrapDefineProperty = (desc) => desc.configurable && desc.enumerable && desc.writable, defaultHandlePromise = (promise) => { | ||
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), defaultHandlePromise = (promise) => { | ||
switch (promise.status) { | ||
@@ -133,33 +133,2 @@ case "fulfilled": | ||
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); | ||
const trapSet = (hasPrevValue, prevValue, prop, value, setValue) => { | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = getUntracked(value) || value; | ||
} | ||
let nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then((v) => { | ||
value.status = "fulfilled"; | ||
value.value = v; | ||
notifyUpdate(["resolve", [prop], v]); | ||
}).catch((e) => { | ||
value.status = "rejected"; | ||
value.reason = e; | ||
notifyUpdate(["reject", [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction(value); | ||
} | ||
const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
setValue(nextValue); | ||
notifyUpdate(["set", [prop], value, prevValue]); | ||
}; | ||
const handler = { | ||
@@ -178,27 +147,32 @@ deleteProperty(target, prop) { | ||
const prevValue = Reflect.get(target, prop, receiver); | ||
trapSet(hasPrevValue, prevValue, prop, value, (nextValue) => { | ||
Reflect.set(target, prop, nextValue, receiver); | ||
}); | ||
return true; | ||
}, | ||
defineProperty(target, prop, desc) { | ||
if (shouldTrapDefineProperty(desc)) { | ||
const prevDesc = Reflect.getOwnPropertyDescriptor(target, prop); | ||
if (!prevDesc || shouldTrapDefineProperty(prevDesc)) { | ||
trapSet( | ||
!!prevDesc && "value" in prevDesc, | ||
prevDesc == null ? void 0 : prevDesc.value, | ||
prop, | ||
desc.value, | ||
(nextValue) => { | ||
Reflect.defineProperty(target, prop, { | ||
...desc, | ||
value: nextValue | ||
}); | ||
} | ||
); | ||
return true; | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return true; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = getUntracked(value) || value; | ||
} | ||
let nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then((v) => { | ||
value.status = "fulfilled"; | ||
value.value = v; | ||
notifyUpdate(["resolve", [prop], v]); | ||
}).catch((e) => { | ||
value.status = "rejected"; | ||
value.reason = e; | ||
notifyUpdate(["reject", [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction(value); | ||
} | ||
const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
return Reflect.defineProperty(target, prop, desc); | ||
Reflect.set(target, prop, nextValue, receiver); | ||
notifyUpdate(["set", [prop], value, prevValue]); | ||
return true; | ||
} | ||
@@ -238,3 +212,2 @@ }; | ||
canProxy, | ||
shouldTrapDefineProperty, | ||
defaultHandlePromise, | ||
@@ -241,0 +214,0 @@ snapCache, |
{ | ||
"name": "valtio", | ||
"private": false, | ||
"version": "1.11.0", | ||
"version": "1.11.1", | ||
"description": "💊 Valtio makes proxy-state simple for React and Vanilla", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
@@ -22,3 +22,3 @@ System.register(['proxy-compare'], (function (exports) { | ||
const refSet = /* @__PURE__ */ new WeakSet(); | ||
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), shouldTrapDefineProperty = (desc) => desc.configurable && desc.enumerable && desc.writable, defaultHandlePromise = (promise) => { | ||
const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), defaultHandlePromise = (promise) => { | ||
switch (promise.status) { | ||
@@ -149,33 +149,2 @@ case "fulfilled": | ||
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); | ||
const trapSet = (hasPrevValue, prevValue, prop, value, setValue) => { | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = getUntracked(value) || value; | ||
} | ||
let nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then((v) => { | ||
value.status = "fulfilled"; | ||
value.value = v; | ||
notifyUpdate(["resolve", [prop], v]); | ||
}).catch((e) => { | ||
value.status = "rejected"; | ||
value.reason = e; | ||
notifyUpdate(["reject", [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction(value); | ||
} | ||
const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
setValue(nextValue); | ||
notifyUpdate(["set", [prop], value, prevValue]); | ||
}; | ||
const handler = { | ||
@@ -194,27 +163,32 @@ deleteProperty(target, prop) { | ||
const prevValue = Reflect.get(target, prop, receiver); | ||
trapSet(hasPrevValue, prevValue, prop, value, (nextValue) => { | ||
Reflect.set(target, prop, nextValue, receiver); | ||
}); | ||
return true; | ||
}, | ||
defineProperty(target, prop, desc) { | ||
if (shouldTrapDefineProperty(desc)) { | ||
const prevDesc = Reflect.getOwnPropertyDescriptor(target, prop); | ||
if (!prevDesc || shouldTrapDefineProperty(prevDesc)) { | ||
trapSet( | ||
!!prevDesc && "value" in prevDesc, | ||
prevDesc == null ? void 0 : prevDesc.value, | ||
prop, | ||
desc.value, | ||
(nextValue) => { | ||
Reflect.defineProperty(target, prop, { | ||
...desc, | ||
value: nextValue | ||
}); | ||
} | ||
); | ||
return true; | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return true; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = getUntracked(value) || value; | ||
} | ||
let nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then((v) => { | ||
value.status = "fulfilled"; | ||
value.value = v; | ||
notifyUpdate(["resolve", [prop], v]); | ||
}).catch((e) => { | ||
value.status = "rejected"; | ||
value.reason = e; | ||
notifyUpdate(["reject", [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = proxyFunction(value); | ||
} | ||
const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
return Reflect.defineProperty(target, prop, desc); | ||
Reflect.set(target, prop, nextValue, receiver); | ||
notifyUpdate(["set", [prop], value, prevValue]); | ||
return true; | ||
} | ||
@@ -254,3 +228,2 @@ }; | ||
canProxy, | ||
shouldTrapDefineProperty, | ||
defaultHandlePromise, | ||
@@ -257,0 +230,0 @@ snapCache, |
@@ -1,1 +0,1 @@ | ||
System.register(["proxy-compare"],function(D){"use strict";var M,F;return{setters:[function(O){M=O.markToTrack,F=O.getUntracked}],execute:function(){D({getVersion:_,proxy:U,ref:C,snapshot:B,subscribe:q});const O=s=>typeof s=="object"&&s!==null,u=new WeakMap,m=new WeakSet,V=(s=Object.is,f=(r,w)=>new Proxy(r,w),k=r=>O(r)&&!m.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer),h=r=>r.configurable&&r.enumerable&&r.writable,d=r=>{switch(r.status){case"fulfilled":return r.value;case"rejected":throw r.reason;default:throw r}},p=new WeakMap,A=(r,w,g=d)=>{const o=p.get(r);if((o==null?void 0:o[0])===w)return o[1];const a=Array.isArray(r)?[]:Object.create(Object.getPrototypeOf(r));return M(a,!0),p.set(r,[w,a]),Reflect.ownKeys(r).forEach(E=>{if(Object.getOwnPropertyDescriptor(a,E))return;const b=Reflect.get(r,E),P={value:b,enumerable:!0,configurable:!0};if(m.has(b))M(b,!1);else if(b instanceof Promise)delete P.value,P.get=()=>g(b);else if(u.has(b)){const[i,W]=u.get(b);P.value=A(i,W(),g)}Object.defineProperty(a,E,P)}),Object.preventExtensions(a)},y=new WeakMap,v=[1,1],x=r=>{if(!O(r))throw new Error("object required");const w=y.get(r);if(w)return w;let g=v[0];const o=new Set,a=(n,e=++v[0])=>{g!==e&&(g=e,o.forEach(c=>c(n,e)))};let E=v[1];const b=(n=++v[1])=>(E!==n&&!o.size&&(E=n,i.forEach(([e])=>{const c=e[1](n);c>g&&(g=c)})),g),P=n=>(e,c)=>{const t=[...e];t[1]=[n,...t[1]],a(t,c)},i=new Map,W=(n,e)=>{if(o.size){const c=e[3](P(n));i.set(n,[e,c])}else i.set(n,[e])},K=n=>{var e;const c=i.get(n);c&&(i.delete(n),(e=c[1])==null||e.call(c))},G=n=>(o.add(n),o.size===1&&i.forEach(([e,c],t)=>{const j=e[3](P(t));i.set(t,[e,j])}),()=>{o.delete(n),o.size===0&&i.forEach(([e,c],t)=>{c&&(c(),i.set(t,[e]))})}),z=Array.isArray(r)?[]:Object.create(Object.getPrototypeOf(r)),N=(n,e,c,t,j)=>{if(n&&(s(e,t)||y.has(t)&&s(e,y.get(t))))return;K(c),O(t)&&(t=F(t)||t);let R=t;if(t instanceof Promise)t.then(l=>{t.status="fulfilled",t.value=l,a(["resolve",[c],l])}).catch(l=>{t.status="rejected",t.reason=l,a(["reject",[c],l])});else{!u.has(t)&&k(t)&&(R=x(t));const l=!m.has(R)&&u.get(R);l&&W(c,l)}j(R),a(["set",[c],t,e])},T=f(z,{deleteProperty(n,e){const c=Reflect.get(n,e);K(e);const t=Reflect.deleteProperty(n,e);return t&&a(["delete",[e],c]),t},set(n,e,c,t){const j=Reflect.has(n,e),R=Reflect.get(n,e,t);return N(j,R,e,c,l=>{Reflect.set(n,e,l,t)}),!0},defineProperty(n,e,c){if(h(c)){const t=Reflect.getOwnPropertyDescriptor(n,e);if(!t||h(t))return N(!!t&&"value"in t,t==null?void 0:t.value,e,c.value,j=>{Reflect.defineProperty(n,e,{...c,value:j})}),!0}return Reflect.defineProperty(n,e,c)}});y.set(r,T);const H=[z,b,A,G];return u.set(T,H),Reflect.ownKeys(r).forEach(n=>{const e=Object.getOwnPropertyDescriptor(r,n);"value"in e&&(T[n]=r[n],delete e.value,delete e.writable),Object.defineProperty(z,n,e)}),T})=>[x,u,m,s,f,k,h,d,p,A,y,v],[S]=V();function U(s={}){return S(s)}function _(s){const f=u.get(s);return f==null?void 0:f[1]()}function q(s,f,k){const h=u.get(s);let d;const p=[],A=h[3];let y=!1;const v=A(x=>{if(p.push(x),k){f(p.splice(0));return}d||(d=Promise.resolve().then(()=>{d=void 0,y&&f(p.splice(0))}))});return y=!0,()=>{y=!1,v()}}function B(s,f){const k=u.get(s),[h,d,p]=k;return p(h,d(),f)}function C(s){return m.add(s),s}const I=D("unstable_buildProxyFunction",V)}}}); | ||
System.register(["proxy-compare"],function(D){"use strict";var W,K;return{setters:[function(O){W=O.markToTrack,K=O.getUntracked}],execute:function(){D({getVersion:_,proxy:U,ref:L,snapshot:B,subscribe:q});const O=c=>typeof c=="object"&&c!==null,f=new WeakMap,E=new WeakSet,T=(c=Object.is,l=(t,w)=>new Proxy(t,w),v=t=>O(t)&&!E.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),P=t=>{switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t}},u=new WeakMap,d=(t,w,g=P)=>{const s=u.get(t);if((s==null?void 0:s[0])===w)return s[1];const a=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return W(a,!0),u.set(t,[w,a]),Reflect.ownKeys(t).forEach(k=>{if(Object.getOwnPropertyDescriptor(a,k))return;const y=Reflect.get(t,k),j={value:y,enumerable:!0,configurable:!0};if(E.has(y))W(y,!1);else if(y instanceof Promise)delete j.value,j.get=()=>g(y);else if(f.has(y)){const[i,m]=f.get(y);j.value=d(i,m(),g)}Object.defineProperty(a,k,j)}),Object.preventExtensions(a)},p=new WeakMap,b=[1,1],x=t=>{if(!O(t))throw new Error("object required");const w=p.get(t);if(w)return w;let g=b[0];const s=new Set,a=(n,e=++b[0])=>{g!==e&&(g=e,s.forEach(r=>r(n,e)))};let k=b[1];const y=(n=++b[1])=>(k!==n&&!s.size&&(k=n,i.forEach(([e])=>{const r=e[1](n);r>g&&(g=r)})),g),j=n=>(e,r)=>{const o=[...e];o[1]=[n,...o[1]],a(o,r)},i=new Map,m=(n,e)=>{if(s.size){const r=e[3](j(n));i.set(n,[e,r])}else i.set(n,[e])},V=n=>{var e;const r=i.get(n);r&&(i.delete(n),(e=r[1])==null||e.call(r))},N=n=>(s.add(n),s.size===1&&i.forEach(([e,r],o)=>{const M=e[3](j(o));i.set(o,[e,M])}),()=>{s.delete(n),s.size===0&&i.forEach(([e,r],o)=>{r&&(r(),i.set(o,[e]))})}),z=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),R=l(z,{deleteProperty(n,e){const r=Reflect.get(n,e);V(e);const o=Reflect.deleteProperty(n,e);return o&&a(["delete",[e],r]),o},set(n,e,r,o){const M=Reflect.has(n,e),S=Reflect.get(n,e,o);if(M&&(c(S,r)||p.has(r)&&c(S,p.get(r))))return!0;V(e),O(r)&&(r=K(r)||r);let A=r;if(r instanceof Promise)r.then(h=>{r.status="fulfilled",r.value=h,a(["resolve",[e],h])}).catch(h=>{r.status="rejected",r.reason=h,a(["reject",[e],h])});else{!f.has(r)&&v(r)&&(A=x(r));const h=!E.has(A)&&f.get(A);h&&m(e,h)}return Reflect.set(n,e,A,o),a(["set",[e],r,S]),!0}});p.set(t,R);const C=[z,y,d,N];return f.set(R,C),Reflect.ownKeys(t).forEach(n=>{const e=Object.getOwnPropertyDescriptor(t,n);"value"in e&&(R[n]=t[n],delete e.value,delete e.writable),Object.defineProperty(z,n,e)}),R})=>[x,f,E,c,l,v,P,u,d,p,b],[F]=T();function U(c={}){return F(c)}function _(c){const l=f.get(c);return l==null?void 0:l[1]()}function q(c,l,v){const P=f.get(c);let u;const d=[],p=P[3];let b=!1;const x=p(t=>{if(d.push(t),v){l(d.splice(0));return}u||(u=Promise.resolve().then(()=>{u=void 0,b&&l(d.splice(0))}))});return b=!0,()=>{b=!1,x()}}function B(c,l){const v=f.get(c),[P,u,d]=v;return d(P,u(),l)}function L(c){return E.add(c),c}const G=D("unstable_buildProxyFunction",T)}}}); |
@@ -50,3 +50,3 @@ type AnyFunction = (...args: any[]) => any; | ||
export declare function ref<T extends object>(obj: T): T & AsRef; | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, shouldTrapDefineProperty?: (desc: PropertyDescriptor) => boolean | undefined, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
status?: 'pending' | 'fulfilled' | 'rejected'; | ||
@@ -68,3 +68,2 @@ value?: Awaited<P>; | ||
(x: unknown) => boolean, | ||
(desc: PropertyDescriptor) => boolean | undefined, | ||
<P extends Promise<any>>(promise: P & { | ||
@@ -71,0 +70,0 @@ status?: 'pending' | 'fulfilled' | 'rejected'; |
@@ -50,3 +50,3 @@ type AnyFunction = (...args: any[]) => any; | ||
export declare function ref<T extends object>(obj: T): T & AsRef; | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, shouldTrapDefineProperty?: (desc: PropertyDescriptor) => boolean | undefined, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
status?: 'pending' | 'fulfilled' | 'rejected'; | ||
@@ -68,3 +68,2 @@ value?: Awaited<P>; | ||
(x: unknown) => boolean, | ||
(desc: PropertyDescriptor) => boolean | undefined, | ||
<P extends Promise<any>>(promise: P & { | ||
@@ -71,0 +70,0 @@ status?: 'pending' | 'fulfilled' | 'rejected'; |
@@ -7,17 +7,2 @@ (function (global, factory) { | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
var isObject = function isObject(x) { | ||
@@ -28,3 +13,3 @@ return typeof x === 'object' && x !== null; | ||
var refSet = new WeakSet(); | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, shouldTrapDefineProperty, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, _proxyFunction) { | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, _proxyFunction) { | ||
if (objectIs === void 0) { | ||
@@ -43,7 +28,2 @@ objectIs = Object.is; | ||
} | ||
if (shouldTrapDefineProperty === void 0) { | ||
shouldTrapDefineProperty = function shouldTrapDefineProperty(desc) { | ||
return desc.configurable && desc.enumerable && desc.writable; | ||
}; | ||
} | ||
if (defaultHandlePromise === void 0) { | ||
@@ -213,33 +193,2 @@ defaultHandlePromise = function defaultHandlePromise(promise) { | ||
var baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); | ||
var trapSet = function trapSet(hasPrevValue, prevValue, prop, value, setValue) { | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = proxyCompare.getUntracked(value) || value; | ||
} | ||
var nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then(function (v) { | ||
value.status = 'fulfilled'; | ||
value.value = v; | ||
notifyUpdate(['resolve', [prop], v]); | ||
}).catch(function (e) { | ||
value.status = 'rejected'; | ||
value.reason = e; | ||
notifyUpdate(['reject', [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = _proxyFunction(value); | ||
} | ||
var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
setValue(nextValue); | ||
notifyUpdate(['set', [prop], value, prevValue]); | ||
}; | ||
var handler = { | ||
@@ -258,20 +207,32 @@ deleteProperty: function deleteProperty(target, prop) { | ||
var prevValue = Reflect.get(target, prop, receiver); | ||
trapSet(hasPrevValue, prevValue, prop, value, function (nextValue) { | ||
Reflect.set(target, prop, nextValue, receiver); | ||
}); | ||
return true; | ||
}, | ||
defineProperty: function defineProperty(target, prop, desc) { | ||
if (shouldTrapDefineProperty(desc)) { | ||
var prevDesc = Reflect.getOwnPropertyDescriptor(target, prop); | ||
if (!prevDesc || shouldTrapDefineProperty(prevDesc)) { | ||
trapSet(!!prevDesc && 'value' in prevDesc, prevDesc == null ? void 0 : prevDesc.value, prop, desc.value, function (nextValue) { | ||
Reflect.defineProperty(target, prop, _extends({}, desc, { | ||
value: nextValue | ||
})); | ||
}); | ||
return true; | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return true; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = proxyCompare.getUntracked(value) || value; | ||
} | ||
var nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then(function (v) { | ||
value.status = 'fulfilled'; | ||
value.value = v; | ||
notifyUpdate(['resolve', [prop], v]); | ||
}).catch(function (e) { | ||
value.status = 'rejected'; | ||
value.reason = e; | ||
notifyUpdate(['reject', [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = _proxyFunction(value); | ||
} | ||
var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
return Reflect.defineProperty(target, prop, desc); | ||
Reflect.set(target, prop, nextValue, receiver); | ||
notifyUpdate(['set', [prop], value, prevValue]); | ||
return true; | ||
} | ||
@@ -295,3 +256,3 @@ }; | ||
} | ||
return [_proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, shouldTrapDefineProperty, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
return [_proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
}; | ||
@@ -298,0 +259,0 @@ var _buildProxyFunction = buildProxyFunction(), |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("proxy-compare")):"function"==typeof define&&define.amd?define(["exports","proxy-compare"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioVanilla={},e.proxyCompare)}(this,(function(e,t){"use strict";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},n.apply(this,arguments)}var r=function(e){return"object"==typeof e&&null!==e},o=new WeakMap,i=new WeakSet,a=function(e,a,c,f,u,s,l,v,d,p){return void 0===e&&(e=Object.is),void 0===a&&(a=function(e,t){return new Proxy(e,t)}),void 0===c&&(c=function(e){return r(e)&&!i.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)}),void 0===f&&(f=function(e){return e.configurable&&e.enumerable&&e.writable}),void 0===u&&(u=function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),void 0===s&&(s=new WeakMap),void 0===l&&(l=function(e){function t(t,n,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,n,r){void 0===r&&(r=u);var a=s.get(e);if((null==a?void 0:a[0])===n)return a[1];var c=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(c,!0),s.set(e,[n,c]),Reflect.ownKeys(e).forEach((function(n){if(!Object.getOwnPropertyDescriptor(c,n)){var a=Reflect.get(e,n),f={value:a,enumerable:!0,configurable:!0};if(i.has(a))t.markToTrack(a,!1);else if(a instanceof Promise)delete f.value,f.get=function(){return r(a)};else if(o.has(a)){var u=o.get(a),s=u[0],v=u[1];f.value=l(s,v(),r)}Object.defineProperty(c,n,f)}})),Object.preventExtensions(c)}))),void 0===v&&(v=new WeakMap),void 0===d&&(d=[1,1]),void 0===p&&(p=function(u){if(!r(u))throw new Error("object required");var s=v.get(u);if(s)return s;var y=d[0],b=new Set,g=function(e,t){void 0===t&&(t=++d[0]),y!==t&&(y=t,b.forEach((function(n){return n(e,t)})))},h=d[1],w=function(e){return function(t,n){var r=[].concat(t);r[1]=[e].concat(r[1]),g(r,n)}},j=new Map,O=function(e){var t,n=j.get(e);n&&(j.delete(e),null==(t=n[1])||t.call(n))},P=Array.isArray(u)?[]:Object.create(Object.getPrototypeOf(u)),m=function(n,a,f,u,s){if(!n||!(e(a,u)||v.has(u)&&e(a,v.get(u)))){O(f),r(u)&&(u=t.getUntracked(u)||u);var l=u;if(u instanceof Promise)u.then((function(e){u.status="fulfilled",u.value=e,g(["resolve",[f],e])})).catch((function(e){u.status="rejected",u.reason=e,g(["reject",[f],e])}));else{!o.has(u)&&c(u)&&(l=p(u));var d=!i.has(l)&&o.get(l);d&&function(e,t){if(b.size){var n=t[3](w(e));j.set(e,[t,n])}else j.set(e,[t])}(f,d)}s(l),g(["set",[f],u,a])}},R=a(P,{deleteProperty:function(e,t){var n=Reflect.get(e,t);O(t);var r=Reflect.deleteProperty(e,t);return r&&g(["delete",[t],n]),r},set:function(e,t,n,r){var o=Reflect.has(e,t),i=Reflect.get(e,t,r);return m(o,i,t,n,(function(n){Reflect.set(e,t,n,r)})),!0},defineProperty:function(e,t,r){if(f(r)){var o=Reflect.getOwnPropertyDescriptor(e,t);if(!o||f(o))return m(!!o&&"value"in o,null==o?void 0:o.value,t,r.value,(function(o){Reflect.defineProperty(e,t,n({},r,{value:o}))})),!0}return Reflect.defineProperty(e,t,r)}});v.set(u,R);var k=[P,function(e){return void 0===e&&(e=++d[1]),h===e||b.size||(h=e,j.forEach((function(t){var n=t[0][1](e);n>y&&(y=n)}))),y},l,function(e){b.add(e),1===b.size&&j.forEach((function(e,t){var n=e[0];e[1];var r=n[3](w(t));j.set(t,[n,r])}));return function(){b.delete(e),0===b.size&&j.forEach((function(e,t){var n=e[0],r=e[1];r&&(r(),j.set(t,[n]))}))}}];return o.set(R,k),Reflect.ownKeys(u).forEach((function(e){var t=Object.getOwnPropertyDescriptor(u,e);"value"in t&&(R[e]=u[e],delete t.value,delete t.writable),Object.defineProperty(P,e,t)})),R}),[p,o,i,e,a,c,f,u,s,l,v,d]},c=a()[0];var f=a;e.getVersion=function(e){var t=o.get(e);return null==t?void 0:t[1]()},e.proxy=function(e){return void 0===e&&(e={}),c(e)},e.ref=function(e){return i.add(e),e},e.snapshot=function(e,t){var n=o.get(e),r=n[0],i=n[1];return(0,n[2])(r,i(),t)},e.subscribe=function(e,t,n){var r,i=o.get(e),a=[],c=i[3],f=!1,u=c((function(e){a.push(e),n?t(a.splice(0)):r||(r=Promise.resolve().then((function(){r=void 0,f&&t(a.splice(0))})))}));return f=!0,function(){f=!1,u()}},e.unstable_buildProxyFunction=f})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("proxy-compare")):"function"==typeof define&&define.amd?define(["exports","proxy-compare"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).valtioVanilla={},e.proxyCompare)}(this,(function(e,t){"use strict";var n=function(e){return"object"==typeof e&&null!==e},r=new WeakMap,o=new WeakSet,i=function(e,i,a,c,f,u,s,l,v){return void 0===e&&(e=Object.is),void 0===i&&(i=function(e,t){return new Proxy(e,t)}),void 0===a&&(a=function(e){return n(e)&&!o.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)}),void 0===c&&(c=function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),void 0===f&&(f=new WeakMap),void 0===u&&(u=function(e){function t(t,n,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,n,i){void 0===i&&(i=c);var a=f.get(e);if((null==a?void 0:a[0])===n)return a[1];var s=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return t.markToTrack(s,!0),f.set(e,[n,s]),Reflect.ownKeys(e).forEach((function(n){if(!Object.getOwnPropertyDescriptor(s,n)){var a=Reflect.get(e,n),c={value:a,enumerable:!0,configurable:!0};if(o.has(a))t.markToTrack(a,!1);else if(a instanceof Promise)delete c.value,c.get=function(){return i(a)};else if(r.has(a)){var f=r.get(a),l=f[0],v=f[1];c.value=u(l,v(),i)}Object.defineProperty(s,n,c)}})),Object.preventExtensions(s)}))),void 0===s&&(s=new WeakMap),void 0===l&&(l=[1,1]),void 0===v&&(v=function(c){if(!n(c))throw new Error("object required");var f=s.get(c);if(f)return f;var d=l[0],p=new Set,y=function(e,t){void 0===t&&(t=++l[0]),d!==t&&(d=t,p.forEach((function(n){return n(e,t)})))},g=l[1],h=function(e){return function(t,n){var r=[].concat(t);r[1]=[e].concat(r[1]),y(r,n)}},b=new Map,w=function(e){var t,n=b.get(e);n&&(b.delete(e),null==(t=n[1])||t.call(n))},j=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c)),O=i(j,{deleteProperty:function(e,t){var n=Reflect.get(e,t);w(t);var r=Reflect.deleteProperty(e,t);return r&&y(["delete",[t],n]),r},set:function(i,c,f,u){var l=Reflect.has(i,c),d=Reflect.get(i,c,u);if(l&&(e(d,f)||s.has(f)&&e(d,s.get(f))))return!0;w(c),n(f)&&(f=t.getUntracked(f)||f);var g=f;if(f instanceof Promise)f.then((function(e){f.status="fulfilled",f.value=e,y(["resolve",[c],e])})).catch((function(e){f.status="rejected",f.reason=e,y(["reject",[c],e])}));else{!r.has(f)&&a(f)&&(g=v(f));var j=!o.has(g)&&r.get(g);j&&function(e,t){if(p.size){var n=t[3](h(e));b.set(e,[t,n])}else b.set(e,[t])}(c,j)}return Reflect.set(i,c,g,u),y(["set",[c],f,d]),!0}});s.set(c,O);var m=[j,function(e){return void 0===e&&(e=++l[1]),g===e||p.size||(g=e,b.forEach((function(t){var n=t[0][1](e);n>d&&(d=n)}))),d},u,function(e){p.add(e),1===p.size&&b.forEach((function(e,t){var n=e[0];e[1];var r=n[3](h(t));b.set(t,[n,r])}));return function(){p.delete(e),0===p.size&&b.forEach((function(e,t){var n=e[0],r=e[1];r&&(r(),b.set(t,[n]))}))}}];return r.set(O,m),Reflect.ownKeys(c).forEach((function(e){var t=Object.getOwnPropertyDescriptor(c,e);"value"in t&&(O[e]=c[e],delete t.value,delete t.writable),Object.defineProperty(j,e,t)})),O}),[v,r,o,e,i,a,c,f,u,s,l]},a=i()[0];var c=i;e.getVersion=function(e){var t=r.get(e);return null==t?void 0:t[1]()},e.proxy=function(e){return void 0===e&&(e={}),a(e)},e.ref=function(e){return o.add(e),e},e.snapshot=function(e,t){var n=r.get(e),o=n[0],i=n[1];return(0,n[2])(o,i(),t)},e.subscribe=function(e,t,n){var o,i=r.get(e),a=[],c=i[3],f=!1,u=c((function(e){a.push(e),n?t(a.splice(0)):o||(o=Promise.resolve().then((function(){o=void 0,f&&t(a.splice(0))})))}));return f=!0,function(){f=!1,u()}},e.unstable_buildProxyFunction=c})); |
@@ -33,7 +33,7 @@ type AnyFunction = (...args: any[]) => any; | ||
export declare function ref<T extends object>(obj: T): T & AsRef; | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, shouldTrapDefineProperty?: (desc: PropertyDescriptor) => boolean | undefined, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
export declare const unstable_buildProxyFunction: (objectIs?: (value1: any, value2: any) => boolean, newProxy?: <T extends object>(target: T, handler: ProxyHandler<T>) => T, canProxy?: (x: unknown) => boolean, defaultHandlePromise?: <P extends Promise<any>>(promise: P & { | ||
status?: 'pending' | 'fulfilled' | 'rejected'; | ||
value?: Awaited<P>; | ||
reason?: unknown; | ||
}) => Awaited<P>, snapCache?: WeakMap<object, [version: number, snap: unknown]>, createSnapshot?: CreateSnapshot, proxyCache?: WeakMap<object, object>, versionHolder?: [number, number], proxyFunction?: <T_1 extends object>(initialObject: T_1) => T_1) => readonly [<T_1 extends object>(initialObject: T_1) => T_1, WeakMap<object, ProxyState>, WeakSet<object>, (value1: any, value2: any) => boolean, <T extends object>(target: T, handler: ProxyHandler<T>) => T, (x: unknown) => boolean, (desc: PropertyDescriptor) => boolean | undefined, <P extends Promise<any>>(promise: P & { | ||
}) => Awaited<P>, snapCache?: WeakMap<object, [version: number, snap: unknown]>, createSnapshot?: CreateSnapshot, proxyCache?: WeakMap<object, object>, versionHolder?: [number, number], proxyFunction?: <T_1 extends object>(initialObject: T_1) => T_1) => readonly [<T_1 extends object>(initialObject: T_1) => T_1, WeakMap<object, ProxyState>, WeakSet<object>, (value1: any, value2: any) => boolean, <T extends object>(target: T, handler: ProxyHandler<T>) => T, (x: unknown) => boolean, <P extends Promise<any>>(promise: P & { | ||
status?: 'pending' | 'fulfilled' | 'rejected'; | ||
@@ -40,0 +40,0 @@ value?: Awaited<P>; |
@@ -5,17 +5,2 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
var isObject = function isObject(x) { | ||
@@ -26,3 +11,3 @@ return typeof x === 'object' && x !== null; | ||
var refSet = new WeakSet(); | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, shouldTrapDefineProperty, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, _proxyFunction) { | ||
var buildProxyFunction = function buildProxyFunction(objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder, _proxyFunction) { | ||
if (objectIs === void 0) { | ||
@@ -41,7 +26,2 @@ objectIs = Object.is; | ||
} | ||
if (shouldTrapDefineProperty === void 0) { | ||
shouldTrapDefineProperty = function shouldTrapDefineProperty(desc) { | ||
return desc.configurable && desc.enumerable && desc.writable; | ||
}; | ||
} | ||
if (defaultHandlePromise === void 0) { | ||
@@ -211,33 +191,2 @@ defaultHandlePromise = function defaultHandlePromise(promise) { | ||
var baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); | ||
var trapSet = function trapSet(hasPrevValue, prevValue, prop, value, setValue) { | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = proxyCompare.getUntracked(value) || value; | ||
} | ||
var nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then(function (v) { | ||
value.status = 'fulfilled'; | ||
value.value = v; | ||
notifyUpdate(['resolve', [prop], v]); | ||
}).catch(function (e) { | ||
value.status = 'rejected'; | ||
value.reason = e; | ||
notifyUpdate(['reject', [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = _proxyFunction(value); | ||
} | ||
var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
setValue(nextValue); | ||
notifyUpdate(['set', [prop], value, prevValue]); | ||
}; | ||
var handler = { | ||
@@ -256,20 +205,32 @@ deleteProperty: function deleteProperty(target, prop) { | ||
var prevValue = Reflect.get(target, prop, receiver); | ||
trapSet(hasPrevValue, prevValue, prop, value, function (nextValue) { | ||
Reflect.set(target, prop, nextValue, receiver); | ||
}); | ||
return true; | ||
}, | ||
defineProperty: function defineProperty(target, prop, desc) { | ||
if (shouldTrapDefineProperty(desc)) { | ||
var prevDesc = Reflect.getOwnPropertyDescriptor(target, prop); | ||
if (!prevDesc || shouldTrapDefineProperty(prevDesc)) { | ||
trapSet(!!prevDesc && 'value' in prevDesc, prevDesc == null ? void 0 : prevDesc.value, prop, desc.value, function (nextValue) { | ||
Reflect.defineProperty(target, prop, _extends({}, desc, { | ||
value: nextValue | ||
})); | ||
}); | ||
return true; | ||
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { | ||
return true; | ||
} | ||
removePropListener(prop); | ||
if (isObject(value)) { | ||
value = proxyCompare.getUntracked(value) || value; | ||
} | ||
var nextValue = value; | ||
if (value instanceof Promise) { | ||
value.then(function (v) { | ||
value.status = 'fulfilled'; | ||
value.value = v; | ||
notifyUpdate(['resolve', [prop], v]); | ||
}).catch(function (e) { | ||
value.status = 'rejected'; | ||
value.reason = e; | ||
notifyUpdate(['reject', [prop], e]); | ||
}); | ||
} else { | ||
if (!proxyStateMap.has(value) && canProxy(value)) { | ||
nextValue = _proxyFunction(value); | ||
} | ||
var childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); | ||
if (childProxyState) { | ||
addPropListener(prop, childProxyState); | ||
} | ||
} | ||
return Reflect.defineProperty(target, prop, desc); | ||
Reflect.set(target, prop, nextValue, receiver); | ||
notifyUpdate(['set', [prop], value, prevValue]); | ||
return true; | ||
} | ||
@@ -293,3 +254,3 @@ }; | ||
} | ||
return [_proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, shouldTrapDefineProperty, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
return [_proxyFunction, proxyStateMap, refSet, objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder]; | ||
}; | ||
@@ -296,0 +257,0 @@ var _buildProxyFunction = buildProxyFunction(), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
112
3
3
20
320027
7538