render.d.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. import type { IncomingMessage, ServerResponse } from 'http';
  4. import type { ParsedUrlQuery } from 'querystring';
  5. import type { DomainLocale } from './config';
  6. import type { ImageConfigComplete } from '../shared/lib/image-config';
  7. import type { __ApiPreviewProps } from './api-utils';
  8. import type { FontManifest, FontConfig } from './font-utils';
  9. import type { LoadComponentsReturnType } from './load-components';
  10. import type { ServerRuntime } from 'next/types';
  11. import React from 'react';
  12. import { NextParsedUrlQuery } from './request-meta';
  13. import RenderResult from './render-result';
  14. export declare type RenderOptsPartial = {
  15. buildId: string;
  16. canonicalBase: string;
  17. runtimeConfig?: {
  18. [key: string]: any;
  19. };
  20. assetPrefix?: string;
  21. err?: Error | null;
  22. nextExport?: boolean;
  23. dev?: boolean;
  24. ampPath?: string;
  25. ErrorDebug?: React.ComponentType<{
  26. error: Error;
  27. }>;
  28. ampValidator?: (html: string, pathname: string) => Promise<void>;
  29. ampSkipValidation?: boolean;
  30. ampOptimizerConfig?: {
  31. [key: string]: any;
  32. };
  33. isDataReq?: boolean;
  34. params?: ParsedUrlQuery;
  35. previewProps: __ApiPreviewProps;
  36. basePath: string;
  37. unstable_runtimeJS?: false;
  38. unstable_JsPreload?: false;
  39. optimizeFonts: FontConfig;
  40. fontManifest?: FontManifest;
  41. optimizeCss: any;
  42. nextScriptWorkers: any;
  43. devOnlyCacheBusterQueryString?: string;
  44. resolvedUrl?: string;
  45. resolvedAsPath?: string;
  46. serverComponentManifest?: any;
  47. serverCSSManifest?: any;
  48. distDir?: string;
  49. locale?: string;
  50. locales?: string[];
  51. defaultLocale?: string;
  52. domainLocales?: DomainLocale[];
  53. disableOptimizedLoading?: boolean;
  54. supportsDynamicHTML?: boolean;
  55. runtime?: ServerRuntime;
  56. serverComponents?: boolean;
  57. customServer?: boolean;
  58. crossOrigin?: string;
  59. images: ImageConfigComplete;
  60. largePageDataBytes?: number;
  61. };
  62. export declare type RenderOpts = LoadComponentsReturnType & RenderOptsPartial;
  63. export declare function renderToHTML(req: IncomingMessage, res: ServerResponse, pathname: string, query: NextParsedUrlQuery, renderOpts: RenderOpts): Promise<RenderResult | null>;