react-native-mmkv 3.0.0-beta.1 → 3.0.0-beta.3
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/MMKV/Core/CMakeLists.txt +12 -4
- package/MMKV/Core/Core.xcodeproj/project.pbxproj +13 -4
- package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +1 -1
- package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +1 -1
- package/MMKV/Core/MMKV.cpp +3 -4
- package/MMKV/Core/MMKVLog_Android.cpp +56 -1
- package/MMKV/Core/MMKVPredef.h +8 -1
- package/MMKV/Core/MMKV_Android.cpp +3 -3
- package/MMKV/Core/MMKV_IO.cpp +1 -1
- package/MMKV/Core/MemoryFile.cpp +33 -2
- package/MMKV/Core/MemoryFile.h +1 -0
- package/MMKV/Core/MemoryFile_Android.cpp +13 -3
- package/MMKV/Core/MemoryFile_Linux.cpp +8 -3
- package/MMKV/Core/MemoryFile_Win32.cpp +3 -3
- package/MMKV/Core/ThreadLock.cpp +9 -5
- package/MMKV/Core/ThreadLock.h +2 -3
- package/MMKV/Core/aes/AESCrypt.h +1 -0
- package/MMKV/Core/aes/openssl/openssl_aes.h +12 -0
- package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +4 -4
- package/MMKV/Core/core.vcxproj +102 -0
- package/MMKV/Core/crc32/Checksum.h +5 -0
- package/MMKV/Core/crc32/crc32_armv8.cpp +3 -1
- package/MMKV/Core/crc32/zlib/CMakeLists.txt +60 -0
- package/MMKV/LICENSE.TXT +193 -0
- package/MMKV/README.md +74 -10
- package/README.md +40 -8
- package/cpp/MMKVManagedBuffer.h +1 -6
- package/cpp/MmkvHostObject.cpp +1 -0
- package/cpp/MmkvHostObject.h +1 -6
- package/cpp/NativeMmkvModule.cpp +9 -6
- package/lib/commonjs/LazyTurboModule.js +66 -0
- package/lib/commonjs/LazyTurboModule.js.map +1 -0
- package/lib/commonjs/MMKV.js +5 -11
- 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/PlatformChecker.js +3 -3
- package/lib/commonjs/PlatformChecker.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 +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/LazyTurboModule.js +60 -0
- package/lib/module/LazyTurboModule.js.map +1 -0
- package/lib/module/MMKV.js +6 -13
- 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/PlatformChecker.js +2 -2
- package/lib/module/PlatformChecker.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 +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/LazyTurboModule.d.ts +9 -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/PlatformChecker.d.ts +1 -1
- package/lib/typescript/src/PlatformChecker.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 +1 -0
- 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 +98 -0
- package/src/MMKV.ts +7 -98
- package/src/NativeMmkv.ts +19 -46
- package/src/NativeMmkvPlatformContext.ts +5 -3
- package/src/PlatformChecker.ts +4 -2
- 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.ts +4 -0
- package/src/index.tsx +0 -2
package/lib/module/MMKV.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { AppState } from 'react-native';
|
|
2
2
|
import { createMMKV } from './createMMKV';
|
|
3
3
|
import { createMockMMKV } from './createMMKV.mock';
|
|
4
|
-
import {
|
|
4
|
+
import { isTest } from './PlatformChecker';
|
|
5
5
|
export { Configuration, Mode } from './NativeMmkv';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents a single MMKV instance.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
6
|
const onValueChangedListeners = new Map();
|
|
12
7
|
|
|
13
8
|
/**
|
|
@@ -22,14 +17,12 @@ export class MMKV {
|
|
|
22
17
|
id: 'mmkv.default'
|
|
23
18
|
}) {
|
|
24
19
|
this.id = configuration.id;
|
|
25
|
-
this.nativeInstance =
|
|
20
|
+
this.nativeInstance = isTest() ? createMockMMKV() : createMMKV(configuration);
|
|
26
21
|
this.functionCache = {};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
}
|
|
22
|
+
AppState.addEventListener('memoryWarning', () => {
|
|
23
|
+
// when we have a memory warning, delete unused keys by trimming MMKV
|
|
24
|
+
this.trim();
|
|
25
|
+
});
|
|
33
26
|
}
|
|
34
27
|
get onValueChangedListeners() {
|
|
35
28
|
if (!onValueChangedListeners.has(this.id)) {
|
package/lib/module/MMKV.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AppState","createMMKV","createMockMMKV","
|
|
1
|
+
{"version":3,"names":["AppState","createMMKV","createMockMMKV","isTest","Configuration","Mode","onValueChangedListeners","Map","MMKV","constructor","configuration","id","nativeInstance","functionCache","addEventListener","trim","has","set","get","getFunctionFromCache","functionName","onValuesChanged","keys","length","key","listener","size","value","func","getBoolean","getString","getNumber","getBuffer","contains","delete","getAllKeys","clearAll","recrypt","toString","join","toJSON","addOnValueChangedListener","onValueChanged","push","remove","index","indexOf","splice"],"sourceRoot":"../../src","sources":["MMKV.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AAG1C,SAASC,aAAa,EAAEC,IAAI,QAAQ,cAAc;AAElD,MAAMC,uBAAuB,GAAG,IAAIC,GAAG,CAAoC,CAAC;;AAE5E;AACA;AACA;AACA,OAAO,MAAMC,IAAI,CAA0B;EAKzC;AACF;AACA;AACA;EACEC,WAAWA,CAACC,aAA4B,GAAG;IAAEC,EAAE,EAAE;EAAe,CAAC,EAAE;IACjE,IAAI,CAACA,EAAE,GAAGD,aAAa,CAACC,EAAE;IAC1B,IAAI,CAACC,cAAc,GAAGT,MAAM,CAAC,CAAC,GAC1BD,cAAc,CAAC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,eAAe,CAACC,IAAI,CAAC;EAC5B;EACAe,OAAOA,CAACb,GAAuB,EAAQ;IACrC,MAAMI,IAAI,GAAG,IAAI,CAACT,oBAAoB,CAAC,SAAS,CAAC;IACjD,OAAOS,IAAI,CAACJ,GAAG,CAAC;EAClB;EACAT,IAAIA,CAAA,EAAS;IACX,MAAMa,IAAI,GAAG,IAAI,CAACT,oBAAoB,CAAC,MAAM,CAAC;IAC9CS,IAAI,CAAC,CAAC;EACR;EAEAU,QAAQA,CAAA,EAAW;IACjB,OAAQ,SAAQ,IAAI,CAAC3B,EAAG,OAAM,IAAI,CAACwB,UAAU,CAAC,CAAC,CAACI,IAAI,CAAC,IAAI,CAAE,GAAE;EAC/D;EACAC,MAAMA,CAAA,EAAW;IACf,OAAO;MACL,CAAC,IAAI,CAAC7B,EAAE,GAAG,IAAI,CAACwB,UAAU,CAAC;IAC7B,CAAC;EACH;EAEAM,yBAAyBA,CAACC,cAAqC,EAAY;IACzE,IAAI,CAACpC,uBAAuB,CAACqC,IAAI,CAACD,cAAc,CAAC;IAEjD,OAAO;MACLE,MAAM,EAAEA,CAAA,KAAM;QACZ,MAAMC,KAAK,GAAG,IAAI,CAACvC,uBAAuB,CAACwC,OAAO,CAACJ,cAAc,CAAC;QAClE,IAAIG,KAAK,KAAK,CAAC,CAAC,EAAE;UAChB,IAAI,CAACvC,uBAAuB,CAACyC,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;QAC/C;MACF;IACF,CAAC;EACH;AACF","ignoreList":[]}
|
package/lib/module/NativeMmkv.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NativeModules, Platform } from 'react-native';
|
|
2
1
|
import { TurboModuleRegistry } from 'react-native';
|
|
2
|
+
import { getLazyTurboModule } from './LazyTurboModule';
|
|
3
3
|
import { PlatformContext } from './NativeMmkvPlatformContext';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -15,49 +15,18 @@ export let Mode = /*#__PURE__*/function (Mode) {
|
|
|
15
15
|
* Used for configuration of a single MMKV instance.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
let module = null;
|
|
19
18
|
let basePath = null;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (module
|
|
27
|
-
//
|
|
28
|
-
module = TurboModuleRegistry.get('MmkvCxx');
|
|
29
|
-
if (module == null) {
|
|
30
|
-
// if it still is null, something went wrong!
|
|
31
|
-
let message = 'Failed to create a new MMKV instance: The native MMKV Module could not be found.';
|
|
32
|
-
message += '\n* Make sure react-native-mmkv is correctly autolinked (run `npx react-native config` to verify)';
|
|
33
|
-
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
|
|
34
|
-
message += '\n* Make sure you ran `pod install` in the ios/ directory.';
|
|
35
|
-
}
|
|
36
|
-
if (Platform.OS === 'android') {
|
|
37
|
-
message += '\n* Make sure gradle is synced.';
|
|
38
|
-
}
|
|
39
|
-
// check if Expo
|
|
40
|
-
const ExpoConstants = NativeModules.NativeUnimoduleProxy?.modulesConstants?.ExponentConstants;
|
|
41
|
-
if (ExpoConstants != null) {
|
|
42
|
-
if (ExpoConstants.appOwnership === 'expo') {
|
|
43
|
-
// We're running Expo Go
|
|
44
|
-
throw new Error('react-native-mmkv is not supported in Expo Go! Use EAS (`expo prebuild`) or eject to a bare workflow instead.');
|
|
45
|
-
} else {
|
|
46
|
-
// We're running Expo bare / standalone
|
|
47
|
-
message += '\n* Make sure you ran `expo prebuild`.';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
message += '\n* Make sure you rebuilt the app.';
|
|
51
|
-
throw new Error(message);
|
|
52
|
-
}
|
|
53
|
-
if (basePath == null) {
|
|
54
|
-
// Get base path from platform specific context
|
|
55
|
-
basePath = PlatformContext.getBaseDirectory();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Initialize MMKV
|
|
19
|
+
function getNativeModule() {
|
|
20
|
+
if (basePath == null) {
|
|
21
|
+
// use default base path from the Platform (iOS/Android)
|
|
22
|
+
basePath = PlatformContext.getBaseDirectory();
|
|
23
|
+
}
|
|
24
|
+
const module = TurboModuleRegistry.get('MmkvCxx');
|
|
25
|
+
if (module != null) {
|
|
26
|
+
// initialize MMKV
|
|
59
27
|
module.initialize(basePath);
|
|
60
28
|
}
|
|
61
29
|
return module;
|
|
62
30
|
}
|
|
31
|
+
export const MMKVTurboModule = getLazyTurboModule(getNativeModule);
|
|
63
32
|
//# sourceMappingURL=NativeMmkv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getLazyTurboModule","PlatformContext","Mode","basePath","getNativeModule","getBaseDirectory","module","get","initialize","MMKVTurboModule"],"sourceRoot":"../../src","sources":["NativeMmkv.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,SAASC,kBAAkB,QAAQ,mBAAmB;AACtD,SAASC,eAAe,QAAQ,6BAA6B;;AAE7D;AACA;AACA;AACA,WAAYC,IAAI,0BAAJA,IAAI;EAAJA,IAAI,CAAJA,IAAI;EAAJA,IAAI,CAAJA,IAAI;EAAA,OAAJA,IAAI;AAAA;;AAWhB;AACA;AACA;;AAiEA,IAAIC,QAAuB,GAAG,IAAI;AAElC,SAASC,eAAeA,CAAA,EAAgB;EACtC,IAAID,QAAQ,IAAI,IAAI,EAAE;IACpB;IACAA,QAAQ,GAAGF,eAAe,CAACI,gBAAgB,CAAC,CAAC;EAC/C;EAEA,MAAMC,MAAM,GAAGP,mBAAmB,CAACQ,GAAG,CAAO,SAAS,CAAC;EAEvD,IAAID,MAAM,IAAI,IAAI,EAAE;IAClB;IACAA,MAAM,CAACE,UAAU,CAACL,QAAQ,CAAC;EAC7B;EAEA,OAAOG,MAAM;AACf;AACA,OAAO,MAAMG,eAAe,GAAGT,kBAAkB,CAACI,eAAe,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { TurboModuleRegistry } from 'react-native';
|
|
2
|
-
|
|
2
|
+
import { getLazyTurboModule } from './LazyTurboModule';
|
|
3
|
+
function getModule() {
|
|
4
|
+
return TurboModuleRegistry.get('MmkvPlatformContext');
|
|
5
|
+
}
|
|
6
|
+
export const PlatformContext = getLazyTurboModule(getModule);
|
|
3
7
|
//# sourceMappingURL=NativeMmkvPlatformContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getLazyTurboModule","getModule","get","PlatformContext"],"sourceRoot":"../../src","sources":["NativeMmkvPlatformContext.ts"],"mappings":"AAAA,SAAsBA,mBAAmB,QAAQ,cAAc;AAC/D,SAASC,kBAAkB,QAAQ,mBAAmB;AAStD,SAASC,SAASA,CAAA,EAAgB;EAChC,OAAOF,mBAAmB,CAACG,GAAG,CAAO,qBAAqB,CAAC;AAC7D;AACA,OAAO,MAAMC,eAAe,GAAGH,kBAAkB,CAACC,SAAS,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function isTest() {
|
|
2
2
|
if (global.process == null) {
|
|
3
3
|
// In a WebBrowser/Electron the `process` variable does not exist
|
|
4
4
|
return false;
|
|
5
5
|
}
|
|
6
|
-
return process.env.JEST_WORKER_ID != null;
|
|
6
|
+
return process.env.JEST_WORKER_ID != null || process.env.VITEST_WORKER_ID != null;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=PlatformChecker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isTest","global","process","env","JEST_WORKER_ID","VITEST_WORKER_ID"],"sourceRoot":"../../src","sources":["PlatformChecker.ts"],"mappings":"AAAA,OAAO,SAASA,MAAMA,CAAA,EAAY;EAChC,IAAIC,MAAM,CAACC,OAAO,IAAI,IAAI,EAAE;IAC1B;IACA,OAAO,KAAK;EACd;EACA,OACEA,OAAO,CAACC,GAAG,CAACC,cAAc,IAAI,IAAI,IAAIF,OAAO,CAACC,GAAG,CAACE,gBAAgB,IAAI,IAAI;AAE9E","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["Types.ts"],"mappings":"","ignoreList":[]}
|
package/lib/module/createMMKV.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const module = getMMKVTurboModule();
|
|
1
|
+
import { MMKVTurboModule } from './NativeMmkv';
|
|
3
2
|
export const createMMKV = config => {
|
|
4
|
-
const instance =
|
|
3
|
+
const instance = MMKVTurboModule.createMMKV(config);
|
|
5
4
|
if (__DEV__) {
|
|
6
5
|
if (typeof instance !== 'object' || instance == null) {
|
|
7
6
|
throw new Error('Failed to create MMKV instance - an unknown object was returned by createMMKV(..)!');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["MMKVTurboModule","createMMKV","config","instance","__DEV__","Error"],"sourceRoot":"../../src","sources":["createMMKV.ts"],"mappings":"AACA,SAASA,eAAe,QAAQ,cAAc;AAG9C,OAAO,MAAMC,UAAU,GAAIC,MAAqB,IAAiB;EAC/D,MAAMC,QAAQ,GAAGH,eAAe,CAACC,UAAU,CAACC,MAAM,CAAC;EACnD,IAAIE,OAAO,EAAE;IACX,IAAI,OAAOD,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,IAAI,IAAI,EAAE;MACpD,MAAM,IAAIE,KAAK,CACb,oFACF,CAAC;IACH;EACF;EACA,OAAOF,QAAQ;AACjB,CAAC","ignoreList":[]}
|
|
@@ -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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AC;MACjD,IAAIG,KAAK,IAAI,IAAI,EAAE,OAAOsB,SAAS;MACnC,OAAOtB,KAAK,KAAK,MAAM;IACzB,CAAC;IACD0B,SAAS,EAAG7B,GAAG,IAAK;MAClB,MAAMG,KAAK,GAAGL,OAAO,CAAC,CAAC,CAACC,OAAO,CAACqB,WAAW,CAACpB,GAAG,CAAC,CAAC;MACjD,IAAIG,KAAK,IAAI,IAAI,EAAE,OAAOsB,SAAS;MACnC,OAAOT,WAAW,CAACc,MAAM,CAAC3B,KAAK,CAAC;IAClC,CAAC;IACD4B,UAAU,EAAEA,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
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.
|
|
1
|
+
{"version":3,"names":["Mode","Configuration"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,SAAS;AAEvB,SAASA,IAAI,EAAEC,aAAa,QAAQ,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TurboModule } from 'react-native';
|
|
2
|
+
declare global {
|
|
3
|
+
var __turboModuleProxy: unknown | undefined;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Lazily get a TurboModule by wrapping it in a Proxy.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLazyTurboModule<T extends TurboModule>(initializeTurboModule: () => T | null): T;
|
|
9
|
+
//# sourceMappingURL=LazyTurboModule.d.ts.map
|
|
@@ -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;AAEpE,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,kBAAkB,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7C;AAQD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,WAAW,EACtD,qBAAqB,EAAE,MAAM,CAAC,GAAG,IAAI,GACpC,CAAC,CA+EH"}
|
|
@@ -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,aAAa,EAAc,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAInD;;GAEG;AACH,qBAAa,IAAK,YAAW,aAAa;IACxC,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,EAAE,CAAS;IAEnB;;;OAGG;gBACS,aAAa,GAAE,aAAsC;IAajE,OAAO,KAAK,uBAAuB,GAKlC;IAED,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,eAAe;IAUvB,IAAI,IAAI,IAAI,MAAM,CAEjB;IACD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,IAAI;IAMtE,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI5C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI1C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI1C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI/C,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI9B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMzB,UAAU,IAAI,MAAM,EAAE;IAItB,QAAQ,IAAI,IAAI;IAQhB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAItC,IAAI,IAAI,IAAI;IAKZ,QAAQ,IAAI,MAAM;IAGlB,MAAM,IAAI,MAAM;IAMhB,yBAAyB,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,QAAQ;CAY3E"}
|
|
@@ -68,12 +68,16 @@ export interface Configuration {
|
|
|
68
68
|
mode?: Mode;
|
|
69
69
|
}
|
|
70
70
|
export interface Spec extends TurboModule {
|
|
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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function isTest(): boolean;
|
|
2
2
|
//# sourceMappingURL=PlatformChecker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformChecker.d.ts","sourceRoot":"","sources":["../../../src/PlatformChecker.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"PlatformChecker.d.ts","sourceRoot":"","sources":["../../../src/PlatformChecker.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,IAAI,OAAO,CAQhC"}
|
|
@@ -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;AAExB,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,cAAc,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.3",
|
|
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": "^14.0.0-alpha.4",
|
|
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.4"
|
|
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
|
}
|