import Component , { Snapshoot } from "../components/component" ; class Record { component : Component ; recordMap : Snapshoot [ ] = [ ] ; constructor ( component ) { this . component = component ; this . recordMap = [ ] ; } store ( stepId ) { this . recordMap [ stepId ] = this . component . snapshoot ( ) ; } restore ( stepId ) { while ( ! this . recordMap [ stepId ] && stepId >= 0 ) { stepId -- ; } if ( stepId < 0 ) return ; this . component . restore ( this . recordMap [ stepId ] ) ; } clear ( stepId ) { this . recordMap . splice ( stepId ) ; } } export default Record ;