A thermodynamic framework for the additive manufacturing of crystallizing polymers. Part I: A theory that accounts for phase change, shrinkage, warpage and residual stress