diff --git a/.size-snapshot.json b/.size-snapshot.json index e52181c6..01938f21 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,8 +1,8 @@ { "index.js": { - "bundled": 4624, - "minified": 2118, - "gzipped": 926, + "bundled": 4604, + "minified": 2098, + "gzipped": 919, "treeshaked": { "rollup": { "code": 169, @@ -14,8 +14,8 @@ } }, "vanilla.js": { - "bundled": 5814, - "minified": 2829, + "bundled": 5802, + "minified": 2817, "gzipped": 1099, "treeshaked": { "rollup": { diff --git a/package.json b/package.json index d2d88f60..acdb632c 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ ] }, "dependencies": { - "proxy-compare": "1.1.6" + "proxy-compare": "2.0.0" }, "devDependencies": { "@babel/core": "^7.13.16", diff --git a/src/react.ts b/src/react.ts index dc19a945..f2fe4b56 100644 --- a/src/react.ts +++ b/src/react.ts @@ -8,8 +8,8 @@ import { useRef, } from 'react' import { - createDeepProxy, - isDeepChanged, + createProxy as createProxyToCompare, + isChanged, affectedToPathList, } from 'proxy-compare' @@ -139,7 +139,7 @@ export const useSnapshot = ( lastAffected.current = affected if ( prevSnapshot.current !== lastSnapshot.current && - isDeepChanged( + isChanged( prevSnapshot.current, lastSnapshot.current, affected, @@ -161,7 +161,7 @@ export const useSnapshot = ( try { if ( lastAffected.current && - !isDeepChanged( + !isChanged( prevSnapshot.current, nextSnapshot, lastAffected.current, @@ -191,5 +191,5 @@ export const useSnapshot = ( useAffectedDebugValue(currSnapshot, affected) } const proxyCache = useMemo(() => new WeakMap(), []) // per-hook proxyCache - return createDeepProxy(currSnapshot, affected, proxyCache) + return createProxyToCompare(currSnapshot, affected, proxyCache) } diff --git a/src/utils.ts b/src/utils.ts index a797fc8f..5ecc2d35 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { createDeepProxy, isDeepChanged } from 'proxy-compare' +import { createProxy as createProxyToCompare, isChanged } from 'proxy-compare' import { proxy, subscribe, snapshot } from './vanilla' import type { DeepResolveType } from './vanilla' @@ -162,10 +162,10 @@ export const addComputed = ( const nextSnapshot = snapshot(proxyObject) if ( !pending && - (!prevSnapshot || isDeepChanged(prevSnapshot, nextSnapshot, affected)) + (!prevSnapshot || isChanged(prevSnapshot, nextSnapshot, affected)) ) { affected = new WeakMap() - const value = get(createDeepProxy(nextSnapshot, affected)) + const value = get(createProxyToCompare(nextSnapshot, affected)) prevSnapshot = nextSnapshot if (value instanceof Promise) { pending = true @@ -248,12 +248,9 @@ export const proxyWithComputed = ( const desc: PropertyDescriptor = {} desc.get = () => { const nextSnapshot = snapshot(proxyObject) - if ( - !prevSnapshot || - isDeepChanged(prevSnapshot, nextSnapshot, affected) - ) { + if (!prevSnapshot || isChanged(prevSnapshot, nextSnapshot, affected)) { affected = new WeakMap() - computedValue = get(createDeepProxy(nextSnapshot, affected)) + computedValue = get(createProxyToCompare(nextSnapshot, affected)) prevSnapshot = nextSnapshot } return computedValue diff --git a/src/vanilla.ts b/src/vanilla.ts index 4884cd87..3b1cee0c 100644 --- a/src/vanilla.ts +++ b/src/vanilla.ts @@ -1,4 +1,4 @@ -import { getUntrackedObject, markToTrack } from 'proxy-compare' +import { getUntracked, markToTrack } from 'proxy-compare' const VERSION = Symbol() const LISTENERS = Symbol() @@ -148,7 +148,7 @@ export const proxy = (initialObject: T = {} as T): T => { notifyUpdate() }) } else { - value = getUntrackedObject(value) || value + value = getUntracked(value) || value if (value[LISTENERS]) { target[prop] = value } else { diff --git a/yarn.lock b/yarn.lock index f122c30f..9e47b348 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5775,10 +5775,10 @@ prop-types@^15.7.2: object-assign "^4.1.1" react-is "^16.8.1" -proxy-compare@1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-1.1.6.tgz#dd7737be611a9d7142fae10dbc6d0ceb74ad6da0" - integrity sha512-V65euKrKgKjVyEh5+4nVlAf4dHJ6Q0cF77MCeZiJaOldAl9lndy/u270SJneHiz3UkVcSIhxfOKY7aFkrMyo5g== +proxy-compare@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.0.0.tgz#36f41114a25fcf359037308d12529183a9dc182c" + integrity sha512-xhJF1+vPCnu93QYva3Weii5ho1AeX5dsR/P5O7pzy9QLxeOgMSQNC8zDo0bGg9vtn61Pu5Qn+5w/Y8OSU5k+8g== prr@~1.0.1: version "1.0.1"