import type { Context, MiddlewareHandler } from 'hono'; /** Hono variables used to collect Server-Timing metrics. */ export type Variables = { /** Operations that have started but not finished. */ activeTimings?: Active[] | undefined; /** State used to collapse overlapping samples of one logical operation. */ timingSums?: Map | undefined; /** Metrics emitted in the `Server-Timing` response header. */ serverTiming?: Metric[] | undefined; }; /** Hono environment shape used by timing helpers. */ export type Environment = { Variables: Variables; }; /** One Server-Timing metric. */ export type Metric = { /** Metric duration in milliseconds. */ duration: number; /** Metric name. */ name: string; }; /** One operation that has started but not finished. */ export type Active = { /** Metric name. */ name: string; /** Monotonic start time. */ start: number; }; /** Request-scoped state for one overlap-aware accumulated metric. */ export type Sum = { /** Number of currently overlapping samples. */ active: number; /** Start of the current uninterrupted interval. */ start: number; }; /** Timings started by an outer runtime before the Hono app receives a request. */ export type Seed = { /** Operations still running when request middleware begins. */ active?: readonly Active[] | undefined; /** Operations already completed before request middleware begins. */ metrics?: readonly Metric[] | undefined; }; /** Seeds timings collected by an outer runtime onto the same request object. */ export declare function seed(request: Request, value: Seed): void; /** Adds a `Server-Timing` header with total request duration. */ export declare function middleware(): MiddlewareHandler; /** Appends metrics to a response's `Server-Timing` header and returns it. */ export declare function append(response: Response, metrics: readonly Metric[]): Response; /** Measures one async operation and adds it to the current request timings. */ export declare function time(c: Context, name: string, fn: () => Promise | value): Promise; /** * Measures async work and accumulates its wall-clock union under one metric * name. Sequential samples add up while overlapping samples count only once, * keeping repeated page and parallel chain work bounded and latency-shaped. */ export declare function sum(c: Context, name: string, fn: () => Promise | value): Promise; //# sourceMappingURL=Timing.d.ts.map