@umituz/react-native-storage 2.6.6 → 2.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-storage",
3
- "version": "2.6.6",
3
+ "version": "2.6.8",
4
4
  "description": "Unified storage solution with AsyncStorage persistence, Zustand state management, and in-memory caching for React Native",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -3,8 +3,8 @@
3
3
  * Create Zustand stores with AsyncStorage persistence and actions
4
4
  */
5
5
 
6
- import { create, type StateCreator } from 'zustand';
7
- import { persist, createJSONStorage, type PersistOptions } from 'zustand/middleware';
6
+ import { create } from 'zustand';
7
+ import { persist, createJSONStorage } from 'zustand/middleware';
8
8
  import type { StoreConfig } from '../types/Store';
9
9
  import { storageService } from '../../infrastructure/adapters/StorageService';
10
10
 
@@ -17,13 +17,11 @@ export function createStore<
17
17
  >(config: StoreConfig<TState, TActions>) {
18
18
  type Store = TState & TActions;
19
19
 
20
- const stateCreator: StateCreator<Store> = (set, get) => {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ const stateCreator = (set: any, get: any): Store => {
21
22
  const state = config.initialState as TState;
22
23
  const actions = config.actions
23
- ? config.actions(
24
- (partial: Partial<TState>) => set(partial as Partial<Store>),
25
- get as () => TState
26
- )
24
+ ? config.actions(set, get)
27
25
  : ({} as TActions);
28
26
  return { ...state, ...actions } as Store;
29
27
  };
@@ -32,28 +30,32 @@ export function createStore<
32
30
  return create<Store>(stateCreator);
33
31
  }
34
32
 
35
- const persistOptions: PersistOptions<Store, Partial<Store>> = {
36
- name: config.name,
37
- storage: createJSONStorage(() => storageService),
38
- version: config.version || 1,
39
- partialize: config.partialize
40
- ? (state) => config.partialize!(state as TState) as Partial<Store>
41
- : (state) => {
42
- const persisted: Record<string, unknown> = {};
43
- for (const key of Object.keys(state)) {
44
- if (typeof state[key as keyof Store] !== 'function') {
45
- persisted[key] = state[key as keyof Store];
33
+ return create<Store>()(
34
+ persist(stateCreator, {
35
+ name: config.name,
36
+ storage: createJSONStorage(() => storageService),
37
+ version: config.version || 1,
38
+ partialize: config.partialize
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ ? (state) => config.partialize!(state as any) as any
41
+ : (state) => {
42
+ const persisted: Record<string, unknown> = {};
43
+ for (const key of Object.keys(state)) {
44
+ if (typeof state[key as keyof Store] !== 'function') {
45
+ persisted[key] = state[key as keyof Store];
46
+ }
46
47
  }
47
- }
48
- return persisted as Partial<Store>;
49
- },
50
- onRehydrateStorage: () => (state) => {
51
- if (state && config.onRehydrate) {
52
- config.onRehydrate(state as TState);
53
- }
54
- },
55
- migrate: config.migrate as PersistOptions<Store, Partial<Store>>['migrate'],
56
- };
57
-
58
- return create<Store>()(persist(stateCreator, persistOptions));
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ return persisted as any;
50
+ },
51
+ onRehydrateStorage: () => (state) => {
52
+ if (state && config.onRehydrate) {
53
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ config.onRehydrate(state as any);
55
+ }
56
+ },
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ migrate: config.migrate as any,
59
+ })
60
+ );
59
61
  }