Comparing version 2.0.0-rc.1 to 2.0.0-rc.2
{ | ||
"name": "valtio", | ||
"description": "💊 Valtio makes proxy-state simple for React and Vanilla", | ||
"description": "🧙 Valtio makes proxy-state simple for React and Vanilla", | ||
"private": false, | ||
"type": "commonjs", | ||
"version": "2.0.0-rc.1", | ||
"version": "2.0.0-rc.2", | ||
"publishConfig": { | ||
@@ -8,0 +8,0 @@ "tag": "next" |
type AnyFunction = (...args: any[]) => any; | ||
type Path = (string | symbol)[]; | ||
type Op = [op: 'set', path: Path, value: unknown, prevValue: unknown] | [op: 'delete', path: Path, prevValue: unknown] | [op: 'resolve', path: Path, value: unknown] | [op: 'reject', path: Path, error: unknown]; | ||
type Op = [op: 'set', path: Path, value: unknown, prevValue: unknown] | [op: 'delete', path: Path, prevValue: unknown]; | ||
type Listener = (op: Op, nextVersion: number) => void; | ||
@@ -5,0 +5,0 @@ type Primitive = string | number | boolean | null | undefined | symbol | bigint; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const isObject = (x) => typeof x === "object" && x !== null; | ||
const canProxyDefault = (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); | ||
const canProxyDefault = (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) && !(x instanceof Promise); | ||
const createSnapshotDefault = (target, version) => { | ||
@@ -64,19 +64,4 @@ const cache = snapCache.get(target); | ||
} | ||
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 = proxy(value); | ||
} | ||
addPropListener(prop, nextValue); | ||
} | ||
const nextValue = !proxyStateMap.has(value) && canProxy(value) ? proxy(value) : value; | ||
addPropListener(prop, nextValue); | ||
Reflect.set(target, prop, nextValue, receiver); | ||
@@ -83,0 +68,0 @@ notifyUpdate(["set", [prop], value, prevValue]); |
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
75946
1591