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.
Files changed (97) hide show
  1. package/MMKV/Core/CMakeLists.txt +12 -4
  2. package/MMKV/Core/Core.xcodeproj/project.pbxproj +13 -4
  3. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +1 -1
  4. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +1 -1
  5. package/MMKV/Core/MMKV.cpp +3 -4
  6. package/MMKV/Core/MMKVLog_Android.cpp +56 -1
  7. package/MMKV/Core/MMKVPredef.h +8 -1
  8. package/MMKV/Core/MMKV_Android.cpp +3 -3
  9. package/MMKV/Core/MMKV_IO.cpp +1 -1
  10. package/MMKV/Core/MemoryFile.cpp +33 -2
  11. package/MMKV/Core/MemoryFile.h +1 -0
  12. package/MMKV/Core/MemoryFile_Android.cpp +13 -3
  13. package/MMKV/Core/MemoryFile_Linux.cpp +8 -3
  14. package/MMKV/Core/MemoryFile_Win32.cpp +3 -3
  15. package/MMKV/Core/ThreadLock.cpp +9 -5
  16. package/MMKV/Core/ThreadLock.h +2 -3
  17. package/MMKV/Core/aes/AESCrypt.h +1 -0
  18. package/MMKV/Core/aes/openssl/openssl_aes.h +12 -0
  19. package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +4 -4
  20. package/MMKV/Core/core.vcxproj +102 -0
  21. package/MMKV/Core/crc32/Checksum.h +5 -0
  22. package/MMKV/Core/crc32/crc32_armv8.cpp +3 -1
  23. package/MMKV/Core/crc32/zlib/CMakeLists.txt +60 -0
  24. package/MMKV/LICENSE.TXT +193 -0
  25. package/MMKV/README.md +74 -10
  26. package/README.md +40 -8
  27. package/cpp/MMKVManagedBuffer.h +1 -6
  28. package/cpp/MmkvHostObject.cpp +1 -0
  29. package/cpp/MmkvHostObject.h +1 -6
  30. package/cpp/NativeMmkvModule.cpp +9 -6
  31. package/lib/commonjs/LazyTurboModule.js +66 -0
  32. package/lib/commonjs/LazyTurboModule.js.map +1 -0
  33. package/lib/commonjs/MMKV.js +5 -11
  34. package/lib/commonjs/MMKV.js.map +1 -1
  35. package/lib/commonjs/NativeMmkv.js +13 -44
  36. package/lib/commonjs/NativeMmkv.js.map +1 -1
  37. package/lib/commonjs/NativeMmkvPlatformContext.js +5 -1
  38. package/lib/commonjs/NativeMmkvPlatformContext.js.map +1 -1
  39. package/lib/commonjs/PlatformChecker.js +3 -3
  40. package/lib/commonjs/PlatformChecker.js.map +1 -1
  41. package/lib/commonjs/Types.js +2 -0
  42. package/lib/commonjs/Types.js.map +1 -0
  43. package/lib/commonjs/createMMKV.js +1 -2
  44. package/lib/commonjs/createMMKV.js.map +1 -1
  45. package/lib/commonjs/createMMKV.web.js.map +1 -1
  46. package/lib/commonjs/index.js +19 -0
  47. package/lib/commonjs/index.js.map +1 -1
  48. package/lib/module/LazyTurboModule.js +60 -0
  49. package/lib/module/LazyTurboModule.js.map +1 -0
  50. package/lib/module/MMKV.js +6 -13
  51. package/lib/module/MMKV.js.map +1 -1
  52. package/lib/module/NativeMmkv.js +10 -41
  53. package/lib/module/NativeMmkv.js.map +1 -1
  54. package/lib/module/NativeMmkvPlatformContext.js +5 -1
  55. package/lib/module/NativeMmkvPlatformContext.js.map +1 -1
  56. package/lib/module/PlatformChecker.js +2 -2
  57. package/lib/module/PlatformChecker.js.map +1 -1
  58. package/lib/module/Types.js +2 -0
  59. package/lib/module/Types.js.map +1 -0
  60. package/lib/module/createMMKV.js +2 -3
  61. package/lib/module/createMMKV.js.map +1 -1
  62. package/lib/module/createMMKV.web.js.map +1 -1
  63. package/lib/module/index.js +1 -0
  64. package/lib/module/index.js.map +1 -1
  65. package/lib/typescript/src/LazyTurboModule.d.ts +9 -0
  66. package/lib/typescript/src/LazyTurboModule.d.ts.map +1 -0
  67. package/lib/typescript/src/MMKV.d.ts +1 -85
  68. package/lib/typescript/src/MMKV.d.ts.map +1 -1
  69. package/lib/typescript/src/NativeMmkv.d.ts +9 -5
  70. package/lib/typescript/src/NativeMmkv.d.ts.map +1 -1
  71. package/lib/typescript/src/NativeMmkvPlatformContext.d.ts.map +1 -1
  72. package/lib/typescript/src/PlatformChecker.d.ts +1 -1
  73. package/lib/typescript/src/PlatformChecker.d.ts.map +1 -1
  74. package/lib/typescript/src/Types.d.ts +86 -0
  75. package/lib/typescript/src/Types.d.ts.map +1 -0
  76. package/lib/typescript/src/createMMKV.d.ts +2 -1
  77. package/lib/typescript/src/createMMKV.d.ts.map +1 -1
  78. package/lib/typescript/src/createMMKV.mock.d.ts +1 -1
  79. package/lib/typescript/src/createMMKV.mock.d.ts.map +1 -1
  80. package/lib/typescript/src/createMMKV.web.d.ts +2 -1
  81. package/lib/typescript/src/createMMKV.web.d.ts.map +1 -1
  82. package/lib/typescript/src/index.d.ts +1 -0
  83. package/lib/typescript/src/index.d.ts.map +1 -1
  84. package/package.json +17 -14
  85. package/react-native.config.js +20 -0
  86. package/src/LazyTurboModule.ts +98 -0
  87. package/src/MMKV.ts +7 -98
  88. package/src/NativeMmkv.ts +19 -46
  89. package/src/NativeMmkvPlatformContext.ts +5 -3
  90. package/src/PlatformChecker.ts +4 -2
  91. package/src/Types.ts +89 -0
  92. package/src/__tests__/hooks.test.tsx +1 -0
  93. package/src/createMMKV.mock.ts +1 -1
  94. package/src/createMMKV.ts +4 -5
  95. package/src/createMMKV.web.ts +2 -1
  96. package/src/index.ts +4 -0
  97. package/src/index.tsx +0 -2
@@ -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,98 @@
1
+ import { NativeModules, Platform, TurboModule } from 'react-native';
2
+
3
+ declare global {
4
+ // A react-native internal from TurboModuleRegistry.js
5
+ var __turboModuleProxy: unknown | undefined;
6
+ }
7
+
8
+ interface ModuleHolder<T> {
9
+ module: T | null;
10
+ }
11
+
12
+ const BULLET_POINT = '\n* ';
13
+
14
+ /**
15
+ * Lazily get a TurboModule by wrapping it in a Proxy.
16
+ */
17
+ export function getLazyTurboModule<T extends TurboModule>(
18
+ initializeTurboModule: () => T | null
19
+ ): T {
20
+ const proxy = new Proxy<ModuleHolder<T>>(
21
+ {
22
+ module: null,
23
+ },
24
+ {
25
+ get: (target, property) => {
26
+ if (target.module == null) {
27
+ // Target is null, let's initialize it!
28
+ target.module = initializeTurboModule();
29
+
30
+ if (target.module == null) {
31
+ // TurboModule not found, something went wrong!
32
+ if (global.__turboModuleProxy == null) {
33
+ // TurboModules are not available/new arch is not enabled.
34
+ // react-native-mmkv 3.x.x requires new arch (react-native >0.74)
35
+ // react-native-mmkv 2.x.x works on old arch (react-native <0.74)
36
+ throw new Error(
37
+ 'Failed to create a new MMKV instance: react-native-mmkv 3.x.x requires TurboModules, but the new architecture is not enabled!' +
38
+ BULLET_POINT +
39
+ 'Downgrade to react-native-mmkv 2.x.x if you want to stay on the old architecture.' +
40
+ BULLET_POINT +
41
+ 'Enable the new architecture in your app to use react-native-mmkv 3.x.x. (See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md)'
42
+ );
43
+ }
44
+
45
+ const message =
46
+ 'Failed to create a new MMKV instance: The native MMKV Module could not be found.';
47
+ const suggestions: string[] = [];
48
+ suggestions.push(
49
+ 'Make sure react-native-mmkv is correctly autolinked (run `npx react-native config` to verify)'
50
+ );
51
+ suggestions.push(
52
+ 'Make sure you enabled the new architecture (TurboModules) and CodeGen properly generated the react-native-mmkv specs. See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md'
53
+ );
54
+ suggestions.push(
55
+ 'Make sure you are using react-native 0.74.0 or higher, because react-native-mmkv is a C++ TurboModule.'
56
+ );
57
+ suggestions.push('Make sure you rebuilt the app.');
58
+ switch (Platform.OS) {
59
+ case 'ios':
60
+ case 'macos':
61
+ suggestions.push(
62
+ 'Make sure you ran `pod install` in the ios/ directory.'
63
+ );
64
+ break;
65
+ case 'android':
66
+ suggestions.push('Make sure gradle is synced.');
67
+ break;
68
+ default:
69
+ throw new Error(`MMKV is not supported on ${Platform.OS}!`);
70
+ }
71
+ // check if Expo
72
+ const ExpoConstants =
73
+ NativeModules.NativeUnimoduleProxy?.modulesConstants
74
+ ?.ExponentConstants;
75
+ if (ExpoConstants != null) {
76
+ if (ExpoConstants.appOwnership === 'expo') {
77
+ // We're running Expo Go
78
+ throw new Error(
79
+ 'react-native-mmkv is not supported in Expo Go! Use EAS (`expo prebuild`) or eject to a bare workflow instead.'
80
+ );
81
+ } else {
82
+ // We're running Expo bare / standalone
83
+ suggestions.push('Make sure you ran `expo prebuild`.');
84
+ }
85
+ }
86
+
87
+ const error =
88
+ message + BULLET_POINT + suggestions.join(BULLET_POINT);
89
+ throw new Error(error);
90
+ }
91
+ }
92
+
93
+ return target.module[property as keyof T];
94
+ },
95
+ }
96
+ );
97
+ return proxy as unknown as T;
98
+ }
package/src/MMKV.ts CHANGED
@@ -1,100 +1,11 @@
1
1
  import { AppState } from 'react-native';
2
2
  import { createMMKV } from './createMMKV';
3
3
  import { createMockMMKV } from './createMMKV.mock';
4
- import { isJest } from './PlatformChecker';
4
+ import { isTest } 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
  /**
@@ -111,17 +22,15 @@ export class MMKV implements MMKVInterface {
111
22
  */
112
23
  constructor(configuration: Configuration = { id: 'mmkv.default' }) {
113
24
  this.id = configuration.id;
114
- this.nativeInstance = isJest()
25
+ this.nativeInstance = isTest()
115
26
  ? createMockMMKV()
116
27
  : createMMKV(configuration);
117
28
  this.functionCache = {};
118
29
 
119
- if ('WeakRef' in global) {
120
- const weakSelf = new WeakRef(this);
121
- AppState.addEventListener('memoryWarning', () => {
122
- weakSelf.deref()?.trim();
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() {
package/src/NativeMmkv.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { NativeModules, Platform, TurboModule } from 'react-native';
1
+ import { TurboModule } from 'react-native';
2
2
  import { TurboModuleRegistry } from 'react-native';
3
3
  import { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
4
+ import { getLazyTurboModule } from './LazyTurboModule';
4
5
  import { PlatformContext } from './NativeMmkvPlatformContext';
5
6
 
6
7
  /**
@@ -72,61 +73,33 @@ export interface Configuration {
72
73
  }
73
74
 
74
75
  export interface Spec extends TurboModule {
76
+ /**
77
+ * Initialize MMKV with the given base storage directory.
78
+ * This should be the documents directory by default.
79
+ */
75
80
  initialize(basePath: string): boolean;
81
+ /**
82
+ * Create a new instance of MMKV.
83
+ * The returned {@linkcode UnsafeObject} is a `jsi::HostObject`.
84
+ */
76
85
  createMMKV(configuration: Configuration): UnsafeObject;
77
86
  }
78
87
 
79
- let module: Spec | null = null;
80
88
  let basePath: string | null = null;
81
89
 
82
- /**
83
- * Get the MMKV TurboModule, and initialize it if this is the first time calling.
84
- * This will throw an error if the module cannot be found.
85
- */
86
- export function getMMKVTurboModule(): Spec {
87
- if (module == null) {
88
- // try to find the turbomodule
89
- module = TurboModuleRegistry.get<Spec>('MmkvCxx');
90
-
91
- if (module == null) {
92
- // if it still is null, something went wrong!
93
- let message =
94
- 'Failed to create a new MMKV instance: The native MMKV Module could not be found.';
95
- message +=
96
- '\n* Make sure react-native-mmkv is correctly autolinked (run `npx react-native config` to verify)';
97
- if (Platform.OS === 'ios' || Platform.OS === 'macos') {
98
- message += '\n* Make sure you ran `pod install` in the ios/ directory.';
99
- }
100
- if (Platform.OS === 'android') {
101
- message += '\n* Make sure gradle is synced.';
102
- }
103
- // check if Expo
104
- const ExpoConstants =
105
- NativeModules.NativeUnimoduleProxy?.modulesConstants?.ExponentConstants;
106
- if (ExpoConstants != null) {
107
- if (ExpoConstants.appOwnership === 'expo') {
108
- // We're running Expo Go
109
- throw new Error(
110
- 'react-native-mmkv is not supported in Expo Go! Use EAS (`expo prebuild`) or eject to a bare workflow instead.'
111
- );
112
- } else {
113
- // We're running Expo bare / standalone
114
- message += '\n* Make sure you ran `expo prebuild`.';
115
- }
116
- }
117
-
118
- message += '\n* Make sure you rebuilt the app.';
119
- throw new Error(message);
120
- }
90
+ function getNativeModule(): Spec | null {
91
+ if (basePath == null) {
92
+ // use default base path from the Platform (iOS/Android)
93
+ basePath = PlatformContext.getBaseDirectory();
94
+ }
121
95
 
122
- if (basePath == null) {
123
- // Get base path from platform specific context
124
- basePath = PlatformContext.getBaseDirectory();
125
- }
96
+ const module = TurboModuleRegistry.get<Spec>('MmkvCxx');
126
97
 
127
- // Initialize MMKV
98
+ if (module != null) {
99
+ // initialize MMKV
128
100
  module.initialize(basePath);
129
101
  }
130
102
 
131
103
  return module;
132
104
  }
105
+ export const MMKVTurboModule = getLazyTurboModule(getNativeModule);
@@ -1,4 +1,5 @@
1
1
  import { TurboModule, TurboModuleRegistry } from 'react-native';
2
+ import { getLazyTurboModule } from './LazyTurboModule';
2
3
 
3
4
  export interface Spec extends TurboModule {
4
5
  /**
@@ -7,6 +8,7 @@ export interface Spec extends TurboModule {
7
8
  getBaseDirectory(): string;
8
9
  }
9
10
 
10
- export const PlatformContext = TurboModuleRegistry.getEnforcing<Spec>(
11
- 'MmkvPlatformContext'
12
- );
11
+ function getModule(): Spec | null {
12
+ return TurboModuleRegistry.get<Spec>('MmkvPlatformContext');
13
+ }
14
+ export const PlatformContext = getLazyTurboModule(getModule);
@@ -1,7 +1,9 @@
1
- export function isJest(): boolean {
1
+ export function isTest(): boolean {
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 (
7
+ process.env.JEST_WORKER_ID != null || process.env.VITEST_WORKER_ID != null
8
+ );
7
9
  }
package/src/Types.ts ADDED
@@ -0,0 +1,89 @@
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
+
75
+ export interface Listener {
76
+ remove: () => void;
77
+ }
78
+
79
+ export 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: (
87
+ onValueChanged: (key: string) => void
88
+ ) => Listener;
89
+ }
@@ -13,6 +13,7 @@ const mmkv = new MMKV();
13
13
 
14
14
  beforeEach(() => {
15
15
  mmkv.clearAll();
16
+ mmkv.trim();
16
17
  });
17
18
 
18
19
  test('hooks update when the value is changed directly through the instance', () => {
@@ -1,4 +1,4 @@
1
- import type { NativeMMKV } from './MMKV';
1
+ import type { NativeMMKV } from './Types';
2
2
 
3
3
  /* Mock MMKV instance for use in tests */
4
4
  export const createMockMMKV = (): NativeMMKV => {
package/src/createMMKV.ts CHANGED
@@ -1,10 +1,9 @@
1
- import type { Configuration, NativeMMKV } from './MMKV';
2
- import { getMMKVTurboModule } from './NativeMmkv';
3
-
4
- const module = getMMKVTurboModule();
1
+ import type { Configuration } from './MMKV';
2
+ import { MMKVTurboModule } from './NativeMmkv';
3
+ import type { NativeMMKV } from './Types';
5
4
 
6
5
  export const createMMKV = (config: Configuration): NativeMMKV => {
7
- const instance = module.createMMKV(config);
6
+ const instance = MMKVTurboModule.createMMKV(config);
8
7
  if (__DEV__) {
9
8
  if (typeof instance !== 'object' || instance == null) {
10
9
  throw new Error(
@@ -1,5 +1,6 @@
1
1
  /* global localStorage */
2
- import type { Configuration, NativeMMKV } from './MMKV';
2
+ import type { Configuration } from './MMKV';
3
+ import type { NativeMMKV } from './Types';
3
4
  import { createTextEncoder } from './createTextEncoder';
4
5
 
5
6
  const canUseDOM =
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './MMKV';
2
+ export * from './hooks';
3
+
4
+ export { Mode, Configuration } from './NativeMmkv';
package/src/index.tsx DELETED
@@ -1,2 +0,0 @@
1
- export * from './MMKV';
2
- export * from './hooks';