import { S as StorageElementType } from './StorageElementType-C7ETezlL.cjs'; export { a as StorageObjectType } from './StorageElementType-C7ETezlL.cjs'; import { S as StorageGameState } from './StorageGameState-C3PGrFPr.cjs'; import { LRUCache } from 'lru-cache'; export { S as StoredClassModel } from './StoredClassModel-Bykjdn8S.cjs'; import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs'; interface StorageExternalStoreHandler { /** * Triggered when {@link StorageRegistry.setVariable} is called. * The key is provided without any storage prefix. */ onSetVariable?: (key: string, value: StorageElementType) => void; /** * Triggered when a temp variable is removed by {@link StorageRegistry.clearOldTempVariables}. * The key is provided without any storage prefix. */ onClearOldTempVariable?: (key: string) => void; /** * Triggered when {@link StorageRegistry.removeVariable} is called. * The key is provided without any storage prefix. */ onRemoveVariable?: (key: string) => void; } interface StorageFlagsInterface { /** * Set a flag to true or false. * @param key The name of the flag * @param value The value of the flag. */ set(key: string, value: boolean): void; /** * Get the value of a flag * @param key The name of the flag * @returns The value of the flag */ get(key: string): boolean; } interface StorageTempInterface { /** * Set a variable in the temporary storage. The lifespan of the variable is the number of opened labels. * To get the temporary variable, use {@link StorageManagerInterface.get} * @param key The key of the temporary variable * @param value The value of the temporary variable. If undefined, the variable will be removed */ set(key: string, value: StorageElementType): void; /** * Remove a temporary variable * @param key The key of the temporary variable */ remove(key: string): void; /** * The deadlines of the temporary variables, expressed as the number of opened labels after which * each variable will be removed. **Do not modify this directly.** */ readonly deadlines: Map; } interface StorageManagerInterface { /** * The internal storage. **Do not modify this directly.** * * ATTENTION: If you edit this directly, the {@link cache} will not be updated. * * You can use Keyv with Pixi’VN by creating a new instance of Keyv and passing the storage object as a parameter. * ```ts * import { storage } from '@drincs/pixi-vn' * import Keyv from 'keyv'; * * const keyvStorage = new Keyv({ store: storage.base }); * * keyvStorage.get("myValue").then((value) => { * console.log(value); * }); * ``` */ readonly base: Map; /** * The internal cache. **Do not modify this directly.** */ readonly cache: LRUCache; /** * Set the starting storage. The starting storage that will be used when the game starts. * **If variables are defined inside it, they can be edited during the game, but if you {@link delete} them, they will be restored to the starting storage.** * By default, the starting storage is empty. */ set default(value: { [key: string]: StorageElementType; }); /** * Set a variable in the storage * @param key The key of the variable * @param value The value of the variable. If undefined, the variable will be removed * @returns */ set(key: string, value: StorageElementType): void; /** * Get a variable from the storage. If the variable is a temporary variable, it will return the temporary variable * @param key The key of the variable * @returns The value of the variable. If the variable does not exist, it will return undefined */ get(key: string): T | undefined; /** * Remove a variable from the storage * @param key The key of the variable * @returns */ remove(key: string): void; /** * Set a variable in the temporary storage. The lifespan of the variable is the number of opened labels. * To get the temporary variable, use {@link get} * @param key The key of the temporary variable * @param value The value of the temporary variable. If undefined, the variable will be removed * @returns * @deprecated Use {@link temp}.set instead. */ setTempVariable(key: string, value: StorageElementType): void; /** * Remove a temporary variable * @param key The key of the temporary variable * @deprecated Use {@link temp}.remove instead. */ removeTempVariable(key: string): void; /** * Namespace for operations on temporary storage variables, whose lifespan is expressed in number of opened labels. */ readonly temp: StorageTempInterface; /** * Set a flag to true or false. * @param key The name of the flag * @param value The value of the flag. * @deprecated Use {@link flags}.set instead. */ setFlag(key: string, value: boolean): void; /** * Get the value of a flag * @param key The name of the flag * @returns The value of the flag * @deprecated Use {@link flags}.get instead. */ getFlag(key: string): boolean; /** * Namespace for operations on flags. */ readonly flags: StorageFlagsInterface; /** * Configure the handler used to mirror game storage changes into an external reactive store. * Call this at any time to start/stop mirroring. * @param value The handler to set. If undefined, the handler will be removed. * @example * ```ts * import { Store } from '@tanstack/store' * * // Create a TanStack store that mirrors the game storage variables * const gameStore = new Store>({}) * * storage.setStorageHandler({ * onSetVariable: (key, value) => { * gameStore.setState((state) => ({ ...state, [key]: value })) * }, * onRemoveVariable: (key) => { * gameStore.setState((state) => { * const next = { ...state } * delete next[key] * return next * }) * }, * onClearOldTempVariable: (key) => { * gameStore.setState((state) => { * const next = { ...state } * delete next[key] * return next * }) * }, * }) * ``` */ setStorageHandler(value?: StorageExternalStoreHandler): void; /** * Clear the storage and the oidsUsed * @returns */ clear(): void; /** * Export the storage to an object * @returns The object */ export(): StorageGameState; /** * Restore the storage from an object * @param data The object */ restore(data: StorageGameState): void; } /** * StorageRegistry is a singleton namespace that holds global state for the storage system. * **DO NOT** import this module directly; use `storage`. */ declare namespace StorageRegistry { const storage: CachedMap; const defaultStorage: CachedMap; const tempStorageDeadlines: Map; function clearOldTempVariables(openedLabelsNumber: number): void; function setExternalStoreHandler(handler?: StorageExternalStoreHandler): void; function setVariable(prefix: string, key: string, value: StorageElementType): void; function getVariable(prefix: string, key: string): T | undefined; function removeVariable(prefix: string, key: string): void; function setFlag(key: string, value: boolean): void; function getFlag(key: string): boolean; } declare const storage: StorageManagerInterface; export { StorageElementType, type StorageExternalStoreHandler, type StorageFlagsInterface, StorageGameState, type StorageManagerInterface, StorageRegistry, type StorageTempInterface, storage };