1 |
|
2 | import { IncomingMessage, ServerResponse } from 'http';
|
3 | import { ParsedUrlQuery } from 'querystring';
|
4 | import { ComponentType } from 'react';
|
5 | import { UrlObject } from 'url';
|
6 | import { NextRouter } from './router/router';
|
7 | import { Env } from '@next/env';
|
8 | import { BuildManifest } from '../server/get-page-files';
|
9 | import { DomainLocales } from '../server/config';
|
10 | import { PreviewData } from 'next/types';
|
11 |
|
12 |
|
13 |
|
14 | export declare type NextComponentType<C extends BaseContext = NextPageContext, IP = {}, P = {}> = ComponentType<P> & {
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 | getInitialProps?(context: C): IP | Promise<IP>;
|
21 | };
|
22 | export declare type DocumentType = NextComponentType<DocumentContext, DocumentInitialProps, DocumentProps> & {
|
23 | renderDocument(Document: DocumentType, props: DocumentProps): React.ReactElement;
|
24 | };
|
25 | export declare type AppType = NextComponentType<AppContextType, AppInitialProps, AppPropsType>;
|
26 | export declare type AppTreeType = ComponentType<AppInitialProps & {
|
27 | [name: string]: any;
|
28 | }>;
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export declare type NextWebVitalsMetric = {
|
34 | id: string;
|
35 | label: string;
|
36 | name: string;
|
37 | startTime: number;
|
38 | value: number;
|
39 | };
|
40 | export declare type Enhancer<C> = (Component: C) => C;
|
41 | export declare type ComponentsEnhancer = {
|
42 | enhanceApp?: Enhancer<AppType>;
|
43 | enhanceComponent?: Enhancer<NextComponentType>;
|
44 | } | Enhancer<NextComponentType>;
|
45 | export declare type RenderPageResult = {
|
46 | html: string;
|
47 | head?: Array<JSX.Element | null>;
|
48 | };
|
49 | export declare type RenderPage = (options?: ComponentsEnhancer) => RenderPageResult | Promise<RenderPageResult>;
|
50 | export declare type BaseContext = {
|
51 | res?: ServerResponse;
|
52 | [k: string]: any;
|
53 | };
|
54 | export declare type NEXT_DATA = {
|
55 | props: Record<string, any>;
|
56 | page: string;
|
57 | query: ParsedUrlQuery;
|
58 | buildId: string;
|
59 | assetPrefix?: string;
|
60 | runtimeConfig?: {
|
61 | [key: string]: any;
|
62 | };
|
63 | nextExport?: boolean;
|
64 | autoExport?: boolean;
|
65 | isFallback?: boolean;
|
66 | dynamicIds?: (string | number)[];
|
67 | err?: Error & {
|
68 | statusCode?: number;
|
69 | };
|
70 | gsp?: boolean;
|
71 | gssp?: boolean;
|
72 | customServer?: boolean;
|
73 | gip?: boolean;
|
74 | appGip?: boolean;
|
75 | locale?: string;
|
76 | locales?: string[];
|
77 | defaultLocale?: string;
|
78 | domainLocales?: DomainLocales;
|
79 | scriptLoader?: any[];
|
80 | isPreview?: boolean;
|
81 | };
|
82 |
|
83 |
|
84 |
|
85 | export interface NextPageContext {
|
86 | |
87 |
|
88 |
|
89 | err?: (Error & {
|
90 | statusCode?: number;
|
91 | }) | null;
|
92 | |
93 |
|
94 |
|
95 | req?: IncomingMessage;
|
96 | |
97 |
|
98 |
|
99 | res?: ServerResponse;
|
100 | |
101 |
|
102 |
|
103 | pathname: string;
|
104 | |
105 |
|
106 |
|
107 | query: ParsedUrlQuery;
|
108 | |
109 |
|
110 |
|
111 | asPath?: string;
|
112 | |
113 |
|
114 |
|
115 | locale?: string;
|
116 | |
117 |
|
118 |
|
119 | locales?: string[];
|
120 | |
121 |
|
122 |
|
123 | defaultLocale?: string;
|
124 | |
125 |
|
126 |
|
127 | AppTree: AppTreeType;
|
128 | }
|
129 | export declare type AppContextType<R extends NextRouter = NextRouter> = {
|
130 | Component: NextComponentType<NextPageContext>;
|
131 | AppTree: AppTreeType;
|
132 | ctx: NextPageContext;
|
133 | router: R;
|
134 | };
|
135 | export declare type AppInitialProps = {
|
136 | pageProps: any;
|
137 | };
|
138 | export declare type AppPropsType<R extends NextRouter = NextRouter, P = {}> = AppInitialProps & {
|
139 | Component: NextComponentType<NextPageContext, any, P>;
|
140 | router: R;
|
141 | __N_SSG?: boolean;
|
142 | __N_SSP?: boolean;
|
143 | };
|
144 | export declare type DocumentContext = NextPageContext & {
|
145 | renderPage: RenderPage;
|
146 | };
|
147 | export declare type DocumentInitialProps = RenderPageResult & {
|
148 | styles?: React.ReactElement[] | React.ReactFragment;
|
149 | };
|
150 | export declare type DocumentProps = DocumentInitialProps & {
|
151 | __NEXT_DATA__: NEXT_DATA;
|
152 | dangerousAsPath: string;
|
153 | docComponentsRendered: {
|
154 | Html?: boolean;
|
155 | Main?: boolean;
|
156 | Head?: boolean;
|
157 | NextScript?: boolean;
|
158 | };
|
159 | buildManifest: BuildManifest;
|
160 | ampPath: string;
|
161 | inAmpMode: boolean;
|
162 | hybridAmp: boolean;
|
163 | isDevelopment: boolean;
|
164 | dynamicImports: string[];
|
165 | assetPrefix?: string;
|
166 | canonicalBase: string;
|
167 | headTags: any[];
|
168 | unstable_runtimeJS?: false;
|
169 | unstable_JsPreload?: false;
|
170 | devOnlyCacheBusterQueryString: string;
|
171 | scriptLoader: {
|
172 | afterInteractive?: string[];
|
173 | beforeInteractive?: any[];
|
174 | };
|
175 | locale?: string;
|
176 | disableOptimizedLoading?: boolean;
|
177 | };
|
178 |
|
179 |
|
180 |
|
181 | export interface NextApiRequest extends IncomingMessage {
|
182 | |
183 |
|
184 |
|
185 | query: {
|
186 | [key: string]: string | string[];
|
187 | };
|
188 | |
189 |
|
190 |
|
191 | cookies: {
|
192 | [key: string]: string;
|
193 | };
|
194 | body: any;
|
195 | env: Env;
|
196 | preview?: boolean;
|
197 | |
198 |
|
199 |
|
200 | previewData?: PreviewData;
|
201 | }
|
202 |
|
203 |
|
204 |
|
205 | declare type Send<T> = (body: T) => void;
|
206 |
|
207 |
|
208 |
|
209 | export declare type NextApiResponse<T = any> = ServerResponse & {
|
210 | |
211 |
|
212 |
|
213 | send: Send<T>;
|
214 | |
215 |
|
216 |
|
217 | json: Send<T>;
|
218 | status: (statusCode: number) => NextApiResponse<T>;
|
219 | redirect(url: string): NextApiResponse<T>;
|
220 | redirect(status: number, url: string): NextApiResponse<T>;
|
221 | |
222 |
|
223 |
|
224 | setPreviewData: (data: object | string, options?: {
|
225 | |
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | maxAge?: number;
|
232 | }) => NextApiResponse<T>;
|
233 | clearPreviewData: () => NextApiResponse<T>;
|
234 | };
|
235 |
|
236 |
|
237 |
|
238 | export declare type NextApiHandler<T = any> = (req: NextApiRequest, res: NextApiResponse<T>) => void | Promise<void>;
|
239 |
|
240 |
|
241 |
|
242 | export declare function execOnce<T extends (...args: any[]) => ReturnType<T>>(fn: T): T;
|
243 | export declare function getLocationOrigin(): string;
|
244 | export declare function getURL(): string;
|
245 | export declare function getDisplayName<P>(Component: ComponentType<P>): string;
|
246 | export declare function isResSent(res: ServerResponse): boolean;
|
247 | export declare function loadGetInitialProps<C extends BaseContext, IP = {}, P = {}>(App: NextComponentType<C, IP, P>, ctx: C): Promise<IP>;
|
248 | export declare const urlObjectKeys: string[];
|
249 | export declare function formatWithValidation(url: UrlObject): string;
|
250 | export declare const SP: boolean;
|
251 | export declare const ST: boolean;
|
252 | export {};
|