import { type ComputedRef, type WritableComputedRef } from '#imports'; import type { AdapterContext, BlokkliAdapter } from '#blokkli/editor/adapter'; export type StorageProvider = { /** * Create a reactive storage value synced to localStorage. * * The value is automatically persisted to localStorage on change. * Can optionally be synced to user settings on the server. * * @param key - Storage key (will be prefixed with 'blokkli:') * @param defaultValue - Default value if no stored value exists * @param persist - Whether to sync to server user settings (default: false) * @returns Reactive writable computed ref synced to storage * * @example * ```ts * const showGrid = storage.use('showGrid', false) * showGrid.value = true // Automatically saved to localStorage * ``` */ use: (key: string | ComputedRef, defaultValue: T, persist?: boolean) => WritableComputedRef; /** * Create a reactive storage value with entity context prefix. * * Same as `use()` but automatically prefixes the key with entity type and UUID. * Useful for entity-specific settings (e.g., sidebar state per page). * * @param key - Storage key (will be prefixed with context) * @param defaultValue - Default value if no stored value exists * @param persist - Whether to sync to server user settings (default: false) * @returns Reactive writable computed ref synced to storage * * @example * ```ts * // If context is node:abc123, key becomes 'sidebarOpen:node:abc123' * const sidebarOpen = storage.useWithContextPrefix('sidebarOpen', false) * ``` */ useWithContextPrefix: (key: string, defaultValue: T, persist?: boolean) => WritableComputedRef; /** * Clear all blokkli storage values. * * Removes all localStorage entries starting with 'blokkli:' prefix. * Does not affect server user settings. */ clearAll: () => void; /** * Clear a specific storage value. * * Removes the value from localStorage (without prefix). * * @param key - The storage key to clear (without 'blokkli:' prefix) */ clear: (key: string) => void; }; /** * Create a reactive variable that is synced to local storage using the * given key. The sync only happens client side and after the component * has been mounted. * * This composable can be used to keep state across page navigations and * even after a refresh. */ export default function (adapter: BlokkliAdapter, context: ComputedRef): Promise;