@unvired/react-native-unvired-sdk 0.0.27 → 0.0.28

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/BuildNo.txt CHANGED
@@ -1 +1 @@
1
- R-0.000.0027
1
+ R-0.000.0028
@@ -9,41 +9,41 @@ export declare class LocalStorage {
9
9
  * @param key - The key to retrieve
10
10
  * @returns The parsed value or null if not found
11
11
  */
12
- static getItem<T = any>(key: string): Promise<T | null>;
12
+ static getItem<T = any>(key: string): T | null;
13
13
  /**
14
14
  * Set an item in storage
15
15
  * @param key - The key to store the value under
16
16
  * @param value - The value to store (will be JSON stringified)
17
17
  */
18
- static setItem(key: string, value: any): Promise<void>;
18
+ static setItem(key: string, value: any): void;
19
19
  /**
20
20
  * Remove an item from storage
21
21
  * @param key - The key to remove
22
22
  */
23
- static removeItem(key: string): Promise<void>;
23
+ static removeItem(key: string): void;
24
24
  /**
25
25
  * Clear all items from storage
26
26
  */
27
- static clear(): Promise<void>;
27
+ static clear(): void;
28
28
  /**
29
29
  * Get all keys from storage
30
30
  * @returns Array of all keys
31
31
  */
32
- static getAllKeys(): Promise<readonly string[]>;
32
+ static getAllKeys(): readonly string[];
33
33
  /**
34
34
  * Get multiple items from storage
35
35
  * @param keys - Array of keys to retrieve
36
36
  * @returns Array of [key, value] pairs
37
37
  */
38
- static multiGet(keys: string[]): Promise<Array<[string, any]>>;
38
+ static multiGet(keys: string[]): Array<[string, any]>;
39
39
  /**
40
40
  * Set multiple items in storage
41
41
  * @param keyValuePairs - Array of [key, value] pairs to store
42
42
  */
43
- static multiSet(keyValuePairs: Array<[string, any]>): Promise<void>;
43
+ static multiSet(keyValuePairs: Array<[string, any]>): void;
44
44
  /**
45
45
  * Remove multiple items from storage
46
46
  * @param keys - Array of keys to remove
47
47
  */
48
- static multiRemove(keys: string[]): Promise<void>;
48
+ static multiRemove(keys: string[]): void;
49
49
  }
@@ -14,9 +14,9 @@ export class LocalStorage {
14
14
  * @param key - The key to retrieve
15
15
  * @returns The parsed value or null if not found
16
16
  */
17
- static async getItem(key) {
17
+ static getItem(key) {
18
18
  try {
19
- const value = await storageImpl.getItem(key);
19
+ const value = storageImpl.getItem(key);
20
20
  return value ? JSON.parse(value) : null;
21
21
  }
22
22
  catch (error) {
@@ -29,10 +29,10 @@ export class LocalStorage {
29
29
  * @param key - The key to store the value under
30
30
  * @param value - The value to store (will be JSON stringified)
31
31
  */
32
- static async setItem(key, value) {
32
+ static setItem(key, value) {
33
33
  try {
34
34
  const jsonValue = JSON.stringify(value);
35
- await storageImpl.setItem(key, jsonValue);
35
+ storageImpl.setItem(key, jsonValue);
36
36
  }
37
37
  catch (error) {
38
38
  console.error(`Error setting item with key "${key}":`, error);
@@ -43,9 +43,9 @@ export class LocalStorage {
43
43
  * Remove an item from storage
44
44
  * @param key - The key to remove
45
45
  */
46
- static async removeItem(key) {
46
+ static removeItem(key) {
47
47
  try {
48
- await storageImpl.removeItem(key);
48
+ storageImpl.removeItem(key);
49
49
  }
50
50
  catch (error) {
51
51
  console.error(`Error removing item with key "${key}":`, error);
@@ -55,9 +55,9 @@ export class LocalStorage {
55
55
  /**
56
56
  * Clear all items from storage
57
57
  */
58
- static async clear() {
58
+ static clear() {
59
59
  try {
60
- await storageImpl.clear();
60
+ storageImpl.clear();
61
61
  }
62
62
  catch (error) {
63
63
  console.error('Error clearing storage:', error);
@@ -68,9 +68,9 @@ export class LocalStorage {
68
68
  * Get all keys from storage
69
69
  * @returns Array of all keys
70
70
  */
71
- static async getAllKeys() {
71
+ static getAllKeys() {
72
72
  try {
73
- return await storageImpl.getAllKeys();
73
+ return storageImpl.getAllKeys();
74
74
  }
75
75
  catch (error) {
76
76
  console.error('Error getting all keys:', error);
@@ -82,9 +82,9 @@ export class LocalStorage {
82
82
  * @param keys - Array of keys to retrieve
83
83
  * @returns Array of [key, value] pairs
84
84
  */
85
- static async multiGet(keys) {
85
+ static multiGet(keys) {
86
86
  try {
87
- const results = await storageImpl.multiGet(keys);
87
+ const results = storageImpl.multiGet(keys);
88
88
  return results.map(([key, value]) => [
89
89
  key,
90
90
  value ? JSON.parse(value) : null
@@ -99,13 +99,13 @@ export class LocalStorage {
99
99
  * Set multiple items in storage
100
100
  * @param keyValuePairs - Array of [key, value] pairs to store
101
101
  */
102
- static async multiSet(keyValuePairs) {
102
+ static multiSet(keyValuePairs) {
103
103
  try {
104
104
  const jsonPairs = keyValuePairs.map(([key, value]) => [
105
105
  key,
106
106
  JSON.stringify(value)
107
107
  ]);
108
- await storageImpl.multiSet(jsonPairs);
108
+ storageImpl.multiSet(jsonPairs);
109
109
  }
110
110
  catch (error) {
111
111
  console.error('Error setting multiple items:', error);
@@ -116,9 +116,9 @@ export class LocalStorage {
116
116
  * Remove multiple items from storage
117
117
  * @param keys - Array of keys to remove
118
118
  */
119
- static async multiRemove(keys) {
119
+ static multiRemove(keys) {
120
120
  try {
121
- await storageImpl.multiRemove(keys);
121
+ storageImpl.multiRemove(keys);
122
122
  }
123
123
  catch (error) {
124
124
  console.error('Error removing multiple items:', error);
@@ -1,10 +1,10 @@
1
1
  export declare class StorageNative {
2
- getItem(key: string): Promise<string | null>;
3
- setItem(key: string, value: string): Promise<void>;
4
- removeItem(key: string): Promise<void>;
5
- clear(): Promise<void>;
6
- getAllKeys(): Promise<readonly string[]>;
7
- multiGet(keys: string[]): Promise<readonly [string, string | null][]>;
8
- multiSet(keyValuePairs: Array<[string, string]>): Promise<void>;
9
- multiRemove(keys: string[]): Promise<void>;
2
+ getItem(key: string): string | null;
3
+ setItem(key: string, value: string): void;
4
+ removeItem(key: string): void;
5
+ clear(): void;
6
+ getAllKeys(): readonly string[];
7
+ multiGet(keys: string[]): readonly [string, string | null][];
8
+ multiSet(keyValuePairs: Array<[string, string]>): void;
9
+ multiRemove(keys: string[]): void;
10
10
  }
@@ -1,27 +1,36 @@
1
- import AsyncStorage from '@react-native-async-storage/async-storage';
1
+ import { createMMKV } from 'react-native-mmkv';
2
+ const storage = createMMKV();
2
3
  export class StorageNative {
3
- async getItem(key) {
4
- return await AsyncStorage.getItem(key);
4
+ getItem(key) {
5
+ const val = storage.getString(key);
6
+ return val !== undefined ? val : null;
5
7
  }
6
- async setItem(key, value) {
7
- await AsyncStorage.setItem(key, value);
8
+ setItem(key, value) {
9
+ storage.set(key, value);
8
10
  }
9
- async removeItem(key) {
10
- await AsyncStorage.removeItem(key);
11
+ removeItem(key) {
12
+ storage.remove(key);
11
13
  }
12
- async clear() {
13
- await AsyncStorage.clear();
14
+ clear() {
15
+ storage.clearAll();
14
16
  }
15
- async getAllKeys() {
16
- return await AsyncStorage.getAllKeys();
17
+ getAllKeys() {
18
+ return storage.getAllKeys();
17
19
  }
18
- async multiGet(keys) {
19
- return await AsyncStorage.multiGet(keys);
20
+ multiGet(keys) {
21
+ return keys.map(key => {
22
+ const val = storage.getString(key);
23
+ return [key, val !== undefined ? val : null];
24
+ });
20
25
  }
21
- async multiSet(keyValuePairs) {
22
- await AsyncStorage.multiSet(keyValuePairs);
26
+ multiSet(keyValuePairs) {
27
+ keyValuePairs.forEach(([key, value]) => {
28
+ storage.set(key, value);
29
+ });
23
30
  }
24
- async multiRemove(keys) {
25
- await AsyncStorage.multiRemove(keys);
31
+ multiRemove(keys) {
32
+ keys.forEach(key => {
33
+ storage.remove(key);
34
+ });
26
35
  }
27
36
  }
@@ -1,10 +1,10 @@
1
1
  export declare class StorageWeb {
2
- getItem(key: string): Promise<string | null>;
3
- setItem(key: string, value: string): Promise<void>;
4
- removeItem(key: string): Promise<void>;
5
- clear(): Promise<void>;
6
- getAllKeys(): Promise<readonly string[]>;
7
- multiGet(keys: string[]): Promise<readonly [string, string | null][]>;
8
- multiSet(keyValuePairs: Array<[string, string]>): Promise<void>;
9
- multiRemove(keys: string[]): Promise<void>;
2
+ getItem(key: string): string | null;
3
+ setItem(key: string, value: string): void;
4
+ removeItem(key: string): void;
5
+ clear(): void;
6
+ getAllKeys(): readonly string[];
7
+ multiGet(keys: string[]): readonly [string, string | null][];
8
+ multiSet(keyValuePairs: Array<[string, string]>): void;
9
+ multiRemove(keys: string[]): void;
10
10
  }
@@ -1,26 +1,26 @@
1
1
  export class StorageWeb {
2
- async getItem(key) {
2
+ getItem(key) {
3
3
  return localStorage.getItem(key);
4
4
  }
5
- async setItem(key, value) {
5
+ setItem(key, value) {
6
6
  localStorage.setItem(key, value);
7
7
  }
8
- async removeItem(key) {
8
+ removeItem(key) {
9
9
  localStorage.removeItem(key);
10
10
  }
11
- async clear() {
11
+ clear() {
12
12
  localStorage.clear();
13
13
  }
14
- async getAllKeys() {
14
+ getAllKeys() {
15
15
  return Object.keys(localStorage);
16
16
  }
17
- async multiGet(keys) {
17
+ multiGet(keys) {
18
18
  return keys.map(key => [key, localStorage.getItem(key)]);
19
19
  }
20
- async multiSet(keyValuePairs) {
20
+ multiSet(keyValuePairs) {
21
21
  keyValuePairs.forEach(([key, value]) => localStorage.setItem(key, value));
22
22
  }
23
- async multiRemove(keys) {
23
+ multiRemove(keys) {
24
24
  keys.forEach(key => localStorage.removeItem(key));
25
25
  }
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unvired/react-native-unvired-sdk",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "Unvired SDK for React Native with logging, database, notifications, and file system support",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "peerDependencies": {
15
15
  "@op-engineering/op-sqlite": "^15.2.5",
16
- "@react-native-async-storage/async-storage": "^2.2.0",
16
+ "react-native-mmkv": "*",
17
17
  "@react-native-firebase/messaging": "^21.8.1",
18
18
  "react": ">=18",
19
19
  "react-native": ">=0.73",
@@ -34,6 +34,9 @@
34
34
  "@react-native-async-storage/async-storage": {
35
35
  "optional": true
36
36
  },
37
+ "react-native-mmkv": {
38
+ "optional": true
39
+ },
37
40
  "react-native-device-info": {
38
41
  "optional": true
39
42
  },
@@ -47,6 +50,7 @@
47
50
  "devDependencies": {
48
51
  "@op-engineering/op-sqlite": "^15.2.5",
49
52
  "@react-native-async-storage/async-storage": "^2.2.0",
53
+ "react-native-mmkv": "^4.3.2",
50
54
  "@react-native-firebase/messaging": "^21.8.1",
51
55
  "@types/pako": "^2.0.4",
52
56
  "@types/react": ">=18",
@@ -66,4 +70,4 @@
66
70
  "publishConfig": {
67
71
  "access": "public"
68
72
  }
69
- }
73
+ }