Comparing version 4.1.0 to 4.1.1
@@ -1,3 +0,3 @@ | ||
import { ReactNode } from 'react'; | ||
import { StoreApi } from 'zustand'; | ||
import type { ReactNode } from 'react'; | ||
import type { StoreApi } from 'zustand'; | ||
declare type UseContextStore<S extends StoreApi<unknown>> = { | ||
@@ -4,0 +4,0 @@ (): ExtractState<S>; |
@@ -1,3 +0,3 @@ | ||
import { ReactNode } from 'react'; | ||
import { StoreApi } from 'zustand'; | ||
import type { ReactNode } from 'react'; | ||
import type { StoreApi } from 'zustand'; | ||
declare type UseContextStore<S extends StoreApi<unknown>> = { | ||
@@ -4,0 +4,0 @@ (): ExtractState<S>; |
@@ -1,9 +0,4 @@ | ||
const isObjectWithTypeProperty$1 = (x) => x !== null && typeof x === "object" && "type" in x; | ||
const reduxImpl = (reducer, initial) => (set, _get, api) => { | ||
api.dispatch = (action) => { | ||
set( | ||
(state) => reducer(state, action), | ||
false, | ||
isObjectWithTypeProperty$1(action) ? action : { type: action } | ||
); | ||
set((state) => reducer(state, action), false, action); | ||
return action; | ||
@@ -16,3 +11,2 @@ }; | ||
const isObjectWithTypeProperty = (x) => x !== null && typeof x === "object" && "type" in x; | ||
const devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => { | ||
@@ -40,3 +34,3 @@ const { enabled, anonymousActionType, ...options } = devtoolsOptions; | ||
extension.send( | ||
nameOrAction === void 0 ? { type: anonymousActionType || "anonymous" } : isObjectWithTypeProperty(nameOrAction) ? nameOrAction : { type: nameOrAction }, | ||
nameOrAction === void 0 ? { type: anonymousActionType || "anonymous" } : typeof nameOrAction === "string" ? { type: nameOrAction } : nameOrAction, | ||
get() | ||
@@ -43,0 +37,0 @@ ); |
@@ -1,2 +0,2 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
@@ -3,0 +3,0 @@ 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>; |
@@ -1,3 +0,62 @@ | ||
import type { Config } from '@redux-devtools/extension'; | ||
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
name?: string; | ||
actionCreators?: ActionCreator<any>[] | { | ||
[key: string]: ActionCreator<any>; | ||
}; | ||
latency?: number; | ||
maxAge?: number; | ||
serialize?: boolean | { | ||
options?: undefined | boolean | { | ||
date?: true; | ||
regex?: true; | ||
undefined?: true; | ||
error?: true; | ||
symbol?: true; | ||
map?: true; | ||
set?: true; | ||
function?: true | ((fn: (...args: any[]) => any) => string); | ||
}; | ||
replacer?: (key: string, value: unknown) => any; | ||
reviver?: (key: string, value: unknown) => any; | ||
immutable?: any; | ||
refs?: any; | ||
}; | ||
actionSanitizer?: <A extends Action>(action: A, id: number) => A; | ||
stateSanitizer?: <S>(state: S, index: number) => S; | ||
actionsBlacklist?: string | string[]; | ||
actionsWhitelist?: string | string[]; | ||
actionsDenylist?: string | string[]; | ||
actionsAllowlist?: string | string[]; | ||
predicate?: <S, A extends Action>(state: S, action: A) => boolean; | ||
shouldRecordChanges?: boolean; | ||
pauseActionType?: string; | ||
autoPause?: boolean; | ||
shouldStartLocked?: boolean; | ||
shouldHotReload?: boolean; | ||
shouldCatchErrors?: boolean; | ||
features?: { | ||
pause?: boolean; | ||
lock?: boolean; | ||
persist?: boolean; | ||
export?: boolean | 'custom'; | ||
import?: boolean | 'custom'; | ||
jump?: boolean; | ||
skip?: boolean; | ||
reorder?: boolean; | ||
dispatch?: boolean; | ||
test?: boolean; | ||
}; | ||
trace?: boolean | (<A extends Action>(action: A) => string); | ||
traceLimit?: number; | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type?: string; | ||
}; | ||
declare module '../vanilla' { | ||
@@ -4,0 +63,0 @@ interface StoreMutators<S, A> { |
@@ -1,3 +0,3 @@ | ||
import { Draft } from 'immer'; | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
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]>; | ||
@@ -4,0 +4,0 @@ declare module '../vanilla' { |
@@ -1,2 +0,2 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
export interface StateStorage { | ||
@@ -3,0 +3,0 @@ getItem: (name: string) => string | null | Promise<string | null>; |
@@ -1,5 +0,5 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
declare type Action = { | ||
type: unknown; | ||
}; | ||
@@ -10,4 +10,7 @@ declare type StoreRedux<A> = { | ||
}; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A, Cms extends [StoreMutatorIdentifier, unknown][] = []>(reducer: (state: T, action: A) => T, initialState: T) => StateCreator<Write<T, ReduxState<A>>, Cms, [['zustand/redux', 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]]>; | ||
declare module '../vanilla' { | ||
@@ -14,0 +17,0 @@ interface StoreMutators<S, A> { |
@@ -1,2 +0,2 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type SubscribeWithSelector = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [ | ||
@@ -3,0 +3,0 @@ ...Mps, |
@@ -1,2 +0,2 @@ | ||
import { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
import type { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
declare type ExtractState<S> = S extends { | ||
@@ -3,0 +3,0 @@ getState: () => infer T; |
@@ -37,6 +37,2 @@ 'use strict'; | ||
var isObjectWithTypeProperty$1 = function isObjectWithTypeProperty(x) { | ||
return x !== null && typeof x === 'object' && 'type' in x; | ||
}; | ||
var reduxImpl = function reduxImpl(reducer, initial) { | ||
@@ -47,5 +43,3 @@ return function (set, _get, api) { | ||
return reducer(state, action); | ||
}, false, isObjectWithTypeProperty$1(action) ? action : { | ||
type: action | ||
}); | ||
}, false, action); | ||
return action; | ||
@@ -69,6 +63,2 @@ }; | ||
var isObjectWithTypeProperty = function isObjectWithTypeProperty(x) { | ||
return x !== null && typeof x === 'object' && 'type' in x; | ||
}; | ||
var devtoolsImpl = function devtoolsImpl(fn, devtoolsOptions) { | ||
@@ -107,5 +97,5 @@ if (devtoolsOptions === void 0) { | ||
type: anonymousActionType || 'anonymous' | ||
} : isObjectWithTypeProperty(nameOrAction) ? nameOrAction : { | ||
} : typeof nameOrAction === 'string' ? { | ||
type: nameOrAction | ||
}, get()); | ||
} : nameOrAction, get()); | ||
return r; | ||
@@ -112,0 +102,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
@@ -3,0 +3,0 @@ 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>; |
@@ -1,3 +0,62 @@ | ||
import type { Config } from '@redux-devtools/extension'; | ||
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
name?: string; | ||
actionCreators?: ActionCreator<any>[] | { | ||
[key: string]: ActionCreator<any>; | ||
}; | ||
latency?: number; | ||
maxAge?: number; | ||
serialize?: boolean | { | ||
options?: undefined | boolean | { | ||
date?: true; | ||
regex?: true; | ||
undefined?: true; | ||
error?: true; | ||
symbol?: true; | ||
map?: true; | ||
set?: true; | ||
function?: true | ((fn: (...args: any[]) => any) => string); | ||
}; | ||
replacer?: (key: string, value: unknown) => any; | ||
reviver?: (key: string, value: unknown) => any; | ||
immutable?: any; | ||
refs?: any; | ||
}; | ||
actionSanitizer?: <A extends Action>(action: A, id: number) => A; | ||
stateSanitizer?: <S>(state: S, index: number) => S; | ||
actionsBlacklist?: string | string[]; | ||
actionsWhitelist?: string | string[]; | ||
actionsDenylist?: string | string[]; | ||
actionsAllowlist?: string | string[]; | ||
predicate?: <S, A extends Action>(state: S, action: A) => boolean; | ||
shouldRecordChanges?: boolean; | ||
pauseActionType?: string; | ||
autoPause?: boolean; | ||
shouldStartLocked?: boolean; | ||
shouldHotReload?: boolean; | ||
shouldCatchErrors?: boolean; | ||
features?: { | ||
pause?: boolean; | ||
lock?: boolean; | ||
persist?: boolean; | ||
export?: boolean | 'custom'; | ||
import?: boolean | 'custom'; | ||
jump?: boolean; | ||
skip?: boolean; | ||
reorder?: boolean; | ||
dispatch?: boolean; | ||
test?: boolean; | ||
}; | ||
trace?: boolean | (<A extends Action>(action: A) => string); | ||
traceLimit?: number; | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type?: string; | ||
}; | ||
declare module '../vanilla' { | ||
@@ -4,0 +63,0 @@ interface StoreMutators<S, A> { |
@@ -1,3 +0,3 @@ | ||
import { Draft } from 'immer'; | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
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]>; | ||
@@ -4,0 +4,0 @@ declare module '../vanilla' { |
@@ -1,2 +0,2 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
export interface StateStorage { | ||
@@ -3,0 +3,0 @@ getItem: (name: string) => string | null | Promise<string | null>; |
@@ -1,5 +0,5 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Omit<T, keyof U> & U; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
declare type Action = { | ||
type: unknown; | ||
}; | ||
@@ -10,4 +10,7 @@ declare type StoreRedux<A> = { | ||
}; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A, Cms extends [StoreMutatorIdentifier, unknown][] = []>(reducer: (state: T, action: A) => T, initialState: T) => StateCreator<Write<T, ReduxState<A>>, Cms, [['zustand/redux', 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]]>; | ||
declare module '../vanilla' { | ||
@@ -14,0 +17,0 @@ interface StoreMutators<S, A> { |
@@ -1,2 +0,2 @@ | ||
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type SubscribeWithSelector = <T, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [ | ||
@@ -3,0 +3,0 @@ ...Mps, |
{ | ||
"name": "zustand", | ||
"private": false, | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "🐻 Bear necessities for state management in React", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
@@ -1,2 +0,2 @@ | ||
import { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
import type { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
declare type ExtractState<S> = S extends { | ||
@@ -3,0 +3,0 @@ getState: () => infer T; |
@@ -6,10 +6,5 @@ System.register([], (function (exports) { | ||
const isObjectWithTypeProperty$1 = (x) => x !== null && typeof x === "object" && "type" in x; | ||
const reduxImpl = (reducer, initial) => (set, _get, api) => { | ||
api.dispatch = (action) => { | ||
set( | ||
(state) => reducer(state, action), | ||
false, | ||
isObjectWithTypeProperty$1(action) ? action : { type: action } | ||
); | ||
set((state) => reducer(state, action), false, action); | ||
return action; | ||
@@ -22,3 +17,2 @@ }; | ||
const isObjectWithTypeProperty = (x) => x !== null && typeof x === "object" && "type" in x; | ||
const devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => { | ||
@@ -46,3 +40,3 @@ const { enabled, anonymousActionType, ...options } = devtoolsOptions; | ||
extension.send( | ||
nameOrAction === void 0 ? { type: anonymousActionType || "anonymous" } : isObjectWithTypeProperty(nameOrAction) ? nameOrAction : { type: nameOrAction }, | ||
nameOrAction === void 0 ? { type: anonymousActionType || "anonymous" } : typeof nameOrAction === "string" ? { type: nameOrAction } : nameOrAction, | ||
get() | ||
@@ -49,0 +43,0 @@ ); |
@@ -1,1 +0,1 @@ | ||
System.register([],function(b){"use strict";return{execute:function(){const w=s=>s!==null&&typeof s=="object"&&"type"in s,I=b("redux",(s,p)=>(o,r,n)=>(n.dispatch=t=>(o(y=>s(y,t),!1,w(t)?t:{type:t}),t),n.dispatchFromDevtools=!0,{dispatch:(...t)=>n.dispatch(...t),...p})),_=s=>s!==null&&typeof s=="object"&&"type"in s,A=b("devtools",(s,p={})=>(o,r,n)=>{const{enabled:t,anonymousActionType:y,...m}=p;let v;try{v=(t!=null?t:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!v)return s(o,r,n);const i=v.connect(m);let u=!0;n.setState=(c,d,l)=>{const e=o(c,d);return u&&i.send(l===void 0?{type:y||"anonymous"}:_(l)?l:{type:l},r()),e};const f=(...c)=>{const d=u;u=!1,o(...c),u=d},S=s(n.setState,r,n);if(i.init(S),n.dispatchFromDevtools&&typeof n.dispatch=="function"){const c=n.dispatch;n.dispatch=(...d)=>{c(...d)}}return i.subscribe(c=>{var d;switch(c.type){case"ACTION":if(typeof c.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return T(c.payload,l=>{if(l.type==="__setState"){f(l.state);return}!n.dispatchFromDevtools||typeof n.dispatch=="function"&&n.dispatch(l)});case"DISPATCH":switch(c.payload.type){case"RESET":return f(S),i.init(n.getState());case"COMMIT":return i.init(n.getState());case"ROLLBACK":return T(c.state,l=>{f(l),i.init(n.getState())});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return T(c.state,l=>{f(l)});case"IMPORT_STATE":{const{nextLiftedState:l}=c.payload,e=(d=l.computedStates.slice(-1)[0])==null?void 0:d.state;if(!e)return;f(e),i.send(null,l);return}case"PAUSE_RECORDING":return u=!u}return}}),S}),T=(s,p)=>{let o;try{o=JSON.parse(s)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}o!==void 0&&p(o)},C=b("subscribeWithSelector",s=>(p,o,r)=>{const n=r.subscribe;return r.subscribe=(t,y,m)=>{let v=t;if(y){const i=(m==null?void 0:m.equalityFn)||Object.is;let u=t(r.getState());v=f=>{const S=t(f);if(!i(u,S)){const c=u;y(u=S,c)}},m!=null&&m.fireImmediately&&y(u,u)}return n(v)},s(p,o,r)}),D=b("combine",(s,p)=>(...o)=>Object.assign({},s,p(...o))),O=s=>p=>{try{const o=s(p);return o instanceof Promise?o:{then(r){return O(r)(o)},catch(r){return this}}}catch(o){return{then(r){return this},catch(r){return O(r)(o)}}}},R=b("persist",(s,p)=>(o,r,n)=>{let t={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:e=>e,version:0,merge:(e,h)=>({...h,...e}),...p},y=!1;const m=new Set,v=new Set;let i;try{i=t.getStorage()}catch{}if(!i)return s((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${t.name}', the given storage is currently unavailable.`),o(...e)},r,n);const u=O(t.serialize),f=()=>{const e=t.partialize({...r()});let h;const a=u({state:e,version:t.version}).then(g=>i.setItem(t.name,g)).catch(g=>{h=g});if(h)throw h;return a},S=n.setState;n.setState=(e,h)=>{S(e,h),f()};const c=s((...e)=>{o(...e),f()},r,n);let d;const l=()=>{var e;if(!i)return;y=!1,m.forEach(a=>a(r()));const h=((e=t.onRehydrateStorage)==null?void 0:e.call(t,r()))||void 0;return O(i.getItem.bind(i))(t.name).then(a=>{if(a)return t.deserialize(a)}).then(a=>{if(a)if(typeof a.version=="number"&&a.version!==t.version){if(t.migrate)return t.migrate(a.state,a.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return a.state}).then(a=>{var g;return d=t.merge(a,(g=r())!=null?g:c),o(d,!0),f()}).then(()=>{h==null||h(d,void 0),y=!0,v.forEach(a=>a(d))}).catch(a=>{h==null||h(void 0,a)})};return n.persist={setOptions:e=>{t={...t,...e},e.getStorage&&(i=e.getStorage())},clearStorage:()=>{i==null||i.removeItem(t.name)},getOptions:()=>t,rehydrate:()=>l(),hasHydrated:()=>y,onHydrate:e=>(m.add(e),()=>{m.delete(e)}),onFinishHydration:e=>(v.add(e),()=>{v.delete(e)})},l(),d||c})}}}); | ||
System.register([],function(b){"use strict";return{execute:function(){const w=b("redux",(l,h)=>(s,n,r)=>(r.dispatch=t=>(s(y=>l(y,t),!1,t),t),r.dispatchFromDevtools=!0,{dispatch:(...t)=>r.dispatch(...t),...h})),I=b("devtools",(l,h={})=>(s,n,r)=>{const{enabled:t,anonymousActionType:y,...m}=h;let v;try{v=(t!=null?t:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!v)return l(s,n,r);const o=v.connect(m);let d=!0;r.setState=(i,u,c)=>{const e=s(i,u);return d&&o.send(c===void 0?{type:y||"anonymous"}:typeof c=="string"?{type:c}:c,n()),e};const f=(...i)=>{const u=d;d=!1,s(...i),d=u},g=l(r.setState,n,r);if(o.init(g),r.dispatchFromDevtools&&typeof r.dispatch=="function"){const i=r.dispatch;r.dispatch=(...u)=>{i(...u)}}return o.subscribe(i=>{var u;switch(i.type){case"ACTION":if(typeof i.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return T(i.payload,c=>{if(c.type==="__setState"){f(c.state);return}!r.dispatchFromDevtools||typeof r.dispatch=="function"&&r.dispatch(c)});case"DISPATCH":switch(i.payload.type){case"RESET":return f(g),o.init(r.getState());case"COMMIT":return o.init(r.getState());case"ROLLBACK":return T(i.state,c=>{f(c),o.init(r.getState())});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return T(i.state,c=>{f(c)});case"IMPORT_STATE":{const{nextLiftedState:c}=i.payload,e=(u=c.computedStates.slice(-1)[0])==null?void 0:u.state;if(!e)return;f(e),o.send(null,c);return}case"PAUSE_RECORDING":return d=!d}return}}),g}),T=(l,h)=>{let s;try{s=JSON.parse(l)}catch(n){console.error("[zustand devtools middleware] Could not parse the received json",n)}s!==void 0&&h(s)},A=b("subscribeWithSelector",l=>(h,s,n)=>{const r=n.subscribe;return n.subscribe=(t,y,m)=>{let v=t;if(y){const o=(m==null?void 0:m.equalityFn)||Object.is;let d=t(n.getState());v=f=>{const g=t(f);if(!o(d,g)){const i=d;y(d=g,i)}},m!=null&&m.fireImmediately&&y(d,d)}return r(v)},l(h,s,n)}),N=b("combine",(l,h)=>(...s)=>Object.assign({},l,h(...s))),O=l=>h=>{try{const s=l(h);return s instanceof Promise?s:{then(n){return O(n)(s)},catch(n){return this}}}catch(s){return{then(n){return this},catch(n){return O(n)(s)}}}},D=b("persist",(l,h)=>(s,n,r)=>{let t={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:e=>e,version:0,merge:(e,p)=>({...p,...e}),...h},y=!1;const m=new Set,v=new Set;let o;try{o=t.getStorage()}catch{}if(!o)return l((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${t.name}', the given storage is currently unavailable.`),s(...e)},n,r);const d=O(t.serialize),f=()=>{const e=t.partialize({...n()});let p;const a=d({state:e,version:t.version}).then(S=>o.setItem(t.name,S)).catch(S=>{p=S});if(p)throw p;return a},g=r.setState;r.setState=(e,p)=>{g(e,p),f()};const i=l((...e)=>{s(...e),f()},n,r);let u;const c=()=>{var e;if(!o)return;y=!1,m.forEach(a=>a(n()));const p=((e=t.onRehydrateStorage)==null?void 0:e.call(t,n()))||void 0;return O(o.getItem.bind(o))(t.name).then(a=>{if(a)return t.deserialize(a)}).then(a=>{if(a)if(typeof a.version=="number"&&a.version!==t.version){if(t.migrate)return t.migrate(a.state,a.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return a.state}).then(a=>{var S;return u=t.merge(a,(S=n())!=null?S:i),s(u,!0),f()}).then(()=>{p==null||p(u,void 0),y=!0,v.forEach(a=>a(u))}).catch(a=>{p==null||p(void 0,a)})};return r.persist={setOptions:e=>{t={...t,...e},e.getStorage&&(o=e.getStorage())},clearStorage:()=>{o==null||o.removeItem(t.name)},getOptions:()=>t,rehydrate:()=>c(),hasHydrated:()=>y,onHydrate:e=>(m.add(e),()=>{m.delete(e)}),onFinishHydration:e=>(v.add(e),()=>{v.delete(e)})},c(),u||i})}}}); |
@@ -1,3 +0,62 @@ | ||
import { Config } from '@redux-devtools/extension'; | ||
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
name?: string; | ||
actionCreators?: ActionCreator<any>[] | { | ||
[key: string]: ActionCreator<any>; | ||
}; | ||
latency?: number; | ||
maxAge?: number; | ||
serialize?: boolean | { | ||
options?: undefined | boolean | { | ||
date?: true; | ||
regex?: true; | ||
undefined?: true; | ||
error?: true; | ||
symbol?: true; | ||
map?: true; | ||
set?: true; | ||
function?: true | ((fn: (...args: any[]) => any) => string); | ||
}; | ||
replacer?: (key: string, value: unknown) => any; | ||
reviver?: (key: string, value: unknown) => any; | ||
immutable?: any; | ||
refs?: any; | ||
}; | ||
actionSanitizer?: <A extends Action>(action: A, id: number) => A; | ||
stateSanitizer?: <S>(state: S, index: number) => S; | ||
actionsBlacklist?: string | string[]; | ||
actionsWhitelist?: string | string[]; | ||
actionsDenylist?: string | string[]; | ||
actionsAllowlist?: string | string[]; | ||
predicate?: <S, A extends Action>(state: S, action: A) => boolean; | ||
shouldRecordChanges?: boolean; | ||
pauseActionType?: string; | ||
autoPause?: boolean; | ||
shouldStartLocked?: boolean; | ||
shouldHotReload?: boolean; | ||
shouldCatchErrors?: boolean; | ||
features?: { | ||
pause?: boolean; | ||
lock?: boolean; | ||
persist?: boolean; | ||
export?: boolean | 'custom'; | ||
import?: boolean | 'custom'; | ||
jump?: boolean; | ||
skip?: boolean; | ||
reorder?: boolean; | ||
dispatch?: boolean; | ||
test?: boolean; | ||
}; | ||
trace?: boolean | (<A extends Action>(action: A) => string); | ||
traceLimit?: number; | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type?: string; | ||
}; | ||
declare module '../vanilla' { | ||
@@ -4,0 +63,0 @@ interface StoreMutators<S, A> { |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
declare type Action = { | ||
type: unknown; | ||
}; | ||
@@ -10,4 +10,7 @@ declare type StoreRedux<A> = { | ||
}; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A, Cms extends [ | ||
declare type Redux = <T, A extends Action, Cms extends [ | ||
StoreMutatorIdentifier, | ||
@@ -14,0 +17,0 @@ unknown |
@@ -1,3 +0,62 @@ | ||
import { Config } from '@redux-devtools/extension'; | ||
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Action<T = any> = { | ||
type: T; | ||
}; | ||
declare type ActionCreator<A, P extends any[] = any[]> = { | ||
(...args: P): A; | ||
}; | ||
declare type EnhancerOptions = { | ||
name?: string; | ||
actionCreators?: ActionCreator<any>[] | { | ||
[key: string]: ActionCreator<any>; | ||
}; | ||
latency?: number; | ||
maxAge?: number; | ||
serialize?: boolean | { | ||
options?: undefined | boolean | { | ||
date?: true; | ||
regex?: true; | ||
undefined?: true; | ||
error?: true; | ||
symbol?: true; | ||
map?: true; | ||
set?: true; | ||
function?: true | ((fn: (...args: any[]) => any) => string); | ||
}; | ||
replacer?: (key: string, value: unknown) => any; | ||
reviver?: (key: string, value: unknown) => any; | ||
immutable?: any; | ||
refs?: any; | ||
}; | ||
actionSanitizer?: <A extends Action>(action: A, id: number) => A; | ||
stateSanitizer?: <S>(state: S, index: number) => S; | ||
actionsBlacklist?: string | string[]; | ||
actionsWhitelist?: string | string[]; | ||
actionsDenylist?: string | string[]; | ||
actionsAllowlist?: string | string[]; | ||
predicate?: <S, A extends Action>(state: S, action: A) => boolean; | ||
shouldRecordChanges?: boolean; | ||
pauseActionType?: string; | ||
autoPause?: boolean; | ||
shouldStartLocked?: boolean; | ||
shouldHotReload?: boolean; | ||
shouldCatchErrors?: boolean; | ||
features?: { | ||
pause?: boolean; | ||
lock?: boolean; | ||
persist?: boolean; | ||
export?: boolean | 'custom'; | ||
import?: boolean | 'custom'; | ||
jump?: boolean; | ||
skip?: boolean; | ||
reorder?: boolean; | ||
dispatch?: boolean; | ||
test?: boolean; | ||
}; | ||
trace?: boolean | (<A extends Action>(action: A) => string); | ||
traceLimit?: number; | ||
}; | ||
declare type Config = EnhancerOptions & { | ||
type?: string; | ||
}; | ||
declare module '../vanilla' { | ||
@@ -4,0 +63,0 @@ interface StoreMutators<S, A> { |
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'; | ||
declare type Write<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
declare type Action = { | ||
type: unknown; | ||
}; | ||
@@ -10,4 +10,7 @@ declare type StoreRedux<A> = { | ||
}; | ||
declare type ReduxState<A> = { | ||
dispatch: StoreRedux<A>['dispatch']; | ||
}; | ||
declare type WithRedux<S, A> = Write<S, StoreRedux<A>>; | ||
declare type Redux = <T, A, Cms extends [ | ||
declare type Redux = <T, A extends Action, Cms extends [ | ||
StoreMutatorIdentifier, | ||
@@ -14,0 +17,0 @@ unknown |
@@ -39,6 +39,2 @@ (function (global, factory) { | ||
var isObjectWithTypeProperty$1 = function isObjectWithTypeProperty(x) { | ||
return x !== null && typeof x === 'object' && 'type' in x; | ||
}; | ||
var reduxImpl = function reduxImpl(reducer, initial) { | ||
@@ -49,5 +45,3 @@ return function (set, _get, api) { | ||
return reducer(state, action); | ||
}, false, isObjectWithTypeProperty$1(action) ? action : { | ||
type: action | ||
}); | ||
}, false, action); | ||
return action; | ||
@@ -71,6 +65,2 @@ }; | ||
var isObjectWithTypeProperty = function isObjectWithTypeProperty(x) { | ||
return x !== null && typeof x === 'object' && 'type' in x; | ||
}; | ||
var devtoolsImpl = function devtoolsImpl(fn, devtoolsOptions) { | ||
@@ -109,5 +99,5 @@ if (devtoolsOptions === void 0) { | ||
type: anonymousActionType || 'anonymous' | ||
} : isObjectWithTypeProperty(nameOrAction) ? nameOrAction : { | ||
} : typeof nameOrAction === 'string' ? { | ||
type: nameOrAction | ||
}, get()); | ||
} : nameOrAction, get()); | ||
return r; | ||
@@ -114,0 +104,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).zustandMiddleware={})}(this,(function(t){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e.apply(this,arguments)}var n=function(t,n){return function(r,i,o){return o.dispatch=function(e){var n;return r((function(n){return t(n,e)}),!1,null!==(n=e)&&"object"==typeof n&&"type"in n?e:{type:e}),e},o.dispatchFromDevtools=!0,e({dispatch:function(){var t;return(t=o).dispatch.apply(t,arguments)}},n)}},r=["enabled","anonymousActionType"],i=function(t,e){return void 0===e&&(e={}),function(n,i,a){var u,c=e,s=c.enabled,f=c.anonymousActionType,d=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(c,r);try{u=null!=s&&s&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(!u)return t(n,i,a);var l=u.connect(d),p=!0;a.setState=function(t,e,r){var o,a=n(t,e);return p?(l.send(void 0===r?{type:f||"anonymous"}:null!==(o=r)&&"object"==typeof o&&"type"in o?r:{type:r},i()),a):a};var v=function(){var t=p;p=!1,n.apply(void 0,arguments),p=t},y=t(a.setState,i,a);if(l.init(y),a.dispatchFromDevtools&&"function"==typeof a.dispatch){var h=a.dispatch;a.dispatch=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];h.apply(void 0,e)}}return l.subscribe((function(t){switch(t.type){case"ACTION":return"string"!=typeof t.payload?void console.error("[zustand devtools middleware] Unsupported action format"):o(t.payload,(function(t){"__setState"!==t.type?a.dispatchFromDevtools&&"function"==typeof a.dispatch&&a.dispatch(t):v(t.state)}));case"DISPATCH":switch(t.payload.type){case"RESET":return v(y),l.init(a.getState());case"COMMIT":return l.init(a.getState());case"ROLLBACK":return o(t.state,(function(t){v(t),l.init(a.getState())}));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return o(t.state,(function(t){v(t)}));case"IMPORT_STATE":var e,n=t.payload.nextLiftedState,r=null==(e=n.computedStates.slice(-1)[0])?void 0:e.state;if(!r)return;return v(r),void l.send(null,n);case"PAUSE_RECORDING":return p=!p}return}})),y}},o=function(t,e){var n;try{n=JSON.parse(t)}catch(t){console.error("[zustand devtools middleware] Could not parse the received json",t)}void 0!==n&&e(n)},a=function(t){return function(e,n,r){var i=r.subscribe;return r.subscribe=function(t,e,n){var o=t;if(e){var a=(null==n?void 0:n.equalityFn)||Object.is,u=t(r.getState());o=function(n){var r=t(n);if(!a(u,r)){var i=u;e(u=r,i)}},null!=n&&n.fireImmediately&&e(u,u)}return i(o)},t(e,n,r)}},u=function t(e){return function(n){try{var r=e(n);return r instanceof Promise?r:{then:function(e){return t(e)(r)},catch:function(t){return this}}}catch(e){return{then:function(t){return this},catch:function(n){return t(n)(e)}}}}},c=function(t,n){return function(r,i,o){var a,c=e({getStorage:function(){return localStorage},serialize:JSON.stringify,deserialize:JSON.parse,partialize:function(t){return t},version:0,merge:function(t,n){return e({},n,t)}},n),s=!1,f=new Set,d=new Set;try{a=c.getStorage()}catch(t){}if(!a)return t((function(){console.warn("[zustand persist middleware] Unable to update item '"+c.name+"', the given storage is currently unavailable."),r.apply(void 0,arguments)}),i,o);var l=u(c.serialize),p=function(){var t,n=c.partialize(e({},i())),r=l({state:n,version:c.version}).then((function(t){return a.setItem(c.name,t)})).catch((function(e){t=e}));if(t)throw t;return r},v=o.setState;o.setState=function(t,e){v(t,e),p()};var y,h=t((function(){r.apply(void 0,arguments),p()}),i,o),g=function(){if(a){s=!1,f.forEach((function(t){return t(i())}));var t=(null==c.onRehydrateStorage?void 0:c.onRehydrateStorage(i()))||void 0;return u(a.getItem.bind(a))(c.name).then((function(t){if(t)return c.deserialize(t)})).then((function(t){if(t){if("number"!=typeof t.version||t.version===c.version)return t.state;if(c.migrate)return c.migrate(t.state,t.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}})).then((function(t){var e;return y=c.merge(t,null!=(e=i())?e:h),r(y,!0),p()})).then((function(){null==t||t(y,void 0),s=!0,d.forEach((function(t){return t(y)}))})).catch((function(e){null==t||t(void 0,e)}))}};return o.persist={setOptions:function(t){c=e({},c,t),t.getStorage&&(a=t.getStorage())},clearStorage:function(){var t;null==(t=a)||t.removeItem(c.name)},getOptions:function(){return c},rehydrate:function(){return g()},hasHydrated:function(){return s},onHydrate:function(t){return f.add(t),function(){f.delete(t)}},onFinishHydration:function(t){return d.add(t),function(){d.delete(t)}}},g(),y||h}};t.combine=function(t,e){return function(){return Object.assign({},t,e.apply(void 0,arguments))}},t.devtools=i,t.persist=c,t.redux=n,t.subscribeWithSelector=a,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).zustandMiddleware={})}(this,(function(t){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e.apply(this,arguments)}var n=function(t,n){return function(r,i,o){return o.dispatch=function(e){return r((function(n){return t(n,e)}),!1,e),e},o.dispatchFromDevtools=!0,e({dispatch:function(){var t;return(t=o).dispatch.apply(t,arguments)}},n)}},r=["enabled","anonymousActionType"],i=function(t,e){return void 0===e&&(e={}),function(n,i,a){var u,c=e,s=c.enabled,f=c.anonymousActionType,d=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(c,r);try{u=null!=s&&s&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(!u)return t(n,i,a);var l=u.connect(d),p=!0;a.setState=function(t,e,r){var o=n(t,e);return p?(l.send(void 0===r?{type:f||"anonymous"}:"string"==typeof r?{type:r}:r,i()),o):o};var v=function(){var t=p;p=!1,n.apply(void 0,arguments),p=t},h=t(a.setState,i,a);if(l.init(h),a.dispatchFromDevtools&&"function"==typeof a.dispatch){var y=a.dispatch;a.dispatch=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];y.apply(void 0,e)}}return l.subscribe((function(t){switch(t.type){case"ACTION":return"string"!=typeof t.payload?void console.error("[zustand devtools middleware] Unsupported action format"):o(t.payload,(function(t){"__setState"!==t.type?a.dispatchFromDevtools&&"function"==typeof a.dispatch&&a.dispatch(t):v(t.state)}));case"DISPATCH":switch(t.payload.type){case"RESET":return v(h),l.init(a.getState());case"COMMIT":return l.init(a.getState());case"ROLLBACK":return o(t.state,(function(t){v(t),l.init(a.getState())}));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return o(t.state,(function(t){v(t)}));case"IMPORT_STATE":var e,n=t.payload.nextLiftedState,r=null==(e=n.computedStates.slice(-1)[0])?void 0:e.state;if(!r)return;return v(r),void l.send(null,n);case"PAUSE_RECORDING":return p=!p}return}})),h}},o=function(t,e){var n;try{n=JSON.parse(t)}catch(t){console.error("[zustand devtools middleware] Could not parse the received json",t)}void 0!==n&&e(n)},a=function(t){return function(e,n,r){var i=r.subscribe;return r.subscribe=function(t,e,n){var o=t;if(e){var a=(null==n?void 0:n.equalityFn)||Object.is,u=t(r.getState());o=function(n){var r=t(n);if(!a(u,r)){var i=u;e(u=r,i)}},null!=n&&n.fireImmediately&&e(u,u)}return i(o)},t(e,n,r)}},u=function t(e){return function(n){try{var r=e(n);return r instanceof Promise?r:{then:function(e){return t(e)(r)},catch:function(t){return this}}}catch(e){return{then:function(t){return this},catch:function(n){return t(n)(e)}}}}},c=function(t,n){return function(r,i,o){var a,c=e({getStorage:function(){return localStorage},serialize:JSON.stringify,deserialize:JSON.parse,partialize:function(t){return t},version:0,merge:function(t,n){return e({},n,t)}},n),s=!1,f=new Set,d=new Set;try{a=c.getStorage()}catch(t){}if(!a)return t((function(){console.warn("[zustand persist middleware] Unable to update item '"+c.name+"', the given storage is currently unavailable."),r.apply(void 0,arguments)}),i,o);var l=u(c.serialize),p=function(){var t,n=c.partialize(e({},i())),r=l({state:n,version:c.version}).then((function(t){return a.setItem(c.name,t)})).catch((function(e){t=e}));if(t)throw t;return r},v=o.setState;o.setState=function(t,e){v(t,e),p()};var h,y=t((function(){r.apply(void 0,arguments),p()}),i,o),g=function(){if(a){s=!1,f.forEach((function(t){return t(i())}));var t=(null==c.onRehydrateStorage?void 0:c.onRehydrateStorage(i()))||void 0;return u(a.getItem.bind(a))(c.name).then((function(t){if(t)return c.deserialize(t)})).then((function(t){if(t){if("number"!=typeof t.version||t.version===c.version)return t.state;if(c.migrate)return c.migrate(t.state,t.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}})).then((function(t){var e;return h=c.merge(t,null!=(e=i())?e:y),r(h,!0),p()})).then((function(){null==t||t(h,void 0),s=!0,d.forEach((function(t){return t(h)}))})).catch((function(e){null==t||t(void 0,e)}))}};return o.persist={setOptions:function(t){c=e({},c,t),t.getStorage&&(a=t.getStorage())},clearStorage:function(){var t;null==(t=a)||t.removeItem(c.name)},getOptions:function(){return c},rehydrate:function(){return g()},hasHydrated:function(){return s},onHydrate:function(t){return f.add(t),function(){f.delete(t)}},onFinishHydration:function(t){return d.add(t),function(){d.delete(t)}}},g(),h||y}};t.combine=function(t,e){return function(){return Object.assign({},t,e.apply(void 0,arguments))}},t.devtools=i,t.persist=c,t.redux=n,t.subscribeWithSelector=a,Object.defineProperty(t,"__esModule",{value:!0})})); |
Sorry, the diff of this file is not supported yet
189413
4449