import type { AnchorHTMLAttributes, ComponentType, ReactNode, Ref } from "react"; /** History state the session UI writes and reads. */ export type NavigationHistoryState = { /** Set only on the Settings "Back to sessions" link that reopens this session. */ restoredSessionId?: string | undefined; [key: string]: unknown; }; export type NavigationLocation = Readonly<{ pathname: string; search: Record; searchStr: string; hash: string; href: string; state: NavigationHistoryState; }>; export type NavigationState = Readonly<{ location: NavigationLocation; }>; export type NavigationSearch = Record; export type NavigationParams = Record; /** A value, `(previous) => next`, or `true` to keep the current one. */ export type NavigationUpdater = true | T | ((previous: T) => T); export type NavigateOptions = { /** A route path such as `/workspaces/$workspaceId`, filled from `params`. */ to?: string | undefined; from?: string | undefined; params?: NavigationUpdater | undefined; search?: NavigationUpdater | undefined; hash?: NavigationUpdater | undefined; state?: NavigationUpdater | undefined; replace?: boolean | undefined; resetScroll?: boolean | undefined; ignoreBlocker?: boolean | undefined; reloadDocument?: boolean | undefined; href?: string | undefined; }; export type NavigateFunction = (options: NavigateOptions) => Promise; export type LinkProps = NavigateOptions & Omit, "href" | "children"> & { children?: ReactNode | ((state: { isActive: boolean; isTransitioning: boolean; }) => ReactNode) | undefined; preload?: false | "intent" | "viewport" | "render" | undefined; disabled?: boolean | undefined; /** When the link counts as the current page (`aria-current`); the router's default otherwise. */ activeOptions?: { exact?: boolean | undefined; includeSearch?: boolean | undefined; } | undefined; ref?: Ref | undefined; }; /** * The page around the session UI, for flows that leave it or return to it * (provider authorization, checkout, connect returns). The web app maps these * to `window.location` and `history`; an embed keeps the host page untouched. */ export type PageHost = Readonly<{ /** Absolute URL of the console page being shown. */ href: () => string; /** The console origin that app paths (`/workspaces/...`) resolve against. */ origin: () => string; /** The page's query, where authorization and connect returns land. */ readQuery: () => URLSearchParams; /** Replaces the page's query after handling a return, without a navigation. */ replaceQuery: (query: URLSearchParams, options?: { keepHistoryState?: boolean; }) => void; /** * Leaves for a URL: an external flow, or an app page outside the session UI. * An embed opens it beside the host page instead of replacing it. */ assign: (url: string, options?: { replace?: boolean; }) => void; /** * True when `assign` opens outside URLs beside the page rather than leaving * it (an embed), so a flow that leaves for checkout stays here and waits. */ opensBeside: boolean; /** Opens a URL beside the page (a file, an image, a provider page). */ open: (url: string) => void; /** * Opens an empty tab inside a click, for a URL known only after an await * (checkout, a freshly signed link). Null when the browser blocks it or the * host shows URLs its own way; the caller then leaves through `assign`. */ openTab: () => Window | null; }>; export type NavigationHost = Readonly<{ useNavigate: () => NavigateFunction; useLocation: () => NavigationLocation; useRouterState: (options: { select: (state: NavigationState) => T; }) => T; /** Live, non-reactive read for event handlers. */ useRouter: () => { readonly state: NavigationState; }; useSearch: (options: { strict: false; }) => NavigationSearch; Link: ComponentType; stringifySearch: (search: NavigationSearch) => string; page: PageHost; }>; /** * The browser window as the page: the default when nothing scopes another one, * and what a host that owns the URL (the web app) passes as its `page`. */ export declare const browserPage: PageHost; /** An empty new tab with no handle back to this page, or null when blocked. */ export declare function openBlankTab(): Window | null; export declare function useNavigate(): NavigateFunction; export declare function useLocation(): NavigationLocation; export declare function useRouterState(options: { select: (state: NavigationState) => T; }): T; export declare function useRouter(): { readonly state: NavigationState; }; export declare function useSearch(options: { strict: false; }): NavigationSearch; export declare function Link(props: LinkProps): import("react").JSX.Element; /** The page around the session UI; the browser window unless a host scopes another. */ export declare function usePage(): PageHost; /** The host's search serializer (`?a=1&b=%22x%22`), for hrefs built outside `Link`. */ export declare function useStringifySearch(): (search: NavigationSearch) => string;