declare function MMKVStorage(): any; type StoredValueAndSetter = [T | null, (value: T | ((prevValue: T) => T)) => void]; export declare function useMMKVStorage( key: string, storage: MMKVStorage.API, defaultValue?: unknown ): StoredValueAndSetter; export declare function create(storage: MMKVStorage.API): (key: string, defaultValue?: unknown) => StoredValueAndSetter; export declare const useIndex: (keys: Array, type: "string" | "number" | "object" | "boolean" | "array", storage: MMKVStorage.API) => [unknown[], (key: string, value: unknown) => void, (key: string) => void] export default MMKVStorage; type ACCESSIBLE = { WHEN_UNLOCKED: string; AFTER_FIRST_UNLOCK: string; ALWAYS: string; WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: string; WHEN_UNLOCKED_THIS_DEVICE_ONLY: string; AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: string; ALWAYS_THIS_DEVICE_ONLY: string; }; type MODES = { SINGLE_PROCESS: number; MULTI_PROCESS: number; }; type Callback = (error: Error | null, result: T | null | undefined) => void; declare module MMKVStorage { export const MODES: MODES; export const ACCESSIBLE: ACCESSIBLE; export declare function getAllMMKVInstanceIDs(): string[]; export declare function getCurrentMMKVInstanceIDs(): Record; export const IDSTORE_ID: string; const myVar: string; class API { /** * Set a string value to storage for a given key. * This method is added for redux-persist support. It is similar to setStringAsync() * * @param {String} key * @param {String} value * */ setItem(key: string, value: string): Promise; /** * Get a string value for a given key. * This method is added for redux-persist support. It is similar to setStringAsync() * @param {String} key */ getItem(key: string): Promise; /** * Set a string value to storag for a given key. * * @param {String} key * @param {String} value * */ setStringAsync(key: string, value: string): Promise; /** * Get a string value for a given key. * @param {String} key */ getStringAsync(key: string): Promise; /** * Set a number value to storage for a given key. * * @param {String} key * @param {number} value * */ setIntAsync(key: string, value: number): Promise; /** * Get a number value for a given key * @param {String} key */ getIntAsync(key: string): Promise; /** * Set a boolean value to storag for a given key. * * @param {String} key * @param {boolean} value * */ setBoolAsync(key: string, value: boolean): Promise; /** * Get a boolean value for a given key. * @param {String} key */ getBoolAsync(key: string): Promise; /** * Set an Object to storage for a given key. * * @param {String} key * @param {Object} value * */ setMapAsync(key: string, value: object): Promise; /** * Get an Object from storage for a given key. * @param {String} key */ getMapAsync(key: string): Promise; /** * Set an array to the db. * @param {String} key * @param {Array} array */ setArrayAsync(key: string, value: Array): Promise; /** * get an array from the storage for give key. * @param {String} key */ getArrayAsync(key: string): Promise | null | undefined>; /** * Retrieve multiple Objects for a given array of keys. Currently will work only if data for all keys is an Object. * Arrays will also be returned but wrappen in a object. * * **Will not work if a key as a String value.** * * @param {Array} keys */ getMultipleItemsAsync( keys: Array, type:"string" |"number" | "map" | "boolean" | "array" | "object", ): Promise>; /** * Remove all keys and values from storage. */ clearStore(): boolean | undefined; /** * Clear memory cache of the current MMKV instance */ clearMemoryCache(): boolean | undefined; /** * Remove an item from storage for a given key. * * @param {String} key */ removeItem(key: string): boolean | undefined; // NON ASYNC CALLS /** * Set a string value to storag for a given key. * * @param {String} key * @param {String} value * @param {Callback} callback */ setString(key: string, value: string, callback?: Callback): boolean | undefined; /** * Get a string value for a given key. * @param {String} key * @param {Callback} callback */ getString(key: string, callback?: Callback): string | null | undefined; /** * Set a number value to storage for a given key. * * @param {String} key * @param {number} value * @param {Callback} callback */ setInt(key: string, value: number, callback?: Callback): boolean | undefined; /** * Get a number value for a given key * @param {String} key * @param {Callback} callback */ getInt(key: string, callback?: Callback): number | null | undefined; /** * Set a boolean value to storag for a given key. * * @param {String} key * @param {boolean} value * @param {Callback} callback */ setBool(key: string, value: boolean, callback?: Callback): boolean | undefined; /** * Get a boolean value for a given key. * @param {String} key * @param {Callback} callback */ getBool(key: string, callback?: Callback): boolean | null | undefined; /** * Set an Object to storage for a given key. * * @param {String} key * @param {Object} value * @param {Callback} callback */ setMap(key: string, value: object, callback?: Callback): boolean | undefined; /** * Get an Object from storage for a given key. * @param {String} key * @param {Callback} callback */ getMap(key: string, callback?: Callback): T | null | undefined; /** * Set an array to the db. * @param {String} key * @param {Array} array * @param {Callback} callback */ setArray( key: string, value: Array, callback?: Callback ): boolean | undefined; /** * get an array from the storage for give key. * @param {String} key * @param {Array} callback */ getArray( key: string, callback?: Callback> ): Array | null | undefined; /** * Retrieve multiple Objects for a given array of keys. Currently will work only if data for all keys is an Object. * Arrays will also be returned but wrappen in a object. * * **Will not work if a key as a String value.** * * @param {Array} keys * @param {Array} callback */ getMultipleItems( keys: Array, type:"string" |"number" | "map" | "boolean" | "array" | "object", callback?: Callback> ): Array; /** * * Get all MMKV Instance IDs. * */ getAllMMKVInstanceIDs(): string[]; /** * * Get all MMKV Instance IDs that are currently loaded * */ getCurrentMMKVInstanceIDs(): Record; /** * Get the key and alias for the encrypted storage */ getKey(): { alias: string, key: string }; encryption: encryption; indexer: indexer; transactions:transcations; } export class Loader { /** * Load MMKV with the specified ID. If instance does not exist, a new instance will be created. * @param {String} id */ withInstanceID(id: string): this; /** * Encrypt MMKV Instance and store the creditials in secured storage for later use. * The key for encryption is automatically generated and the default alias for key storage is 'com.MMKV.ammarahmed' which is converted to HEX for usage. * * Requires an ID to be specified. * */ withEncryption(): this; /** * Set accessible mode for secure storage on ios devices * * @param accessible MMKVStorage.ACCESSIBLE */ setAccessibleIOS(accessible: ACCESSIBLE): this; /** * Provide a custom key to encrypt the storage. Use this if you dont want to generate the key automatically. * You must call withEncryption() to use this. * To store your key for later use call withSecureKeyStorage() too. * * @param {string} key the key to encrypt the storage with * @param {boolean} secureKeyStorage Should the key be stored securely. * @param {string} alias Provide an alias for key storage. Default alias is aliasPrefix + instanceID */ encryptWithCustomKey( key: string, secureKeyStorage: boolean, alias: string ): this; /** * Set the processing mode for storage. * * Will recieve the following values. * MMKV.MULTI_PROCESS * MMKV.SINGLE_PROCESS * * @param {number} mode Set processing mode for storage */ setProcessingMode(mode: number): this; /** * Finally after setting all the options, call this to create the instance. * */ initialize(): API; } } class indexer { /** * Get all keys from storage. * */ getKeys(): Promise>; /** * Check if a key exists in storage. * * @param {String} key */ hasKey(key: string): boolean; strings: { /** * Get all keys from strings index; * */ getKeys(): Promise>; /** * Check if a key exists in strings index; * * @param {String} key */ hasKey(key: string): boolean; /** * Get all strings in the strings index * */ getAll(): Promise>; }; numbers: { /** * Get all keys from numbers index; * */ getKeys(): Promise>; /** * Check if a key exists in numbers index; * * @param {String} key */ hasKey(key: string): boolean; /** * Get all numbers in the numbers index; * */ getAll(): Promise>; }; booleans: { /** * Get all keys from booleans index * */ getKeys(): Promise>; /** * Check if a key exists in booleans index * * @param {String} key */ hasKey(key: string): boolean; /** * Get all booleans in the booleans index * */ getAll(): Promise>; }; maps: { /** * Get all keys from maps index * */ getKeys(): Promise>; /** * Check if a key exists in maps index * * @param {String} key */ hasKey(key: string): boolean; /** * Get all items in the maps index * */ getAll(): Promise>; }; arrays: { /** * Get all keys from array index * */ getKeys(): Promise>; /** * Check if a key exists in array index * * @param {String} key */ hasKey(key: string): boolean; /** * Get all arrays in the array index * */ getAll(): Promise>; }; } class encryption { /** * You can encrypt an MMKV instance anytime, even after it is created. * * Calling this without a key will generate a key itself & store it in secure storage. * If no parameters are provided, a key is generated and securely stored in the storage with the default alias for later use. * * @param {string} key; Provide a custom key to encrypt the storage. * @param {boolean} secureKeyStorage Store the key in secure storage. * @param {string} alias Provide a custom alias to store the key with in secure storage * @param {ACCESSIBLE} accessibleMode Set accessible mode for secure storage on ios devices * @returns An object with alias and key */ encrypt( key: string, secureKeyStorage: boolean, alias: string, accessibleMode: ACCESSIBLE ): Promise; /** * You can decrypt an encrypted MMKV instance anytime, even after it is created. * Decrypting the storage will delete the key you encrypted it with * */ decrypt(): Promise; /** * Change the encryption key incase the old one has been compromised. * @param {string} key; Provide a custom key to encrypt the storage. * @param {boolean} secureKeyStorage Store the key in secure storage. * @param {string} alias Provide a custom alias to store the key with in secure storage * @param {ACCESSIBLE} accessibleMode Set accessible mode for secure storage on ios devices */ changeEncryptionKey( key: string, secureKeyStorage: boolean, alias: string, accessibleMode: ACCESSIBLE ): Promise; } class transcations { register(type: "string" | "number" | "object" | "array" | "boolean", transaction: "beforewrite" | "onwrite" | "onread" | "ondelete", mutator: (key: string, value: unknown) => void):() => {} unregister(type: "string" | "number" | "object" | "array" | "boolean", transaction: "beforewrite" | "onwrite" | "onread" | "ondelete"):void clear():void }