astro
Version:
Astro is a modern site builder with web best practices, performance, and DX front-of-mind.
35 lines (34 loc) • 1.72 kB
TypeScript
import type { RouteData, SSRManifest } from '../../types/public/internal.js';
import { Router } from './router.js';
export interface RouteTable {
/** Route data derived from the manifest, used for route matching. */
routes: RouteData[];
/** Pattern-matching router compiled from `routes`. */
router: Router;
}
/**
* The route table for a manifest: the derived route list (with the default
* 404 ensured) and the compiled router. All route reads — matching, rewrites,
* custom-404 fallbacks, `manifestData` accessors — go through this single
* entry so dev HMR updates are visible to every consumer at once.
*/
export declare function getRouteTable(manifest: SSRManifest): RouteTable;
/**
* Atomically replaces the route table for a manifest (dev `astro:routes-updated`).
* Runs `ensure404Route` on the new list, compiles a fresh `Router`, and swaps
* the memo entry in one step, so no consumer can observe a half-updated table.
*/
export declare function updateRouteTable(manifest: SSRManifest, routes: RouteData[]): void;
/**
* Low-level route matching against the manifest routes. Returns the matched
* `RouteData` or `undefined`. Does not filter prerendered routes or check
* public assets — use the app-level match for that.
*/
export declare function matchRoute(manifest: SSRManifest, pathname: string): RouteData | undefined;
/**
* Returns all routes matching the given pathname, in priority order. Used when
* the first match cannot serve the request (e.g. a prerendered dynamic route
* that doesn't cover this specific path) and the caller needs to try
* subsequent matches.
*/
export declare function matchAllRoutes(manifest: SSRManifest, pathname: string): RouteData[];