import { FileNode } from '../types'; interface FileMetadata { path: string[]; name: string; type: 'file' | 'folder' | string; icon?: string; locked?: boolean; password?: string; broken?: boolean; hint?: string; app?: string; readOnly?: boolean; description?: string; ctime?: string; mtime?: string; atime?: string; importedAt?: string; provenance?: FileNode['provenance']; modifiedAt: number; } interface FileSystemMetadata { files: Record; /** Tombstoned path keys: built-in nodes the user deleted or renamed away. */ deleted?: string[]; version: number; lastModified: number; } export interface RecycleBinItem { item: FileNode; originalPath: string[]; /** Display name at deletion time; the bin key may be suffixed for uniqueness (#81). */ originalName?: string; deletedAt: string | number; } /** * Name of the DOM event dispatched (once per session) when persistent storage * writes fail, e.g. the localStorage quota is exceeded. The desktop listens * and surfaces an XP-style dialog (issue #81). */ export declare const STORAGE_ERROR_EVENT = "windows-xp:storage-error"; /** True when running in a browser-like environment. */ export declare const canUseDOM: boolean; /** SSR-safe localStorage wrapper. No-ops in Node / non-browser envs. */ export interface SafeLocalStorage { getItem: (key: string) => string | null; setItem: (key: string, value: string) => void; removeItem: (key: string) => void; } /** * How a storage handle persists desktop state (#138). * * - `'local'` (default): localStorage metadata + IndexedDB file content — * survives across visits. Right for games/progress. * - `'session'`: sessionStorage metadata + in-memory file content — per-tab * continuity (survives reload within the tab), gone when the tab closes. * - `'none'`: everything in memory, no IndexedDB opened — every mount is * pristine. Right for campaign pages, blogs, and teaching sandboxes. */ export type PersistenceMode = 'local' | 'session' | 'none'; /** * A fully isolated storage handle bound to one prefix. All methods read and * write only under that prefix, and the IndexedDB connection is private to the * handle — two handles with different prefixes never touch each other. */ export interface Storage { readonly prefix: string; /** SSR-safe localStorage wrapper (keys are NOT auto-prefixed — pass full keys via `key()`). */ readonly local: SafeLocalStorage; /** Build a fully-qualified storage key from a short key constant. */ key: (shortKey: string) => string; saveFileContent: (path: string[], content: string) => Promise; getFileContent: (path: string[]) => Promise; deleteFileContent: (path: string[]) => Promise; saveMetadata: (metadata: FileSystemMetadata) => void; getMetadata: () => FileSystemMetadata | null; clearAllStorage: () => Promise; /** Remove every localStorage key under this instance's prefix (SSR-safe). */ clearPrefixedLocal: () => void; saveRecycleBin: (items: Record) => void; getRecycleBin: () => Record | null; /** @internal Drop the cached IndexedDB connection. */ resetConnection: () => void; } /** * Create an isolated storage handle for a prefix (#95), with a selectable * persistence backend (#138). Each handle keeps its own IndexedDB connection or * in-memory maps, so instances never share state. `persistence` defaults to * `'local'` — the historical behavior — so existing callers are unaffected. */ export declare const createStorage: (rawPrefix: string, persistence?: PersistenceMode) => Storage; /** * Reconfigure the process-wide default storage namespace. * * With per-instance isolation (#95) the recommended path is `StorageProvider` + * `useStorage()`, which is unaffected by this global. This remains for the * single-instance default and non-React callers. A second differing prefix * still warns once, since the default instance is shared. */ export declare const setStoragePrefix: (prefix: string) => void; /** @internal */ export declare const getStoragePrefix: () => string; /** The process-wide default storage handle (used when no StorageProvider is present). */ export declare const getDefaultStorage: () => Storage; /** @internal Reset the default instance's cached connection. */ export declare const resetDBConnection: () => void; /** Build a fully-qualified storage key from a short key constant (default instance). */ export declare const getStorageKey: (key: string) => string; /** SSR-safe localStorage wrapper (default instance). */ export declare const safeLocalStorage: SafeLocalStorage; export declare const saveFileContent: (path: string[], content: string) => Promise; export declare const getFileContent: (path: string[]) => Promise; export declare const deleteFileContent: (path: string[]) => Promise; export declare const saveMetadata: (metadata: FileSystemMetadata) => void; export declare const getMetadata: () => FileSystemMetadata | null; export declare const clearAllStorage: () => Promise; export declare const saveRecycleBin: (items: Record) => void; export declare const getRecycleBin: () => Record | null; export type { FileMetadata, FileSystemMetadata };