| import type { IncomingMessage, ServerResponse } from 'http' |
| import type { |
| GetServerSideProps, |
| GetStaticPaths, |
| GetStaticProps, |
| NextComponentType, |
| PageConfig, |
| } from '../../../types' |
| import type { PagesRouteDefinition } from '../../route-definitions/pages-route-definition' |
| import type { NextParsedUrlQuery } from '../../request-meta' |
| import type { |
| PagesRenderContext, |
| PagesSharedContext, |
| RenderOpts, |
| } from '../../render' |
| import type RenderResult from '../../render-result' |
| import type { AppType, DocumentType } from '../../../shared/lib/utils' |
|
|
| import { |
| RouteModule, |
| type RouteModuleHandleContext, |
| type RouteModuleOptions, |
| } from '../route-module' |
| import { renderToHTMLImpl, renderToHTML } from '../../render' |
| import * as vendoredContexts from './vendored/contexts/entrypoints' |
|
|
| |
| |
| |
| |
| export type PagesModule = typeof import('../../../build/templates/pages') |
|
|
| |
| |
| |
| |
| |
| export type PagesUserlandModule = { |
| |
| |
| |
| readonly default: NextComponentType |
|
|
| |
| |
| |
| readonly config?: PageConfig |
|
|
| |
| |
| |
| readonly getStaticProps?: GetStaticProps |
|
|
| |
| |
| |
| readonly getStaticPaths?: GetStaticPaths |
|
|
| |
| |
| |
| readonly getServerSideProps?: GetServerSideProps |
| } |
|
|
| |
| |
| |
| |
| |
| type PagesComponents = { |
| |
| |
| |
| |
| readonly App: AppType |
|
|
| |
| |
| |
| |
| readonly Document: DocumentType |
| } |
|
|
| export interface PagesRouteModuleOptions |
| extends RouteModuleOptions<PagesRouteDefinition, PagesUserlandModule> { |
| readonly components: PagesComponents |
| } |
|
|
| |
| |
| |
| |
| export interface PagesRouteHandlerContext extends RouteModuleHandleContext { |
| |
| |
| |
| page: string |
|
|
| |
| |
| |
| query: NextParsedUrlQuery |
|
|
| |
| |
| |
| sharedContext: PagesSharedContext |
|
|
| |
| |
| |
| renderContext: PagesRenderContext |
|
|
| |
| |
| |
| |
| |
| |
| |
| renderOpts: Omit<RenderOpts, 'Document' | 'App'> |
| } |
|
|
| export class PagesRouteModule extends RouteModule< |
| PagesRouteDefinition, |
| PagesUserlandModule |
| > { |
| private readonly components: PagesComponents |
|
|
| constructor(options: PagesRouteModuleOptions) { |
| super(options) |
|
|
| this.components = options.components |
| } |
|
|
| public render( |
| req: IncomingMessage, |
| res: ServerResponse, |
| context: PagesRouteHandlerContext |
| ): Promise<RenderResult> { |
| return renderToHTMLImpl( |
| req, |
| res, |
| context.page, |
| context.query, |
| context.renderOpts, |
| { |
| App: this.components.App, |
| Document: this.components.Document, |
| }, |
| context.sharedContext, |
| context.renderContext |
| ) |
| } |
| } |
|
|
| const vendored = { |
| contexts: vendoredContexts, |
| } |
|
|
| |
| export { renderToHTML, vendored } |
|
|
| export default PagesRouteModule |
|
|