• Hook to access complete debug context (both state and actions combined). Prefers split contexts but falls back to legacy unified context for backward compatibility. Use useDebugState or useDebugActions separately when possible for better performance.

    Returns DebugContextType

    The complete debug context value.

    If used outside a DebugProvider.

    export function useDebug(): DebugContextType {
    const legacyContext = useContext(DebugContext);
    const stateContext = useContext(DebugStateContext);
    const actionsContext = useContext(DebugActionsContext);

    const mergedContext = React.useMemo(() => {
    if (legacyContext !== undefined) {
    return legacyContext;
    }

    if (stateContext !== undefined && actionsContext !== undefined) {
    return {
    ...stateContext,
    ...actionsContext,
    } satisfies DebugContextType;
    }

    return undefined;
    }, [actionsContext, legacyContext, stateContext]);

    if (mergedContext === undefined) {
    throw new Error("useDebug must be used within a DebugProvider");
    }

    return mergedContext;
    }