@umituz/react-native-storage 2.6.5 → 2.6.7

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.5",
3
+ "version": "2.6.7",
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",
@@ -1,19 +1,6 @@
1
1
  /**
2
2
  * Store Factory
3
3
  * Create Zustand stores with AsyncStorage persistence and actions
4
- *
5
- * @example
6
- * ```typescript
7
- * const useCounterStore = createStore({
8
- * name: 'counter',
9
- * initialState: { count: 0 },
10
- * actions: (set, get) => ({
11
- * increment: () => set({ count: get().count + 1 }),
12
- * reset: () => set({ count: 0 }),
13
- * }),
14
- * persist: true,
15
- * });
16
- * ```
17
4
  */
18
5
 
19
6
  import { create } from 'zustand';
@@ -30,13 +17,13 @@ export function createStore<
30
17
  >(config: StoreConfig<TState, TActions>) {
31
18
  type Store = TState & TActions;
32
19
 
33
- const stateCreator = (
34
- set: (partial: Partial<Store>) => void,
35
- get: () => Store
36
- ): Store => {
37
- const state = config.initialState as Store;
38
- const actions = config.actions ? config.actions(set as any, get as any) : ({} as TActions);
39
- return { ...state, ...actions };
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ const stateCreator = (set: any, get: any): Store => {
22
+ const state = config.initialState as TState;
23
+ const actions = config.actions
24
+ ? config.actions(set, get)
25
+ : ({} as TActions);
26
+ return { ...state, ...actions } as Store;
40
27
  };
41
28
 
42
29
  if (!config.persist) {
@@ -49,22 +36,22 @@ export function createStore<
49
36
  storage: createJSONStorage(() => storageService),
50
37
  version: config.version || 1,
51
38
  partialize: config.partialize
52
- ? (state) => config.partialize!(state) as Store
39
+ ? (state) => config.partialize!(state as TState)
53
40
  : (state) => {
54
- // By default, exclude functions (actions) from persistence
55
41
  const persisted: Record<string, unknown> = {};
56
42
  for (const key of Object.keys(state)) {
57
43
  if (typeof state[key as keyof Store] !== 'function') {
58
44
  persisted[key] = state[key as keyof Store];
59
45
  }
60
46
  }
61
- return persisted as Store;
47
+ return persisted as Partial<Store>;
62
48
  },
63
49
  onRehydrateStorage: () => (state) => {
64
50
  if (state && config.onRehydrate) {
65
- config.onRehydrate(state);
51
+ config.onRehydrate(state as TState);
66
52
  }
67
53
  },
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
55
  migrate: config.migrate as any,
69
56
  })
70
57
  );