import type { Entry } from "./types/HttpArchiveFormat.ts"; import { HarEntryBuilder } from "./HarEntryBuilder.ts"; import type { PopulatedOptions } from "./Options.ts"; import { type FrameId } from "./types/HttpArchiveFormat.ts"; import { TimeLord } from "./TimeLord.ts"; /** * This class is responsible for building the entries of a HAR by handling * Network events through its `onNetworkEvent` method and then returning * the entries via its `entries` getter. */ export declare class HarEntriesBuilder { #private; readonly options: PopulatedOptions; /** * The time lord turns timestamps into monotonically-increasing wall times * (whereas wall times on events are not guaranteed to be monotonically increasing). */ timelord: TimeLord; /** * All entries created are added to this list, regardless of whether we have enough * data about them to create a valid HAR entry. */ allEntryBuilders: HarEntryBuilder[]; /** * Track EntryBuilders by their frameId (to associate them with pages). */ entryBuildersByFrameId: Map; /** * Track EntryBuilders by their requestId so we can associate events * for the same request. * * Note that redirects have the same requestId, so when a redirect happens, * the EntryBuilder for the request to the original/prior URL will * be kicked out of this map and replaced by the request to the new * (redirected) URL, as subsequent events pertain to the redirected/new URL. */ entryBuildersByRequestId: Map; /** * For debugging and legacy purposes, we track the order in which we create entries * and assign each new one an creation-order index. */ harEntryCreationIndex: number; constructor(options: PopulatedOptions); /** * Computes a list of all EntryBuilders that are valid for inclusion in a HAR archive. * * This should only be called after all the events are collected, as it will be * computed only once and its results will be cached. */ getCompletedHarEntryBuilders: () => HarEntryBuilder[]; /** * Computes a list of all EntryBuilders that are valid for inclusion in a HAR archive * and then sorts them by their request time. * * This should only be called after all the events are collected, as it will be * computed only once and its results will be cached. */ getCompletedHarEntryBuildersSortedByRequestTime: () => HarEntryBuilder[]; /** * Retrieves all the HAR Entry records computed by the HAR Entry Builders. They are * sorted by request time. * * This should only be called after all the events are collected, as it will be * computed only once and its results will be cached. */ getCompletedHarEntries: () => Entry[]; /** * An array of HAR Entry records sorted by request time ready for inclusion into the * `entries` property of a HAR Log. * * This should only be accessed after all the events are collected, as it will be * computed only once and its results will be cached. */ get entries(): Entry[]; /** * Gets all the HAREntryBuilders that have timestamps and can be associated with pages, sorted by request time, * so that pages can find the first event associated with it and copy over their timestamp. * @param frameIds * @returns */ getHarEntriesBuildersForFrameIdsSortedByRequestSentTimeStamp: (...frameIds: FrameId[]) => HarEntryBuilder[]; /** * Handle a Chrome DevTools Protocol network event by * 1. fetching the entry associated with it's requestId, * or creating a new entry if one does not exist * 2. adding the event to the entry. * * Processing the event data itself will happen after all the * events have been collected. * * @param eventName The event name (e.g. "Network.requestWillBeSent") * @param untypedEvent The raw event dat provided by the Chrome DevTools * Protocol for the event type specified by eventName */ onNetworkEvent: (eventName: string, untypedEvent: unknown) => void; }