@umituz/react-native-design-system 4.27.24 → 4.27.25
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-design-system",
|
|
3
|
-
"version": "4.27.
|
|
3
|
+
"version": "4.27.25",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities - TanStack persistence and expo-image-manipulator now lazy loaded",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Store Factory
|
|
3
|
-
* Create Zustand stores with
|
|
3
|
+
* Create Zustand stores with optional persistence and actions
|
|
4
|
+
*
|
|
5
|
+
* NOTE: For persistence, provide a storage implementation.
|
|
6
|
+
* Use `storageRepository` from '@umituz/react-native-design-system/storage'
|
|
7
|
+
* for a centralized AsyncStorage abstraction.
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
10
|
import { create } from 'zustand';
|
|
7
11
|
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
8
12
|
import type { StoreApi } from 'zustand';
|
|
9
13
|
import type { StoreConfig } from '../types/Store';
|
|
10
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Create a Zustand store with optional persistence and actions
|
|
@@ -28,16 +31,35 @@ export function createStore<
|
|
|
28
31
|
return { ...state, ...actions } as Store;
|
|
29
32
|
};
|
|
30
33
|
|
|
34
|
+
// No persistence requested
|
|
31
35
|
if (!config.persist) {
|
|
32
36
|
return create<Store>(stateCreator);
|
|
33
37
|
}
|
|
34
38
|
|
|
39
|
+
// Persistence requested but no storage provided - warn and create in-memory store
|
|
40
|
+
if (!config.storage) {
|
|
41
|
+
if (__DEV__) {
|
|
42
|
+
console.warn(
|
|
43
|
+
`[StoreFactory] ⚠️ Store "${config.name}" requested persistence but no storage was provided.\n` +
|
|
44
|
+
`Creating in-memory store instead (data will be lost on reload).\n\n` +
|
|
45
|
+
`💡 Fix: Import and provide storage:\n` +
|
|
46
|
+
` import { storageRepository } from '@umituz/react-native-design-system/storage';\n\n` +
|
|
47
|
+
` createStore({\n` +
|
|
48
|
+
` name: 'my-store',\n` +
|
|
49
|
+
` persist: true,\n` +
|
|
50
|
+
` storage: storageRepository, // ← Add this\n` +
|
|
51
|
+
` ...config\n` +
|
|
52
|
+
` });`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return create<Store>(stateCreator);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Persistence with storage
|
|
35
59
|
return create<Store>()(
|
|
36
60
|
persist<Store>(stateCreator, {
|
|
37
61
|
name: config.name,
|
|
38
|
-
storage: config.storage
|
|
39
|
-
? createJSONStorage(() => config.storage!)
|
|
40
|
-
: createJSONStorage(() => AsyncStorage),
|
|
62
|
+
storage: createJSONStorage(() => config.storage!),
|
|
41
63
|
version: config.version || 1,
|
|
42
64
|
partialize: (config.partialize
|
|
43
65
|
? (state: Store) => config.partialize!(state)
|