app-render.d.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /// <reference types="node" />
  2. import type { IncomingMessage, ServerResponse } from 'http';
  3. import type { LoadComponentsReturnType } from './load-components';
  4. import type { ServerRuntime } from '../types';
  5. import React from 'react';
  6. import { NextParsedUrlQuery } from './request-meta';
  7. import RenderResult from './render-result';
  8. import { FlightCSSManifest, FlightManifest } from '../build/webpack/plugins/flight-manifest-plugin';
  9. export declare type RenderOptsPartial = {
  10. err?: Error | null;
  11. dev?: boolean;
  12. serverComponentManifest?: FlightManifest;
  13. serverCSSManifest?: FlightCSSManifest;
  14. supportsDynamicHTML?: boolean;
  15. runtime?: ServerRuntime;
  16. serverComponents?: boolean;
  17. assetPrefix?: string;
  18. };
  19. export declare type RenderOpts = LoadComponentsReturnType & RenderOptsPartial;
  20. export declare type DynamicParamTypesShort = 'c' | 'oc' | 'd';
  21. /**
  22. * Segment in the router state.
  23. */
  24. export declare type Segment = string | [param: string, value: string, type: DynamicParamTypesShort];
  25. /**
  26. * Router state
  27. */
  28. export declare type FlightRouterState = [
  29. segment: Segment,
  30. parallelRoutes: {
  31. [parallelRouterKey: string]: FlightRouterState;
  32. },
  33. url?: string,
  34. refresh?: 'refetch'
  35. ];
  36. /**
  37. * Individual Flight response path
  38. */
  39. export declare type FlightSegmentPath = any[] | [
  40. segment: Segment,
  41. parallelRouterKey: string,
  42. segment: Segment,
  43. parallelRouterKey: string,
  44. segment: Segment,
  45. parallelRouterKey: string
  46. ];
  47. export declare type FlightDataPath = any[] | [
  48. ...FlightSegmentPath,
  49. Segment,
  50. FlightRouterState,
  51. React.ReactNode | null
  52. ];
  53. /**
  54. * The Flight response data
  55. */
  56. export declare type FlightData = Array<FlightDataPath> | string;
  57. /**
  58. * Property holding the current subTreeData.
  59. */
  60. export declare type ChildProp = {
  61. /**
  62. * Null indicates that the tree is partial
  63. */
  64. current: React.ReactNode | null;
  65. segment: Segment;
  66. };
  67. export declare function renderToHTMLOrFlight(req: IncomingMessage, res: ServerResponse, pathname: string, query: NextParsedUrlQuery, renderOpts: RenderOpts, isPagesDir: boolean, isStaticGeneration?: boolean): Promise<RenderResult | null>;