export type ResourceType = 'document' | 'stylesheet' | 'image' | 'media' | 'font' | 'script' | 'texttrack' | 'xhr' | 'fetch' | 'eventsource' | 'websocket' | 'manifest' | 'other' ; export interface RawResponse { timestamp : number ; wallTime : number ; type : ResourceType ; status : number ; url : string ; timing : Record < string , any > ; frameId : string ; loaderId : string ; requestId : string ; response : { connectionId : number ; connectionReused : boolean ; encodedDataLength : number ; fromDiskCache : boolean ; fromServiceWorker : boolean ; headers : { } ; headersText : string ; mimeType : string ; protocol : string ; remoteIPAddress : string ; remotePort : number ; requestHeaders : { } ; requestHeadersText : string ; securityDetails : { } ; securityState : string ; status : number ; statusText : string ; timing : { connectEnd : number ; connectStart : number ; dnsEnd : number ; dnsStart : number ; proxyEnd : number ; proxyStart : number ; pushEnd : number ; pushStart : number ; receiveHeadersEnd : number ; requestTime : number ; sendEnd : number ; sendStart : number ; sslEnd : number ; sslStart : number ; workerReady : number ; workerStart : number ; } ; url : string ; timestamp : number ; } ; } export class EntryRequest { _epoch = - 1 ; _issueTime = - 1 ; _wallIssueTime = - 1 ; _startTime = - 1 ; _endTime = - 1 ; _ttfb = - 1 ; _responseReceivedTime = - 1 ; _timing : any = { } ; timestamp : number ; method : string ; url : string ; httpVersion : string ; headers : { name : string ; value : string ; } [ ] ; queryString : string [ ] ; headersSize : number ; bodySize : null ; postData : string ; cookies : { name : string ; value : string ; expires : string | null ; httpOnly : boolean ; secure : boolean ; } [ ] ; setIssueTime ( monotonicTime , wallTime ) { this . _issueTime = monotonicTime ; this . _wallIssueTime = wallTime ; this . _startTime = monotonicTime ; } param { number } monotonicTime return { number } pseudoWallTime ( monotonicTime ) { return this . _wallIssueTime ? this . _wallIssueTime - this . _issueTime + monotonicTime : monotonicTime ; } param { ! Protocol . Network . ResourceTiming | undefined } timingInfo set timing ( timingInfo ) { if ( ! timingInfo ) return ; this . _startTime = timingInfo . requestTime * 1e3 ; const headersReceivedTime = timingInfo . requestTime * 1e3 + timingInfo . receiveHeadersEnd ; if ( ( this . _responseReceivedTime || - 1 ) < 0 || this . _responseReceivedTime > headersReceivedTime ) this . _responseReceivedTime = headersReceivedTime ; if ( this . _startTime > this . _responseReceivedTime ) this . _responseReceivedTime = this . _startTime ; this . _ttfb = timingInfo . receiveHeadersEnd - timingInfo . sendEnd ; this . _timing = timingInfo ; } get timing ( ) { return this . _timing ; } return { number } get endTime ( ) { return this . _endTime || - 1 ; } param { number } x set endTime ( x ) { if ( this . timing && this . timing . requestTime ) { this . _endTime = Math . max ( x , this . _responseReceivedTime ) ; } else { this . _endTime = x ; if ( this . _responseReceivedTime > x ) this . _responseReceivedTime = x ; } } return { number } get duration ( ) { if ( this . _endTime === - 1 || this . _startTime === - 1 ) return - 1 ; return this . _endTime - this . _startTime ; } return { number } get latency ( ) { if ( this . _responseReceivedTime === - 1 || this . _startTime === - 1 ) return - 1 ; return this . _responseReceivedTime - this . _startTime ; } get ttfb ( ) { return this . _ttfb || - 1 ; } public toJSON ( ) { return { timestamp : this . timestamp , method : this . method , url : this . url , httpVersion : this . httpVersion , headers : this . headers , queryString : this . queryString , headersSize : this . headersSize , bodySize : this . bodySize , cookies : this . cookies , } ; } } export class EntryResponse { timestamp : number ; status : number ; statusText : string ; httpVersion : string ; headers : { name : string ; value : string ; } [ ] ; redirectURL : string ; headersSize : number ; bodySize : number ; _transferSize : number ; cookies : { name : string ; value : string ; expires : string | null ; httpOnly : boolean ; secure : boolean ; path : string ; } [ ] ; content : { size : number ; mimeType : string ; compression ? : number ; text : string ; } ; public toJSON ( ) { return { timestamp : this . timestamp , status : this . status , statusText : this . statusText , httpVersion : this . httpVersion , headers : this . headers , redirectURL : this . redirectURL , headersSize : this . headersSize , bodySize : this . bodySize , _transferSize : this . _transferSize , cookies : this . cookies , content : this . content , } ; } } export class Entry { requestId : string ; frameId : string ; loaderId : string ; startedDateTime : Date ; time : number ; type : string ; request : EntryRequest ; response : EntryResponse ; cache : { } ; timings : { blocked : number ; dns : number ; ssl : number ; connect : number ; send : number ; wait : number ; receive : number ; _blocked_queueing : number ; } ; serverIPAddress : string ; connection : string ; pageref : string ; constructor ( attrs = { } ) { this . request = new EntryRequest ( ) ; this . response = new EntryResponse ( ) ; Object . assign ( this , attrs ) ; } public toJSON ( ) { return { requestId : this . requestId , startedDateTime : this . startedDateTime , time : this . time , type : this . type , request : this . request . toJSON ( ) , response : this . response . toJSON ( ) , cache : this . cache , timings : this . timings , serverIPAddress : this . serverIPAddress , connection : this . connection , pageref : this . pageref , } ; } } export class Page { _epoch : number ; startedDateTime : Date ; id : string ; title : string ; pageTimings : { onContentLoad : number ; onLoad : number ; } ; public toJSON ( ) { return { startedDateTime : this . startedDateTime , id : this . id , title : this . title , pageTimings : this . pageTimings , } ; } }