react-native-mmkv 3.0.0-beta.1 → 3.0.0-beta.2
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/README.md +28 -3
- package/cpp/MMKVManagedBuffer.h +1 -6
- package/cpp/MmkvHostObject.h +1 -6
- package/cpp/NativeMmkvModule.cpp +7 -1
- package/lib/commonjs/LazyTurboModule.js +49 -0
- package/lib/commonjs/LazyTurboModule.js.map +1 -0
- package/lib/commonjs/MMKV.js +4 -10
- package/lib/commonjs/MMKV.js.map +1 -1
- package/lib/commonjs/NativeMmkv.js +13 -44
- package/lib/commonjs/NativeMmkv.js.map +1 -1
- package/lib/commonjs/NativeMmkvPlatformContext.js +5 -1
- package/lib/commonjs/NativeMmkvPlatformContext.js.map +1 -1
- package/lib/commonjs/Types.js +2 -0
- package/lib/commonjs/Types.js.map +1 -0
- package/lib/commonjs/createMMKV.js +1 -2
- package/lib/commonjs/createMMKV.js.map +1 -1
- package/lib/commonjs/createMMKV.web.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/LazyTurboModule.js +43 -0
- package/lib/module/LazyTurboModule.js.map +1 -0
- package/lib/module/MMKV.js +4 -11
- package/lib/module/MMKV.js.map +1 -1
- package/lib/module/NativeMmkv.js +10 -41
- package/lib/module/NativeMmkv.js.map +1 -1
- package/lib/module/NativeMmkvPlatformContext.js +5 -1
- package/lib/module/NativeMmkvPlatformContext.js.map +1 -1
- package/lib/module/Types.js +2 -0
- package/lib/module/Types.js.map +1 -0
- package/lib/module/createMMKV.js +2 -3
- package/lib/module/createMMKV.js.map +1 -1
- package/lib/module/createMMKV.web.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/LazyTurboModule.d.ts +6 -0
- package/lib/typescript/src/LazyTurboModule.d.ts.map +1 -0
- package/lib/typescript/src/MMKV.d.ts +1 -85
- package/lib/typescript/src/MMKV.d.ts.map +1 -1
- package/lib/typescript/src/NativeMmkv.d.ts +9 -5
- package/lib/typescript/src/NativeMmkv.d.ts.map +1 -1
- package/lib/typescript/src/NativeMmkvPlatformContext.d.ts.map +1 -1
- package/lib/typescript/src/Types.d.ts +86 -0
- package/lib/typescript/src/Types.d.ts.map +1 -0
- package/lib/typescript/src/createMMKV.d.ts +2 -1
- package/lib/typescript/src/createMMKV.d.ts.map +1 -1
- package/lib/typescript/src/createMMKV.mock.d.ts +1 -1
- package/lib/typescript/src/createMMKV.mock.d.ts.map +1 -1
- package/lib/typescript/src/createMMKV.web.d.ts +2 -1
- package/lib/typescript/src/createMMKV.web.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +17 -14
- package/react-native.config.js +20 -0
- package/src/LazyTurboModule.ts +62 -0
- package/src/MMKV.ts +5 -96
- package/src/NativeMmkv.ts +19 -46
- package/src/NativeMmkvPlatformContext.ts +5 -3
- package/src/Types.ts +89 -0
- package/src/__tests__/hooks.test.tsx +1 -0
- package/src/createMMKV.mock.ts +1 -1
- package/src/createMMKV.ts +4 -5
- package/src/createMMKV.web.ts +2 -1
- /package/src/{index.tsx → index.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createTextEncoder","canUseDOM","window","document","createElement","hasAccessToLocalStorage","localStorage","KEY_WILDCARD","inMemoryStorage","Map","createMMKV","config","encryptionKey","Error","path","console","warn","storage","getItem","key","get","setItem","value","set","removeItem","delete","clear","length","size","index","Object","keys","at","domStorage","global","textEncoder","id","includes","keyPrefix","prefixedKey","clearAll","startsWith","toString","getString","undefined","getNumber","Number","getBoolean","getBuffer","encode","getAllKeys","filter","map","slice","contains","recrypt","trim"],"sourceRoot":"../../src","sources":["createMMKV.web.ts"],"mappings":"AAAA;;
|
|
1
|
+
{"version":3,"names":["createTextEncoder","canUseDOM","window","document","createElement","hasAccessToLocalStorage","localStorage","KEY_WILDCARD","inMemoryStorage","Map","createMMKV","config","encryptionKey","Error","path","console","warn","storage","getItem","key","get","setItem","value","set","removeItem","delete","clear","length","size","index","Object","keys","at","domStorage","global","textEncoder","id","includes","keyPrefix","prefixedKey","clearAll","startsWith","toString","getString","undefined","getNumber","Number","getBoolean","getBuffer","encode","getAllKeys","filter","map","slice","contains","recrypt","trim"],"sourceRoot":"../../src","sources":["createMMKV.web.ts"],"mappings":"AAAA;;AAGA,SAASA,iBAAiB,QAAQ,qBAAqB;AAEvD,MAAMC,SAAS,GACb,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,QAAQ,EAAEC,aAAa,IAAI,IAAI;AAEzE,MAAMC,uBAAuB,GAAGA,CAAA,KAAM;EACpC,IAAI;IACF;IACAH,MAAM,CAACI,YAAY;IAEnB,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF,CAAC;AAED,MAAMC,YAAY,GAAG,IAAI;AACzB,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEjD,OAAO,MAAMC,UAAU,GAAIC,MAAqB,IAAiB;EAC/D,IAAIA,MAAM,CAACC,aAAa,IAAI,IAAI,EAAE;IAChC,MAAM,IAAIC,KAAK,CAAC,gDAAgD,CAAC;EACnE;EACA,IAAIF,MAAM,CAACG,IAAI,IAAI,IAAI,EAAE;IACvB,MAAM,IAAID,KAAK,CAAC,uCAAuC,CAAC;EAC1D;;EAEA;EACA,IAAI,CAACR,uBAAuB,CAAC,CAAC,IAAIJ,SAAS,EAAE;IAC3Cc,OAAO,CAACC,IAAI,CACV,6FACF,CAAC;EACH;EAEA,MAAMC,OAAO,GAAGA,CAAA,KAAM;IACpB,IAAI,CAAChB,SAAS,EAAE;MACd,MAAM,IAAIY,KAAK,CACb,kFACF,CAAC;IACH;IAEA,IAAI,CAACR,uBAAuB,CAAC,CAAC,EAAE;MAC9B,OAAO;QACLa,OAAO,EAAGC,GAAW,IAAKX,eAAe,CAACY,GAAG,CAACD,GAAG,CAAC,IAAI,IAAI;QAC1DE,OAAO,EAAEA,CAACF,GAAW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,CAAA,KAAM;MAChB,MAAMnB,IAAI,GAAGD,MAAM,CAACC,IAAI,CAACd,OAAO,CAAC,CAAC,CAAC;MACnC,OAAOc,IAAI,CACRoB,MAAM,CAAEhC,GAAG,IAAKA,GAAG,CAACsB,UAAU,CAACH,SAAS,CAAC,CAAC,CAC1Cc,GAAG,CAAEjC,GAAG,IAAKA,GAAG,CAACkC,KAAK,CAACf,SAAS,CAACX,MAAM,CAAC,CAAC;IAC9C,CAAC;IACD2B,QAAQ,EAAGnC,GAAG,IAAKF,OAAO,CAAC,CAAC,CAACC,OAAO,CAACqB,WAAW,CAACpB,GAAG,CAAC,CAAC,IAAI,IAAI;IAC9DoC,OAAO,EAAEA,CAAA,KAAM;MACb,MAAM,IAAI1C,KAAK,CAAC,wCAAwC,CAAC;IAC3D,CAAC;IACDe,IAAI,EAAE,CAAC;IACP4B,IAAI,EAAEA,CAAA,KAAM;MACV;IAAA;EAEJ,CAAC;AACH,CAAC","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LazyTurboModule.d.ts","sourceRoot":"","sources":["../../../src/LazyTurboModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,WAAW,EAAE,MAAM,cAAc,CAAC;AAMpE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,WAAW,EACtD,qBAAqB,EAAE,MAAM,CAAC,GAAG,IAAI,GACpC,CAAC,CAkDH"}
|
|
@@ -1,90 +1,6 @@
|
|
|
1
1
|
import { Configuration } from './NativeMmkv';
|
|
2
|
+
import { Listener, MMKVInterface } from './Types';
|
|
2
3
|
export { Configuration, Mode } from './NativeMmkv';
|
|
3
|
-
interface Listener {
|
|
4
|
-
remove: () => void;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Represents a single MMKV instance.
|
|
8
|
-
*/
|
|
9
|
-
export interface NativeMMKV {
|
|
10
|
-
/**
|
|
11
|
-
* Set a value for the given `key`.
|
|
12
|
-
*/
|
|
13
|
-
set: (key: string, value: boolean | string | number | ArrayBuffer) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Get the boolean value for the given `key`, or `undefined` if it does not exist.
|
|
16
|
-
*
|
|
17
|
-
* @default undefined
|
|
18
|
-
*/
|
|
19
|
-
getBoolean: (key: string) => boolean | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Get the string value for the given `key`, or `undefined` if it does not exist.
|
|
22
|
-
*
|
|
23
|
-
* @default undefined
|
|
24
|
-
*/
|
|
25
|
-
getString: (key: string) => string | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Get the number value for the given `key`, or `undefined` if it does not exist.
|
|
28
|
-
*
|
|
29
|
-
* @default undefined
|
|
30
|
-
*/
|
|
31
|
-
getNumber: (key: string) => number | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Get a raw buffer of unsigned 8-bit (0-255) data.
|
|
34
|
-
*
|
|
35
|
-
* @default undefined
|
|
36
|
-
*/
|
|
37
|
-
getBuffer: (key: string) => ArrayBuffer | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Checks whether the given `key` is being stored in this MMKV instance.
|
|
40
|
-
*/
|
|
41
|
-
contains: (key: string) => boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Delete the given `key`.
|
|
44
|
-
*/
|
|
45
|
-
delete: (key: string) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Get all keys.
|
|
48
|
-
*
|
|
49
|
-
* @default []
|
|
50
|
-
*/
|
|
51
|
-
getAllKeys: () => string[];
|
|
52
|
-
/**
|
|
53
|
-
* Delete all keys.
|
|
54
|
-
*/
|
|
55
|
-
clearAll: () => void;
|
|
56
|
-
/**
|
|
57
|
-
* Sets (or updates) the encryption-key to encrypt all data in this MMKV instance with.
|
|
58
|
-
*
|
|
59
|
-
* To remove encryption, pass `undefined` as a key.
|
|
60
|
-
*
|
|
61
|
-
* Encryption keys can have a maximum length of 16 bytes.
|
|
62
|
-
*/
|
|
63
|
-
recrypt: (key: string | undefined) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Trims the storage space and clears memory cache.
|
|
66
|
-
*
|
|
67
|
-
* Since MMKV does not resize itself after deleting keys, you can call `trim()`
|
|
68
|
-
* after deleting a bunch of keys to manually trim the memory- and
|
|
69
|
-
* disk-file to reduce storage and memory usage.
|
|
70
|
-
*
|
|
71
|
-
* In most applications, this is not needed at all.
|
|
72
|
-
*/
|
|
73
|
-
trim(): void;
|
|
74
|
-
/**
|
|
75
|
-
* Get the current total size of the storage, in bytes.
|
|
76
|
-
*/
|
|
77
|
-
readonly size: number;
|
|
78
|
-
}
|
|
79
|
-
interface MMKVInterface extends NativeMMKV {
|
|
80
|
-
/**
|
|
81
|
-
* Adds a value changed listener. The Listener will be called whenever any value
|
|
82
|
-
* in this storage instance changes (set or delete).
|
|
83
|
-
*
|
|
84
|
-
* To unsubscribe from value changes, call `remove()` on the Listener.
|
|
85
|
-
*/
|
|
86
|
-
addOnValueChangedListener: (onValueChanged: (key: string) => void) => Listener;
|
|
87
|
-
}
|
|
88
4
|
/**
|
|
89
5
|
* A single MMKV instance.
|
|
90
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MMKV.d.ts","sourceRoot":"","sources":["../../../src/MMKV.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"MMKV.d.ts","sourceRoot":"","sources":["../../../src/MMKV.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,aA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|
|
71
|
+
/**
|
|
72
|
+
* Initialize MMKV with the given base storage directory.
|
|
73
|
+
* This should be the documents directory by default.
|
|
74
|
+
*/
|
|
71
75
|
initialize(basePath: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Create a new instance of MMKV.
|
|
78
|
+
* The returned {@linkcode UnsafeObject} is a `jsi::HostObject`.
|
|
79
|
+
*/
|
|
72
80
|
createMMKV(configuration: Configuration): UnsafeObject;
|
|
73
81
|
}
|
|
74
|
-
|
|
75
|
-
* Get the MMKV TurboModule, and initialize it if this is the first time calling.
|
|
76
|
-
* This will throw an error if the module cannot be found.
|
|
77
|
-
*/
|
|
78
|
-
export declare function getMMKVTurboModule(): Spec;
|
|
82
|
+
export declare const MMKVTurboModule: Spec;
|
|
79
83
|
//# sourceMappingURL=NativeMmkv.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeMmkv.d.ts","sourceRoot":"","sources":["../../../src/NativeMmkv.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"NativeMmkv.d.ts","sourceRoot":"","sources":["../../../src/NativeMmkv.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAIzE;;GAEG;AACH,oBAAY,IAAI;IACd;;OAEG;IACH,cAAc,IAAA;IACd;;OAEG;IACH,aAAa,IAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;OAUG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACtC;;;OAGG;IACH,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,YAAY,CAAC;CACxD;AAmBD,eAAO,MAAM,eAAe,MAAsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeMmkvPlatformContext.d.ts","sourceRoot":"","sources":["../../../src/NativeMmkvPlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeMmkvPlatformContext.d.ts","sourceRoot":"","sources":["../../../src/NativeMmkvPlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAC;AAGhE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;OAEG;IACH,gBAAgB,IAAI,MAAM,CAAC;CAC5B;AAKD,eAAO,MAAM,eAAe,MAAgC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single MMKV instance.
|
|
3
|
+
*/
|
|
4
|
+
export interface NativeMMKV {
|
|
5
|
+
/**
|
|
6
|
+
* Set a value for the given `key`.
|
|
7
|
+
*/
|
|
8
|
+
set: (key: string, value: boolean | string | number | ArrayBuffer) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Get the boolean value for the given `key`, or `undefined` if it does not exist.
|
|
11
|
+
*
|
|
12
|
+
* @default undefined
|
|
13
|
+
*/
|
|
14
|
+
getBoolean: (key: string) => boolean | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get the string value for the given `key`, or `undefined` if it does not exist.
|
|
17
|
+
*
|
|
18
|
+
* @default undefined
|
|
19
|
+
*/
|
|
20
|
+
getString: (key: string) => string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Get the number value for the given `key`, or `undefined` if it does not exist.
|
|
23
|
+
*
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
getNumber: (key: string) => number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get a raw buffer of unsigned 8-bit (0-255) data.
|
|
29
|
+
*
|
|
30
|
+
* @default undefined
|
|
31
|
+
*/
|
|
32
|
+
getBuffer: (key: string) => ArrayBuffer | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Checks whether the given `key` is being stored in this MMKV instance.
|
|
35
|
+
*/
|
|
36
|
+
contains: (key: string) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Delete the given `key`.
|
|
39
|
+
*/
|
|
40
|
+
delete: (key: string) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Get all keys.
|
|
43
|
+
*
|
|
44
|
+
* @default []
|
|
45
|
+
*/
|
|
46
|
+
getAllKeys: () => string[];
|
|
47
|
+
/**
|
|
48
|
+
* Delete all keys.
|
|
49
|
+
*/
|
|
50
|
+
clearAll: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Sets (or updates) the encryption-key to encrypt all data in this MMKV instance with.
|
|
53
|
+
*
|
|
54
|
+
* To remove encryption, pass `undefined` as a key.
|
|
55
|
+
*
|
|
56
|
+
* Encryption keys can have a maximum length of 16 bytes.
|
|
57
|
+
*/
|
|
58
|
+
recrypt: (key: string | undefined) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Trims the storage space and clears memory cache.
|
|
61
|
+
*
|
|
62
|
+
* Since MMKV does not resize itself after deleting keys, you can call `trim()`
|
|
63
|
+
* after deleting a bunch of keys to manually trim the memory- and
|
|
64
|
+
* disk-file to reduce storage and memory usage.
|
|
65
|
+
*
|
|
66
|
+
* In most applications, this is not needed at all.
|
|
67
|
+
*/
|
|
68
|
+
trim(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get the current total size of the storage, in bytes.
|
|
71
|
+
*/
|
|
72
|
+
readonly size: number;
|
|
73
|
+
}
|
|
74
|
+
export interface Listener {
|
|
75
|
+
remove: () => void;
|
|
76
|
+
}
|
|
77
|
+
export interface MMKVInterface extends NativeMMKV {
|
|
78
|
+
/**
|
|
79
|
+
* Adds a value changed listener. The Listener will be called whenever any value
|
|
80
|
+
* in this storage instance changes (set or delete).
|
|
81
|
+
*
|
|
82
|
+
* To unsubscribe from value changes, call `remove()` on the Listener.
|
|
83
|
+
*/
|
|
84
|
+
addOnValueChangedListener: (onValueChanged: (key: string) => void) => Listener;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/Types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,KAAK,IAAI,CAAC;IAC3E;;;;OAIG;IACH,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAC;IACjD;;;;OAIG;IACH,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC/C;;;;OAIG;IACH,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC/C;;;;OAIG;IACH,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACnC;;OAEG;IACH,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B;;;;OAIG;IACH,UAAU,EAAE,MAAM,MAAM,EAAE,CAAC;IAC3B;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3C;;;;;;;;OAQG;IACH,IAAI,IAAI,IAAI,CAAC;IACb;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C;;;;;OAKG;IACH,yBAAyB,EAAE,CACzB,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,KAClC,QAAQ,CAAC;CACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMMKV.d.ts","sourceRoot":"","sources":["../../../src/createMMKV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createMMKV.d.ts","sourceRoot":"","sources":["../../../src/createMMKV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,UAAU,WAAY,aAAa,KAAG,UAUlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMMKV.mock.d.ts","sourceRoot":"","sources":["../../../src/createMMKV.mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createMMKV.mock.d.ts","sourceRoot":"","sources":["../../../src/createMMKV.mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,eAAO,MAAM,cAAc,QAAO,UAiCjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMMKV.web.d.ts","sourceRoot":"","sources":["../../../src/createMMKV.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createMMKV.web.d.ts","sourceRoot":"","sources":["../../../src/createMMKV.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAoB1C,eAAO,MAAM,UAAU,WAAY,aAAa,KAAG,UAwGlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-mmkv",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
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",
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
"react-native": "src/index",
|
|
9
9
|
"source": "src/index",
|
|
10
10
|
"files": [
|
|
11
|
+
"cpp/**/*.h",
|
|
12
|
+
"cpp/**/*.cpp",
|
|
13
|
+
"MMKV/Core",
|
|
11
14
|
"android/src",
|
|
12
15
|
"android/build.gradle",
|
|
13
16
|
"android/CMakeLists.txt",
|
|
14
17
|
"android/cpp-adapter.cpp",
|
|
15
18
|
"android/gradle.properties",
|
|
16
|
-
"cpp",
|
|
17
|
-
"MMKV/Core",
|
|
18
19
|
"lib/commonjs",
|
|
19
20
|
"lib/module",
|
|
20
21
|
"lib/typescript",
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"ios/**/*.cpp",
|
|
25
26
|
"src",
|
|
26
27
|
"react-native-mmkv.podspec",
|
|
28
|
+
"react-native.config.js",
|
|
27
29
|
"README.md",
|
|
28
30
|
"img/banner-light.png",
|
|
29
31
|
"img/banner-dark.png"
|
|
@@ -69,26 +71,30 @@
|
|
|
69
71
|
"registry": "https://registry.npmjs.org/"
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
72
|
-
"@
|
|
73
|
-
"@
|
|
74
|
+
"@firmnav/eslint-github-actions-formatter": "^1.0.1",
|
|
75
|
+
"@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
|
|
76
|
+
"@react-native-community/cli-types": "^13.6.6",
|
|
77
|
+
"@react-native/eslint-config": "^0.74.81",
|
|
74
78
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
79
|
+
"@testing-library/react-native": "^12.4.3",
|
|
75
80
|
"@types/jest": "^29.5.5",
|
|
76
|
-
"@types/react": "^18.
|
|
81
|
+
"@types/react": "^18.3.1",
|
|
77
82
|
"del-cli": "^5.1.0",
|
|
78
83
|
"eslint": "^8.51.0",
|
|
79
84
|
"eslint-config-prettier": "^9.0.0",
|
|
80
85
|
"eslint-plugin-prettier": "^5.0.1",
|
|
81
86
|
"jest": "^29.7.0",
|
|
82
87
|
"prettier": "^3.0.3",
|
|
83
|
-
"react": "18.
|
|
84
|
-
"react-native": "0.74.0
|
|
88
|
+
"react": "18.3.1",
|
|
89
|
+
"react-native": "0.74.0",
|
|
85
90
|
"react-native-builder-bob": "^0.23.2",
|
|
86
|
-
"
|
|
87
|
-
"
|
|
91
|
+
"react-test-renderer": "18.3.1",
|
|
92
|
+
"release-it": "^17.2.1",
|
|
93
|
+
"typescript": "^5.4.5"
|
|
88
94
|
},
|
|
89
95
|
"resolutions": {
|
|
90
96
|
"@types/react": "^18.2.44",
|
|
91
|
-
"@react-native-community/cli": "^14.0.0-alpha.
|
|
97
|
+
"@react-native-community/cli": "^14.0.0-alpha.2"
|
|
92
98
|
},
|
|
93
99
|
"peerDependencies": {
|
|
94
100
|
"react": "*",
|
|
@@ -191,8 +197,5 @@
|
|
|
191
197
|
"type": "modules",
|
|
192
198
|
"jsSrcsDir": "src"
|
|
193
199
|
},
|
|
194
|
-
"dependencies": {
|
|
195
|
-
"@testing-library/react-native": "^12.4.4"
|
|
196
|
-
},
|
|
197
200
|
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
|
|
198
201
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// https://github.com/react-native-community/cli/blob/main/docs/dependencies.md
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
dependency: {
|
|
5
|
+
platforms: {
|
|
6
|
+
/**
|
|
7
|
+
* @type {import('@react-native-community/cli-types').IOSDependencyParams}
|
|
8
|
+
*/
|
|
9
|
+
ios: {},
|
|
10
|
+
/**
|
|
11
|
+
* @type {import('@react-native-community/cli-types').AndroidDependencyParams}
|
|
12
|
+
*/
|
|
13
|
+
android: {
|
|
14
|
+
cxxModuleCMakeListsModuleName: 'react-native-mmkv',
|
|
15
|
+
cxxModuleCMakeListsPath: `${__dirname}/android/CMakeLists.txt`,
|
|
16
|
+
cxxModuleHeaderName: 'NativeMmkvModule',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { NativeModules, Platform, TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface ModuleHolder<T> {
|
|
4
|
+
module: T | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Lazily get a TurboModule by wrapping it in a Proxy.
|
|
9
|
+
*/
|
|
10
|
+
export function getLazyTurboModule<T extends TurboModule>(
|
|
11
|
+
initializeTurboModule: () => T | null
|
|
12
|
+
): T {
|
|
13
|
+
const proxy = new Proxy<ModuleHolder<T>>(
|
|
14
|
+
{
|
|
15
|
+
module: null,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
get: (target, property) => {
|
|
19
|
+
if (target.module == null) {
|
|
20
|
+
// Target is null, let's initialize it!
|
|
21
|
+
target.module = initializeTurboModule();
|
|
22
|
+
|
|
23
|
+
if (target.module == null) {
|
|
24
|
+
// TurboModule not found, something went wrong!
|
|
25
|
+
let message =
|
|
26
|
+
'Failed to create a new MMKV instance: The native MMKV Module could not be found.';
|
|
27
|
+
message +=
|
|
28
|
+
'\n* Make sure react-native-mmkv is correctly autolinked (run `npx react-native config` to verify)';
|
|
29
|
+
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
|
|
30
|
+
message +=
|
|
31
|
+
'\n* Make sure you ran `pod install` in the ios/ directory.';
|
|
32
|
+
}
|
|
33
|
+
if (Platform.OS === 'android') {
|
|
34
|
+
message += '\n* Make sure gradle is synced.';
|
|
35
|
+
}
|
|
36
|
+
// check if Expo
|
|
37
|
+
const ExpoConstants =
|
|
38
|
+
NativeModules.NativeUnimoduleProxy?.modulesConstants
|
|
39
|
+
?.ExponentConstants;
|
|
40
|
+
if (ExpoConstants != null) {
|
|
41
|
+
if (ExpoConstants.appOwnership === 'expo') {
|
|
42
|
+
// We're running Expo Go
|
|
43
|
+
throw new Error(
|
|
44
|
+
'react-native-mmkv is not supported in Expo Go! Use EAS (`expo prebuild`) or eject to a bare workflow instead.'
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
// We're running Expo bare / standalone
|
|
48
|
+
message += '\n* Make sure you ran `expo prebuild`.';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
message += '\n* Make sure you rebuilt the app.';
|
|
53
|
+
throw new Error(message);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return target.module[property as keyof T];
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
return proxy as unknown as T;
|
|
62
|
+
}
|
package/src/MMKV.ts
CHANGED
|
@@ -3,98 +3,9 @@ import { createMMKV } from './createMMKV';
|
|
|
3
3
|
import { createMockMMKV } from './createMMKV.mock';
|
|
4
4
|
import { isJest } from './PlatformChecker';
|
|
5
5
|
import { Configuration } from './NativeMmkv';
|
|
6
|
+
import { Listener, MMKVInterface, NativeMMKV } from './Types';
|
|
6
7
|
export { Configuration, Mode } from './NativeMmkv';
|
|
7
8
|
|
|
8
|
-
interface Listener {
|
|
9
|
-
remove: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Represents a single MMKV instance.
|
|
14
|
-
*/
|
|
15
|
-
export interface NativeMMKV {
|
|
16
|
-
/**
|
|
17
|
-
* Set a value for the given `key`.
|
|
18
|
-
*/
|
|
19
|
-
set: (key: string, value: boolean | string | number | ArrayBuffer) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Get the boolean value for the given `key`, or `undefined` if it does not exist.
|
|
22
|
-
*
|
|
23
|
-
* @default undefined
|
|
24
|
-
*/
|
|
25
|
-
getBoolean: (key: string) => boolean | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Get the string value for the given `key`, or `undefined` if it does not exist.
|
|
28
|
-
*
|
|
29
|
-
* @default undefined
|
|
30
|
-
*/
|
|
31
|
-
getString: (key: string) => string | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Get the number value for the given `key`, or `undefined` if it does not exist.
|
|
34
|
-
*
|
|
35
|
-
* @default undefined
|
|
36
|
-
*/
|
|
37
|
-
getNumber: (key: string) => number | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Get a raw buffer of unsigned 8-bit (0-255) data.
|
|
40
|
-
*
|
|
41
|
-
* @default undefined
|
|
42
|
-
*/
|
|
43
|
-
getBuffer: (key: string) => ArrayBuffer | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Checks whether the given `key` is being stored in this MMKV instance.
|
|
46
|
-
*/
|
|
47
|
-
contains: (key: string) => boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Delete the given `key`.
|
|
50
|
-
*/
|
|
51
|
-
delete: (key: string) => void;
|
|
52
|
-
/**
|
|
53
|
-
* Get all keys.
|
|
54
|
-
*
|
|
55
|
-
* @default []
|
|
56
|
-
*/
|
|
57
|
-
getAllKeys: () => string[];
|
|
58
|
-
/**
|
|
59
|
-
* Delete all keys.
|
|
60
|
-
*/
|
|
61
|
-
clearAll: () => void;
|
|
62
|
-
/**
|
|
63
|
-
* Sets (or updates) the encryption-key to encrypt all data in this MMKV instance with.
|
|
64
|
-
*
|
|
65
|
-
* To remove encryption, pass `undefined` as a key.
|
|
66
|
-
*
|
|
67
|
-
* Encryption keys can have a maximum length of 16 bytes.
|
|
68
|
-
*/
|
|
69
|
-
recrypt: (key: string | undefined) => void;
|
|
70
|
-
/**
|
|
71
|
-
* Trims the storage space and clears memory cache.
|
|
72
|
-
*
|
|
73
|
-
* Since MMKV does not resize itself after deleting keys, you can call `trim()`
|
|
74
|
-
* after deleting a bunch of keys to manually trim the memory- and
|
|
75
|
-
* disk-file to reduce storage and memory usage.
|
|
76
|
-
*
|
|
77
|
-
* In most applications, this is not needed at all.
|
|
78
|
-
*/
|
|
79
|
-
trim(): void;
|
|
80
|
-
/**
|
|
81
|
-
* Get the current total size of the storage, in bytes.
|
|
82
|
-
*/
|
|
83
|
-
readonly size: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface MMKVInterface extends NativeMMKV {
|
|
87
|
-
/**
|
|
88
|
-
* Adds a value changed listener. The Listener will be called whenever any value
|
|
89
|
-
* in this storage instance changes (set or delete).
|
|
90
|
-
*
|
|
91
|
-
* To unsubscribe from value changes, call `remove()` on the Listener.
|
|
92
|
-
*/
|
|
93
|
-
addOnValueChangedListener: (
|
|
94
|
-
onValueChanged: (key: string) => void
|
|
95
|
-
) => Listener;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
9
|
const onValueChangedListeners = new Map<string, ((key: string) => void)[]>();
|
|
99
10
|
|
|
100
11
|
/**
|
|
@@ -116,12 +27,10 @@ export class MMKV implements MMKVInterface {
|
|
|
116
27
|
: createMMKV(configuration);
|
|
117
28
|
this.functionCache = {};
|
|
118
29
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
}
|
|
30
|
+
AppState.addEventListener('memoryWarning', () => {
|
|
31
|
+
// when we have a memory warning, delete unused keys by trimming MMKV
|
|
32
|
+
this.trim();
|
|
33
|
+
});
|
|
125
34
|
}
|
|
126
35
|
|
|
127
36
|
private get onValueChangedListeners() {
|