Comparing version 4.2.0 to 4.3.0
@@ -13,2 +13,5 @@ import type { ReactNode } from 'react'; | ||
}; | ||
/** | ||
* @deprecated Use `createStore` and `useStore` for context usage | ||
*/ | ||
declare function createContext<S extends StoreApi<unknown>>(): { | ||
@@ -15,0 +18,0 @@ Provider: ({ createStore, children, }: { |
@@ -22,2 +22,5 @@ 'use strict'; | ||
function createContext() { | ||
if (process.env.NODE_ENV !== "production") { | ||
console.warn('[DEPRECATED] zustand/context will be removed in the future version. Please use `import { createStore, useStore } from "zustand"` for context usage. See: https://github.com/pmndrs/zustand/discussions/1180'); | ||
} | ||
var ZustandContext = react.createContext(undefined); | ||
@@ -24,0 +27,0 @@ var Provider = function Provider(_ref) { |
@@ -13,2 +13,5 @@ import type { ReactNode } from 'react'; | ||
}; | ||
/** | ||
* @deprecated Use `createStore` and `useStore` for context usage | ||
*/ | ||
declare function createContext<S extends StoreApi<unknown>>(): { | ||
@@ -15,0 +18,0 @@ Provider: ({ createStore, children, }: { |
@@ -5,2 +5,7 @@ import { createContext as createContext$1, useRef, createElement, useContext, useMemo } from 'react'; | ||
function createContext() { | ||
if (process.env.NODE_ENV !== "production") { | ||
console.warn( | ||
'[DEPRECATED] zustand/context will be removed in the future version. Please use `import { createStore, useStore } from "zustand"` for context usage. See: https://github.com/pmndrs/zustand/discussions/1180' | ||
); | ||
} | ||
const ZustandContext = createContext$1(void 0); | ||
@@ -7,0 +12,0 @@ const Provider = ({ |
export * from './vanilla'; | ||
export * from './react'; | ||
export { default as createStore } from './vanilla'; | ||
export { default } from './react'; |
@@ -1,4 +0,3 @@ | ||
import createStore__default from 'zustand/vanilla'; | ||
import { createStore } from 'zustand/vanilla'; | ||
export * from 'zustand/vanilla'; | ||
export { default as createStore } from 'zustand/vanilla'; | ||
import { useDebugValue } from 'react'; | ||
@@ -20,3 +19,8 @@ import useSyncExternalStoreExports from 'use-sync-external-store/shim/with-selector.js'; | ||
const createImpl = (createState) => { | ||
const api = typeof createState === "function" ? createStore__default(createState) : createState; | ||
if (process.env.NODE_ENV !== "production" && typeof createState !== "function") { | ||
console.warn( | ||
'[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.' | ||
); | ||
} | ||
const api = typeof createState === "function" ? createStore(createState) : createState; | ||
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn); | ||
@@ -27,3 +31,9 @@ Object.assign(useBoundStore, api); | ||
const create = (createState) => createState ? createImpl(createState) : createImpl; | ||
var react = (createState) => { | ||
console.warn( | ||
"[DEPRECATED] default export is deprecated, instead import { create } from'zustand'" | ||
); | ||
return create(createState); | ||
}; | ||
export { create as default, useStore }; | ||
export { create, react as default, useStore }; |
@@ -199,2 +199,3 @@ const reduxImpl = (reducer, initial) => (set, _get, api) => { | ||
null, | ||
// FIXME no-any | ||
nextLiftedState | ||
@@ -497,3 +498,3 @@ ); | ||
const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get())) || void 0; | ||
return Promise.resolve(storage.getItem.bind(storage)(options.name)).then((deserializedStorageValue) => { | ||
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => { | ||
if (deserializedStorageValue) { | ||
@@ -500,0 +501,0 @@ if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) { |
@@ -17,5 +17,12 @@ import type { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
<T>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>; | ||
/** | ||
* @deprecated Use `useStore` hook to bind store | ||
*/ | ||
<S extends StoreApi<unknown>>(store: S): UseBoundStore<S>; | ||
}; | ||
declare const create: Create; | ||
export default create; | ||
export declare const create: Create; | ||
/** | ||
* @deprecated Use `import { create } from 'zustand'` | ||
*/ | ||
declare const _default: Create; | ||
export default _default; |
@@ -1,2 +0,6 @@ | ||
declare function shallow<T>(objA: T, objB: T): boolean; | ||
export default shallow; | ||
export declare function shallow<T>(objA: T, objB: T): boolean; | ||
/** | ||
* @deprecated Use `import { shallow } from 'zustand/shallow'` | ||
*/ | ||
declare const _default: typeof shallow; | ||
export default _default; |
@@ -39,3 +39,9 @@ function shallow(objA, objB) { | ||
} | ||
var shallow$1 = (objA, objB) => { | ||
console.warn( | ||
"[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'" | ||
); | ||
return shallow(objA, objB); | ||
}; | ||
export { shallow as default }; | ||
export { shallow$1 as default, shallow }; |
@@ -10,2 +10,5 @@ type SetStateInternal<T> = { | ||
subscribe: (listener: (state: T, prevState: T) => void) => () => void; | ||
/** | ||
* @deprecated Use `unsubscribe` returned by `subscribe` | ||
*/ | ||
destroy: () => void; | ||
@@ -25,5 +28,9 @@ } | ||
}; | ||
declare const createStore: CreateStore; | ||
export default createStore; | ||
export declare const createStore: CreateStore; | ||
/** | ||
* @deprecated Use `import { createStore } from ...` | ||
*/ | ||
declare const _default: CreateStore; | ||
export default _default; | ||
/** | ||
* @deprecated Use `unknown` instead of `State` | ||
@@ -30,0 +37,0 @@ */ |
@@ -17,3 +17,10 @@ const createStoreImpl = (createState) => { | ||
}; | ||
const destroy = () => listeners.clear(); | ||
const destroy = () => { | ||
if (process.env.NODE_ENV !== "production") { | ||
console.warn( | ||
"[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected." | ||
); | ||
} | ||
listeners.clear(); | ||
}; | ||
const api = { setState, getState, subscribe, destroy }; | ||
@@ -24,3 +31,9 @@ state = createState(setState, getState, api); | ||
const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl; | ||
var vanilla = (createState) => { | ||
console.warn( | ||
"[DEPRECATED] default export is deprecated, instead import { createStore } ..." | ||
); | ||
return createStore(createState); | ||
}; | ||
export { createStore as default }; | ||
export { createStore, vanilla as default }; |
export * from './vanilla'; | ||
export * from './react'; | ||
export { default as createStore } from './vanilla'; | ||
export { default } from './react'; |
24
index.js
'use strict'; | ||
var createStore = require('zustand/vanilla'); | ||
var react = require('react'); | ||
var vanilla = require('zustand/vanilla'); | ||
var react$1 = require('react'); | ||
var useSyncExternalStoreExports = require('use-sync-external-store/shim/with-selector'); | ||
@@ -13,7 +13,10 @@ | ||
var slice = useSyncExternalStoreWithSelector(api.subscribe, api.getState, api.getServerState || api.getState, selector, equalityFn); | ||
react.useDebugValue(slice); | ||
react$1.useDebugValue(slice); | ||
return slice; | ||
} | ||
var createImpl = function createImpl(createState) { | ||
var api = typeof createState === 'function' ? createStore(createState) : createState; | ||
if (process.env.NODE_ENV !== "production" && typeof createState !== 'function') { | ||
console.warn('[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.'); | ||
} | ||
var api = typeof createState === 'function' ? vanilla.createStore(createState) : createState; | ||
var useBoundStore = function useBoundStore(selector, equalityFn) { | ||
@@ -28,11 +31,14 @@ return useStore(api, selector, equalityFn); | ||
}; | ||
var create$1 = create; | ||
var react = (function (createState) { | ||
console.warn("[DEPRECATED] default export is deprecated, instead import { create } from'zustand'"); | ||
return create(createState); | ||
}); | ||
exports.createStore = createStore; | ||
exports.default = create$1; | ||
exports.create = create; | ||
exports.default = react; | ||
exports.useStore = useStore; | ||
Object.keys(createStore).forEach(function (k) { | ||
Object.keys(vanilla).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return createStore[k]; } | ||
get: function () { return vanilla[k]; } | ||
}); | ||
@@ -39,0 +45,0 @@ }); |
@@ -525,3 +525,3 @@ 'use strict'; | ||
var postRehydrationCallback = (options.onRehydrateStorage == null ? void 0 : options.onRehydrateStorage(get())) || undefined; | ||
return Promise.resolve(storage.getItem.bind(storage)(options.name)).then(function (deserializedStorageValue) { | ||
return toThenable(storage.getItem.bind(storage))(options.name).then(function (deserializedStorageValue) { | ||
if (deserializedStorageValue) { | ||
@@ -528,0 +528,0 @@ if (typeof deserializedStorageValue.version === 'number' && deserializedStorageValue.version !== options.version) { |
{ | ||
"name": "zustand", | ||
"private": false, | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "🐻 Bear necessities for state management in React", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
@@ -17,5 +17,12 @@ import type { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
<T>(): <Mos extends [StoreMutatorIdentifier, unknown][] = []>(initializer: StateCreator<T, [], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>; | ||
/** | ||
* @deprecated Use `useStore` hook to bind store | ||
*/ | ||
<S extends StoreApi<unknown>>(store: S): UseBoundStore<S>; | ||
}; | ||
declare const create: Create; | ||
export default create; | ||
export declare const create: Create; | ||
/** | ||
* @deprecated Use `import { create } from 'zustand'` | ||
*/ | ||
declare const _default: Create; | ||
export default _default; |
@@ -5,3 +5,3 @@ <p align="center"> | ||
[![Build Status](https://img.shields.io/github/workflow/status/pmndrs/zustand/Lint?style=flat&colorA=000000&colorB=000000)](https://github.com/pmndrs/zustand/actions?query=workflow%3ALint) | ||
[![Build Status](https://img.shields.io/github/actions/workflow/status/pmndrs/zustand/lint-and-type.yml?branch=main&style=flat&colorA=000000&colorB=000000)](https://github.com/pmndrs/zustand/actions?query=workflow%3ALint) | ||
[![Build Size](https://img.shields.io/bundlephobia/minzip/zustand?label=bundle%20size&style=flat&colorA=000000&colorB=000000)](https://bundlephobia.com/result?p=zustand) | ||
@@ -12,5 +12,5 @@ [![Version](https://img.shields.io/npm/v/zustand?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/zustand) | ||
A small, fast and scalable bearbones state-management solution using simplified flux principles. Has a comfy api based on hooks, isn't boilerplatey or opinionated. | ||
A small, fast and scalable bearbones state-management solution using simplified flux principles. Has a comfy API based on hooks, isn't boilerplatey or opinionated. | ||
Don't disregard it because it's cute. It has quite the claws, lots of time was spent to deal with common pitfalls, like the dreaded [zombie child problem](https://react-redux.js.org/api/hooks#stale-props-and-zombie-children), [react concurrency](https://github.com/bvaughn/rfcs/blob/useMutableSource/text/0000-use-mutable-source.md), and [context loss](https://github.com/facebook/react/issues/13332) between mixed renderers. It may be the one state-manager in the React space that gets all of these right. | ||
Don't disregard it because it's cute. It has quite the claws, lots of time was spent dealing with common pitfalls, like the dreaded [zombie child problem](https://react-redux.js.org/api/hooks#stale-props-and-zombie-children), [react concurrency](https://github.com/bvaughn/rfcs/blob/useMutableSource/text/0000-use-mutable-source.md), and [context loss](https://github.com/facebook/react/issues/13332) between mixed renderers. It may be the one state-manager in the React space that gets all of these right. | ||
@@ -30,3 +30,3 @@ You can try a live demo [here](https://githubbox.com/pmndrs/zustand/tree/main/examples/demo). | ||
```jsx | ||
import create from 'zustand' | ||
import { create } from 'zustand' | ||
@@ -42,3 +42,3 @@ const useBearStore = create((set) => ({ | ||
Use the hook anywhere, no providers needed. Select your state and the component will re-render on changes. | ||
Use the hook anywhere, no providers are needed. Select your state and the component will re-render on changes. | ||
@@ -94,3 +94,3 @@ ```jsx | ||
```jsx | ||
import shallow from 'zustand/shallow' | ||
import { shallow } from 'zustand/shallow' | ||
@@ -180,4 +180,2 @@ // Object pick, re-renders the component when either state.nuts or state.honey change | ||
unsub1() | ||
// Destroying the store (removing all listeners) | ||
useDogStore.destroy() | ||
@@ -228,18 +226,20 @@ // You can of course use the hook as you always would | ||
Zustand core can be imported and used without the React dependency. The only difference is that the create function does not return a hook, but the api utilities. | ||
Zustand core can be imported and used without the React dependency. The only difference is that the create function does not return a hook, but the API utilities. | ||
```jsx | ||
import create from 'zustand/vanilla' | ||
import { createStore } from 'zustand/vanilla' | ||
const store = create(() => ({ ... })) | ||
const { getState, setState, subscribe, destroy } = store | ||
const store = createStore(() => ({ ... })) | ||
const { getState, setState, subscribe } = store | ||
export default store | ||
``` | ||
You can even consume an existing vanilla store with React: | ||
You can use a vanilla store with `useStore` hook available since v4. | ||
```jsx | ||
import create from 'zustand' | ||
import vanillaStore from './vanillaStore' | ||
import { useStore } from 'zustand' | ||
import { vanillaStore } from './vanillaStore' | ||
const useBoundStore = create(vanillaStore) | ||
const useBoundStore = (selector) => useStore(vanillaStore, selector) | ||
``` | ||
@@ -319,3 +319,3 @@ | ||
```jsx | ||
import create from 'zustand' | ||
import { create } from 'zustand' | ||
import { persist, createJSONStorage } from 'zustand/middleware' | ||
@@ -344,3 +344,3 @@ | ||
```jsx | ||
import create from 'zustand' | ||
import { create } from 'zustand' | ||
import { immer } from 'zustand/middleware/immer' | ||
@@ -382,3 +382,3 @@ | ||
Or, just use our redux-middleware. It wires up your main-reducer, sets initial state, and adds a dispatch function to the state itself and the vanilla api. | ||
Or, just use our redux-middleware. It wires up your main-reducer, sets initial state, and adds a dispatch function to the state itself and the vanilla API. | ||
@@ -415,3 +415,3 @@ ```jsx | ||
Assingning different connection names, will separate stores in redux devtools. This also helps grouping different stores into separate redux devtools connections. | ||
Assigning different connection names will separate stores in redux devtools. This also helps group different stores into separate redux devtools connections. | ||
@@ -441,3 +441,3 @@ devtools takes the store function as its first argument, optionally you can name the store or configure [serialize](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize) options with a second argument. | ||
You can also log action's type along with its payload: | ||
You can also log the action's type along with its payload: | ||
@@ -468,5 +468,5 @@ ```jsx | ||
The store created with `create` doesn't require context providers. In some cases, you may want to use contexts for dependency injection or if you want to initialize your store with props from a component. Because the normal store is a hook, passing it as a normal context value may violate rules of hooks. | ||
The store created with `create` doesn't require context providers. In some cases, you may want to use contexts for dependency injection or if you want to initialize your store with props from a component. Because the normal store is a hook, passing it as a normal context value may violate the rules of hooks. | ||
The recommended method available since v4 is to use vanilla store. | ||
The recommended method available since v4 is to use the vanilla store. | ||
@@ -493,4 +493,2 @@ ```jsx | ||
[Alternatively, a special createContext is provided.](./docs/previous-versions/zustand-v3-create-context.md) | ||
## TypeScript Usage | ||
@@ -501,3 +499,3 @@ | ||
```ts | ||
import create from 'zustand' | ||
import { create } from 'zustand' | ||
import { devtools, persist } from 'zustand/middleware' | ||
@@ -504,0 +502,0 @@ |
@@ -1,2 +0,6 @@ | ||
declare function shallow<T>(objA: T, objB: T): boolean; | ||
export default shallow; | ||
export declare function shallow<T>(objA: T, objB: T): boolean; | ||
/** | ||
* @deprecated Use `import { shallow } from 'zustand/shallow'` | ||
*/ | ||
declare const _default: typeof shallow; | ||
export default _default; |
@@ -75,3 +75,8 @@ 'use strict'; | ||
} | ||
var shallow$1 = (function (objA, objB) { | ||
console.warn("[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'"); | ||
return shallow(objA, objB); | ||
}); | ||
module.exports = shallow; | ||
exports.default = shallow$1; | ||
exports.shallow = shallow; |
@@ -19,2 +19,7 @@ System.register(['react', 'zustand'], (function (exports) { | ||
function createContext() { | ||
{ | ||
console.warn( | ||
'[DEPRECATED] zustand/context will be removed in the future version. Please use `import { createStore, useStore } from "zustand"` for context usage. See: https://github.com/pmndrs/zustand/discussions/1180' | ||
); | ||
} | ||
const ZustandContext = createContext$1(void 0); | ||
@@ -21,0 +26,0 @@ const Provider = ({ |
System.register(['zustand/vanilla', 'react', 'use-sync-external-store/shim/with-selector'], (function (exports) { | ||
'use strict'; | ||
var _starExcludes = { | ||
create: 1, | ||
default: 1, | ||
useStore: 1, | ||
createStore: 1 | ||
useStore: 1 | ||
}; | ||
var createStore__default, useDebugValue, useSyncExternalStoreExports; | ||
var createStore, useDebugValue, useSyncExternalStoreExports; | ||
return { | ||
setters: [function (module) { | ||
createStore__default = module.default; | ||
var setter = { createStore: module.default }; | ||
createStore = module.createStore; | ||
var setter = {}; | ||
for (var name in module) { | ||
@@ -39,3 +39,8 @@ if (!_starExcludes[name]) setter[name] = module[name]; | ||
const createImpl = (createState) => { | ||
const api = typeof createState === "function" ? createStore__default(createState) : createState; | ||
if (typeof createState !== "function") { | ||
console.warn( | ||
'[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.' | ||
); | ||
} | ||
const api = typeof createState === "function" ? createStore(createState) : createState; | ||
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn); | ||
@@ -45,3 +50,9 @@ Object.assign(useBoundStore, api); | ||
}; | ||
const create = exports('default', (createState) => createState ? createImpl(createState) : createImpl); | ||
const create = exports('create', (createState) => createState ? createImpl(createState) : createImpl); | ||
var react = exports('default', (createState) => { | ||
console.warn( | ||
"[DEPRECATED] default export is deprecated, instead import { create } from'zustand'" | ||
); | ||
return create(createState); | ||
}); | ||
@@ -48,0 +59,0 @@ }) |
@@ -1,1 +0,1 @@ | ||
System.register(["zustand/vanilla","react","use-sync-external-store/shim/with-selector"],function(c){"use strict";var S={default:1,useStore:1,createStore:1},i,o,f;return{setters:[function(t){i=t.default;var u={createStore:t.default};for(var r in t)S[r]||(u[r]=t[r]);c(u)},function(t){o=t.useDebugValue},function(t){f=t.default}],execute:function(){c("useStore",u);const{useSyncExternalStoreWithSelector:t}=f;function u(e,n=e.getState,s){const a=t(e.subscribe,e.getState,e.getServerState||e.getState,n,s);return o(a),a}const r=e=>{const n=typeof e=="function"?i(e):e,s=(a,l)=>u(n,a,l);return Object.assign(s,n),s},g=c("default",e=>e?r(e):r)}}}); | ||
System.register(["zustand/vanilla","react","use-sync-external-store/shim/with-selector"],function(n){"use strict";var S={create:1,default:1,useStore:1},o,i,f;return{setters:[function(t){o=t.createStore;var a={};for(var r in t)S[r]||(a[r]=t[r]);n(a)},function(t){i=t.useDebugValue},function(t){f=t.default}],execute:function(){n("useStore",a);const{useSyncExternalStoreWithSelector:t}=f;function a(e,s=e.getState,c){const u=t(e.subscribe,e.getState,e.getServerState||e.getState,s,c);return i(u),u}const r=e=>{const s=typeof e=="function"?o(e):e,c=(u,d)=>a(s,u,d);return Object.assign(c,s),c},l=n("create",e=>e?r(e):r);var g=n("default",e=>(console.warn("[DEPRECATED] default export is deprecated, instead import { create } from'zustand'"),l(e)))}}}); |
@@ -206,2 +206,3 @@ System.register([], (function (exports) { | ||
null, | ||
// FIXME no-any | ||
nextLiftedState | ||
@@ -504,3 +505,3 @@ ); | ||
const postRehydrationCallback = ((_a = options.onRehydrateStorage) == null ? void 0 : _a.call(options, get())) || void 0; | ||
return Promise.resolve(storage.getItem.bind(storage)(options.name)).then((deserializedStorageValue) => { | ||
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => { | ||
if (deserializedStorageValue) { | ||
@@ -507,0 +508,0 @@ if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) { |
@@ -1,5 +0,5 @@ | ||
System.register([],function(b){"use strict";return{execute:function(){b("createJSONStorage",_);const P=b("redux",(d,c)=>(a,s,o)=>(o.dispatch=e=>(a(v=>d(v,e),!1,e),e),o.dispatchFromDevtools=!0,{dispatch:(...e)=>o.dispatch(...e),...c})),I=new Map,O=d=>{const c=I.get(d);return c?Object.fromEntries(Object.entries(c.stores).map(([a,s])=>[a,s.getState()])):{}},T=(d,c,a)=>{if(d===void 0)return{type:"untracked",connection:c.connect(a)};const s=I.get(a.name);if(s)return{type:"tracked",store:d,...s};const o={connection:c.connect(a),stores:{}};return I.set(a.name,o),{type:"tracked",store:d,...o}},j=b("devtools",(d,c={})=>(a,s,o)=>{const{enabled:e,anonymousActionType:v,store:u,...p}=c;let m;try{m=(e!=null?e:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!m)return d(a,s,o);const{connection:i,...f}=T(u,m,p);let h=!0;o.setState=(r,n,t)=>{const l=a(r,n);if(!h)return l;const S=t===void 0?{type:v||"anonymous"}:typeof t=="string"?{type:t}:t;return u===void 0?(i==null||i.send(S,s()),l):(i==null||i.send({...S,type:`${u}/${S.type}`},{...O(p.name),[u]:o.getState()}),l)};const g=(...r)=>{const n=h;h=!1,a(...r),h=n},y=d(o.setState,s,o);if(f.type==="untracked"?i==null||i.init(y):(f.stores[f.store]=o,i==null||i.init(Object.fromEntries(Object.entries(f.stores).map(([r,n])=>[r,r===f.store?y:n.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){const r=o.dispatch;o.dispatch=(...n)=>{r(...n)}}return i.subscribe(r=>{var n;switch(r.type){case"ACTION":if(typeof r.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return E(r.payload,t=>{if(t.type==="__setState"){if(u===void 0){g(t.state);return}Object.keys(t.state).length!==1&&console.error(` | ||
System.register([],function(b){"use strict";return{execute:function(){b("createJSONStorage",_);const A=b("redux",(d,c)=>(a,s,o)=>(o.dispatch=e=>(a(v=>d(v,e),!1,e),e),o.dispatchFromDevtools=!0,{dispatch:(...e)=>o.dispatch(...e),...c})),I=new Map,w=d=>{const c=I.get(d);return c?Object.fromEntries(Object.entries(c.stores).map(([a,s])=>[a,s.getState()])):{}},T=(d,c,a)=>{if(d===void 0)return{type:"untracked",connection:c.connect(a)};const s=I.get(a.name);if(s)return{type:"tracked",store:d,...s};const o={connection:c.connect(a),stores:{}};return I.set(a.name,o),{type:"tracked",store:d,...o}},j=b("devtools",(d,c={})=>(a,s,o)=>{const{enabled:e,anonymousActionType:v,store:u,...p}=c;let g;try{g=(e!=null?e:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return d(a,s,o);const{connection:i,...f}=T(u,g,p);let h=!0;o.setState=(r,n,t)=>{const l=a(r,n);if(!h)return l;const S=t===void 0?{type:v||"anonymous"}:typeof t=="string"?{type:t}:t;return u===void 0?(i==null||i.send(S,s()),l):(i==null||i.send({...S,type:`${u}/${S.type}`},{...w(p.name),[u]:o.getState()}),l)};const m=(...r)=>{const n=h;h=!1,a(...r),h=n},y=d(o.setState,s,o);if(f.type==="untracked"?i==null||i.init(y):(f.stores[f.store]=o,i==null||i.init(Object.fromEntries(Object.entries(f.stores).map(([r,n])=>[r,r===f.store?y:n.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){const r=o.dispatch;o.dispatch=(...n)=>{r(...n)}}return i.subscribe(r=>{var n;switch(r.type){case"ACTION":if(typeof r.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return E(r.payload,t=>{if(t.type==="__setState"){if(u===void 0){m(t.state);return}Object.keys(t.state).length!==1&&console.error(` | ||
[zustand devtools middleware] Unsupported __setState action format. | ||
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(), | ||
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } } | ||
`);const l=t.state[u];if(l==null)return;JSON.stringify(o.getState())!==JSON.stringify(l)&&g(l);return}o.dispatchFromDevtools&&typeof o.dispatch=="function"&&o.dispatch(t)});case"DISPATCH":switch(r.payload.type){case"RESET":return g(y),u===void 0?i==null?void 0:i.init(o.getState()):i==null?void 0:i.init(O(p.name));case"COMMIT":if(u===void 0){i==null||i.init(o.getState());return}return i==null?void 0:i.init(O(p.name));case"ROLLBACK":return E(r.state,t=>{if(u===void 0){g(t),i==null||i.init(o.getState());return}g(t[u]),i==null||i.init(O(p.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return E(r.state,t=>{if(u===void 0){g(t);return}JSON.stringify(o.getState())!==JSON.stringify(t[u])&&g(t[u])});case"IMPORT_STATE":{const{nextLiftedState:t}=r.payload,l=(n=t.computedStates.slice(-1)[0])==null?void 0:n.state;if(!l)return;g(u===void 0?l:l[u]),i==null||i.send(null,t);return}case"PAUSE_RECORDING":return h=!h}return}}),y}),E=(d,c)=>{let a;try{a=JSON.parse(d)}catch(s){console.error("[zustand devtools middleware] Could not parse the received json",s)}a!==void 0&&c(a)},R=b("subscribeWithSelector",d=>(c,a,s)=>{const o=s.subscribe;return s.subscribe=(e,v,u)=>{let p=e;if(v){const m=(u==null?void 0:u.equalityFn)||Object.is;let i=e(s.getState());p=f=>{const h=e(f);if(!m(i,h)){const g=i;v(i=h,g)}},u!=null&&u.fireImmediately&&v(i,i)}return o(p)},d(c,a,s)}),$=b("combine",(d,c)=>(...a)=>Object.assign({},d,c(...a)));function _(d){let c;try{c=d()}catch{return}return{getItem:a=>{var s;const o=v=>v===null?null:JSON.parse(v),e=(s=c.getItem(a))!=null?s:null;return e instanceof Promise?e.then(o):o(e)},setItem:(a,s)=>c.setItem(a,JSON.stringify(s)),removeItem:a=>c.removeItem(a)}}const w=d=>c=>{try{const a=d(c);return a instanceof Promise?a:{then(s){return w(s)(a)},catch(s){return this}}}catch(a){return{then(s){return this},catch(s){return w(s)(a)}}}},z=(d,c)=>(a,s,o)=>{let e={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:n=>n,version:0,merge:(n,t)=>({...t,...n}),...c},v=!1;const u=new Set,p=new Set;let m;try{m=e.getStorage()}catch{}if(!m)return d((...n)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),a(...n)},s,o);const i=w(e.serialize),f=()=>{const n=e.partialize({...s()});let t;const l=i({state:n,version:e.version}).then(S=>m.setItem(e.name,S)).catch(S=>{t=S});if(t)throw t;return l},h=o.setState;o.setState=(n,t)=>{h(n,t),f()};const g=d((...n)=>{a(...n),f()},s,o);let y;const r=()=>{var n;if(!m)return;v=!1,u.forEach(l=>l(s()));const t=((n=e.onRehydrateStorage)==null?void 0:n.call(e,s()))||void 0;return w(m.getItem.bind(m))(e.name).then(l=>{if(l)return e.deserialize(l)}).then(l=>{if(l)if(typeof l.version=="number"&&l.version!==e.version){if(e.migrate)return e.migrate(l.state,l.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return l.state}).then(l=>{var S;return y=e.merge(l,(S=s())!=null?S:g),a(y,!0),f()}).then(()=>{t==null||t(y,void 0),v=!0,p.forEach(l=>l(y))}).catch(l=>{t==null||t(void 0,l)})};return o.persist={setOptions:n=>{e={...e,...n},n.getStorage&&(m=n.getStorage())},clearStorage:()=>{m==null||m.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>r(),hasHydrated:()=>v,onHydrate:n=>(u.add(n),()=>{u.delete(n)}),onFinishHydration:n=>(p.add(n),()=>{p.delete(n)})},r(),y||g},N=(d,c)=>(a,s,o)=>{let e={storage:_(()=>localStorage),partialize:r=>r,version:0,merge:(r,n)=>({...n,...r}),...c},v=!1;const u=new Set,p=new Set;let m=e.storage;if(!m)return d((...r)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),a(...r)},s,o);const i=()=>{const r=e.partialize({...s()});return m.setItem(e.name,{state:r,version:e.version})},f=o.setState;o.setState=(r,n)=>{f(r,n),i()};const h=d((...r)=>{a(...r),i()},s,o);let g;const y=()=>{var r;if(!m)return;v=!1,u.forEach(t=>t(s()));const n=((r=e.onRehydrateStorage)==null?void 0:r.call(e,s()))||void 0;return Promise.resolve(m.getItem.bind(m)(e.name)).then(t=>{if(t)if(typeof t.version=="number"&&t.version!==e.version){if(e.migrate)return e.migrate(t.state,t.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return t.state}).then(t=>{var l;return g=e.merge(t,(l=s())!=null?l:h),a(g,!0),i()}).then(()=>{n==null||n(g,void 0),v=!0,p.forEach(t=>t(g))}).catch(t=>{n==null||n(void 0,t)})};return o.persist={setOptions:r=>{e={...e,...r},r.storage&&(m=r.storage)},clearStorage:()=>{m==null||m.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>y(),hasHydrated:()=>v,onHydrate:r=>(u.add(r),()=>{u.delete(r)}),onFinishHydration:r=>(p.add(r),()=>{p.delete(r)})},y(),g||h},U=b("persist",(d,c)=>"getStorage"in c||"serialize"in c||"deserialize"in c?(console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Please use `storage` option instead."),z(d,c)):N(d,c))}}}); | ||
`);const l=t.state[u];if(l==null)return;JSON.stringify(o.getState())!==JSON.stringify(l)&&m(l);return}o.dispatchFromDevtools&&typeof o.dispatch=="function"&&o.dispatch(t)});case"DISPATCH":switch(r.payload.type){case"RESET":return m(y),u===void 0?i==null?void 0:i.init(o.getState()):i==null?void 0:i.init(w(p.name));case"COMMIT":if(u===void 0){i==null||i.init(o.getState());return}return i==null?void 0:i.init(w(p.name));case"ROLLBACK":return E(r.state,t=>{if(u===void 0){m(t),i==null||i.init(o.getState());return}m(t[u]),i==null||i.init(w(p.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return E(r.state,t=>{if(u===void 0){m(t);return}JSON.stringify(o.getState())!==JSON.stringify(t[u])&&m(t[u])});case"IMPORT_STATE":{const{nextLiftedState:t}=r.payload,l=(n=t.computedStates.slice(-1)[0])==null?void 0:n.state;if(!l)return;m(u===void 0?l:l[u]),i==null||i.send(null,t);return}case"PAUSE_RECORDING":return h=!h}return}}),y}),E=(d,c)=>{let a;try{a=JSON.parse(d)}catch(s){console.error("[zustand devtools middleware] Could not parse the received json",s)}a!==void 0&&c(a)},R=b("subscribeWithSelector",d=>(c,a,s)=>{const o=s.subscribe;return s.subscribe=(e,v,u)=>{let p=e;if(v){const g=(u==null?void 0:u.equalityFn)||Object.is;let i=e(s.getState());p=f=>{const h=e(f);if(!g(i,h)){const m=i;v(i=h,m)}},u!=null&&u.fireImmediately&&v(i,i)}return o(p)},d(c,a,s)}),C=b("combine",(d,c)=>(...a)=>Object.assign({},d,c(...a)));function _(d){let c;try{c=d()}catch{return}return{getItem:a=>{var s;const o=v=>v===null?null:JSON.parse(v),e=(s=c.getItem(a))!=null?s:null;return e instanceof Promise?e.then(o):o(e)},setItem:(a,s)=>c.setItem(a,JSON.stringify(s)),removeItem:a=>c.removeItem(a)}}const O=d=>c=>{try{const a=d(c);return a instanceof Promise?a:{then(s){return O(s)(a)},catch(s){return this}}}catch(a){return{then(s){return this},catch(s){return O(s)(a)}}}},z=(d,c)=>(a,s,o)=>{let e={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:n=>n,version:0,merge:(n,t)=>({...t,...n}),...c},v=!1;const u=new Set,p=new Set;let g;try{g=e.getStorage()}catch{}if(!g)return d((...n)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),a(...n)},s,o);const i=O(e.serialize),f=()=>{const n=e.partialize({...s()});let t;const l=i({state:n,version:e.version}).then(S=>g.setItem(e.name,S)).catch(S=>{t=S});if(t)throw t;return l},h=o.setState;o.setState=(n,t)=>{h(n,t),f()};const m=d((...n)=>{a(...n),f()},s,o);let y;const r=()=>{var n;if(!g)return;v=!1,u.forEach(l=>l(s()));const t=((n=e.onRehydrateStorage)==null?void 0:n.call(e,s()))||void 0;return O(g.getItem.bind(g))(e.name).then(l=>{if(l)return e.deserialize(l)}).then(l=>{if(l)if(typeof l.version=="number"&&l.version!==e.version){if(e.migrate)return e.migrate(l.state,l.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return l.state}).then(l=>{var S;return y=e.merge(l,(S=s())!=null?S:m),a(y,!0),f()}).then(()=>{t==null||t(y,void 0),v=!0,p.forEach(l=>l(y))}).catch(l=>{t==null||t(void 0,l)})};return o.persist={setOptions:n=>{e={...e,...n},n.getStorage&&(g=n.getStorage())},clearStorage:()=>{g==null||g.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>r(),hasHydrated:()=>v,onHydrate:n=>(u.add(n),()=>{u.delete(n)}),onFinishHydration:n=>(p.add(n),()=>{p.delete(n)})},r(),y||m},N=(d,c)=>(a,s,o)=>{let e={storage:_(()=>localStorage),partialize:r=>r,version:0,merge:(r,n)=>({...n,...r}),...c},v=!1;const u=new Set,p=new Set;let g=e.storage;if(!g)return d((...r)=>{console.warn(`[zustand persist middleware] Unable to update item '${e.name}', the given storage is currently unavailable.`),a(...r)},s,o);const i=()=>{const r=e.partialize({...s()});return g.setItem(e.name,{state:r,version:e.version})},f=o.setState;o.setState=(r,n)=>{f(r,n),i()};const h=d((...r)=>{a(...r),i()},s,o);let m;const y=()=>{var r;if(!g)return;v=!1,u.forEach(t=>t(s()));const n=((r=e.onRehydrateStorage)==null?void 0:r.call(e,s()))||void 0;return O(g.getItem.bind(g))(e.name).then(t=>{if(t)if(typeof t.version=="number"&&t.version!==e.version){if(e.migrate)return e.migrate(t.state,t.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return t.state}).then(t=>{var l;return m=e.merge(t,(l=s())!=null?l:h),a(m,!0),i()}).then(()=>{n==null||n(m,void 0),v=!0,p.forEach(t=>t(m))}).catch(t=>{n==null||n(void 0,t)})};return o.persist={setOptions:r=>{e={...e,...r},r.storage&&(g=r.storage)},clearStorage:()=>{g==null||g.removeItem(e.name)},getOptions:()=>e,rehydrate:()=>y(),hasHydrated:()=>v,onHydrate:r=>(u.add(r),()=>{u.delete(r)}),onFinishHydration:r=>(p.add(r),()=>{p.delete(r)})},y(),m||h},k=b("persist",(d,c)=>"getStorage"in c||"serialize"in c||"deserialize"in c?(console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Please use `storage` option instead."),z(d,c)):N(d,c))}}}); |
@@ -6,3 +6,3 @@ System.register([], (function (exports) { | ||
exports('default', shallow); | ||
exports('shallow', shallow); | ||
@@ -47,2 +47,8 @@ function shallow(objA, objB) { | ||
} | ||
var shallow$1 = exports('default', (objA, objB) => { | ||
console.warn( | ||
"[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'" | ||
); | ||
return shallow(objA, objB); | ||
}); | ||
@@ -49,0 +55,0 @@ }) |
@@ -1,1 +0,1 @@ | ||
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}}}}); | ||
System.register([],function(o){"use strict";return{execute:function(){o("shallow",s);function s(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[r,i]of t)if(!Object.is(i,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(e,n[r])||!Object.is(t[n[r]],e[n[r]]))return!1;return!0}var f=o("default",(t,e)=>(console.warn("[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'"),s(t,e)))}}}); |
@@ -22,3 +22,10 @@ System.register([], (function (exports) { | ||
}; | ||
const destroy = () => listeners.clear(); | ||
const destroy = () => { | ||
{ | ||
console.warn( | ||
"[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected." | ||
); | ||
} | ||
listeners.clear(); | ||
}; | ||
const api = { setState, getState, subscribe, destroy }; | ||
@@ -28,3 +35,9 @@ state = createState(setState, getState, api); | ||
}; | ||
const createStore = exports('default', (createState) => createState ? createStoreImpl(createState) : createStoreImpl); | ||
const createStore = exports('createStore', (createState) => createState ? createStoreImpl(createState) : createStoreImpl); | ||
var vanilla = exports('default', (createState) => { | ||
console.warn( | ||
"[DEPRECATED] default export is deprecated, instead import { createStore } ..." | ||
); | ||
return createStore(createState); | ||
}); | ||
@@ -31,0 +44,0 @@ }) |
@@ -1,1 +0,1 @@ | ||
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)}}}); | ||
System.register([],function(a){"use strict";return{execute:function(){const r=t=>{let e;const n=new Set,s=(c,l)=>{const o=typeof c=="function"?c(e):c;if(!Object.is(o,e)){const f=e;e=(l!=null?l:typeof o!="object")?o:Object.assign({},e,o),n.forEach(S=>S(e,f))}},i=()=>e,u={setState:s,getState:i,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{n.clear()}};return e=t(s,i,u),u},d=a("createStore",t=>t?r(t):r);var b=a("default",t=>(console.warn("[DEPRECATED] default export is deprecated, instead import { createStore } ..."),d(t)))}}}); |
@@ -13,2 +13,5 @@ import { ReactNode } from 'react'; | ||
}; | ||
/** | ||
* @deprecated Use `createStore` and `useStore` for context usage | ||
*/ | ||
declare function createContext<S extends StoreApi<unknown>>(): { | ||
@@ -15,0 +18,0 @@ Provider: ({ createStore, children, }: { |
@@ -13,2 +13,5 @@ import { ReactNode } from 'react'; | ||
}; | ||
/** | ||
* @deprecated Use `createStore` and `useStore` for context usage | ||
*/ | ||
declare function createContext<S extends StoreApi<unknown>>(): { | ||
@@ -15,0 +18,0 @@ Provider: ({ createStore, children, }: { |
export * from './vanilla'; | ||
export * from './react'; | ||
export { default as createStore } from './vanilla'; | ||
export { default } from './react'; |
@@ -27,5 +27,12 @@ import { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>; | ||
/** | ||
* @deprecated Use `useStore` hook to bind store | ||
*/ | ||
<S extends StoreApi<unknown>>(store: S): UseBoundStore<S>; | ||
}; | ||
declare const create: Create; | ||
export default create; | ||
export declare const create: Create; | ||
/** | ||
* @deprecated Use `import { create } from 'zustand'` | ||
*/ | ||
declare const _default: Create; | ||
export default _default; |
@@ -1,2 +0,6 @@ | ||
declare function shallow<T>(objA: T, objB: T): boolean; | ||
export default shallow; | ||
export declare function shallow<T>(objA: T, objB: T): boolean; | ||
/** | ||
* @deprecated Use `import { shallow } from 'zustand/shallow'` | ||
*/ | ||
declare const _default: typeof shallow; | ||
export default _default; |
@@ -10,2 +10,5 @@ type SetStateInternal<T> = { | ||
subscribe: (listener: (state: T, prevState: T) => void) => () => void; | ||
/** | ||
* @deprecated Use `unsubscribe` returned by `subscribe` | ||
*/ | ||
destroy: () => void; | ||
@@ -50,5 +53,9 @@ } | ||
}; | ||
declare const createStore: CreateStore; | ||
export default createStore; | ||
export declare const createStore: CreateStore; | ||
/** | ||
* @deprecated Use `import { createStore } from ...` | ||
*/ | ||
declare const _default: CreateStore; | ||
export default _default; | ||
/** | ||
* @deprecated Use `unknown` instead of `State` | ||
@@ -55,0 +62,0 @@ */ |
export * from './vanilla'; | ||
export * from './react'; | ||
export { default as createStore } from './vanilla'; | ||
export { default } from './react'; |
@@ -27,5 +27,12 @@ import { Mutate, StateCreator, StoreApi, StoreMutatorIdentifier } from './vanilla'; | ||
], Mos>) => UseBoundStore<Mutate<StoreApi<T>, Mos>>; | ||
/** | ||
* @deprecated Use `useStore` hook to bind store | ||
*/ | ||
<S extends StoreApi<unknown>>(store: S): UseBoundStore<S>; | ||
}; | ||
declare const create: Create; | ||
export default create; | ||
export declare const create: Create; | ||
/** | ||
* @deprecated Use `import { create } from 'zustand'` | ||
*/ | ||
declare const _default: Create; | ||
export default _default; |
@@ -1,2 +0,6 @@ | ||
declare function shallow<T>(objA: T, objB: T): boolean; | ||
export default shallow; | ||
export declare function shallow<T>(objA: T, objB: T): boolean; | ||
/** | ||
* @deprecated Use `import { shallow } from 'zustand/shallow'` | ||
*/ | ||
declare const _default: typeof shallow; | ||
export default _default; |
@@ -10,2 +10,5 @@ type SetStateInternal<T> = { | ||
subscribe: (listener: (state: T, prevState: T) => void) => () => void; | ||
/** | ||
* @deprecated Use `unsubscribe` returned by `subscribe` | ||
*/ | ||
destroy: () => void; | ||
@@ -50,5 +53,9 @@ } | ||
}; | ||
declare const createStore: CreateStore; | ||
export default createStore; | ||
export declare const createStore: CreateStore; | ||
/** | ||
* @deprecated Use `import { createStore } from ...` | ||
*/ | ||
declare const _default: CreateStore; | ||
export default _default; | ||
/** | ||
* @deprecated Use `unknown` instead of `State` | ||
@@ -55,0 +62,0 @@ */ |
@@ -23,2 +23,5 @@ (function (global, factory) { | ||
function createContext() { | ||
{ | ||
console.warn('[DEPRECATED] zustand/context will be removed in the future version. Please use `import { createStore, useStore } from "zustand"` for context usage. See: https://github.com/pmndrs/zustand/discussions/1180'); | ||
} | ||
var ZustandContext = react.createContext(undefined); | ||
@@ -25,0 +28,0 @@ var Provider = function Provider(_ref) { |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zustand = {}, global.zustandVanilla, global.React, global.useSyncExternalStoreShimWithSelector)); | ||
})(this, (function (exports, createStore, react, useSyncExternalStoreExports) { 'use strict'; | ||
})(this, (function (exports, vanilla, react$1, useSyncExternalStoreExports) { 'use strict'; | ||
@@ -14,7 +14,10 @@ var useSyncExternalStoreWithSelector = useSyncExternalStoreExports.useSyncExternalStoreWithSelector; | ||
var slice = useSyncExternalStoreWithSelector(api.subscribe, api.getState, api.getServerState || api.getState, selector, equalityFn); | ||
react.useDebugValue(slice); | ||
react$1.useDebugValue(slice); | ||
return slice; | ||
} | ||
var createImpl = function createImpl(createState) { | ||
var api = typeof createState === 'function' ? createStore(createState) : createState; | ||
if (typeof createState !== 'function') { | ||
console.warn('[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.'); | ||
} | ||
var api = typeof createState === 'function' ? vanilla.createStore(createState) : createState; | ||
var useBoundStore = function useBoundStore(selector, equalityFn) { | ||
@@ -29,11 +32,14 @@ return useStore(api, selector, equalityFn); | ||
}; | ||
var create$1 = create; | ||
var react = (function (createState) { | ||
console.warn("[DEPRECATED] default export is deprecated, instead import { create } from'zustand'"); | ||
return create(createState); | ||
}); | ||
exports.createStore = createStore; | ||
exports.default = create$1; | ||
exports.create = create; | ||
exports.default = react; | ||
exports.useStore = useStore; | ||
Object.keys(createStore).forEach(function (k) { | ||
Object.keys(vanilla).forEach(function (k) { | ||
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return createStore[k]; } | ||
get: function () { return vanilla[k]; } | ||
}); | ||
@@ -40,0 +46,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("zustand/vanilla"),require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","zustand/vanilla","react","use-sync-external-store/shim/with-selector"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zustand={},e.zustandVanilla,e.React,e.useSyncExternalStoreShimWithSelector)}(this,(function(e,t,n,r){"use strict";var u=r.useSyncExternalStoreWithSelector;function o(e,t,r){void 0===t&&(t=e.getState);var o=u(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return n.useDebugValue(o),o}var a=function(e){var n="function"==typeof e?t(e):e,r=function(e,t){return o(n,e,t)};return Object.assign(r,n),r},i=function(e){return e?a(e):a};e.createStore=t,e.default=i,e.useStore=o,Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("zustand/vanilla"),require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","zustand/vanilla","react","use-sync-external-store/shim/with-selector"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zustand={},e.zustandVanilla,e.React,e.useSyncExternalStoreShimWithSelector)}(this,(function(e,t,r,n){"use strict";var a=n.useSyncExternalStoreWithSelector;function o(e,t,n){void 0===t&&(t=e.getState);var o=a(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return r.useDebugValue(o),o}var u=function(e){var r="function"==typeof e?t.createStore(e):e,n=function(e,t){return o(r,e,t)};return Object.assign(n,r),n},i=function(e){return e?u(e):u};e.create=i,e.default=function(e){return console.warn("[DEPRECATED] default export is deprecated, instead import { create } from'zustand'"),i(e)},e.useStore=o,Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -529,3 +529,3 @@ (function (global, factory) { | ||
var postRehydrationCallback = (options.onRehydrateStorage == null ? void 0 : options.onRehydrateStorage(get())) || undefined; | ||
return Promise.resolve(storage.getItem.bind(storage)(options.name)).then(function (deserializedStorageValue) { | ||
return toThenable(storage.getItem.bind(storage))(options.name).then(function (deserializedStorageValue) { | ||
if (deserializedStorageValue) { | ||
@@ -532,0 +532,0 @@ if (typeof deserializedStorageValue.version === 'number' && deserializedStorageValue.version !== options.version) { |
@@ -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)}function n(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}var r=function(t,n){return function(r,o,i){return i.dispatch=function(e){return r((function(n){return t(n,e)}),!1,e),e},i.dispatchFromDevtools=!0,e({dispatch:function(){var t;return(t=i).dispatch.apply(t,arguments)}},n)}},o=["enabled","anonymousActionType","store"],i=["connection"],a=new Map,u=function(t){var e=a.get(t);return e?Object.fromEntries(Object.entries(e.stores).map((function(t){return[t[0],t[1].getState()]}))):{}},s=function(t,r){return void 0===r&&(r={}),function(s,f,l){var d,v=r,p=v.enabled,g=v.anonymousActionType,y=v.store,m=n(v,o);try{d=null!=p&&p&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(!d)return t(s,f,l);var h=function(t,n,r){if(void 0===t)return{type:"untracked",connection:n.connect(r)};var o=a.get(r.name);if(o)return e({type:"tracked",store:t},o);var i={connection:n.connect(r),stores:{}};return a.set(r.name,i),e({type:"tracked",store:t},i)}(y,d,m),S=h.connection,b=n(h,i),O=!0;l.setState=function(t,n,r){var o,i=s(t,n);if(!O)return i;var a=void 0===r?{type:g||"anonymous"}:"string"==typeof r?{type:r}:r;return void 0===y?(null==S||S.send(a,f()),i):(null==S||S.send(e({},a,{type:y+"/"+a.type}),e({},u(m.name),((o={})[y]=l.getState(),o))),i)};var w=function(){var t=O;O=!1,s.apply(void 0,arguments),O=t},E=t(l.setState,f,l);if("untracked"===b.type?null==S||S.init(E):(b.stores[b.store]=l,null==S||S.init(Object.fromEntries(Object.entries(b.stores).map((function(t){var e=t[0],n=t[1];return[e,e===b.store?E:n.getState()]}))))),l.dispatchFromDevtools&&"function"==typeof l.dispatch){var I=l.dispatch;l.dispatch=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];I.apply(void 0,e)}}return S.subscribe((function(t){switch(t.type){case"ACTION":return"string"!=typeof t.payload?void console.error("[zustand devtools middleware] Unsupported action format"):c(t.payload,(function(t){if("__setState"!==t.type)l.dispatchFromDevtools&&"function"==typeof l.dispatch&&l.dispatch(t);else{if(void 0===y)return void w(t.state);1!==Object.keys(t.state).length&&console.error('\n [zustand devtools middleware] Unsupported __setState action format. \n When using \'store\' option in devtools(), the \'state\' should have only one key, which is a value of \'store\' that was passed in devtools(),\n and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }\n ');var e=t.state[y];if(null==e)return;JSON.stringify(l.getState())!==JSON.stringify(e)&&w(e)}}));case"DISPATCH":switch(t.payload.type){case"RESET":return w(E),void 0===y?null==S?void 0:S.init(l.getState()):null==S?void 0:S.init(u(m.name));case"COMMIT":return void 0===y?void(null==S||S.init(l.getState())):null==S?void 0:S.init(u(m.name));case"ROLLBACK":return c(t.state,(function(t){if(void 0===y)return w(t),void(null==S||S.init(l.getState()));w(t[y]),null==S||S.init(u(m.name))}));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return c(t.state,(function(t){void 0!==y?JSON.stringify(l.getState())!==JSON.stringify(t[y])&&w(t[y]):w(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 w(void 0===y?r:r[y]),void(null==S||S.send(null,n));case"PAUSE_RECORDING":return O=!O}return}})),E}},c=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)},f=function(t){return function(e,n,r){var o=r.subscribe;return r.subscribe=function(t,e,n){var i=t;if(e){var a=(null==n?void 0:n.equalityFn)||Object.is,u=t(r.getState());i=function(n){var r=t(n);if(!a(u,r)){var o=u;e(u=r,o)}},null!=n&&n.fireImmediately&&e(u,u)}return o(i)},t(e,n,r)}};function l(t){var e;try{e=t()}catch(t){return}return{getItem:function(t){var n,r=function(t){return null===t?null:JSON.parse(t)},o=null!=(n=e.getItem(t))?n:null;return o instanceof Promise?o.then(r):r(o)},setItem:function(t,n){return e.setItem(t,JSON.stringify(n))},removeItem:function(t){return e.removeItem(t)}}}var d=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)}}}}},v=function(t,n){return"getStorage"in n||"serialize"in n||"deserialize"in n?(console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Please use `storage` option instead."),function(t,n){return function(r,o,i){var a,u=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,c=new Set,f=new Set;try{a=u.getStorage()}catch(t){}if(!a)return t((function(){console.warn("[zustand persist middleware] Unable to update item '"+u.name+"', the given storage is currently unavailable."),r.apply(void 0,arguments)}),o,i);var l=d(u.serialize),v=function(){var t,n=u.partialize(e({},o())),r=l({state:n,version:u.version}).then((function(t){return a.setItem(u.name,t)})).catch((function(e){t=e}));if(t)throw t;return r},p=i.setState;i.setState=function(t,e){p(t,e),v()};var g,y=t((function(){r.apply(void 0,arguments),v()}),o,i),m=function(){if(a){s=!1,c.forEach((function(t){return t(o())}));var t=(null==u.onRehydrateStorage?void 0:u.onRehydrateStorage(o()))||void 0;return d(a.getItem.bind(a))(u.name).then((function(t){if(t)return u.deserialize(t)})).then((function(t){if(t){if("number"!=typeof t.version||t.version===u.version)return t.state;if(u.migrate)return u.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 g=u.merge(t,null!=(e=o())?e:y),r(g,!0),v()})).then((function(){null==t||t(g,void 0),s=!0,f.forEach((function(t){return t(g)}))})).catch((function(e){null==t||t(void 0,e)}))}};return i.persist={setOptions:function(t){u=e({},u,t),t.getStorage&&(a=t.getStorage())},clearStorage:function(){var t;null==(t=a)||t.removeItem(u.name)},getOptions:function(){return u},rehydrate:function(){return m()},hasHydrated:function(){return s},onHydrate:function(t){return c.add(t),function(){c.delete(t)}},onFinishHydration:function(t){return f.add(t),function(){f.delete(t)}}},m(),g||y}}(t,n)):function(t,n){return function(r,o,i){var a=e({storage:l((function(){return localStorage})),partialize:function(t){return t},version:0,merge:function(t,n){return e({},n,t)}},n),u=!1,s=new Set,c=new Set,f=a.storage;if(!f)return t((function(){console.warn("[zustand persist middleware] Unable to update item '"+a.name+"', the given storage is currently unavailable."),r.apply(void 0,arguments)}),o,i);var d=function(){var t=a.partialize(e({},o()));return f.setItem(a.name,{state:t,version:a.version})},v=i.setState;i.setState=function(t,e){v(t,e),d()};var p,g=t((function(){r.apply(void 0,arguments),d()}),o,i),y=function(){if(f){u=!1,s.forEach((function(t){return t(o())}));var t=(null==a.onRehydrateStorage?void 0:a.onRehydrateStorage(o()))||void 0;return Promise.resolve(f.getItem.bind(f)(a.name)).then((function(t){if(t){if("number"!=typeof t.version||t.version===a.version)return t.state;if(a.migrate)return a.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 p=a.merge(t,null!=(e=o())?e:g),r(p,!0),d()})).then((function(){null==t||t(p,void 0),u=!0,c.forEach((function(t){return t(p)}))})).catch((function(e){null==t||t(void 0,e)}))}};return i.persist={setOptions:function(t){a=e({},a,t),t.storage&&(f=t.storage)},clearStorage:function(){var t;null==(t=f)||t.removeItem(a.name)},getOptions:function(){return a},rehydrate:function(){return y()},hasHydrated:function(){return u},onHydrate:function(t){return s.add(t),function(){s.delete(t)}},onFinishHydration:function(t){return c.add(t),function(){c.delete(t)}}},y(),p||g}}(t,n)};t.combine=function(t,e){return function(){return Object.assign({},t,e.apply(void 0,arguments))}},t.createJSONStorage=l,t.devtools=s,t.persist=v,t.redux=r,t.subscribeWithSelector=f})); | ||
!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)}function n(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}var r=function(t,n){return function(r,o,i){return i.dispatch=function(e){return r((function(n){return t(n,e)}),!1,e),e},i.dispatchFromDevtools=!0,e({dispatch:function(){var t;return(t=i).dispatch.apply(t,arguments)}},n)}},o=["enabled","anonymousActionType","store"],i=["connection"],a=new Map,u=function(t){var e=a.get(t);return e?Object.fromEntries(Object.entries(e.stores).map((function(t){return[t[0],t[1].getState()]}))):{}},s=function(t,r){return void 0===r&&(r={}),function(s,f,l){var d,v=r,p=v.enabled,g=v.anonymousActionType,y=v.store,m=n(v,o);try{d=null!=p&&p&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(t){}if(!d)return t(s,f,l);var h=function(t,n,r){if(void 0===t)return{type:"untracked",connection:n.connect(r)};var o=a.get(r.name);if(o)return e({type:"tracked",store:t},o);var i={connection:n.connect(r),stores:{}};return a.set(r.name,i),e({type:"tracked",store:t},i)}(y,d,m),S=h.connection,b=n(h,i),O=!0;l.setState=function(t,n,r){var o,i=s(t,n);if(!O)return i;var a=void 0===r?{type:g||"anonymous"}:"string"==typeof r?{type:r}:r;return void 0===y?(null==S||S.send(a,f()),i):(null==S||S.send(e({},a,{type:y+"/"+a.type}),e({},u(m.name),((o={})[y]=l.getState(),o))),i)};var w=function(){var t=O;O=!1,s.apply(void 0,arguments),O=t},E=t(l.setState,f,l);if("untracked"===b.type?null==S||S.init(E):(b.stores[b.store]=l,null==S||S.init(Object.fromEntries(Object.entries(b.stores).map((function(t){var e=t[0],n=t[1];return[e,e===b.store?E:n.getState()]}))))),l.dispatchFromDevtools&&"function"==typeof l.dispatch){var I=l.dispatch;l.dispatch=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];I.apply(void 0,e)}}return S.subscribe((function(t){switch(t.type){case"ACTION":return"string"!=typeof t.payload?void console.error("[zustand devtools middleware] Unsupported action format"):c(t.payload,(function(t){if("__setState"!==t.type)l.dispatchFromDevtools&&"function"==typeof l.dispatch&&l.dispatch(t);else{if(void 0===y)return void w(t.state);1!==Object.keys(t.state).length&&console.error('\n [zustand devtools middleware] Unsupported __setState action format. \n When using \'store\' option in devtools(), the \'state\' should have only one key, which is a value of \'store\' that was passed in devtools(),\n and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }\n ');var e=t.state[y];if(null==e)return;JSON.stringify(l.getState())!==JSON.stringify(e)&&w(e)}}));case"DISPATCH":switch(t.payload.type){case"RESET":return w(E),void 0===y?null==S?void 0:S.init(l.getState()):null==S?void 0:S.init(u(m.name));case"COMMIT":return void 0===y?void(null==S||S.init(l.getState())):null==S?void 0:S.init(u(m.name));case"ROLLBACK":return c(t.state,(function(t){if(void 0===y)return w(t),void(null==S||S.init(l.getState()));w(t[y]),null==S||S.init(u(m.name))}));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return c(t.state,(function(t){void 0!==y?JSON.stringify(l.getState())!==JSON.stringify(t[y])&&w(t[y]):w(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 w(void 0===y?r:r[y]),void(null==S||S.send(null,n));case"PAUSE_RECORDING":return O=!O}return}})),E}},c=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)},f=function(t){return function(e,n,r){var o=r.subscribe;return r.subscribe=function(t,e,n){var i=t;if(e){var a=(null==n?void 0:n.equalityFn)||Object.is,u=t(r.getState());i=function(n){var r=t(n);if(!a(u,r)){var o=u;e(u=r,o)}},null!=n&&n.fireImmediately&&e(u,u)}return o(i)},t(e,n,r)}};function l(t){var e;try{e=t()}catch(t){return}return{getItem:function(t){var n,r=function(t){return null===t?null:JSON.parse(t)},o=null!=(n=e.getItem(t))?n:null;return o instanceof Promise?o.then(r):r(o)},setItem:function(t,n){return e.setItem(t,JSON.stringify(n))},removeItem:function(t){return e.removeItem(t)}}}var d=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)}}}}},v=function(t,n){return"getStorage"in n||"serialize"in n||"deserialize"in n?(console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Please use `storage` option instead."),function(t,n){return function(r,o,i){var a,u=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,c=new Set,f=new Set;try{a=u.getStorage()}catch(t){}if(!a)return t((function(){console.warn("[zustand persist middleware] Unable to update item '"+u.name+"', the given storage is currently unavailable."),r.apply(void 0,arguments)}),o,i);var l=d(u.serialize),v=function(){var t,n=u.partialize(e({},o())),r=l({state:n,version:u.version}).then((function(t){return a.setItem(u.name,t)})).catch((function(e){t=e}));if(t)throw t;return r},p=i.setState;i.setState=function(t,e){p(t,e),v()};var g,y=t((function(){r.apply(void 0,arguments),v()}),o,i),m=function(){if(a){s=!1,c.forEach((function(t){return t(o())}));var t=(null==u.onRehydrateStorage?void 0:u.onRehydrateStorage(o()))||void 0;return d(a.getItem.bind(a))(u.name).then((function(t){if(t)return u.deserialize(t)})).then((function(t){if(t){if("number"!=typeof t.version||t.version===u.version)return t.state;if(u.migrate)return u.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 g=u.merge(t,null!=(e=o())?e:y),r(g,!0),v()})).then((function(){null==t||t(g,void 0),s=!0,f.forEach((function(t){return t(g)}))})).catch((function(e){null==t||t(void 0,e)}))}};return i.persist={setOptions:function(t){u=e({},u,t),t.getStorage&&(a=t.getStorage())},clearStorage:function(){var t;null==(t=a)||t.removeItem(u.name)},getOptions:function(){return u},rehydrate:function(){return m()},hasHydrated:function(){return s},onHydrate:function(t){return c.add(t),function(){c.delete(t)}},onFinishHydration:function(t){return f.add(t),function(){f.delete(t)}}},m(),g||y}}(t,n)):function(t,n){return function(r,o,i){var a=e({storage:l((function(){return localStorage})),partialize:function(t){return t},version:0,merge:function(t,n){return e({},n,t)}},n),u=!1,s=new Set,c=new Set,f=a.storage;if(!f)return t((function(){console.warn("[zustand persist middleware] Unable to update item '"+a.name+"', the given storage is currently unavailable."),r.apply(void 0,arguments)}),o,i);var v=function(){var t=a.partialize(e({},o()));return f.setItem(a.name,{state:t,version:a.version})},p=i.setState;i.setState=function(t,e){p(t,e),v()};var g,y=t((function(){r.apply(void 0,arguments),v()}),o,i),m=function(){if(f){u=!1,s.forEach((function(t){return t(o())}));var t=(null==a.onRehydrateStorage?void 0:a.onRehydrateStorage(o()))||void 0;return d(f.getItem.bind(f))(a.name).then((function(t){if(t){if("number"!=typeof t.version||t.version===a.version)return t.state;if(a.migrate)return a.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 g=a.merge(t,null!=(e=o())?e:y),r(g,!0),v()})).then((function(){null==t||t(g,void 0),u=!0,c.forEach((function(t){return t(g)}))})).catch((function(e){null==t||t(void 0,e)}))}};return i.persist={setOptions:function(t){a=e({},a,t),t.storage&&(f=t.storage)},clearStorage:function(){var t;null==(t=f)||t.removeItem(a.name)},getOptions:function(){return a},rehydrate:function(){return m()},hasHydrated:function(){return u},onHydrate:function(t){return s.add(t),function(){s.delete(t)}},onFinishHydration:function(t){return c.add(t),function(){c.delete(t)}}},m(),g||y}}(t,n)};t.combine=function(t,e){return function(){return Object.assign({},t,e.apply(void 0,arguments))}},t.createJSONStorage=l,t.devtools=s,t.persist=v,t.redux=r,t.subscribeWithSelector=f})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.zustandShallow = factory()); | ||
})(this, (function () { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zustandShallow = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
@@ -79,5 +79,12 @@ function _unsupportedIterableToArray(o, minLen) { | ||
} | ||
var shallow$1 = (function (objA, objB) { | ||
console.warn("[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'"); | ||
return shallow(objA, objB); | ||
}); | ||
return shallow; | ||
exports.default = shallow$1; | ||
exports.shallow = shallow; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); |
@@ -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";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}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zustandShallow={})}(this,(function(e){"use strict";function t(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 r(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[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.")}function n(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(var n,o=r(e);!(n=o()).done;){var i=n.value,a=i[0],f=i[1];if(!Object.is(f,t.get(a)))return!1}return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(var l,u=r(e);!(l=u()).done;){var s=l.value;if(!t.has(s))return!1}return!0}var c=Object.keys(e);if(c.length!==Object.keys(t).length)return!1;for(var d=0;d<c.length;d++)if(!Object.prototype.hasOwnProperty.call(t,c[d])||!Object.is(e[c[d]],t[c[d]]))return!1;return!0}e.default=function(e,t){return console.warn("[DEPRECATED] default export is deprecated, instead import { shallow } from'zustand/shallow'"),n(e,t)},e.shallow=n,Object.defineProperty(e,"__esModule",{value:!0})})); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.zustandVanilla = factory()); | ||
})(this, (function () { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zustandVanilla = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
@@ -30,3 +30,6 @@ var createStoreImpl = function createStoreImpl(createState) { | ||
var destroy = function destroy() { | ||
return listeners.clear(); | ||
{ | ||
console.warn('[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected.'); | ||
} | ||
listeners.clear(); | ||
}; | ||
@@ -45,5 +48,12 @@ var api = { | ||
}; | ||
var vanilla = (function (createState) { | ||
console.warn('[DEPRECATED] default export is deprecated, instead import { createStore } ...'); | ||
return createStore(createState); | ||
}); | ||
return createStore; | ||
exports.createStore = createStore; | ||
exports.default = vanilla; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); |
@@ -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).zustandVanilla=t()}(this,(function(){"use strict";var e=function(e){var t,n=new Set,o=function(e,o){var u="function"==typeof e?e(t):e;if(!Object.is(u,t)){var r=t;t=(null!=o?o:"object"!=typeof u)?u:Object.assign({},t,u),n.forEach((function(e){return e(t,r)}))}},u=function(){return t},r={setState:o,getState:u,subscribe:function(e){return n.add(e),function(){return n.delete(e)}},destroy:function(){return n.clear()}};return t=e(o,u,r),r};return function(t){return t?e(t):e}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zustandVanilla={})}(this,(function(e){"use strict";var t=function(e){var t,n=new Set,o=function(e,o){var r="function"==typeof e?e(t):e;if(!Object.is(r,t)){var i=t;t=(null!=o?o:"object"!=typeof r)?r:Object.assign({},t,r),n.forEach((function(e){return e(t,i)}))}},r=function(){return t},i={setState:o,getState:r,subscribe:function(e){return n.add(e),function(){return n.delete(e)}},destroy:function(){n.clear()}};return t=e(o,r,i),i},n=function(e){return e?t(e):t};e.createStore=n,e.default=function(e){return console.warn("[DEPRECATED] default export is deprecated, instead import { createStore } ..."),n(e)},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -10,2 +10,5 @@ type SetStateInternal<T> = { | ||
subscribe: (listener: (state: T, prevState: T) => void) => () => void; | ||
/** | ||
* @deprecated Use `unsubscribe` returned by `subscribe` | ||
*/ | ||
destroy: () => void; | ||
@@ -25,5 +28,9 @@ } | ||
}; | ||
declare const createStore: CreateStore; | ||
export default createStore; | ||
export declare const createStore: CreateStore; | ||
/** | ||
* @deprecated Use `import { createStore } from ...` | ||
*/ | ||
declare const _default: CreateStore; | ||
export default _default; | ||
/** | ||
* @deprecated Use `unknown` instead of `State` | ||
@@ -30,0 +37,0 @@ */ |
@@ -26,3 +26,6 @@ 'use strict'; | ||
var destroy = function destroy() { | ||
return listeners.clear(); | ||
if (process.env.NODE_ENV !== "production") { | ||
console.warn('[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected.'); | ||
} | ||
listeners.clear(); | ||
}; | ||
@@ -41,3 +44,8 @@ var api = { | ||
}; | ||
var vanilla = (function (createState) { | ||
console.warn('[DEPRECATED] default export is deprecated, instead import { createStore } ...'); | ||
return createStore(createState); | ||
}); | ||
module.exports = createStore; | ||
exports.createStore = createStore; | ||
exports.default = vanilla; |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
278215
6175
524
4