///
import { ParsedUrlQuery } from 'querystring';
import { ComponentType } from 'react';
import { UrlObject } from 'url';
import { GoodPageCache, StyleSheetTuple } from '../../../client/page-loader';
import { DomainLocales } from '../../server/config';
import { MittEmitter } from '../mitt';
import { NextPageContext, NEXT_DATA } from '../utils';
declare global {
interface Window {
__NEXT_DATA__: NEXT_DATA;
}
}
interface RouteProperties {
shallow: boolean;
}
interface TransitionOptions {
shallow?: boolean;
locale?: string | false;
scroll?: boolean;
}
interface NextHistoryState {
url: string;
as: string;
options: TransitionOptions;
}
export declare function getDomainLocale(path: string, locale?: string | false, locales?: string[], domainLocales?: DomainLocales): string | false;
export declare function addLocale(path: string, locale?: string | false, defaultLocale?: string): string;
export declare function delLocale(path: string, locale?: string): string;
export declare function hasBasePath(path: string): boolean;
export declare function addBasePath(path: string): string;
export declare function delBasePath(path: string): string;
/**
* Detects whether a given url is routable by the Next.js router (browser only).
*/
export declare function isLocalURL(url: string): boolean;
declare type Url = UrlObject | string;
export declare function interpolateAs(route: string, asPathname: string, query: ParsedUrlQuery): {
params: string[];
result: string;
};
/**
* Resolves a given hyperlink with a certain router state (basePath not included).
* Preserves absolute urls.
*/
export declare function resolveHref(currentPath: string, href: Url, resolveAs?: boolean): string;
export declare type BaseRouter = {
route: string;
pathname: string;
query: ParsedUrlQuery;
asPath: string;
basePath: string;
locale?: string;
locales?: string[];
defaultLocale?: string;
domainLocales?: DomainLocales;
isLocaleDomain: boolean;
};
export declare type NextRouter = BaseRouter & Pick;
export declare type PrefetchOptions = {
priority?: boolean;
locale?: string | false;
};
export declare type PrivateRouteInfo = (Omit & {
initial: true;
}) | CompletePrivateRouteInfo;
export declare type CompletePrivateRouteInfo = {
Component: ComponentType;
styleSheets: StyleSheetTuple[];
__N_SSG?: boolean;
__N_SSP?: boolean;
props?: Record;
err?: Error;
error?: any;
};
export declare type AppProps = Pick & {
router: Router;
} & Record;
export declare type AppComponent = ComponentType;
declare type Subscription = (data: PrivateRouteInfo, App: AppComponent, resetScroll: {
x: number;
y: number;
} | null) => Promise;
declare type BeforePopStateCallback = (state: NextHistoryState) => boolean;
declare type ComponentLoadCancel = (() => void) | null;
declare type HistoryMethod = 'replaceState' | 'pushState';
export default class Router implements BaseRouter {
route: string;
pathname: string;
query: ParsedUrlQuery;
asPath: string;
basePath: string;
/**
* Map of all components loaded in `Router`
*/
components: {
[pathname: string]: PrivateRouteInfo;
};
sdc: {
[asPath: string]: object;
};
sdr: {
[asPath: string]: Promise