import { createSourceMapStore , MapStore } from 'istanbul-lib-source-maps' ; import { createCoverageMap , CoverageMap , CoverageMapData , FileCoverage , } from 'istanbul-lib-coverage' ; export class CoverageMapProvider { private mapStore ! : MapStore ; /**
     * Transformed coverage map
     */ private _map ! : CoverageMap ; constructor ( ) { this . reset ( ) ; } reset ( ) { this . _map = createCoverageMap ( ) ; this . mapStore = createSourceMapStore ( ) ; } get map ( ) : CoverageMap { return this . _map ; } async update ( obj ? ) { const map = createCoverageMap ( obj ) ; const transformed = await this . mapStore . transformCoverage ( map ) ; if ( this . _map ) { transformed . files ( ) . forEach ( ( fileName ) => { this . setFileCoverage ( fileName , transformed ) ; } ) ; } else { this . _map = transformed ; } } setFileCoverage ( filePath , map ) { this . _map . data [ filePath ] = map . fileCoverageFor ( filePath ) ; } public getFileCoverage ( filePath ) { return this . _map . data [ filePath ] as FileCoverage ; } public onVisibilityChanged ( visible ) { if ( ! visible ) { this . reset ( ) ; } } }