Quantifying cosmic dust production in core-collapse supernovae and supernova remnants