123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- import type { HtmlProps } from './html-context';
- import type { ComponentType } from 'react';
- import type { DomainLocale } from '../../server/config';
- import type { Env } from '@next/env';
- import type { IncomingMessage, ServerResponse } from 'http';
- import type { NextRouter } from './router/router';
- import type { ParsedUrlQuery } from 'querystring';
- import type { PreviewData } from 'next/types';
- import { COMPILER_NAMES } from './constants';
- export declare type NextComponentType<C extends BaseContext = NextPageContext, IP = {}, P = {}> = ComponentType<P> & {
-
- getInitialProps?(context: C): IP | Promise<IP>;
- };
- export declare type DocumentType = NextComponentType<DocumentContext, DocumentInitialProps, DocumentProps>;
- export declare type AppType<P = {}> = NextComponentType<AppContextType, P, AppPropsType<any, P>>;
- export declare type AppTreeType = ComponentType<AppInitialProps & {
- [name: string]: any;
- }>;
- export declare type NextWebVitalsMetric = {
- id: string;
- startTime: number;
- value: number;
- } & ({
- label: 'web-vital';
- name: 'FCP' | 'LCP' | 'CLS' | 'FID' | 'TTFB' | 'INP';
- } | {
- label: 'custom';
- name: 'Next.js-hydration' | 'Next.js-route-change-to-render' | 'Next.js-render';
- });
- export declare type Enhancer<C> = (Component: C) => C;
- export declare type ComponentsEnhancer = {
- enhanceApp?: Enhancer<AppType>;
- enhanceComponent?: Enhancer<NextComponentType>;
- } | Enhancer<NextComponentType>;
- export declare type RenderPageResult = {
- html: string;
- head?: Array<JSX.Element | null>;
- };
- export declare type RenderPage = (options?: ComponentsEnhancer) => DocumentInitialProps | Promise<DocumentInitialProps>;
- export declare type BaseContext = {
- res?: ServerResponse;
- [k: string]: any;
- };
- export declare type NEXT_DATA = {
- props: Record<string, any>;
- page: string;
- query: ParsedUrlQuery;
- buildId: string;
- assetPrefix?: string;
- runtimeConfig?: {
- [key: string]: any;
- };
- nextExport?: boolean;
- autoExport?: boolean;
- isFallback?: boolean;
- dynamicIds?: (string | number)[];
- err?: Error & {
- statusCode?: number;
- source?: typeof COMPILER_NAMES.server | typeof COMPILER_NAMES.edgeServer;
- };
- gsp?: boolean;
- gssp?: boolean;
- customServer?: boolean;
- gip?: boolean;
- appGip?: boolean;
- locale?: string;
- locales?: string[];
- defaultLocale?: string;
- domainLocales?: DomainLocale[];
- scriptLoader?: any[];
- isPreview?: boolean;
- notFoundSrcPage?: string;
- };
- export interface NextPageContext {
-
- err?: (Error & {
- statusCode?: number;
- }) | null;
-
- req?: IncomingMessage;
-
- res?: ServerResponse;
-
- pathname: string;
-
- query: ParsedUrlQuery;
-
- asPath?: string;
-
- locale?: string;
-
- locales?: string[];
-
- defaultLocale?: string;
-
- AppTree: AppTreeType;
- }
- export declare type AppContextType<R extends NextRouter = NextRouter> = {
- Component: NextComponentType<NextPageContext>;
- AppTree: AppTreeType;
- ctx: NextPageContext;
- router: R;
- };
- export declare type AppInitialProps<P = any> = {
- pageProps: P;
- };
- export declare type AppPropsType<R extends NextRouter = NextRouter, P = {}> = AppInitialProps<P> & {
- Component: NextComponentType<NextPageContext, any, any>;
- router: R;
- __N_SSG?: boolean;
- __N_SSP?: boolean;
- };
- export declare type DocumentContext = NextPageContext & {
- renderPage: RenderPage;
- defaultGetInitialProps(ctx: DocumentContext, options?: {
- nonce?: string;
- }): Promise<DocumentInitialProps>;
- };
- export declare type DocumentInitialProps = RenderPageResult & {
- styles?: React.ReactElement[] | React.ReactFragment | JSX.Element;
- };
- export declare type DocumentProps = DocumentInitialProps & HtmlProps;
- export interface NextApiRequest extends IncomingMessage {
-
- query: Partial<{
- [key: string]: string | string[];
- }>;
-
- cookies: Partial<{
- [key: string]: string;
- }>;
- body: any;
- env: Env;
- preview?: boolean;
-
- previewData?: PreviewData;
- }
- declare type Send<T> = (body: T) => void;
- export declare type NextApiResponse<T = any> = ServerResponse & {
-
- send: Send<T>;
-
- json: Send<T>;
- status: (statusCode: number) => NextApiResponse<T>;
- redirect(url: string): NextApiResponse<T>;
- redirect(status: number, url: string): NextApiResponse<T>;
-
- setPreviewData: (data: object | string, options?: {
-
- maxAge?: number;
-
- path?: string;
- }) => NextApiResponse<T>;
-
- clearPreviewData: (options?: {
- path?: string;
- }) => NextApiResponse<T>;
-
- unstable_revalidate: () => void;
- revalidate: (urlPath: string, opts?: {
- unstable_onlyGenerated?: boolean;
- }) => Promise<void>;
- };
- export declare type NextApiHandler<T = any> = (req: NextApiRequest, res: NextApiResponse<T>) => unknown | Promise<unknown>;
- export declare function execOnce<T extends (...args: any[]) => ReturnType<T>>(fn: T): T;
- export declare const isAbsoluteUrl: (url: string) => boolean;
- export declare function getLocationOrigin(): string;
- export declare function getURL(): string;
- export declare function getDisplayName<P>(Component: ComponentType<P>): string;
- export declare function isResSent(res: ServerResponse): boolean;
- export declare function normalizeRepeatedSlashes(url: string): string;
- export declare function loadGetInitialProps<C extends BaseContext, IP = {}, P = {}>(App: NextComponentType<C, IP, P>, ctx: C): Promise<IP>;
- declare let warnOnce: (_: string) => void;
- export { warnOnce };
- export declare const SP: boolean;
- export declare const ST: boolean;
- export declare class DecodeError extends Error {
- }
- export declare class NormalizeError extends Error {
- }
- export declare class PageNotFoundError extends Error {
- code: string;
- constructor(page: string);
- }
- export declare class MissingStaticPage extends Error {
- constructor(page: string, message: string);
- }
- export declare class MiddlewareNotFoundError extends Error {
- code: string;
- constructor();
- }
- export interface CacheFs {
- readFile(f: string): Promise<string>;
- readFileSync(f: string): string;
- writeFile(f: string, d: any): Promise<void>;
- mkdir(dir: string): Promise<void | string>;
- stat(f: string): Promise<{
- mtime: Date;
- }>;
- }
|