/** * persist.ts * * Forma - localStorage/sessionStorage 영속성 유틸리티 * Persistence utilities for localStorage/sessionStorage * * @license MIT License * @copyright 2025 KIM YOUNG JIN (Kim Young Jin) * @author KIM YOUNG JIN (ehfuse@gmail.com) */ /** * Persist 옵션 타입 | Persist options type */ export interface PersistOptions { /** localStorage 키 | localStorage key */ key: string; /** 저장 디바운스 시간 (ms, 기본값: 300) | Debounce time for saving (ms, default: 300) */ debounce?: number; /** 저장에서 제외할 필드 | Fields to exclude from saving */ exclude?: string[]; /** 스토리지 타입 (기본값: 'localStorage') | Storage type (default: 'localStorage') */ storage?: "localStorage" | "sessionStorage"; } /** * Persist 설정 타입 (string 또는 옵션 객체) * Persist configuration type (string or options object) */ export type PersistConfig = string | PersistOptions; /** * PersistConfig를 PersistOptions로 정규화 * Normalize PersistConfig to PersistOptions */ export declare function normalizePersistConfig(config: PersistConfig): PersistOptions; /** * storagePrefix가 적용된 전체 키 생성 | Generate full key with storagePrefix */ export declare function getFullStorageKey(key: string, storagePrefix?: string): string; /** * localStorage에서 데이터 불러오기 | Load data from localStorage * @param config persist 설정 | persist configuration * @param storagePrefix 스토리지 키 prefix (GlobalFormaProvider에서 제공) | Storage key prefix (from GlobalFormaProvider) */ export declare function loadPersistedData>(config: PersistConfig, storagePrefix?: string): Partial | null; /** * localStorage에 데이터 저장 | Save data to localStorage * @param config persist 설정 | persist configuration * @param values 저장할 값 | values to save * @param storagePrefix 스토리지 키 prefix (GlobalFormaProvider에서 제공) | Storage key prefix (from GlobalFormaProvider) */ export declare function savePersistedData>(config: PersistConfig, values: T, storagePrefix?: string): boolean; /** * localStorage에서 데이터 삭제 | Clear persisted data from localStorage * @param config persist 설정 | persist configuration * @param storagePrefix 스토리지 키 prefix (GlobalFormaProvider에서 제공) | Storage key prefix (from GlobalFormaProvider) */ export declare function clearPersistedData(config: PersistConfig, storagePrefix?: string): boolean; /** * 저장된 데이터가 있는지 확인 | Check if persisted data exists * @param config persist 설정 | persist configuration * @param storagePrefix 스토리지 키 prefix (GlobalFormaProvider에서 제공) | Storage key prefix (from GlobalFormaProvider) */ export declare function hasPersistedData(config: PersistConfig, storagePrefix?: string): boolean; /** * flush/cancel 가능한 디바운스 함수 타입 | Debounced function with flush/cancel */ export interface DebouncedFunction any> { (...args: Parameters): void; /** 대기 중인 호출을 즉시 실행 | Immediately invoke the pending call (if any) */ flush: () => void; /** 대기 중인 호출을 취소 | Cancel the pending call */ cancel: () => void; } /** * 디바운스 유틸리티 | Debounce utility * * flush(): 대기 중인 마지막 호출을 즉시 실행 (언마운트/페이지 이탈 시 저장 손실 방지용) * flush(): immediately runs the pending call — used to avoid losing the last save on unmount/page unload * cancel(): 대기 중인 호출을 취소 | cancel pending call */ export declare function debounce any>(fn: T, delay: number): DebouncedFunction; //# sourceMappingURL=persist.d.ts.map