import type { PerformanceEntry, PerformanceMark, PerformanceMeasure } from 'node:perf_hooks'; import type { TraceEvent, TraceEventContainer, TraceMetadata, TracingStartedInBrowserOptions } from './trace-file.type.js'; /** * Generates a unique ID for linking begin and end span events in Chrome traces. * @returns Object with local ID string for the id2 field */ export declare const nextId2: () => { local: string; }; /** * Generates a frame tree node ID from process and thread IDs. * @param pid - Process ID * @param tid - Thread ID * @returns Frame tree node ID as a number */ export declare const frameTreeNodeId: (pid: number, tid: number) => number; /** * Generates a frame name from process and thread IDs. * @param pid - Process ID * @param tid - Thread ID * @returns Frame name string in format FRAME0P{pid}T{tid} */ export declare const frameName: (pid: number, tid: number) => string; /** * Creates an instant trace event for marking a point in time. * @param name - Event name * @param ts - Optional timestamp in microseconds * @param opt - Optional event configuration * @returns Instant trace event (ph: 'I') */ export declare const instant: (name: string, ts?: number, opt?: Partial) => TraceEvent; /** * Creates a pair of begin and end span events. * @param name - Span name * @param tsB - Begin timestamp in microseconds * @param tsE - End timestamp in microseconds * @param opt - Optional event configuration * @param opt.tsMarkerPadding - Padding to apply to timestamps (default: 1) * @returns Array of [begin event, end event] */ export declare const span: (name: string, tsB: number, tsE: number, opt?: Partial & { tsMarkerPadding?: number; }) => TraceEvent[]; /** * Creates a start tracing event with frame information. * This event is needed at the beginning of the traceEvents array to make tell the UI profiling has started, and it should visualize the data. * @param opt - Tracing configuration options * @returns StartTracingEvent object */ export declare const getInstantEventTracingStartedInBrowser: (opt: TracingStartedInBrowserOptions) => TraceEvent; /** * Creates a complete trace event with duration. * @param name - Event name * @param dur - Duration in microseconds * @param opt - Optional event configuration * @returns Complete trace event (ph: 'X') */ export declare const complete: (name: string, dur: number, opt?: Partial) => TraceEvent; /** * Converts a PerformanceMark to an instant trace event. * @param entry - Performance mark entry * @param opt - Optional overrides for name, pid, and tid * @returns Instant trace event */ export declare const markToInstantEvent: (entry: PerformanceMark, opt?: { name?: string; pid?: number; tid?: number; }) => TraceEvent; /** * Converts a PerformanceMeasure to a pair of span events. * @param entry - Performance measure entry * @param opt - Optional overrides for name, pid, and tid * @returns Array of [begin event, end event] */ export declare const measureToSpanEvents: (entry: PerformanceMeasure, opt?: { name?: string; pid?: number; tid?: number; }) => TraceEvent[]; /** * Converts a PerformanceEntry to an array of trace events. * A mark is converted to an instant event, and a measure is converted to a pair of span events. * Other entry types are ignored. * @param entry - Performance entry * @returns Array of trace events */ export declare function entryToTraceEvents(entry: PerformanceEntry): TraceEvent[]; /** * Encodes a trace event by converting object details to JSON strings. * @param e - Trace event with potentially object details * @returns Trace event with string-encoded details */ export declare const encodeEvent: (e: TraceEvent) => TraceEvent; /** * Decodes a trace event by parsing JSON string details back to objects. * @param e - Trace event with potentially string-encoded details * @returns Trace event with decoded object details */ export declare const decodeEvent: (e: TraceEvent) => TraceEvent; /** * Serializes a trace event to a JSON string for storage. * First encodes the event structure (converting object details to JSON strings), * then stringifies the entire event. * @param event - Trace event to serialize * @returns JSON string representation of the encoded trace event */ export declare const serializeTraceEvent: (event: TraceEvent) => string; /** * Deserializes a JSON string back to a trace event. * First parses the JSON string, then decodes the event structure * (parsing JSON string details back to objects). * @param json - JSON string representation of a trace event * @returns Decoded trace event */ export declare const deserializeTraceEvent: (json: string) => TraceEvent; /** * Creates trace metadata object with standard DevTools fields and custom metadata. * @param startDate - Optional start date for the trace, defaults to current date * @param metadata - Optional additional metadata to merge into the trace metadata * @returns TraceMetadata object with source, startTime, and merged custom metadata */ export declare function getTraceMetadata({ startDate, ...metadata }?: Partial): TraceMetadata; /** * Creates a complete trace file container with metadata. * @param opt - Trace file configuration * @returns TraceEventContainer with events and metadata */ export declare const createTraceFile: (opt: { traceEvents: TraceEvent[]; metadata?: Partial; }) => TraceEventContainer;