react-native-mmkv 2.4.4 → 2.5.1

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.
@@ -45,7 +45,7 @@ interface MMKVInterface {
45
45
  /**
46
46
  * Set a value for the given `key`.
47
47
  */
48
- set: (key: string, value: boolean | string | number) => void;
48
+ set: (key: string, value: boolean | string | number | Uint8Array) => void;
49
49
  /**
50
50
  * Get the boolean value for the given `key`, or `undefined` if it does not exist.
51
51
  *
@@ -64,6 +64,12 @@ interface MMKVInterface {
64
64
  * @default undefined
65
65
  */
66
66
  getNumber: (key: string) => number | undefined;
67
+ /**
68
+ * Get a raw buffer of unsigned 8-bit (0-255) data.
69
+ *
70
+ * @default undefined
71
+ */
72
+ getBuffer: (key: string) => Uint8Array | undefined;
67
73
  /**
68
74
  * Checks whether the given `key` is being stored in this MMKV instance.
69
75
  */
@@ -98,7 +104,7 @@ interface MMKVInterface {
98
104
  */
99
105
  addOnValueChangedListener: (onValueChanged: (key: string) => void) => Listener;
100
106
  }
101
- export declare type NativeMMKV = Pick<MMKVInterface, 'clearAll' | 'contains' | 'delete' | 'getAllKeys' | 'getBoolean' | 'getNumber' | 'getString' | 'set' | 'recrypt'>;
107
+ export declare type NativeMMKV = Pick<MMKVInterface, 'clearAll' | 'contains' | 'delete' | 'getAllKeys' | 'getBoolean' | 'getNumber' | 'getString' | 'getBuffer' | 'set' | 'recrypt'>;
102
108
  /**
103
109
  * A single MMKV instance.
104
110
  */
@@ -114,10 +120,11 @@ export declare class MMKV implements MMKVInterface {
114
120
  private get onValueChangedListeners();
115
121
  private getFunctionFromCache;
116
122
  private onValuesChanged;
117
- set(key: string, value: boolean | string | number): void;
123
+ set(key: string, value: boolean | string | number | Uint8Array): void;
118
124
  getBoolean(key: string): boolean | undefined;
119
125
  getString(key: string): string | undefined;
120
126
  getNumber(key: string): number | undefined;
127
+ getBuffer(key: string): Uint8Array | undefined;
121
128
  contains(key: string): boolean;
122
129
  delete(key: string): void;
123
130
  getAllKeys(): string[];
@@ -0,0 +1 @@
1
+ export declare function createTextEncoder(): TextEncoder;
@@ -41,6 +41,17 @@ export declare const useMMKVNumber: (key: string, instance?: MMKV | undefined) =
41
41
  * ```
42
42
  */
43
43
  export declare const useMMKVBoolean: (key: string, instance?: MMKV | undefined) => [value: boolean | undefined, setValue: (value: boolean | ((current: boolean | undefined) => boolean | undefined) | undefined) => void];
44
+ /**
45
+ * Use the buffer value (unsigned 8-bit (0-255)) of the given `key` from the given MMKV storage instance.
46
+ *
47
+ * If no instance is provided, a shared default instance will be used.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const [privateKey, setPrivateKey] = useMMKVBuffer("user.privateKey")
52
+ * ```
53
+ */
54
+ export declare const useMMKVBuffer: (key: string, instance?: MMKV | undefined) => [value: Uint8Array | undefined, setValue: (value: Uint8Array | ((current: Uint8Array | undefined) => Uint8Array | undefined) | undefined) => void];
44
55
  /**
45
56
  * Use an object value of the given `key` from the given MMKV storage instance.
46
57
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mmkv",
3
- "version": "2.4.4",
3
+ "version": "2.5.1",
4
4
  "description": "The fastest key/value storage for React Native. ~30x faster than AsyncStorage! Works on Android, iOS and Web.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -12,6 +12,7 @@
12
12
  "android/build.gradle",
13
13
  "android/gradle.properties",
14
14
  "android/CMakeLists.txt",
15
+ "cpp",
15
16
  "MMKV/Core",
16
17
  "lib/commonjs",
17
18
  "lib/module",
@@ -17,7 +17,8 @@ Pod::Spec.new do |s|
17
17
  # Note how this does not include headers, since those can nameclash.
18
18
  s.source_files = [
19
19
  "ios/**/*.{m,mm}",
20
- "ios/MmkvModule.h"
20
+ "ios/MmkvModule.h",
21
+ "cpp/**/*.{h,cpp}"
21
22
  ]
22
23
  # Any private headers that are not globally unique should be mentioned here.
23
24
  # Otherwise there will be a nameclash, since CocoaPods flattens out any header directories