import { createContext, type ReactNode, useContext } from "react"; import type { BestiaryCachePort, BestiaryIndexPort, EncounterPersistence, PlayerCharacterPersistence, UndoRedoPersistence, } from "../adapters/ports.js"; export interface Adapters { encounterPersistence: EncounterPersistence; undoRedoPersistence: UndoRedoPersistence; playerCharacterPersistence: PlayerCharacterPersistence; bestiaryCache: BestiaryCachePort; bestiaryIndex: BestiaryIndexPort; } const AdapterContext = createContext(null); export function AdapterProvider({ adapters, children, }: { adapters: Adapters; children: ReactNode; }) { return ( {children} ); } export function useAdapters(): Adapters { const ctx = useContext(AdapterContext); if (!ctx) throw new Error("useAdapters requires AdapterProvider"); return ctx; }