import * as React from "react"; import type { Render, BaseRender } from "./Render.js"; type ValidSnapshot = void | (object & { call?: never; }); /** only used for passing around data internally */ declare const _stackTrace: unique symbol; /** @internal */ export interface NextRenderOptions { timeout?: number; [_stackTrace]?: string; } /** @internal */ interface ProfilerProps { children: React.ReactNode; } /** @internal */ export interface Profiler extends React.FC, ProfiledComponentFields, ProfiledComponentOnlyFields { } interface ReplaceSnapshot { (newSnapshot: Snapshot): void; (updateSnapshot: (lastSnapshot: Readonly) => Snapshot): void; } interface MergeSnapshot { (partialSnapshot: Partial): void; (updatePartialSnapshot: (lastSnapshot: Readonly) => Partial): void; } interface ProfiledComponentOnlyFields { mergeSnapshot: MergeSnapshot; replaceSnapshot: ReplaceSnapshot; } interface ProfiledComponentFields { /** * An array of all renders that have happened so far. * Errors thrown during component render will be captured here, too. */ renders: Array | { phase: "snapshotError"; count: number; error: unknown; }>; /** * Peeks the next render from the current iterator position, without advancing the iterator. * If no render has happened yet, it will wait for the next render to happen. * @throws {WaitForRenderTimeoutError} if no render happens within the timeout */ peekRender(options?: NextRenderOptions): Promise>; /** * Iterates to the next render and returns it. * If no render has happened yet, it will wait for the next render to happen. * @throws {WaitForRenderTimeoutError} if no render happens within the timeout */ takeRender(options?: NextRenderOptions): Promise>; /** * Returns the total number of renders. */ totalRenderCount(): number; /** * Returns the current render. * @throws {Error} if no render has happened yet */ getCurrentRender(): Render; /** * Waits for the next render to happen. * Does not advance the render iterator. */ waitForNextRender(options?: NextRenderOptions): Promise>; } export interface ProfiledComponent extends React.FC, ProfiledComponentFields, ProfiledComponentOnlyFields { } /** @internal */ export declare function profile({ Component, ...options }: Parameters>[0] & { Component: React.ComponentType; }): ProfiledComponent; /** @internal */ export declare function createProfiler({ onRender, snapshotDOM, initialSnapshot, skipNonTrackingRenders, }?: { onRender?: (info: BaseRender & { snapshot: Snapshot; replaceSnapshot: ReplaceSnapshot; mergeSnapshot: MergeSnapshot; }) => void; snapshotDOM?: boolean; initialSnapshot?: Snapshot; /** * This will skip renders during which no renders tracked by * `useTrackRenders` occured. */ skipNonTrackingRenders?: boolean; }): Profiler; /** @internal */ export declare class WaitForRenderTimeoutError extends Error { constructor(); } type StringReplaceRenderWithSnapshot = T extends `${infer Pre}Render${infer Post}` ? `${Pre}Snapshot${Post}` : T; type ResultReplaceRenderWithSnapshot = T extends (...args: infer Args) => Render ? (...args: Args) => Snapshot : T extends (...args: infer Args) => Promise> ? (...args: Args) => Promise : T; type ProfiledHookFields = ProfiledComponentFields extends infer PC ? { [K in keyof PC as StringReplaceRenderWithSnapshot]: ResultReplaceRenderWithSnapshot; } : never; /** @internal */ export interface ProfiledHook extends React.FC, ProfiledHookFields { Profiler: Profiler; } /** @internal */ export declare function profileHook(renderCallback: (props: Props) => ReturnValue): ProfiledHook; export declare function useTrackRenders({ name }?: { name?: string; }): void; export {}; //# sourceMappingURL=profile.d.ts.map