diff --git a/src/index.ts b/src/index.ts index 991864d..e3fb9a3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ export { getVersion, - proxy, ref, snapshot, type INTERNAL_Op, @@ -22,3 +21,4 @@ export { type ReactiveClass, type ReactiveProxy, } from './runtime/instance' +export { proxy } from './runtime/proxy' diff --git a/src/runtime/proxy.ts b/src/runtime/proxy.ts new file mode 100644 index 0000000..3e95e57 --- /dev/null +++ b/src/runtime/proxy.ts @@ -0,0 +1,10 @@ +import { proxy as createProxy, unstable_getInternalStates } from 'valtio' + +const { proxyStateMap } = unstable_getInternalStates() + +export function proxy(data: T): T { + if (proxyStateMap.has(data)) { + return data + } + return createProxy(data) +}