Socket
Socket
Sign inDemoInstall

valtio

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valtio - npm Package Compare versions

Comparing version 1.2.12 to 1.3.0

system/index.development.js

20

esm/index.js

@@ -8,7 +8,9 @@ import { useRef, useState, useEffect, useReducer, useCallback, useMemo, useLayoutEffect, useDebugValue } from 'react';

const GET_VERSION = "_uMS_V";
const createMutableSource = (target, getVersion) => ({
[TARGET]: target,
[GET_VERSION]: getVersion
});
const useMutableSource = (source, getSnapshot, subscribe) => {
function createMutableSource(target, getVersion) {
return {
[TARGET]: target,
[GET_VERSION]: getVersion
};
}
function useMutableSource(source, getSnapshot, subscribe) {
const lastVersion = useRef();

@@ -82,3 +84,3 @@ const currentVersion = source[GET_VERSION](source[TARGET]);

return currentSnapshot;
};
}

@@ -101,3 +103,3 @@ const isSSR = typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);

};
const useSnapshot = (proxyObject, options) => {
function useSnapshot(proxyObject, options) {
const forceUpdate = useReducer((c) => c + 1, 0)[1];

@@ -132,3 +134,3 @@ const affected = /* @__PURE__ */ new WeakMap();

const currSnapshot = useMutableSource(getMutableSource(proxyObject), snapshot, sub);
if (typeof process === "object" && process.env.NODE_ENV !== "production") {
if ((import.meta.env && import.meta.env.MODE) !== "production") {
useAffectedDebugValue(currSnapshot, affected);

@@ -138,4 +140,4 @@ }

return createProxy(currSnapshot, affected, proxyCache);
};
}
export { useSnapshot };

@@ -83,3 +83,3 @@ declare type AsRef = {

*/
export declare const useSnapshot: <T extends object>(proxyObject: T, options?: Options | undefined) => Snapshot<T>;
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): Snapshot<T>;
export {};

@@ -7,4 +7,4 @@ declare const TARGET = "_uMS_T";

};
export declare const createMutableSource: <T, V>(target: T, getVersion: (target: T) => V) => MutableSource<T, V>;
export declare const useMutableSource: <T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void) => S;
export declare function createMutableSource<T, V>(target: T, getVersion: (target: T) => V): MutableSource<T, V>;
export declare function useMutableSource<T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void): S;
export {};
import { subscribe, snapshot, proxy, getVersion, ref } from 'valtio/vanilla';
import { createProxy, isChanged } from 'proxy-compare';
import { proxy as proxy$1 } from 'valtio';
const subscribeKey = (proxyObject, key, callback, notifyInSync) => subscribe(proxyObject, (ops) => {
if (ops.some((op) => op[1][0] === key)) {
callback(proxyObject[key]);
}
}, notifyInSync);
function subscribeKey(proxyObject, key, callback, notifyInSync) {
return subscribe(proxyObject, (ops) => {
if (ops.some((op) => op[1][0] === key)) {
callback(proxyObject[key]);
}
}, notifyInSync);
}
let currentCleanups;
const watch = (callback, options) => {
function watch(callback, options) {
const cleanups = /* @__PURE__ */ new Set();

@@ -57,6 +58,6 @@ const subscriptions = /* @__PURE__ */ new Set();

return wrappedCleanup;
};
}
const DEVTOOLS = Symbol();
const devtools = (proxyObject, name) => {
function devtools(proxyObject, name) {
let extension;

@@ -68,3 +69,3 @@ try {

if (!extension) {
if (typeof process === "object" && process.env.NODE_ENV === "development" && typeof window !== "undefined") {
if ((import.meta.env && import.meta.env.MODE) !== "production" && typeof window !== "undefined") {
console.warn("[Warning] Please install/enable Redux devtools extension");

@@ -130,3 +131,3 @@ }

};
};
}

@@ -244,3 +245,3 @@ const sourceObjectMap = /* @__PURE__ */ new WeakMap();

};
const derive = (derivedFns, options) => {
function derive(derivedFns, options) {
const proxyObject = (options == null ? void 0 : options.proxy) || proxy({});

@@ -306,4 +307,4 @@ const notifyInSync = !!(options == null ? void 0 : options.sync);

return proxyObject;
};
const underive = (proxyObject, options) => {
}
function underive(proxyObject, options) {
const keysToDelete = (options == null ? void 0 : options.delete) ? /* @__PURE__ */ new Set() : null;

@@ -324,5 +325,5 @@ listSubscriptions(proxyObject).forEach((subscription) => {

}
};
}
const addComputed_DEPRECATED = (proxyObject, computedFns_FAKE, targetObject = proxyObject) => {
function addComputed_DEPRECATED(proxyObject, computedFns_FAKE, targetObject = proxyObject) {
console.warn("addComputed is deprecated. Please consider using `derive` or `proxyWithComputed` instead. Falling back to emulation with derive.");

@@ -334,5 +335,5 @@ const derivedFns = {};

return derive(derivedFns, { proxy: targetObject });
};
}
const proxyWithComputed = (initialObject, computedFns) => {
function proxyWithComputed(initialObject, computedFns) {
Object.keys(computedFns).forEach((key) => {

@@ -364,5 +365,5 @@ if (Object.getOwnPropertyDescriptor(initialObject, key)) {

return proxyObject;
};
}
const proxyWithHistory = (initialValue, skipSubscribe = false) => {
function proxyWithHistory(initialValue, skipSubscribe = false) {
const proxyObject = proxy({

@@ -405,6 +406,6 @@ value: initialValue,

return proxyObject;
};
}
const proxySet = (initialValues) => {
const set = proxy$1({
function proxySet(initialValues) {
const set = proxy({
data: Array.from(new Set(initialValues)),

@@ -417,3 +418,3 @@ has(value) {

if (typeof value === "object" && value !== null) {
hasProxy = this.data.indexOf(proxy$1(value)) !== -1;
hasProxy = this.data.indexOf(proxy(value)) !== -1;
}

@@ -476,6 +477,6 @@ if (this.data.indexOf(value) === -1 && !hasProxy) {

return set;
};
}
const proxyMap = (entries) => {
const map = proxy$1({
function proxyMap(entries) {
const map = proxy({
data: Array.from(entries || []),

@@ -549,4 +550,4 @@ has(key) {

return map;
};
}
export { addComputed_DEPRECATED as addComputed, derive, devtools, proxyMap, proxySet, proxyWithComputed, proxyWithHistory, subscribeKey, underive, unstable_deriveSubscriptions, watch };

@@ -6,2 +6,4 @@ /**

*/
export declare const addComputed_DEPRECATED: <T extends object, U extends object>(proxyObject: T, computedFns_FAKE: { [K in keyof U]: (snap_FAKE: T) => U[K]; }, targetObject?: any) => any;
export declare function addComputed_DEPRECATED<T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
[K in keyof U]: (snap_FAKE: T) => U[K];
}, targetObject?: any): any;

@@ -40,6 +40,8 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*/
export declare const derive: <T extends object, U extends object>(derivedFns: { [K in keyof U]: (get: DeriveGet) => U[K]; }, options?: {
export declare function derive<T extends object, U extends object>(derivedFns: {
[K in keyof U]: (get: DeriveGet) => U[K];
}, options?: {
proxy?: T;
sync?: boolean;
} | undefined) => T & U;
}): T & U;
/**

@@ -67,6 +69,6 @@ * underive

*/
export declare const underive: <T extends object, U extends object>(proxyObject: T & U, options?: {
export declare function underive<T extends object, U extends object>(proxyObject: T & U, options?: {
delete?: boolean;
keys?: (keyof U)[];
} | undefined) => void;
}): void;
export {};

@@ -12,2 +12,2 @@ /**

*/
export declare const devtools: <T extends object>(proxyObject: T, name?: string | undefined) => (() => void) | undefined;
export declare function devtools<T extends object>(proxyObject: T, name?: string): (() => void) | undefined;

@@ -29,2 +29,2 @@ /**

*/
export declare const proxyMap: <K, V>(entries?: Iterable<readonly [K, V]> | null | undefined) => Map<K, V>;
export declare function proxyMap<K, V>(entries?: Iterable<readonly [K, V]> | null): Map<K, V>;

@@ -16,2 +16,2 @@ /**

*/
export declare const proxySet: <T>(initialValues?: Iterable<T> | null | undefined) => Set<T>;
export declare function proxySet<T>(initialValues?: Iterable<T> | null): Set<T>;

@@ -32,6 +32,8 @@ declare type AsRef = {

*/
export declare const proxyWithComputed: <T extends object, U extends object>(initialObject: T, computedFns: { [K in keyof U]: {
get: (snap: Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
} | ((snap: Snapshot<T>) => U[K]); }) => T & U;
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: ((snap: Snapshot<T>) => U[K]) | {
get: (snap: Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
};
}): T & U;
export {};

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
value: V;

@@ -27,0 +27,0 @@ history: {

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare function subscribeKey<T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean): () => void;

@@ -29,3 +29,3 @@ declare type WatchGet = <T extends object>(value: T) => T;

*/
export declare const watch: (callback: WatchCallback, options?: WatchOptions | undefined) => (() => void);
export declare function watch(callback: WatchCallback, options?: WatchOptions): () => void;
export {};
declare type AsRef = {
$$valtioRef: true;
};
export declare const ref: <T extends object>(o: T) => T & AsRef;
export declare function ref<T extends object>(o: T): T & AsRef;
declare type Path = (string | symbol)[];
declare 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];
export declare const proxy: <T extends object>(initialObject?: T) => T;
export declare const getVersion: (proxyObject: unknown) => number | undefined;
export declare const subscribe: <T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean | undefined) => () => void;
/**
* @deprecated this will be removed in next versions
*/
export declare type DeepResolveType<T> = T extends (...args: any[]) => any ? T : T extends AsRef ? T : T extends Promise<infer V> ? DeepResolveType<V> : T extends object ? {
readonly [K in keyof T]: DeepResolveType<T[K]>;
} : T;
export declare function proxy<T extends object>(initialObject?: T): T;
export declare function getVersion(proxyObject: unknown): number | undefined;
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
declare type AnyFunction = (...args: any[]) => any;

@@ -20,4 +14,4 @@ declare type Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<infer V> ? Snapshot<V> : {

};
export declare const snapshot: <T extends object>(proxyObject: T) => Snapshot<T>;
export declare const getHandler: <T extends object>(proxyObject: T) => any;
export declare function snapshot<T extends object>(proxyObject: T): Snapshot<T>;
export declare function getHandler<T extends object>(proxyObject: T): any;
export {};

@@ -10,6 +10,6 @@ import { getUntracked, markToTrack } from 'proxy-compare';

const refSet = /* @__PURE__ */ new WeakSet();
const ref = (o) => {
function ref(o) {
refSet.add(o);
return o;
};
}
const isObject = (x) => typeof x === "object" && x !== null;

@@ -20,3 +20,3 @@ const 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);

const snapshotCache = /* @__PURE__ */ new WeakMap();
const proxy = (initialObject = {}) => {
function proxy(initialObject = {}) {
if (!isObject(initialObject)) {

@@ -175,6 +175,8 @@ throw new Error("object required");

return proxyObject;
};
const getVersion = (proxyObject) => isObject(proxyObject) ? proxyObject[VERSION] : void 0;
const subscribe = (proxyObject, callback, notifyInSync) => {
if (typeof process === "object" && process.env.NODE_ENV !== "production" && !(proxyObject == null ? void 0 : proxyObject[LISTENERS])) {
}
function getVersion(proxyObject) {
return isObject(proxyObject) ? proxyObject[VERSION] : void 0;
}
function subscribe(proxyObject, callback, notifyInSync) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && !(proxyObject == null ? void 0 : proxyObject[LISTENERS])) {
console.warn("Please use proxy object");

@@ -201,16 +203,16 @@ }

};
};
const snapshot = (proxyObject) => {
if (typeof process === "object" && process.env.NODE_ENV !== "production" && !(proxyObject == null ? void 0 : proxyObject[SNAPSHOT])) {
}
function snapshot(proxyObject) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && !(proxyObject == null ? void 0 : proxyObject[SNAPSHOT])) {
console.warn("Please use proxy object");
}
return proxyObject[SNAPSHOT];
};
const getHandler = (proxyObject) => {
if (typeof process === "object" && process.env.NODE_ENV !== "production" && !(proxyObject == null ? void 0 : proxyObject[HANDLER])) {
}
function getHandler(proxyObject) {
if ((import.meta.env && import.meta.env.MODE) !== "production" && !(proxyObject == null ? void 0 : proxyObject[HANDLER])) {
console.warn("Please use proxy object");
}
return proxyObject[HANDLER];
};
}
export { getHandler, getVersion, proxy, ref, snapshot, subscribe };

@@ -11,8 +11,8 @@ 'use strict';

var GET_VERSION = '_uMS_V';
var createMutableSource = function createMutableSource(target, getVersion) {
function createMutableSource(target, getVersion) {
var _ref;
return _ref = {}, _ref[TARGET] = target, _ref[GET_VERSION] = getVersion, _ref;
};
var useMutableSource = function useMutableSource(source, getSnapshot, subscribe) {
}
function useMutableSource(source, getSnapshot, subscribe) {
var lastVersion = react.useRef();

@@ -78,3 +78,3 @@ var currentVersion = source[GET_VERSION](source[TARGET]);

return currentSnapshot;
};
}

@@ -103,3 +103,3 @@ var isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);

var useSnapshot = function useSnapshot(proxyObject, options) {
function useSnapshot(proxyObject, options) {
var forceUpdate = react.useReducer(function (c) {

@@ -141,3 +141,3 @@ return c + 1;

if (typeof process === 'object' && process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== "production") {
useAffectedDebugValue(currSnapshot, affected);

@@ -150,3 +150,3 @@ }

return proxyCompare.createProxy(currSnapshot, affected, proxyCache);
};
}

@@ -153,0 +153,0 @@ Object.defineProperty(exports, 'getVersion', {

{
"name": "valtio",
"private": false,
"version": "1.2.12",
"version": "1.3.0",
"description": "💊 Valtio makes proxy-state simple for React and Vanilla",

@@ -6,0 +6,0 @@ "main": "./index.js",

@@ -83,3 +83,3 @@ declare type AsRef = {

*/
export declare const useSnapshot: <T extends object>(proxyObject: T, options?: Options | undefined) => Snapshot<T>;
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): Snapshot<T>;
export {};

@@ -51,2 +51,18 @@ <img src="logo.svg" alt="valtio">

<details>
<summary>Note for TypeScript users: Return type of useSnapshot can be too strict.</summary>
The `snap` variable returned by `useSnapshot` is a (deeply) read-only object.
Its type has `readonly` attribute, which may be too strict for some use cases.
To mitigate typing difficulties, you might want to loosen the type definition:
```ts
declare module "valtio" {
function useSnapshot<T extends object>(p: T): T;
}
```
See [#327](https://github.com/pmndrs/valtio/issues/327) for more information.
</details>
<details>
<summary>Note: useSnapshot returns a new proxy for render optimization.</summary>

@@ -53,0 +69,0 @@

@@ -83,3 +83,3 @@ declare type AsRef = {

*/
export declare const useSnapshot: <T extends object>(proxyObject: T, options?: Options | undefined) => Snapshot<T>;
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): Snapshot<T>;
export {};

@@ -7,4 +7,4 @@ declare const TARGET = "_uMS_T";

};
export declare const createMutableSource: <T, V>(target: T, getVersion: (target: T) => V) => MutableSource<T, V>;
export declare const useMutableSource: <T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void) => S;
export declare function createMutableSource<T, V>(target: T, getVersion: (target: T) => V): MutableSource<T, V>;
export declare function useMutableSource<T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void): S;
export {};

@@ -6,4 +6,4 @@ /**

*/
export declare const addComputed_DEPRECATED: <T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
export declare function addComputed_DEPRECATED<T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
[K in keyof U]: (snap_FAKE: T) => U[K];
}, targetObject?: any) => any;
}, targetObject?: any): any;

@@ -40,3 +40,3 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*/
export declare const derive: <T extends object, U extends object>(derivedFns: {
export declare function derive<T extends object, U extends object>(derivedFns: {
[K in keyof U]: (get: DeriveGet) => U[K];

@@ -46,3 +46,3 @@ }, options?: {

sync?: boolean;
} | undefined) => T & U;
}): T & U;
/**

@@ -70,6 +70,6 @@ * underive

*/
export declare const underive: <T extends object, U extends object>(proxyObject: T & U, options?: {
export declare function underive<T extends object, U extends object>(proxyObject: T & U, options?: {
delete?: boolean;
keys?: (keyof U)[];
} | undefined) => void;
}): void;
export {};

@@ -12,2 +12,2 @@ /**

*/
export declare const devtools: <T extends object>(proxyObject: T, name?: string | undefined) => (() => void) | undefined;
export declare function devtools<T extends object>(proxyObject: T, name?: string): (() => void) | undefined;

@@ -29,5 +29,5 @@ /**

*/
export declare const proxyMap: <K, V>(entries?: Iterable<readonly [
export declare function proxyMap<K, V>(entries?: Iterable<readonly [
K,
V
]> | null | undefined) => Map<K, V>;
]> | null): Map<K, V>;

@@ -16,2 +16,2 @@ /**

*/
export declare const proxySet: <T>(initialValues?: Iterable<T> | null | undefined) => Set<T>;
export declare function proxySet<T>(initialValues?: Iterable<T> | null): Set<T>;

@@ -32,8 +32,8 @@ declare type AsRef = {

*/
export declare const proxyWithComputed: <T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: {
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: ((snap: Snapshot<T>) => U[K]) | {
get: (snap: Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
} | ((snap: Snapshot<T>) => U[K]);
}) => T & U;
};
}): T & U;
export {};

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
value: V;

@@ -27,0 +27,0 @@ history: {

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare function subscribeKey<T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean): () => void;

@@ -29,3 +29,3 @@ declare type WatchGet = <T extends object>(value: T) => T;

*/
export declare const watch: (callback: WatchCallback, options?: WatchOptions | undefined) => (() => void);
export declare function watch(callback: WatchCallback, options?: WatchOptions): () => void;
export {};
declare type AsRef = {
$$valtioRef: true;
};
export declare const ref: <T extends object>(o: T) => T & AsRef;
export declare function ref<T extends object>(o: T): T & AsRef;
declare type Path = (string | symbol)[];

@@ -24,11 +24,5 @@ declare type Op = [

];
export declare const proxy: <T extends object>(initialObject?: T) => T;
export declare const getVersion: (proxyObject: unknown) => number | undefined;
export declare const subscribe: <T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean | undefined) => () => void;
/**
* @deprecated this will be removed in next versions
*/
export declare type DeepResolveType<T> = T extends (...args: any[]) => any ? T : T extends AsRef ? T : T extends Promise<infer V> ? DeepResolveType<V> : T extends object ? {
readonly [K in keyof T]: DeepResolveType<T[K]>;
} : T;
export declare function proxy<T extends object>(initialObject?: T): T;
export declare function getVersion(proxyObject: unknown): number | undefined;
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
declare type AnyFunction = (...args: any[]) => any;

@@ -38,4 +32,4 @@ declare type Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<infer V> ? Snapshot<V> : {

};
export declare const snapshot: <T extends object>(proxyObject: T) => Snapshot<T>;
export declare const getHandler: <T extends object>(proxyObject: T) => any;
export declare function snapshot<T extends object>(proxyObject: T): Snapshot<T>;
export declare function getHandler<T extends object>(proxyObject: T): any;
export {};

@@ -83,3 +83,3 @@ declare type AsRef = {

*/
export declare const useSnapshot: <T extends object>(proxyObject: T, options?: Options | undefined) => Snapshot<T>;
export declare function useSnapshot<T extends object>(proxyObject: T, options?: Options): Snapshot<T>;
export {};

@@ -7,4 +7,4 @@ declare const TARGET = "_uMS_T";

};
export declare const createMutableSource: <T, V>(target: T, getVersion: (target: T) => V) => MutableSource<T, V>;
export declare const useMutableSource: <T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void) => S;
export declare function createMutableSource<T, V>(target: T, getVersion: (target: T) => V): MutableSource<T, V>;
export declare function useMutableSource<T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void): S;
export {};

@@ -6,4 +6,4 @@ /**

*/
export declare const addComputed_DEPRECATED: <T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
export declare function addComputed_DEPRECATED<T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
[K in keyof U]: (snap_FAKE: T) => U[K];
}, targetObject?: any) => any;
}, targetObject?: any): any;

@@ -40,3 +40,3 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*/
export declare const derive: <T extends object, U extends object>(derivedFns: {
export declare function derive<T extends object, U extends object>(derivedFns: {
[K in keyof U]: (get: DeriveGet) => U[K];

@@ -46,3 +46,3 @@ }, options?: {

sync?: boolean;
} | undefined) => T & U;
}): T & U;
/**

@@ -70,6 +70,6 @@ * underive

*/
export declare const underive: <T extends object, U extends object>(proxyObject: T & U, options?: {
export declare function underive<T extends object, U extends object>(proxyObject: T & U, options?: {
delete?: boolean;
keys?: (keyof U)[];
} | undefined) => void;
}): void;
export {};

@@ -12,2 +12,2 @@ /**

*/
export declare const devtools: <T extends object>(proxyObject: T, name?: string | undefined) => (() => void) | undefined;
export declare function devtools<T extends object>(proxyObject: T, name?: string): (() => void) | undefined;

@@ -29,5 +29,5 @@ /**

*/
export declare const proxyMap: <K, V>(entries?: Iterable<readonly [
export declare function proxyMap<K, V>(entries?: Iterable<readonly [
K,
V
]> | null | undefined) => Map<K, V>;
]> | null): Map<K, V>;

@@ -16,2 +16,2 @@ /**

*/
export declare const proxySet: <T>(initialValues?: Iterable<T> | null | undefined) => Set<T>;
export declare function proxySet<T>(initialValues?: Iterable<T> | null): Set<T>;

@@ -32,8 +32,8 @@ declare type AsRef = {

*/
export declare const proxyWithComputed: <T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: {
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: ((snap: Snapshot<T>) => U[K]) | {
get: (snap: Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
} | ((snap: Snapshot<T>) => U[K]);
}) => T & U;
};
}): T & U;
export {};

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
value: V;

@@ -27,0 +27,0 @@ history: {

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare function subscribeKey<T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean): () => void;

@@ -29,3 +29,3 @@ declare type WatchGet = <T extends object>(value: T) => T;

*/
export declare const watch: (callback: WatchCallback, options?: WatchOptions | undefined) => (() => void);
export declare function watch(callback: WatchCallback, options?: WatchOptions): () => void;
export {};
declare type AsRef = {
$$valtioRef: true;
};
export declare const ref: <T extends object>(o: T) => T & AsRef;
export declare function ref<T extends object>(o: T): T & AsRef;
declare type Path = (string | symbol)[];

@@ -24,11 +24,5 @@ declare type Op = [

];
export declare const proxy: <T extends object>(initialObject?: T) => T;
export declare const getVersion: (proxyObject: unknown) => number | undefined;
export declare const subscribe: <T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean | undefined) => () => void;
/**
* @deprecated this will be removed in next versions
*/
export declare type DeepResolveType<T> = T extends (...args: any[]) => any ? T : T extends AsRef ? T : T extends Promise<infer V> ? DeepResolveType<V> : T extends object ? {
readonly [K in keyof T]: DeepResolveType<T[K]>;
} : T;
export declare function proxy<T extends object>(initialObject?: T): T;
export declare function getVersion(proxyObject: unknown): number | undefined;
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
declare type AnyFunction = (...args: any[]) => any;

@@ -38,4 +32,4 @@ declare type Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<infer V> ? Snapshot<V> : {

};
export declare const snapshot: <T extends object>(proxyObject: T) => Snapshot<T>;
export declare const getHandler: <T extends object>(proxyObject: T) => any;
export declare function snapshot<T extends object>(proxyObject: T): Snapshot<T>;
export declare function getHandler<T extends object>(proxyObject: T): any;
export {};

@@ -7,4 +7,4 @@ declare const TARGET = "_uMS_T";

};
export declare const createMutableSource: <T, V>(target: T, getVersion: (target: T) => V) => MutableSource<T, V>;
export declare const useMutableSource: <T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void) => S;
export declare function createMutableSource<T, V>(target: T, getVersion: (target: T) => V): MutableSource<T, V>;
export declare function useMutableSource<T, V, S>(source: MutableSource<T, V>, getSnapshot: (target: T) => S, subscribe: (target: T, callback: () => void) => () => void): S;
export {};

@@ -7,5 +7,4 @@ 'use strict';

var proxyCompare = require('proxy-compare');
var valtio = require('valtio');
var subscribeKey = function subscribeKey(proxyObject, key, callback, notifyInSync) {
function subscribeKey(proxyObject, key, callback, notifyInSync) {
return vanilla.subscribe(proxyObject, function (ops) {

@@ -18,6 +17,6 @@ if (ops.some(function (op) {

}, notifyInSync);
};
}
var currentCleanups;
var watch = function watch(callback, options) {
function watch(callback, options) {
var cleanups = new Set();

@@ -76,6 +75,6 @@ var subscriptions = new Set();

return wrappedCleanup;
};
}
var DEVTOOLS = Symbol();
var devtools = function devtools(proxyObject, name) {
function devtools(proxyObject, name) {
var extension;

@@ -88,3 +87,3 @@

if (!extension) {
if (typeof process === 'object' && process.env.NODE_ENV === 'development' && typeof window !== 'undefined') {
if (process.env.NODE_ENV !== "production" && typeof window !== 'undefined') {
console.warn('[Warning] Please install/enable Redux devtools extension');

@@ -172,3 +171,3 @@ }

};
};
}

@@ -326,3 +325,3 @@ var sourceObjectMap = new WeakMap();

};
var derive = function derive(derivedFns, options) {
function derive(derivedFns, options) {
var proxyObject = (options == null ? void 0 : options.proxy) || vanilla.proxy({});

@@ -413,4 +412,4 @@ var notifyInSync = !!(options != null && options.sync);

return proxyObject;
};
var underive = function underive(proxyObject, options) {
}
function underive(proxyObject, options) {
var keysToDelete = options != null && options.delete ? new Set() : null;

@@ -434,5 +433,5 @@ listSubscriptions(proxyObject).forEach(function (subscription) {

}
};
}
var addComputed_DEPRECATED = function addComputed_DEPRECATED(proxyObject, computedFns_FAKE, targetObject) {
function addComputed_DEPRECATED(proxyObject, computedFns_FAKE, targetObject) {
if (targetObject === void 0) {

@@ -452,5 +451,5 @@ targetObject = proxyObject;

});
};
}
var proxyWithComputed = function proxyWithComputed(initialObject, computedFns) {
function proxyWithComputed(initialObject, computedFns) {
Object.keys(computedFns).forEach(function (key) {

@@ -496,5 +495,5 @@ if (Object.getOwnPropertyDescriptor(initialObject, key)) {

return proxyObject;
};
}
var proxyWithHistory = function proxyWithHistory(initialValue, skipSubscribe) {
function proxyWithHistory(initialValue, skipSubscribe) {
if (skipSubscribe === void 0) {

@@ -551,3 +550,3 @@ skipSubscribe = false;

return proxyObject;
};
}

@@ -577,6 +576,6 @@ function _defineEnumerableProperties(obj, descs) {

var proxySet = function proxySet(initialValues) {
function proxySet(initialValues) {
var _Symbol$toStringTag, _proxy, _mutatorMap;
var set = valtio.proxy((_proxy = {
var set = vanilla.proxy((_proxy = {
data: Array.from(new Set(initialValues)),

@@ -590,3 +589,3 @@ has: function has(value) {

if (typeof value === 'object' && value !== null) {
hasProxy = this.data.indexOf(valtio.proxy(value)) !== -1;
hasProxy = this.data.indexOf(vanilla.proxy(value)) !== -1;
}

@@ -651,8 +650,8 @@

return set;
};
}
var proxyMap = function proxyMap(entries) {
function proxyMap(entries) {
var _Symbol$toStringTag, _proxy, _mutatorMap;
var map = valtio.proxy((_proxy = {
var map = vanilla.proxy((_proxy = {
data: Array.from(entries || []),

@@ -745,3 +744,3 @@ has: function has(key) {

return map;
};
}

@@ -748,0 +747,0 @@ exports.addComputed = addComputed_DEPRECATED;

@@ -6,2 +6,4 @@ /**

*/
export declare const addComputed_DEPRECATED: <T extends object, U extends object>(proxyObject: T, computedFns_FAKE: { [K in keyof U]: (snap_FAKE: T) => U[K]; }, targetObject?: any) => any;
export declare function addComputed_DEPRECATED<T extends object, U extends object>(proxyObject: T, computedFns_FAKE: {
[K in keyof U]: (snap_FAKE: T) => U[K];
}, targetObject?: any): any;

@@ -40,6 +40,8 @@ declare type DeriveGet = <T extends object>(proxyObject: T) => T;

*/
export declare const derive: <T extends object, U extends object>(derivedFns: { [K in keyof U]: (get: DeriveGet) => U[K]; }, options?: {
export declare function derive<T extends object, U extends object>(derivedFns: {
[K in keyof U]: (get: DeriveGet) => U[K];
}, options?: {
proxy?: T;
sync?: boolean;
} | undefined) => T & U;
}): T & U;
/**

@@ -67,6 +69,6 @@ * underive

*/
export declare const underive: <T extends object, U extends object>(proxyObject: T & U, options?: {
export declare function underive<T extends object, U extends object>(proxyObject: T & U, options?: {
delete?: boolean;
keys?: (keyof U)[];
} | undefined) => void;
}): void;
export {};

@@ -12,2 +12,2 @@ /**

*/
export declare const devtools: <T extends object>(proxyObject: T, name?: string | undefined) => (() => void) | undefined;
export declare function devtools<T extends object>(proxyObject: T, name?: string): (() => void) | undefined;

@@ -29,2 +29,2 @@ /**

*/
export declare const proxyMap: <K, V>(entries?: Iterable<readonly [K, V]> | null | undefined) => Map<K, V>;
export declare function proxyMap<K, V>(entries?: Iterable<readonly [K, V]> | null): Map<K, V>;

@@ -16,2 +16,2 @@ /**

*/
export declare const proxySet: <T>(initialValues?: Iterable<T> | null | undefined) => Set<T>;
export declare function proxySet<T>(initialValues?: Iterable<T> | null): Set<T>;

@@ -32,6 +32,8 @@ declare type AsRef = {

*/
export declare const proxyWithComputed: <T extends object, U extends object>(initialObject: T, computedFns: { [K in keyof U]: {
get: (snap: Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
} | ((snap: Snapshot<T>) => U[K]); }) => T & U;
export declare function proxyWithComputed<T extends object, U extends object>(initialObject: T, computedFns: {
[K in keyof U]: ((snap: Snapshot<T>) => U[K]) | {
get: (snap: Snapshot<T>) => U[K];
set?: (state: T, newValue: U[K]) => void;
};
}): T & U;
export {};

@@ -24,3 +24,3 @@ /**

*/
export declare const proxyWithHistory: <V>(initialValue: V, skipSubscribe?: boolean) => {
export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
value: V;

@@ -27,0 +27,0 @@ history: {

@@ -12,2 +12,2 @@ /**

*/
export declare const subscribeKey: <T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean | undefined) => () => void;
export declare function subscribeKey<T extends object, K extends keyof T>(proxyObject: T, key: K, callback: (value: T[K]) => void, notifyInSync?: boolean): () => void;

@@ -29,3 +29,3 @@ declare type WatchGet = <T extends object>(value: T) => T;

*/
export declare const watch: (callback: WatchCallback, options?: WatchOptions | undefined) => (() => void);
export declare function watch(callback: WatchCallback, options?: WatchOptions): () => void;
export {};
declare type AsRef = {
$$valtioRef: true;
};
export declare const ref: <T extends object>(o: T) => T & AsRef;
export declare function ref<T extends object>(o: T): T & AsRef;
declare type Path = (string | symbol)[];
declare 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];
export declare const proxy: <T extends object>(initialObject?: T) => T;
export declare const getVersion: (proxyObject: unknown) => number | undefined;
export declare const subscribe: <T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean | undefined) => () => void;
/**
* @deprecated this will be removed in next versions
*/
export declare type DeepResolveType<T> = T extends (...args: any[]) => any ? T : T extends AsRef ? T : T extends Promise<infer V> ? DeepResolveType<V> : T extends object ? {
readonly [K in keyof T]: DeepResolveType<T[K]>;
} : T;
export declare function proxy<T extends object>(initialObject?: T): T;
export declare function getVersion(proxyObject: unknown): number | undefined;
export declare function subscribe<T extends object>(proxyObject: T, callback: (ops: Op[]) => void, notifyInSync?: boolean): () => void;
declare type AnyFunction = (...args: any[]) => any;

@@ -20,4 +14,4 @@ declare type Snapshot<T> = T extends AnyFunction ? T : T extends AsRef ? T : T extends Promise<infer V> ? Snapshot<V> : {

};
export declare const snapshot: <T extends object>(proxyObject: T) => Snapshot<T>;
export declare const getHandler: <T extends object>(proxyObject: T) => any;
export declare function snapshot<T extends object>(proxyObject: T): Snapshot<T>;
export declare function getHandler<T extends object>(proxyObject: T): any;
export {};

@@ -14,6 +14,6 @@ 'use strict';

var refSet = new WeakSet();
var ref = function ref(o) {
function ref(o) {
refSet.add(o);
return o;
};
}

@@ -31,3 +31,3 @@ var isObject = function isObject(x) {

var snapshotCache = new WeakMap();
var proxy = function proxy(initialObject) {
function proxy(initialObject) {
if (initialObject === void 0) {

@@ -226,8 +226,8 @@ initialObject = {};

return proxyObject;
};
var getVersion = function getVersion(proxyObject) {
}
function getVersion(proxyObject) {
return isObject(proxyObject) ? proxyObject[VERSION] : undefined;
};
var subscribe = function subscribe(proxyObject, callback, notifyInSync) {
if (typeof process === 'object' && process.env.NODE_ENV !== 'production' && !(proxyObject != null && proxyObject[LISTENERS])) {
}
function subscribe(proxyObject, callback, notifyInSync) {
if (process.env.NODE_ENV !== "production" && !(proxyObject != null && proxyObject[LISTENERS])) {
console.warn('Please use proxy object');

@@ -259,5 +259,5 @@ }

};
};
var snapshot = function snapshot(proxyObject) {
if (typeof process === 'object' && process.env.NODE_ENV !== 'production' && !(proxyObject != null && proxyObject[SNAPSHOT])) {
}
function snapshot(proxyObject) {
if (process.env.NODE_ENV !== "production" && !(proxyObject != null && proxyObject[SNAPSHOT])) {
console.warn('Please use proxy object');

@@ -267,5 +267,5 @@ }

return proxyObject[SNAPSHOT];
};
var getHandler = function getHandler(proxyObject) {
if (typeof process === 'object' && process.env.NODE_ENV !== 'production' && !(proxyObject != null && proxyObject[HANDLER])) {
}
function getHandler(proxyObject) {
if (process.env.NODE_ENV !== "production" && !(proxyObject != null && proxyObject[HANDLER])) {
console.warn('Please use proxy object');

@@ -275,3 +275,3 @@ }

return proxyObject[HANDLER];
};
}

@@ -278,0 +278,0 @@ exports.getHandler = getHandler;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc