import { type AnchorHTMLAttributes, type FormHTMLAttributes, type ReactNode } from "react"; import { type VextPageEnvelopeV1 } from "../contract/page-envelope.js"; type VextBodyInit = RequestInit["body"]; type VextHeadersInit = ConstructorParameters[0]; export type VextNavigationPhase = "idle" | "loading" | "submitting" | "revalidating" | "error" | "aborted"; export interface VextNavigationSnapshot { phase: VextNavigationPhase; sequence: number; url: string; method: string; error?: Error; } export interface VextNavigateOptions { replace?: boolean; preserveScroll?: boolean; input?: "keyboard" | "pointer" | "programmatic" | "popstate"; state?: unknown; } export interface VextPrefetchOptions { signal?: AbortSignal; intent?: "click" | "visible" | "explicit"; } export interface VextRevalidateTarget { routeId?: string; path?: string; tags?: string[]; keys?: string[]; } export interface VextSubmitOptions extends VextNavigateOptions { method?: string; body?: VextBodyInit | null; headers?: VextHeadersInit; } export interface VextFetcherSnapshot { phase: VextNavigationPhase; data?: T; error?: Error; } export interface VextFetcher extends VextFetcherSnapshot { load(url: string): Promise; submit(url: string, options?: VextSubmitOptions): Promise; } export interface VextBrowserRuntimeDiagnostics { snapshot: VextNavigationSnapshot; cacheKeys: string[]; inFlightKeys: string[]; hardFallbackCount: number; currentEnvelope?: VextPageEnvelopeV1; } export interface ConfigureVextBrowserRuntimeOptions { buildId: string; contractDigest: string; initialEnvelope?: VextPageEnvelopeV1; render(envelope: VextPageEnvelopeV1): void | Promise; environment?: VextBrowserEnvironment; } export interface VextBrowserEnvironment { fetch: typeof fetch; location: { href: string; origin: string; pathname: string; search: string; hash: string; assign(url: string): void; replace(url: string): void; }; history: { state: unknown; scrollRestoration?: string; pushState(data: unknown, unused: string, url?: string | URL | null): void; replaceState(data: unknown, unused: string, url?: string | URL | null): void; }; navigator?: { connection?: { saveData?: boolean; effectiveType?: string; }; }; document?: VextBrowserDocument; addEventListener?(type: string, listener: (event: any) => void): void; removeEventListener?(type: string, listener: (event: any) => void): void; requestAnimationFrame?(callback: () => void): unknown; scrollTo?(x: number, y: number): void; readonly scrollX?: number; readonly scrollY?: number; } interface VextBrowserDocument { title: string; documentElement?: { lang?: string; }; head?: { appendChild(node: unknown): void; }; body?: { appendChild(node: unknown): void; }; createElement?(name: string): any; getElementById?(id: string): any; querySelector?(selector: string): any; querySelectorAll?(selector: string): ArrayLike; } export declare class VextPageResultError extends Error { readonly name = "VextPageResultError"; readonly status: number; readonly code?: string | number; readonly requestId?: string; constructor(envelope: VextPageEnvelopeV1); } export declare class VextBrowserRuntime { private readonly options; private readonly environment; private readonly subscribers; private readonly cache; private readonly inFlight; private readonly fetchers; private readonly fetcherControllers; private readonly fetcherSequences; private snapshot; private currentEnvelope; private navigationController; private sequence; private hardFallbackCount; private hardFallbackStarted; private disposed; constructor(options: ConfigureVextBrowserRuntimeOptions); subscribe: (listener: () => void) => (() => void); getSnapshot: () => VextNavigationSnapshot; getRouteData(): T | undefined; getDiagnostics(): VextBrowserRuntimeDiagnostics; navigate(input: string | URL, options?: VextNavigateOptions): Promise; prefetch(input: string | URL, options?: VextPrefetchOptions): Promise; revalidate(target?: VextRevalidateTarget): Promise; submit(input: string | URL, options?: VextSubmitOptions): Promise; fetcherLoad(id: string, input: string | URL): Promise; fetcherSubmit(id: string, input: string | URL, options?: VextSubmitOptions): Promise; getFetcherSnapshot(id: string): VextFetcherSnapshot; dispose(): void; private runFetcher; private fetchEnvelope; private consumeEnvelope; private handleNavigationFailure; private abortActiveNavigation; private hardNavigate; private invalidate; private storeEnvelope; private createRequestKey; private currentPartition; private canPrefetch; private resolveUrl; private isHashOnlyNavigation; private commitHistory; private saveCurrentScroll; private bindHistory; private readonly onPopState; private restoreScrollAndFocus; private scrollToAnchor; private loadAssets; private ensureAnnouncementRegion; private announce; private afterPaint; private setSnapshot; private setFetcher; private emit; } export declare function configureVextBrowserRuntime(options: ConfigureVextBrowserRuntimeOptions): VextBrowserRuntime; export declare function navigate(url: string | URL, options?: VextNavigateOptions): Promise; export declare function prefetch(url: string | URL, options?: VextPrefetchOptions): Promise; export declare function revalidate(target?: VextRevalidateTarget): Promise; export interface VextLinkProps extends Omit, "href"> { href: string; prefetch?: "click" | "visible" | "none"; replace?: boolean; preserveScroll?: boolean; children?: ReactNode; } export declare function Link(props: VextLinkProps): ReactNode; export interface VextFormProps extends Omit, "action" | "method"> { action?: string; method?: string; navigate?: boolean; replace?: boolean; preserveScroll?: boolean; children?: ReactNode; } export declare function Form(props: VextFormProps): ReactNode; export declare function useNavigation(): VextNavigationSnapshot; export declare function useRouteData(): T | undefined; export declare function useFetcher(): VextFetcher; export {};