/** * memoryAdapter (API ยง8.1) โ€” the default scope backing: holds one location in a * closure (per-pane state, no URL form โ†’ Link renders `role="link"`). */ import type { SerializedLocation } from '../history.js' import type { NavAdapter } from './adapter.js' /** In-memory adapter โ€” the default scope backing (per-pane state, no URL). */ export function memoryAdapter(initial?: SerializedLocation): NavAdapter { let current: SerializedLocation | null = initial ?? null const listeners = new Set<() => void>() return { kind: 'memory', read: () => current, write: (loc) => { current = loc }, clear: () => { current = null }, subscribe: (cb) => { listeners.add(cb) return () => listeners.delete(cb) }, } }