/** * rApp Shortcut configuration utility. * * Reads/writes shortcut slot assignments (1–9) from localStorage. * Used by the settings UI in rstack-identity.ts. * The shell inline script reads localStorage directly (can't import ES modules). */ const STORAGE_KEY = "rspace-shortcuts"; export function getShortcuts(): Record { try { return JSON.parse(localStorage.getItem(STORAGE_KEY) || "{}"); } catch { return {}; } } export function setShortcut(slot: string, moduleId: string): void { if (slot < "1" || slot > "9") return; const shortcuts = getShortcuts(); shortcuts[slot] = moduleId; localStorage.setItem(STORAGE_KEY, JSON.stringify(shortcuts)); } export function removeShortcut(slot: string): void { const shortcuts = getShortcuts(); delete shortcuts[slot]; localStorage.setItem(STORAGE_KEY, JSON.stringify(shortcuts)); } export function getModuleForSlot(slot: string): string | null { return getShortcuts()[slot] ?? null; }