import type { ReactNode } from 'react'; import type { Config } from '../config.js'; import type { ConfigPrd } from '../lib/config.js'; import type { PathSpec } from '../lib/utils/path.js'; type Elements = Record; type RenderRsc = (elements: Record, options?: Opts) => Promise; type RenderHtml = (elements: Elements, html: ReactNode, options: { rscPath: string; actionResult?: unknown; } & Opts) => Promise<{ body: ReadableStream & { allReady: Promise; }; headers: Record<'content-type', string>; }>; export type HandleRequest = (input: ({ type: 'component'; rscPath: string; rscParams: unknown; } | { type: 'function'; fn: (...args: unknown[]) => Promise; args: unknown[]; } | { type: 'action'; fn: () => Promise; pathname: string; } | { type: 'custom'; pathname: string; }) & { req: HandlerReq; }, utils: { renderRsc: RenderRsc; renderHtml: RenderHtml; }) => Promise; type BuildConfig = { type: 'file'; pathname: string; body: Promise; } | { type: 'htmlHead'; pathSpec: PathSpec; head?: string; } | { type: 'defaultHtml'; pathname: string; head?: string; }; export type HandleBuild = (utils: { renderRsc: RenderRsc<{ moduleIdCallback?: (id: string) => void; }>; renderHtml: RenderHtml<{ htmlHead?: string; }>; rscPath2pathname: (rscPath: string) => string; unstable_generatePrefetchCode: (rscPaths: Iterable, moduleIds: Iterable) => string; unstable_collectClientModules: (elements: Elements) => Promise; }) => AsyncIterable | null; export type EntriesDev = { default: { handleRequest: HandleRequest; handleBuild: HandleBuild; }; }; export type EntriesPrd = EntriesDev & { loadConfig: () => Promise; configPrd: ConfigPrd; loadModule: (id: string) => Promise; dynamicHtmlPaths: [pathSpec: PathSpec, htmlHead: string][]; publicIndexHtml: string; loadPlatformData?: (key: string) => Promise; }; export type HandlerReq = { body: ReadableStream | null; url: URL; method: string; headers: Readonly>; }; export type HandlerRes = { body?: ReadableStream; headers?: Record; status?: number; }; export {};