Comparing version 4.1.4 to 4.1.5
import type { ReactNode } from 'react'; | ||
import type { StoreApi } from 'zustand'; | ||
declare type UseContextStore<S extends StoreApi<unknown>> = { | ||
type UseContextStore<S extends StoreApi<unknown>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
}; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithoutCallSignature<T> = { | ||
type WithoutCallSignature<T> = { | ||
[K in keyof T]: T[K]; | ||
@@ -12,0 +12,0 @@ }; |
import type { ReactNode } from 'react'; | ||
import type { StoreApi } from 'zustand'; | ||
declare type UseContextStore<S extends StoreApi<unknown>> = { | ||
type UseContextStore<S extends StoreApi<unknown>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
}; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithoutCallSignature<T> = { | ||
type WithoutCallSignature<T> = { | ||
[K in keyof T]: T[K]; | ||
@@ -12,0 +12,0 @@ }; |
@@ -16,3 +16,3 @@ const reduxImpl = (reducer, initial) => (set, _get, api) => { | ||
extensionConnector = (enabled != null ? enabled : process.env.NODE_ENV !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
} catch { | ||
} catch (e) { | ||
} | ||
@@ -19,0 +19,0 @@ if (!extensionConnector) { |
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type Combine = <T extends object, U extends object, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initialState: T, additionalStateCreator: StateCreator<T, Mps, Mcs, U>) => StateCreator<Write<T, U>, Mps, Mcs>; | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type Combine = <T extends object, U extends object, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initialState: T, additionalStateCreator: StateCreator<T, Mps, Mcs, U>) => StateCreator<Write<T, U>, Mps, Mcs>; | ||
export declare const combine: Combine; | ||
export {}; |
import type { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
type EnhancerOptions = { | ||
name?: string; | ||
@@ -59,3 +59,3 @@ actionCreators?: ActionCreator<any>[] | { | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type Config = EnhancerOptions & { | ||
type?: string; | ||
@@ -68,5 +68,5 @@ }; | ||
} | ||
declare type Cast<T, U> = T extends U ? T : U; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type TakeTwo<T> = T extends { | ||
type Cast<T, U> = T extends U ? T : U; | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type TakeTwo<T> = T extends { | ||
length: 0; | ||
@@ -84,4 +84,4 @@ } ? [undefined, undefined] : T extends { | ||
} ? T : T extends [infer A0, infer A1, ...unknown[]] ? [A0, A1] : T extends [infer A0, (infer A1)?, ...unknown[]] ? [A0, A1?] : T extends [(infer A0)?, (infer A1)?, ...unknown[]] ? [A0?, A1?] : never; | ||
declare type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
declare type StoreDevtools<S> = S extends { | ||
type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
type StoreDevtools<S> = S extends { | ||
setState: (...a: infer Sa) => infer Sr; | ||
@@ -97,3 +97,3 @@ } ? { | ||
} | ||
declare type Devtools = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/devtools', never]], Mcs>, devtoolsOptions?: DevtoolsOptions) => StateCreator<T, Mps, [['zustand/devtools', never], ...Mcs]>; | ||
type Devtools = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/devtools', never]], Mcs>, devtoolsOptions?: DevtoolsOptions) => StateCreator<T, Mps, [['zustand/devtools', never], ...Mcs]>; | ||
declare module '../vanilla' { | ||
@@ -104,4 +104,4 @@ interface StoreMutators<S, A> { | ||
} | ||
export declare type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export declare const devtools: Devtools; | ||
export {}; |
import type { Draft } from 'immer'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Immer = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/immer', never]], Mcs>) => StateCreator<T, Mps, [['zustand/immer', never], ...Mcs]>; | ||
type Immer = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/immer', never]], Mcs>) => StateCreator<T, Mps, [['zustand/immer', never], ...Mcs]>; | ||
declare module '../vanilla' { | ||
@@ -9,4 +9,4 @@ interface StoreMutators<S, A> { | ||
} | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type SkipTwo<T> = T extends { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type SkipTwo<T> = T extends { | ||
length: 0; | ||
@@ -18,4 +18,4 @@ } ? [] : T extends { | ||
} ? [] : T extends [unknown, unknown, ...infer A] ? A : T extends [unknown, unknown?, ...infer A] ? A : T extends [unknown?, unknown?, ...infer A] ? A : never; | ||
declare type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
declare type StoreImmer<S> = S extends { | ||
type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
type StoreImmer<S> = S extends { | ||
getState: () => infer T; | ||
@@ -22,0 +22,0 @@ setState: infer SetState; |
@@ -7,3 +7,3 @@ import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
} | ||
declare type StorageValue<S> = { | ||
type StorageValue<S> = { | ||
state: S; | ||
@@ -66,4 +66,4 @@ version?: number; | ||
} | ||
declare type PersistListener<S> = (state: S) => void; | ||
declare type StorePersist<S, Ps> = { | ||
type PersistListener<S> = (state: S) => void; | ||
type StorePersist<S, Ps> = { | ||
persist: { | ||
@@ -79,3 +79,3 @@ setOptions: (options: Partial<PersistOptions<S, Ps>>) => void; | ||
}; | ||
declare type Persist = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = [], U = T>(initializer: StateCreator<T, [...Mps, ['zustand/persist', unknown]], Mcs>, options?: PersistOptions<T, U>) => StateCreator<T, Mps, [['zustand/persist', U], ...Mcs]>; | ||
type Persist = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = [], U = T>(initializer: StateCreator<T, [...Mps, ['zustand/persist', unknown]], Mcs>, options?: PersistOptions<T, U>) => StateCreator<T, Mps, [['zustand/persist', U], ...Mcs]>; | ||
declare module '../vanilla' { | ||
@@ -86,4 +86,4 @@ interface StoreMutators<S, A> { | ||
} | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type WithPersist<S, A> = S extends { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type WithPersist<S, A> = S extends { | ||
getState: () => infer T; | ||
@@ -90,0 +90,0 @@ } ? Write<S, StorePersist<T, A>> : never; |
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type Action = { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type Action = { | ||
type: unknown; | ||
}; | ||
declare type StoreRedux<A> = { | ||
type StoreRedux<A> = { | ||
dispatch: (a: A) => A; | ||
dispatchFromDevtools: true; | ||
}; | ||
declare type ReduxState<A> = { | ||
type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A extends Action, Cms extends [StoreMutatorIdentifier, unknown][] = []>(reducer: (state: T, action: A) => T, initialState: T) => StateCreator<Write<T, ReduxState<A>>, Cms, [['zustand/redux', A]]>; | ||
type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
type Redux = <T, A extends Action, Cms extends [StoreMutatorIdentifier, unknown][] = []>(reducer: (state: T, action: A) => T, initialState: T) => StateCreator<Write<T, ReduxState<A>>, Cms, [['zustand/redux', A]]>; | ||
declare module '../vanilla' { | ||
@@ -16,0 +16,0 @@ interface StoreMutators<S, A> { |
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type SubscribeWithSelector = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [ | ||
type SubscribeWithSelector = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [ | ||
...Mps, | ||
['zustand/subscribeWithSelector', never] | ||
], Mcs>) => StateCreator<T, Mps, [['zustand/subscribeWithSelector', never], ...Mcs]>; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type WithSelectorSubscribe<S> = S extends { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type WithSelectorSubscribe<S> = S extends { | ||
getState: () => infer T; | ||
@@ -15,3 +15,3 @@ } ? Write<S, StoreSubscribeWithSelector<T>> : never; | ||
} | ||
declare type StoreSubscribeWithSelector<T> = { | ||
type StoreSubscribeWithSelector<T> = { | ||
subscribe: { | ||
@@ -18,0 +18,0 @@ (listener: (selectedState: T, previousSelectedState: T) => void): () => void; |
import type { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithReact<S extends StoreApi<unknown>> = S & { | ||
type WithReact<S extends StoreApi<unknown>> = S & { | ||
getServerState?: () => ExtractState<S>; | ||
@@ -10,7 +10,7 @@ }; | ||
export declare function useStore<S extends WithReact<StoreApi<unknown>>, U>(api: S, selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
export declare type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
export type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equals?: (a: U, b: U) => boolean): U; | ||
} & S; | ||
declare type Create = { | ||
type Create = { | ||
<T, Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>): UseBoundStore<Mutate<StoreApi<T>, Mos>>; | ||
@@ -17,0 +17,0 @@ <T>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>; |
@@ -8,2 +8,22 @@ function shallow(objA, objB) { | ||
} | ||
if (objA instanceof Map && objB instanceof Map) { | ||
if (objA.size !== objB.size) | ||
return false; | ||
for (const [key, value] of objA) { | ||
if (!Object.is(value, objB.get(key))) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
if (objA instanceof Set && objB instanceof Set) { | ||
if (objA.size !== objB.size) | ||
return false; | ||
for (const value of objA) { | ||
if (!objB.has(value)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
const keysA = Object.keys(objA); | ||
@@ -10,0 +30,0 @@ if (keysA.length !== Object.keys(objB).length) { |
@@ -1,2 +0,2 @@ | ||
declare type SetStateInternal<T> = { | ||
type SetStateInternal<T> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -12,5 +12,5 @@ _(state: T): T | Partial<T>; | ||
} | ||
declare type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export declare type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [] ? S : Ms extends [[infer Mi, infer Ma], ...infer Mrs] ? Mutate<StoreMutators<S, Ma>[Mi & StoreMutatorIdentifier], Mrs> : never; | ||
export declare type StateCreator<T, Mis extends [StoreMutatorIdentifier, unknown][] = [], Mos extends [StoreMutatorIdentifier, unknown][] = [], U = T> = ((setState: Get<Mutate<StoreApi<T>, Mis>, 'setState', never>, getState: Get<Mutate<StoreApi<T>, Mis>, 'getState', never>, store: Mutate<StoreApi<T>, Mis>) => U) & { | ||
type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [] ? S : Ms extends [[infer Mi, infer Ma], ...infer Mrs] ? Mutate<StoreMutators<S, Ma>[Mi & StoreMutatorIdentifier], Mrs> : never; | ||
export type StateCreator<T, Mis extends [StoreMutatorIdentifier, unknown][] = [], Mos extends [StoreMutatorIdentifier, unknown][] = [], U = T> = ((setState: Get<Mutate<StoreApi<T>, Mis>, 'setState', never>, getState: Get<Mutate<StoreApi<T>, Mis>, 'getState', never>, store: Mutate<StoreApi<T>, Mis>) => U) & { | ||
$$storeMutators?: Mos; | ||
@@ -20,4 +20,4 @@ }; | ||
} | ||
export declare type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
declare type CreateStore = { | ||
export type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
type CreateStore = { | ||
<T, Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>): Mutate<StoreApi<T>, Mos>; | ||
@@ -31,27 +31,27 @@ <T>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>) => Mutate<StoreApi<T>, Mos>; | ||
*/ | ||
export declare type State = unknown; | ||
export type State = unknown; | ||
/** | ||
* @deprecated Use `Partial<T> | ((s: T) => Partial<T>)` instead of `PartialState<T>` | ||
*/ | ||
export declare type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
export type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
/** | ||
* @deprecated Use `(s: T) => U` instead of `StateSelector<T, U>` | ||
*/ | ||
export declare type StateSelector<T extends State, U> = (state: T) => U; | ||
export type StateSelector<T extends State, U> = (state: T) => U; | ||
/** | ||
* @deprecated Use `(a: T, b: T) => boolean` instead of `EqualityChecker<T>` | ||
*/ | ||
export declare type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
export type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
/** | ||
* @deprecated Use `(state: T, previousState: T) => void` instead of `StateListener<T>` | ||
*/ | ||
export declare type StateListener<T> = (state: T, previousState: T) => void; | ||
export type StateListener<T> = (state: T, previousState: T) => void; | ||
/** | ||
* @deprecated Use `(slice: T, previousSlice: T) => void` instead of `StateSliceListener<T>`. | ||
*/ | ||
export declare type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
export type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
/** | ||
* @deprecated Use `(listener: (state: T) => void) => void` instead of `Subscribe<T>`. | ||
*/ | ||
export declare type Subscribe<T extends State> = { | ||
export type Subscribe<T extends State> = { | ||
(listener: (state: T, previousState: T) => void): () => void; | ||
@@ -63,3 +63,3 @@ }; | ||
*/ | ||
export declare type SetState<T extends State> = { | ||
export type SetState<T extends State> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -73,6 +73,6 @@ _(state: T): T | Partial<T>; | ||
*/ | ||
export declare type GetState<T extends State> = () => T; | ||
export type GetState<T extends State> = () => T; | ||
/** | ||
* @deprecated Use `StoreApi<T>['destroy']` instead of `Destroy`. | ||
*/ | ||
export declare type Destroy = () => void; | ||
export type Destroy = () => void; |
@@ -40,1 +40,3 @@ 'use strict'; | ||
}); | ||
module.exports = exports.default; Object.assign(exports.default, exports); |
@@ -50,3 +50,2 @@ 'use strict'; | ||
var _excluded = ["enabled", "anonymousActionType"]; | ||
var devtoolsImpl = function devtoolsImpl(fn, devtoolsOptions) { | ||
@@ -64,4 +63,3 @@ if (devtoolsOptions === void 0) { | ||
extensionConnector = (enabled != null ? enabled : process.env.NODE_ENV !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
} catch (_unused) { | ||
} | ||
} catch (e) {} | ||
if (!extensionConnector) { | ||
@@ -147,4 +145,3 @@ if (process.env.NODE_ENV !== "production" && enabled) { | ||
setStateFromDevtools(lastComputedState); | ||
extension.send(null, | ||
nextLiftedState); | ||
extension.send(null, nextLiftedState); | ||
return; | ||
@@ -254,4 +251,3 @@ } | ||
storage = options.getStorage(); | ||
} catch (e) { | ||
} | ||
} catch (e) {} | ||
if (!storage) { | ||
@@ -289,5 +285,3 @@ return config(function () { | ||
}, get, api); | ||
var stateFromStorage; | ||
var hydrate = function hydrate() { | ||
@@ -300,3 +294,2 @@ if (!storage) return; | ||
var postRehydrationCallback = (options.onRehydrateStorage == null ? void 0 : options.onRehydrateStorage(get())) || undefined; | ||
return toThenable(storage.getItem.bind(storage))(options.name).then(function (storageValue) { | ||
@@ -303,0 +296,0 @@ if (storageValue) { |
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type Combine = <T extends object, U extends object, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initialState: T, additionalStateCreator: StateCreator<T, Mps, Mcs, U>) => StateCreator<Write<T, U>, Mps, Mcs>; | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type Combine = <T extends object, U extends object, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initialState: T, additionalStateCreator: StateCreator<T, Mps, Mcs, U>) => StateCreator<Write<T, U>, Mps, Mcs>; | ||
export declare const combine: Combine; | ||
export {}; |
import type { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
type EnhancerOptions = { | ||
name?: string; | ||
@@ -59,3 +59,3 @@ actionCreators?: ActionCreator<any>[] | { | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type Config = EnhancerOptions & { | ||
type?: string; | ||
@@ -68,5 +68,5 @@ }; | ||
} | ||
declare type Cast<T, U> = T extends U ? T : U; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type TakeTwo<T> = T extends { | ||
type Cast<T, U> = T extends U ? T : U; | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type TakeTwo<T> = T extends { | ||
length: 0; | ||
@@ -84,4 +84,4 @@ } ? [undefined, undefined] : T extends { | ||
} ? T : T extends [infer A0, infer A1, ...unknown[]] ? [A0, A1] : T extends [infer A0, (infer A1)?, ...unknown[]] ? [A0, A1?] : T extends [(infer A0)?, (infer A1)?, ...unknown[]] ? [A0?, A1?] : never; | ||
declare type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
declare type StoreDevtools<S> = S extends { | ||
type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
type StoreDevtools<S> = S extends { | ||
setState: (...a: infer Sa) => infer Sr; | ||
@@ -97,3 +97,3 @@ } ? { | ||
} | ||
declare type Devtools = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/devtools', never]], Mcs>, devtoolsOptions?: DevtoolsOptions) => StateCreator<T, Mps, [['zustand/devtools', never], ...Mcs]>; | ||
type Devtools = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/devtools', never]], Mcs>, devtoolsOptions?: DevtoolsOptions) => StateCreator<T, Mps, [['zustand/devtools', never], ...Mcs]>; | ||
declare module '../vanilla' { | ||
@@ -104,4 +104,4 @@ interface StoreMutators<S, A> { | ||
} | ||
export declare type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export declare const devtools: Devtools; | ||
export {}; |
import type { Draft } from 'immer'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Immer = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/immer', never]], Mcs>) => StateCreator<T, Mps, [['zustand/immer', never], ...Mcs]>; | ||
type Immer = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [...Mps, ['zustand/immer', never]], Mcs>) => StateCreator<T, Mps, [['zustand/immer', never], ...Mcs]>; | ||
declare module '../vanilla' { | ||
@@ -9,4 +9,4 @@ interface StoreMutators<S, A> { | ||
} | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type SkipTwo<T> = T extends { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type SkipTwo<T> = T extends { | ||
length: 0; | ||
@@ -18,4 +18,4 @@ } ? [] : T extends { | ||
} ? [] : T extends [unknown, unknown, ...infer A] ? A : T extends [unknown, unknown?, ...infer A] ? A : T extends [unknown?, unknown?, ...infer A] ? A : never; | ||
declare type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
declare type StoreImmer<S> = S extends { | ||
type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
type StoreImmer<S> = S extends { | ||
getState: () => infer T; | ||
@@ -22,0 +22,0 @@ setState: infer SetState; |
@@ -7,3 +7,3 @@ import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
} | ||
declare type StorageValue<S> = { | ||
type StorageValue<S> = { | ||
state: S; | ||
@@ -66,4 +66,4 @@ version?: number; | ||
} | ||
declare type PersistListener<S> = (state: S) => void; | ||
declare type StorePersist<S, Ps> = { | ||
type PersistListener<S> = (state: S) => void; | ||
type StorePersist<S, Ps> = { | ||
persist: { | ||
@@ -79,3 +79,3 @@ setOptions: (options: Partial<PersistOptions<S, Ps>>) => void; | ||
}; | ||
declare type Persist = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = [], U = T>(initializer: StateCreator<T, [...Mps, ['zustand/persist', unknown]], Mcs>, options?: PersistOptions<T, U>) => StateCreator<T, Mps, [['zustand/persist', U], ...Mcs]>; | ||
type Persist = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = [], U = T>(initializer: StateCreator<T, [...Mps, ['zustand/persist', unknown]], Mcs>, options?: PersistOptions<T, U>) => StateCreator<T, Mps, [['zustand/persist', U], ...Mcs]>; | ||
declare module '../vanilla' { | ||
@@ -86,4 +86,4 @@ interface StoreMutators<S, A> { | ||
} | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type WithPersist<S, A> = S extends { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type WithPersist<S, A> = S extends { | ||
getState: () => infer T; | ||
@@ -90,0 +90,0 @@ } ? Write<S, StorePersist<T, A>> : never; |
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type Action = { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type Action = { | ||
type: unknown; | ||
}; | ||
declare type StoreRedux<A> = { | ||
type StoreRedux<A> = { | ||
dispatch: (a: A) => A; | ||
dispatchFromDevtools: true; | ||
}; | ||
declare type ReduxState<A> = { | ||
type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A extends Action, Cms extends [StoreMutatorIdentifier, unknown][] = []>(reducer: (state: T, action: A) => T, initialState: T) => StateCreator<Write<T, ReduxState<A>>, Cms, [['zustand/redux', A]]>; | ||
type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
type Redux = <T, A extends Action, Cms extends [StoreMutatorIdentifier, unknown][] = []>(reducer: (state: T, action: A) => T, initialState: T) => StateCreator<Write<T, ReduxState<A>>, Cms, [['zustand/redux', A]]>; | ||
declare module '../vanilla' { | ||
@@ -16,0 +16,0 @@ interface StoreMutators<S, A> { |
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type SubscribeWithSelector = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [ | ||
type SubscribeWithSelector = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [ | ||
...Mps, | ||
['zustand/subscribeWithSelector', never] | ||
], Mcs>) => StateCreator<T, Mps, [['zustand/subscribeWithSelector', never], ...Mcs]>; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type WithSelectorSubscribe<S> = S extends { | ||
type Write<T, U> = Omit<T, keyof U> & U; | ||
type WithSelectorSubscribe<S> = S extends { | ||
getState: () => infer T; | ||
@@ -15,3 +15,3 @@ } ? Write<S, StoreSubscribeWithSelector<T>> : never; | ||
} | ||
declare type StoreSubscribeWithSelector<T> = { | ||
type StoreSubscribeWithSelector<T> = { | ||
subscribe: { | ||
@@ -18,0 +18,0 @@ (listener: (selectedState: T, previousSelectedState: T) => void): () => void; |
{ | ||
"name": "zustand", | ||
"private": false, | ||
"version": "4.1.4", | ||
"version": "4.1.5", | ||
"description": "🐻 Bear necessities for state management in React", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
import type { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithReact<S extends StoreApi<unknown>> = S & { | ||
type WithReact<S extends StoreApi<unknown>> = S & { | ||
getServerState?: () => ExtractState<S>; | ||
@@ -10,7 +10,7 @@ }; | ||
export declare function useStore<S extends WithReact<StoreApi<unknown>>, U>(api: S, selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
export declare type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
export type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equals?: (a: U, b: U) => boolean): U; | ||
} & S; | ||
declare type Create = { | ||
type Create = { | ||
<T, Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>): UseBoundStore<Mutate<StoreApi<T>, Mos>>; | ||
@@ -17,0 +17,0 @@ <T>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>; |
'use strict'; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function shallow(objA, objB) { | ||
@@ -10,2 +42,24 @@ if (Object.is(objA, objB)) { | ||
} | ||
if (objA instanceof Map && objB instanceof Map) { | ||
if (objA.size !== objB.size) return false; | ||
for (var _iterator = _createForOfIteratorHelperLoose(objA), _step; !(_step = _iterator()).done;) { | ||
var _step$value = _step.value, | ||
key = _step$value[0], | ||
value = _step$value[1]; | ||
if (!Object.is(value, objB.get(key))) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
if (objA instanceof Set && objB instanceof Set) { | ||
if (objA.size !== objB.size) return false; | ||
for (var _iterator2 = _createForOfIteratorHelperLoose(objA), _step2; !(_step2 = _iterator2()).done;) { | ||
var _value = _step2.value; | ||
if (!objB.has(_value)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
var keysA = Object.keys(objA); | ||
@@ -12,0 +66,0 @@ if (keysA.length !== Object.keys(objB).length) { |
@@ -21,3 +21,3 @@ System.register([], (function (exports) { | ||
extensionConnector = (enabled != null ? enabled : true) && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
} catch { | ||
} catch (e) { | ||
} | ||
@@ -24,0 +24,0 @@ if (!extensionConnector) { |
@@ -15,2 +15,22 @@ System.register([], (function (exports) { | ||
} | ||
if (objA instanceof Map && objB instanceof Map) { | ||
if (objA.size !== objB.size) | ||
return false; | ||
for (const [key, value] of objA) { | ||
if (!Object.is(value, objB.get(key))) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
if (objA instanceof Set && objB instanceof Set) { | ||
if (objA.size !== objB.size) | ||
return false; | ||
for (const value of objA) { | ||
if (!objB.has(value)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
const keysA = Object.keys(objA); | ||
@@ -17,0 +37,0 @@ if (keysA.length !== Object.keys(objB).length) { |
@@ -1,1 +0,1 @@ | ||
System.register([],function(c){"use strict";return{execute:function(){c("default",u);function u(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}}}}); | ||
System.register([],function(f){"use strict";return{execute:function(){f("default",i);function i(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[n,s]of t)if(!Object.is(s,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(e,r[n])||!Object.is(t[r[n]],e[r[n]]))return!1;return!0}}}}); |
@@ -1,1 +0,1 @@ | ||
System.register([],function(f){"use strict";return{execute:function(){const o=s=>{let t;const c=new Set,i=(e,a)=>{const n=typeof e=="function"?e(t):e;if(!Object.is(n,t)){const l=t;t=(a!=null?a:typeof n!="object")?n:Object.assign({},t,n),c.forEach(b=>b(t,l))}},r=()=>t,u={setState:i,getState:r,subscribe:e=>(c.add(e),()=>c.delete(e)),destroy:()=>c.clear()};return t=s(i,r,u),u},d=f("default",s=>s?o(s):o)}}}); | ||
System.register([],function(f){"use strict";return{execute:function(){const o=n=>{let t;const c=new Set,i=(e,a)=>{const s=typeof e=="function"?e(t):e;if(!Object.is(s,t)){const l=t;t=(a!=null?a:typeof s!="object")?s:Object.assign({},t,s),c.forEach(b=>b(t,l))}},r=()=>t,u={setState:i,getState:r,subscribe:e=>(c.add(e),()=>c.delete(e)),destroy:()=>c.clear()};return t=n(i,r,u),u},d=f("default",n=>n?o(n):o)}}}); |
import { ReactNode } from 'react'; | ||
import { StoreApi } from 'zustand'; | ||
declare type UseContextStore<S extends StoreApi<unknown>> = { | ||
type UseContextStore<S extends StoreApi<unknown>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
}; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithoutCallSignature<T> = { | ||
type WithoutCallSignature<T> = { | ||
[K in keyof T]: T[K]; | ||
@@ -12,0 +12,0 @@ }; |
import { ReactNode } from 'react'; | ||
import { StoreApi } from 'zustand'; | ||
declare type UseContextStore<S extends StoreApi<unknown>> = { | ||
type UseContextStore<S extends StoreApi<unknown>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
}; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithoutCallSignature<T> = { | ||
type WithoutCallSignature<T> = { | ||
[K in keyof T]: T[K]; | ||
@@ -12,0 +12,0 @@ }; |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type Combine = <T extends object, U extends object, Mps extends [ | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type Combine = <T extends object, U extends object, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -5,0 +5,0 @@ unknown |
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
type EnhancerOptions = { | ||
name?: string; | ||
@@ -59,3 +59,3 @@ actionCreators?: ActionCreator<any>[] | { | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type Config = EnhancerOptions & { | ||
type?: string; | ||
@@ -68,5 +68,5 @@ }; | ||
} | ||
declare type Cast<T, U> = T extends U ? T : U; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type TakeTwo<T> = T extends { | ||
type Cast<T, U> = T extends U ? T : U; | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type TakeTwo<T> = T extends { | ||
length: 0; | ||
@@ -114,4 +114,4 @@ } ? [ | ||
] : never; | ||
declare type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
declare type StoreDevtools<S> = S extends { | ||
type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
type StoreDevtools<S> = S extends { | ||
setState: (...a: infer Sa) => infer Sr; | ||
@@ -130,3 +130,3 @@ } ? { | ||
} | ||
declare type Devtools = <T, Mps extends [ | ||
type Devtools = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -157,4 +157,4 @@ unknown | ||
} | ||
export declare type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export declare const devtools: Devtools; | ||
export {}; |
import { Draft } from 'immer'; | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Immer = <T, Mps extends [ | ||
type Immer = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -29,4 +29,4 @@ unknown | ||
} | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type SkipTwo<T> = T extends { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type SkipTwo<T> = T extends { | ||
length: 0; | ||
@@ -53,4 +53,4 @@ } ? [ | ||
] ? A : never; | ||
declare type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
declare type StoreImmer<S> = S extends { | ||
type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
type StoreImmer<S> = S extends { | ||
getState: () => infer T; | ||
@@ -57,0 +57,0 @@ setState: infer SetState; |
@@ -7,3 +7,3 @@ import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
} | ||
declare type StorageValue<S> = { | ||
type StorageValue<S> = { | ||
state: S; | ||
@@ -66,4 +66,4 @@ version?: number; | ||
} | ||
declare type PersistListener<S> = (state: S) => void; | ||
declare type StorePersist<S, Ps> = { | ||
type PersistListener<S> = (state: S) => void; | ||
type StorePersist<S, Ps> = { | ||
persist: { | ||
@@ -79,3 +79,3 @@ setOptions: (options: Partial<PersistOptions<S, Ps>>) => void; | ||
}; | ||
declare type Persist = <T, Mps extends [ | ||
type Persist = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -106,4 +106,4 @@ unknown | ||
} | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type WithPersist<S, A> = S extends { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type WithPersist<S, A> = S extends { | ||
getState: () => infer T; | ||
@@ -110,0 +110,0 @@ } ? Write<S, StorePersist<T, A>> : never; |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type Action = { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type Action = { | ||
type: unknown; | ||
}; | ||
declare type StoreRedux<A> = { | ||
type StoreRedux<A> = { | ||
dispatch: (a: A) => A; | ||
dispatchFromDevtools: true; | ||
}; | ||
declare type ReduxState<A> = { | ||
type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A extends Action, Cms extends [ | ||
type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
type Redux = <T, A extends Action, Cms extends [ | ||
StoreMutatorIdentifier, | ||
@@ -16,0 +16,0 @@ unknown |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type SubscribeWithSelector = <T, Mps extends [ | ||
type SubscribeWithSelector = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -23,4 +23,4 @@ unknown | ||
]>; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type WithSelectorSubscribe<S> = S extends { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type WithSelectorSubscribe<S> = S extends { | ||
getState: () => infer T; | ||
@@ -33,3 +33,3 @@ } ? Write<S, StoreSubscribeWithSelector<T>> : never; | ||
} | ||
declare type StoreSubscribeWithSelector<T> = { | ||
type StoreSubscribeWithSelector<T> = { | ||
subscribe: { | ||
@@ -36,0 +36,0 @@ (listener: (selectedState: T, previousSelectedState: T) => void): () => void; |
import { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithReact<S extends StoreApi<unknown>> = S & { | ||
type WithReact<S extends StoreApi<unknown>> = S & { | ||
getServerState?: () => ExtractState<S>; | ||
@@ -10,7 +10,7 @@ }; | ||
export declare function useStore<S extends WithReact<StoreApi<unknown>>, U>(api: S, selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
export declare type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
export type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equals?: (a: U, b: U) => boolean): U; | ||
} & S; | ||
declare type Create = { | ||
type Create = { | ||
<T, Mos extends [ | ||
@@ -17,0 +17,0 @@ StoreMutatorIdentifier, |
@@ -1,2 +0,2 @@ | ||
declare type SetStateInternal<T> = { | ||
type SetStateInternal<T> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -12,4 +12,4 @@ _(state: T): T | Partial<T>; | ||
} | ||
declare type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export declare type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [ | ||
type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [ | ||
] ? S : Ms extends [ | ||
@@ -22,3 +22,3 @@ [ | ||
] ? Mutate<StoreMutators<S, Ma>[Mi & StoreMutatorIdentifier], Mrs> : never; | ||
export declare type StateCreator<T, Mis extends [ | ||
export type StateCreator<T, Mis extends [ | ||
StoreMutatorIdentifier, | ||
@@ -36,4 +36,4 @@ unknown | ||
} | ||
export declare type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
declare type CreateStore = { | ||
export type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
type CreateStore = { | ||
<T, Mos extends [ | ||
@@ -57,27 +57,27 @@ StoreMutatorIdentifier, | ||
*/ | ||
export declare type State = unknown; | ||
export type State = unknown; | ||
/** | ||
* @deprecated Use `Partial<T> | ((s: T) => Partial<T>)` instead of `PartialState<T>` | ||
*/ | ||
export declare type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
export type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
/** | ||
* @deprecated Use `(s: T) => U` instead of `StateSelector<T, U>` | ||
*/ | ||
export declare type StateSelector<T extends State, U> = (state: T) => U; | ||
export type StateSelector<T extends State, U> = (state: T) => U; | ||
/** | ||
* @deprecated Use `(a: T, b: T) => boolean` instead of `EqualityChecker<T>` | ||
*/ | ||
export declare type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
export type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
/** | ||
* @deprecated Use `(state: T, previousState: T) => void` instead of `StateListener<T>` | ||
*/ | ||
export declare type StateListener<T> = (state: T, previousState: T) => void; | ||
export type StateListener<T> = (state: T, previousState: T) => void; | ||
/** | ||
* @deprecated Use `(slice: T, previousSlice: T) => void` instead of `StateSliceListener<T>`. | ||
*/ | ||
export declare type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
export type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
/** | ||
* @deprecated Use `(listener: (state: T) => void) => void` instead of `Subscribe<T>`. | ||
*/ | ||
export declare type Subscribe<T extends State> = { | ||
export type Subscribe<T extends State> = { | ||
(listener: (state: T, previousState: T) => void): () => void; | ||
@@ -89,3 +89,3 @@ }; | ||
*/ | ||
export declare type SetState<T extends State> = { | ||
export type SetState<T extends State> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -99,6 +99,6 @@ _(state: T): T | Partial<T>; | ||
*/ | ||
export declare type GetState<T extends State> = () => T; | ||
export type GetState<T extends State> = () => T; | ||
/** | ||
* @deprecated Use `StoreApi<T>['destroy']` instead of `Destroy`. | ||
*/ | ||
export declare type Destroy = () => void; | ||
export type Destroy = () => void; |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type Combine = <T extends object, U extends object, Mps extends [ | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type Combine = <T extends object, U extends object, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -5,0 +5,0 @@ unknown |
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
type EnhancerOptions = { | ||
name?: string; | ||
@@ -59,3 +59,3 @@ actionCreators?: ActionCreator<any>[] | { | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type Config = EnhancerOptions & { | ||
type?: string; | ||
@@ -68,5 +68,5 @@ }; | ||
} | ||
declare type Cast<T, U> = T extends U ? T : U; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type TakeTwo<T> = T extends { | ||
type Cast<T, U> = T extends U ? T : U; | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type TakeTwo<T> = T extends { | ||
length: 0; | ||
@@ -114,4 +114,4 @@ } ? [ | ||
] : never; | ||
declare type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
declare type StoreDevtools<S> = S extends { | ||
type WithDevtools<S> = Write<S, StoreDevtools<S>>; | ||
type StoreDevtools<S> = S extends { | ||
setState: (...a: infer Sa) => infer Sr; | ||
@@ -130,3 +130,3 @@ } ? { | ||
} | ||
declare type Devtools = <T, Mps extends [ | ||
type Devtools = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -157,4 +157,4 @@ unknown | ||
} | ||
export declare type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export type NamedSet<T> = WithDevtools<StoreApi<T>>['setState']; | ||
export declare const devtools: Devtools; | ||
export {}; |
import { Draft } from 'immer'; | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Immer = <T, Mps extends [ | ||
type Immer = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -29,4 +29,4 @@ unknown | ||
} | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type SkipTwo<T> = T extends { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type SkipTwo<T> = T extends { | ||
length: 0; | ||
@@ -53,4 +53,4 @@ } ? [ | ||
] ? A : never; | ||
declare type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
declare type StoreImmer<S> = S extends { | ||
type WithImmer<S> = Write<S, StoreImmer<S>>; | ||
type StoreImmer<S> = S extends { | ||
getState: () => infer T; | ||
@@ -57,0 +57,0 @@ setState: infer SetState; |
@@ -7,3 +7,3 @@ import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
} | ||
declare type StorageValue<S> = { | ||
type StorageValue<S> = { | ||
state: S; | ||
@@ -66,4 +66,4 @@ version?: number; | ||
} | ||
declare type PersistListener<S> = (state: S) => void; | ||
declare type StorePersist<S, Ps> = { | ||
type PersistListener<S> = (state: S) => void; | ||
type StorePersist<S, Ps> = { | ||
persist: { | ||
@@ -79,3 +79,3 @@ setOptions: (options: Partial<PersistOptions<S, Ps>>) => void; | ||
}; | ||
declare type Persist = <T, Mps extends [ | ||
type Persist = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -106,4 +106,4 @@ unknown | ||
} | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type WithPersist<S, A> = S extends { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type WithPersist<S, A> = S extends { | ||
getState: () => infer T; | ||
@@ -110,0 +110,0 @@ } ? Write<S, StorePersist<T, A>> : never; |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type Action = { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type Action = { | ||
type: unknown; | ||
}; | ||
declare type StoreRedux<A> = { | ||
type StoreRedux<A> = { | ||
dispatch: (a: A) => A; | ||
dispatchFromDevtools: true; | ||
}; | ||
declare type ReduxState<A> = { | ||
type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A extends Action, Cms extends [ | ||
type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
type Redux = <T, A extends Action, Cms extends [ | ||
StoreMutatorIdentifier, | ||
@@ -16,0 +16,0 @@ unknown |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type SubscribeWithSelector = <T, Mps extends [ | ||
type SubscribeWithSelector = <T, Mps extends [ | ||
StoreMutatorIdentifier, | ||
@@ -23,4 +23,4 @@ unknown | ||
]>; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type WithSelectorSubscribe<S> = S extends { | ||
type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
type WithSelectorSubscribe<S> = S extends { | ||
getState: () => infer T; | ||
@@ -33,3 +33,3 @@ } ? Write<S, StoreSubscribeWithSelector<T>> : never; | ||
} | ||
declare type StoreSubscribeWithSelector<T> = { | ||
type StoreSubscribeWithSelector<T> = { | ||
subscribe: { | ||
@@ -36,0 +36,0 @@ (listener: (selectedState: T, previousSelectedState: T) => void): () => void; |
import { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
declare type ExtractState<S> = S extends { | ||
type ExtractState<S> = S extends { | ||
getState: () => infer T; | ||
} ? T : never; | ||
declare type WithReact<S extends StoreApi<unknown>> = S & { | ||
type WithReact<S extends StoreApi<unknown>> = S & { | ||
getServerState?: () => ExtractState<S>; | ||
@@ -10,7 +10,7 @@ }; | ||
export declare function useStore<S extends WithReact<StoreApi<unknown>>, U>(api: S, selector: (state: ExtractState<S>) => U, equalityFn?: (a: U, b: U) => boolean): U; | ||
export declare type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
export type UseBoundStore<S extends WithReact<StoreApi<unknown>>> = { | ||
(): ExtractState<S>; | ||
<U>(selector: (state: ExtractState<S>) => U, equals?: (a: U, b: U) => boolean): U; | ||
} & S; | ||
declare type Create = { | ||
type Create = { | ||
<T, Mos extends [ | ||
@@ -17,0 +17,0 @@ StoreMutatorIdentifier, |
@@ -1,2 +0,2 @@ | ||
declare type SetStateInternal<T> = { | ||
type SetStateInternal<T> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -12,4 +12,4 @@ _(state: T): T | Partial<T>; | ||
} | ||
declare type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export declare type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [ | ||
type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [ | ||
] ? S : Ms extends [ | ||
@@ -22,3 +22,3 @@ [ | ||
] ? Mutate<StoreMutators<S, Ma>[Mi & StoreMutatorIdentifier], Mrs> : never; | ||
export declare type StateCreator<T, Mis extends [ | ||
export type StateCreator<T, Mis extends [ | ||
StoreMutatorIdentifier, | ||
@@ -36,4 +36,4 @@ unknown | ||
} | ||
export declare type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
declare type CreateStore = { | ||
export type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
type CreateStore = { | ||
<T, Mos extends [ | ||
@@ -57,27 +57,27 @@ StoreMutatorIdentifier, | ||
*/ | ||
export declare type State = unknown; | ||
export type State = unknown; | ||
/** | ||
* @deprecated Use `Partial<T> | ((s: T) => Partial<T>)` instead of `PartialState<T>` | ||
*/ | ||
export declare type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
export type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
/** | ||
* @deprecated Use `(s: T) => U` instead of `StateSelector<T, U>` | ||
*/ | ||
export declare type StateSelector<T extends State, U> = (state: T) => U; | ||
export type StateSelector<T extends State, U> = (state: T) => U; | ||
/** | ||
* @deprecated Use `(a: T, b: T) => boolean` instead of `EqualityChecker<T>` | ||
*/ | ||
export declare type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
export type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
/** | ||
* @deprecated Use `(state: T, previousState: T) => void` instead of `StateListener<T>` | ||
*/ | ||
export declare type StateListener<T> = (state: T, previousState: T) => void; | ||
export type StateListener<T> = (state: T, previousState: T) => void; | ||
/** | ||
* @deprecated Use `(slice: T, previousSlice: T) => void` instead of `StateSliceListener<T>`. | ||
*/ | ||
export declare type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
export type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
/** | ||
* @deprecated Use `(listener: (state: T) => void) => void` instead of `Subscribe<T>`. | ||
*/ | ||
export declare type Subscribe<T extends State> = { | ||
export type Subscribe<T extends State> = { | ||
(listener: (state: T, previousState: T) => void): () => void; | ||
@@ -89,3 +89,3 @@ }; | ||
*/ | ||
export declare type SetState<T extends State> = { | ||
export type SetState<T extends State> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -99,6 +99,6 @@ _(state: T): T | Partial<T>; | ||
*/ | ||
export declare type GetState<T extends State> = () => T; | ||
export type GetState<T extends State> = () => T; | ||
/** | ||
* @deprecated Use `StoreApi<T>['destroy']` instead of `Destroy`. | ||
*/ | ||
export declare type Destroy = () => void; | ||
export type Destroy = () => void; |
@@ -54,3 +54,2 @@ (function (global, factory) { | ||
var _excluded = ["enabled", "anonymousActionType"]; | ||
var devtoolsImpl = function devtoolsImpl(fn, devtoolsOptions) { | ||
@@ -68,4 +67,3 @@ if (devtoolsOptions === void 0) { | ||
extensionConnector = (enabled != null ? enabled : true) && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
} catch (_unused) { | ||
} | ||
} catch (e) {} | ||
if (!extensionConnector) { | ||
@@ -151,4 +149,3 @@ if (enabled) { | ||
setStateFromDevtools(lastComputedState); | ||
extension.send(null, | ||
nextLiftedState); | ||
extension.send(null, nextLiftedState); | ||
return; | ||
@@ -258,4 +255,3 @@ } | ||
storage = options.getStorage(); | ||
} catch (e) { | ||
} | ||
} catch (e) {} | ||
if (!storage) { | ||
@@ -293,5 +289,3 @@ return config(function () { | ||
}, get, api); | ||
var stateFromStorage; | ||
var hydrate = function hydrate() { | ||
@@ -304,3 +298,2 @@ if (!storage) return; | ||
var postRehydrationCallback = (options.onRehydrateStorage == null ? void 0 : options.onRehydrateStorage(get())) || undefined; | ||
return toThenable(storage.getItem.bind(storage))(options.name).then(function (storageValue) { | ||
@@ -307,0 +300,0 @@ if (storageValue) { |
@@ -7,2 +7,34 @@ (function (global, factory) { | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function shallow(objA, objB) { | ||
@@ -15,2 +47,24 @@ if (Object.is(objA, objB)) { | ||
} | ||
if (objA instanceof Map && objB instanceof Map) { | ||
if (objA.size !== objB.size) return false; | ||
for (var _iterator = _createForOfIteratorHelperLoose(objA), _step; !(_step = _iterator()).done;) { | ||
var _step$value = _step.value, | ||
key = _step$value[0], | ||
value = _step$value[1]; | ||
if (!Object.is(value, objB.get(key))) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
if (objA instanceof Set && objB instanceof Set) { | ||
if (objA.size !== objB.size) return false; | ||
for (var _iterator2 = _createForOfIteratorHelperLoose(objA), _step2; !(_step2 = _iterator2()).done;) { | ||
var _value = _step2.value; | ||
if (!objB.has(_value)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
var keysA = Object.keys(objA); | ||
@@ -17,0 +71,0 @@ if (keysA.length !== Object.keys(objB).length) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).zustandShallow=t()}(this,(function(){"use strict";return function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(var o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).zustandShallow=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return function(e,r){if(Object.is(e,r))return!0;if("object"!=typeof e||null===e||"object"!=typeof r||null===r)return!1;if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(var n,o=t(e);!(n=o()).done;){var i=n.value,a=i[0],f=i[1];if(!Object.is(f,r.get(a)))return!1}return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(var u,l=t(e);!(u=l()).done;){var c=u.value;if(!r.has(c))return!1}return!0}var s=Object.keys(e);if(s.length!==Object.keys(r).length)return!1;for(var y=0;y<s.length;y++)if(!Object.prototype.hasOwnProperty.call(r,s[y])||!Object.is(e[s[y]],r[s[y]]))return!1;return!0}})); |
@@ -1,2 +0,2 @@ | ||
declare type SetStateInternal<T> = { | ||
type SetStateInternal<T> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -12,5 +12,5 @@ _(state: T): T | Partial<T>; | ||
} | ||
declare type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export declare type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [] ? S : Ms extends [[infer Mi, infer Ma], ...infer Mrs] ? Mutate<StoreMutators<S, Ma>[Mi & StoreMutatorIdentifier], Mrs> : never; | ||
export declare type StateCreator<T, Mis extends [StoreMutatorIdentifier, unknown][] = [], Mos extends [StoreMutatorIdentifier, unknown][] = [], U = T> = ((setState: Get<Mutate<StoreApi<T>, Mis>, 'setState', never>, getState: Get<Mutate<StoreApi<T>, Mis>, 'getState', never>, store: Mutate<StoreApi<T>, Mis>) => U) & { | ||
type Get<T, K, F> = K extends keyof T ? T[K] : F; | ||
export type Mutate<S, Ms> = number extends Ms['length' & keyof Ms] ? S : Ms extends [] ? S : Ms extends [[infer Mi, infer Ma], ...infer Mrs] ? Mutate<StoreMutators<S, Ma>[Mi & StoreMutatorIdentifier], Mrs> : never; | ||
export type StateCreator<T, Mis extends [StoreMutatorIdentifier, unknown][] = [], Mos extends [StoreMutatorIdentifier, unknown][] = [], U = T> = ((setState: Get<Mutate<StoreApi<T>, Mis>, 'setState', never>, getState: Get<Mutate<StoreApi<T>, Mis>, 'getState', never>, store: Mutate<StoreApi<T>, Mis>) => U) & { | ||
$$storeMutators?: Mos; | ||
@@ -20,4 +20,4 @@ }; | ||
} | ||
export declare type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
declare type CreateStore = { | ||
export type StoreMutatorIdentifier = keyof StoreMutators<unknown, unknown>; | ||
type CreateStore = { | ||
<T, Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>): Mutate<StoreApi<T>, Mos>; | ||
@@ -31,27 +31,27 @@ <T>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>) => Mutate<StoreApi<T>, Mos>; | ||
*/ | ||
export declare type State = unknown; | ||
export type State = unknown; | ||
/** | ||
* @deprecated Use `Partial<T> | ((s: T) => Partial<T>)` instead of `PartialState<T>` | ||
*/ | ||
export declare type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
export type PartialState<T extends State> = Partial<T> | ((state: T) => Partial<T>); | ||
/** | ||
* @deprecated Use `(s: T) => U` instead of `StateSelector<T, U>` | ||
*/ | ||
export declare type StateSelector<T extends State, U> = (state: T) => U; | ||
export type StateSelector<T extends State, U> = (state: T) => U; | ||
/** | ||
* @deprecated Use `(a: T, b: T) => boolean` instead of `EqualityChecker<T>` | ||
*/ | ||
export declare type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
export type EqualityChecker<T> = (state: T, newState: T) => boolean; | ||
/** | ||
* @deprecated Use `(state: T, previousState: T) => void` instead of `StateListener<T>` | ||
*/ | ||
export declare type StateListener<T> = (state: T, previousState: T) => void; | ||
export type StateListener<T> = (state: T, previousState: T) => void; | ||
/** | ||
* @deprecated Use `(slice: T, previousSlice: T) => void` instead of `StateSliceListener<T>`. | ||
*/ | ||
export declare type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
export type StateSliceListener<T> = (slice: T, previousSlice: T) => void; | ||
/** | ||
* @deprecated Use `(listener: (state: T) => void) => void` instead of `Subscribe<T>`. | ||
*/ | ||
export declare type Subscribe<T extends State> = { | ||
export type Subscribe<T extends State> = { | ||
(listener: (state: T, previousState: T) => void): () => void; | ||
@@ -63,3 +63,3 @@ }; | ||
*/ | ||
export declare type SetState<T extends State> = { | ||
export type SetState<T extends State> = { | ||
_(partial: T | Partial<T> | { | ||
@@ -73,6 +73,6 @@ _(state: T): T | Partial<T>; | ||
*/ | ||
export declare type GetState<T extends State> = () => T; | ||
export type GetState<T extends State> = () => T; | ||
/** | ||
* @deprecated Use `StoreApi<T>['destroy']` instead of `Destroy`. | ||
*/ | ||
export declare type Destroy = () => void; | ||
export type Destroy = () => void; |
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
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
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
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
209717
4614