Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc authored May 15, 2021
2 parents 7bcc7af + 18491a5 commit bab8b5b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
10 changes: 5 additions & 5 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"index.js": {
"bundled": 4624,
"minified": 2118,
"gzipped": 926,
"bundled": 4604,
"minified": 2098,
"gzipped": 919,
"treeshaked": {
"rollup": {
"code": 169,
Expand All @@ -14,8 +14,8 @@
}
},
"vanilla.js": {
"bundled": 5814,
"minified": 2829,
"bundled": 5802,
"minified": 2817,
"gzipped": 1099,
"treeshaked": {
"rollup": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
]
},
"dependencies": {
"proxy-compare": "1.1.6"
"proxy-compare": "2.0.0"
},
"devDependencies": {
"@babel/core": "^7.13.16",
Expand Down
10 changes: 5 additions & 5 deletions src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
useRef,
} from 'react'
import {
createDeepProxy,
isDeepChanged,
createProxy as createProxyToCompare,
isChanged,
affectedToPathList,
} from 'proxy-compare'

Expand Down Expand Up @@ -139,7 +139,7 @@ export const useSnapshot = <T extends object>(
lastAffected.current = affected
if (
prevSnapshot.current !== lastSnapshot.current &&
isDeepChanged(
isChanged(
prevSnapshot.current,
lastSnapshot.current,
affected,
Expand All @@ -161,7 +161,7 @@ export const useSnapshot = <T extends object>(
try {
if (
lastAffected.current &&
!isDeepChanged(
!isChanged(
prevSnapshot.current,
nextSnapshot,
lastAffected.current,
Expand Down Expand Up @@ -191,5 +191,5 @@ export const useSnapshot = <T extends object>(
useAffectedDebugValue(currSnapshot, affected)
}
const proxyCache = useMemo(() => new WeakMap(), []) // per-hook proxyCache
return createDeepProxy(currSnapshot, affected, proxyCache)
return createProxyToCompare(currSnapshot, affected, proxyCache)
}
13 changes: 5 additions & 8 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -162,10 +162,10 @@ export const addComputed = <T extends object, U extends object>(
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
Expand Down Expand Up @@ -248,12 +248,9 @@ export const proxyWithComputed = <T extends object, U extends object>(
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
Expand Down
4 changes: 2 additions & 2 deletions src/vanilla.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getUntrackedObject, markToTrack } from 'proxy-compare'
import { getUntracked, markToTrack } from 'proxy-compare'

const VERSION = Symbol()
const LISTENERS = Symbol()
Expand Down Expand Up @@ -148,7 +148,7 @@ export const proxy = <T extends object>(initialObject: T = {} as T): T => {
notifyUpdate()
})
} else {
value = getUntrackedObject(value) || value
value = getUntracked(value) || value
if (value[LISTENERS]) {
target[prop] = value
} else {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit bab8b5b

Please sign in to comment.