import { type RouteEntry } from "./manifest.js"; /** Minimal app surface the driver needs - just a fetch handler (a built `createWebApp`). */ export interface PrerenderApp { fetch(req: Request): Response | Promise; } export interface PrerenderOptions { /** The built web app (a `createWebApp` result). A synthetic `GET ` is issued per * prerenderable route; its drained response body is written to disk. */ readonly app: PrerenderApp; /** The route manifest's `routes`. Only **static** routes whose module exports `prerender === true` * are emitted; everything else is recorded in {@link PrerenderResult.skipped} with a reason. */ readonly routes: readonly RouteEntry[]; /** Absolute output directory. `/index.html` is written under it (`/` → `index.html`). */ readonly outDir: string; /** Origin for the synthetic request URL. Default `http://localhost`. Only the path is meaningful; * loaders see this as `request.url`, so set it if a loader builds absolute URLs from the origin. */ readonly origin?: string; } export interface PrerenderEntry { /** The route pattern that was prerendered (e.g. `/`, `/about`). */ readonly path: string; /** The written file, relative to `outDir` (e.g. `index.html`, `about/index.html`). */ readonly file: string; /** Byte length of the written HTML. */ readonly bytes: number; /** The loader-data file written alongside (`/_data.json`) so a client soft-nav INTO this * route skips the worker. Absent when the data-mode response is NDJSON (a deferred loader). */ readonly dataFile?: string; } export interface PrerenderResult { readonly prerendered: readonly PrerenderEntry[]; readonly skipped: readonly { readonly path: string; readonly reason: string; }[]; /** Per dynamic route pattern, its `getStaticPaths` `fallback` (`"ssr"` default) - so the deploy * layer knows whether unlisted paths should hit the worker (`"ssr"`) or 404 (`"404"`). */ readonly fallbacks: Readonly>; } /** Map a route path to its output file: `/` → `index.html`, `/a/b` → `a/b/index.html`. */ export declare function htmlFileFor(pattern: string): string; /** The static loader-data file next to a route's `index.html`: `/` → `_data.json`, `/a/b` → * `a/b/_data.json`. The client fetches it on soft-nav into a prerendered route (no worker). */ export declare function dataFileFor(pattern: string): string; /** * Render every opted-in static route to a static `index.html` under `outDir`. Run AFTER `buildClient` * (so the app references the hashed client entry). Returns a report of what was emitted vs skipped - * the caller can use `prerendered` to wire a hybrid deploy (e.g. exclude those paths from the SSR * worker so the CDN serves the static file). Never throws on a per-route miss: a non-OK response or a * non-opted/dynamic route is recorded in `skipped` and the build continues. */ export declare function prerenderRoutes(options: PrerenderOptions): Promise; /** A Cloudflare Pages `_routes.json` document. `exclude`d paths are served straight from the CDN (the * Function/worker is NOT invoked); everything else in `include` hits the worker. */ export interface CloudflarePagesRoutes { readonly version: 1; readonly include: readonly string[]; readonly exclude: readonly string[]; } export interface CloudflarePagesRoutesOptions { /** Prerendered request paths (e.g. `prerenderRoutes(...).prerendered.map(p => p.path)`, or the * build's `prerendered.json`). Each is excluded from the worker - plus its static `_data.json`. */ readonly prerendered: readonly string[]; /** Extra globs to keep OFF the worker (CDN-served). Default `["/assets/*"]` (the hashed bundle). */ readonly staticGlobs?: readonly string[]; } /** * Build a Cloudflare Pages `_routes.json` for a HYBRID SSG deploy: the prerendered HTML + their static * `_data.json` + the asset bundle are `exclude`d (CDN serves them directly), and everything else falls * through to the SSR `_worker.js`. Write the result to `dist/_routes.json`. * * ⚠️ Cloudflare caps `_routes.json` at **100** include+exclude rules total, and each prerendered path * costs 2 (the doc + its `_data.json`). For a large SSG site, exclude by **prefix glob** (e.g. * `/blog/*`) instead of listing every path - pass those via `staticGlobs` and a smaller `prerendered`. */ export declare function cloudflarePagesRoutes(options: CloudflarePagesRoutesOptions): CloudflarePagesRoutes; //# sourceMappingURL=prerender.d.ts.map