Single-bubble dynamics in nanopores: Transition between homogeneous and heterogeneous nucleation