@idealyst/storage 1.2.9 → 1.2.12
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 +8 -3
- package/src/index.native.ts +2 -1
- package/src/index.ts +1 -1
- package/src/index.web.ts +2 -1
- package/src/storage.native.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/storage",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "Cross-platform storage abstraction for React and React Native",
|
|
5
5
|
"documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/storage#readme",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.8.0",
|
|
42
42
|
"react-native": ">=0.60.0",
|
|
43
|
-
"react-native-mmkv": ">=
|
|
43
|
+
"react-native-mmkv": ">=4.0.0",
|
|
44
|
+
"react-native-nitro-modules": ">=0.20.0"
|
|
44
45
|
},
|
|
45
46
|
"peerDependenciesMeta": {
|
|
46
47
|
"react-native": {
|
|
@@ -48,11 +49,15 @@
|
|
|
48
49
|
},
|
|
49
50
|
"react-native-mmkv": {
|
|
50
51
|
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"react-native-nitro-modules": {
|
|
54
|
+
"optional": true
|
|
51
55
|
}
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
58
|
"@types/react": "^19.1.0",
|
|
55
|
-
"react-native-mmkv": "^
|
|
59
|
+
"react-native-mmkv": "^4.1.1",
|
|
60
|
+
"react-native-nitro-modules": "^0.32.1",
|
|
56
61
|
"typescript": "^5.0.0"
|
|
57
62
|
},
|
|
58
63
|
"files": [
|
package/src/index.native.ts
CHANGED
|
@@ -4,5 +4,6 @@ import NativeStorage from './storage.native';
|
|
|
4
4
|
const storage = new BaseStorage(new NativeStorage());
|
|
5
5
|
|
|
6
6
|
export default storage;
|
|
7
|
-
|
|
7
|
+
// Export instance as both `storage` and `Storage` for convenience
|
|
8
|
+
export { storage, storage as Storage, BaseStorage, NativeStorage };
|
|
8
9
|
export * from './types';
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,6 @@ import BaseStorage from './storage';
|
|
|
2
2
|
|
|
3
3
|
// For non-platform-specific imports, export the class (not an instance)
|
|
4
4
|
// Platform-specific entry points (index.native.ts, index.web.ts) export instances
|
|
5
|
-
export { BaseStorage
|
|
5
|
+
export { BaseStorage };
|
|
6
6
|
export default BaseStorage;
|
|
7
7
|
export * from './types';
|
package/src/index.web.ts
CHANGED
|
@@ -4,5 +4,6 @@ import WebStorage from './storage.web';
|
|
|
4
4
|
const storage = new BaseStorage(new WebStorage());
|
|
5
5
|
|
|
6
6
|
export default storage;
|
|
7
|
-
|
|
7
|
+
// Export instance as both `storage` and `Storage` for convenience
|
|
8
|
+
export { storage, storage as Storage, BaseStorage, WebStorage };
|
|
8
9
|
export * from './types';
|
package/src/storage.native.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createMMKV } from 'react-native-mmkv';
|
|
2
2
|
import { IStorage } from './types';
|
|
3
3
|
|
|
4
4
|
class NativeStorage implements IStorage {
|
|
5
|
-
private storage =
|
|
5
|
+
private storage = createMMKV();
|
|
6
6
|
|
|
7
7
|
async getItem(key: string): Promise<string | null> {
|
|
8
8
|
try {
|
|
@@ -24,7 +24,7 @@ class NativeStorage implements IStorage {
|
|
|
24
24
|
|
|
25
25
|
async removeItem(key: string): Promise<void> {
|
|
26
26
|
try {
|
|
27
|
-
this.storage.
|
|
27
|
+
this.storage.remove(key);
|
|
28
28
|
} catch (error) {
|
|
29
29
|
console.error('Error removing item from MMKV:', error);
|
|
30
30
|
throw error;
|
|
@@ -72,7 +72,7 @@ class NativeStorage implements IStorage {
|
|
|
72
72
|
async multiRemove(keys: string[]): Promise<void> {
|
|
73
73
|
try {
|
|
74
74
|
keys.forEach(key => {
|
|
75
|
-
this.storage.
|
|
75
|
+
this.storage.remove(key);
|
|
76
76
|
});
|
|
77
77
|
} catch (error) {
|
|
78
78
|
console.error('Error in multiRemove from MMKV:', error);
|