import type { ReactNode } from 'react'; export type CssAsset = { type: 'css'; href: string; } | { type: 'inline'; source: string; hmrId?: string; } | { type: 'external'; href: string; media?: string; }; /** * Asset manifest for client hydration bundles. * * {@link import('@expo/router-server/src/server/renderStreamingContent').GetStreamingContentOptions} */ export interface AssetInfo { /** * Ordered CSS assets; strings are legacy bundled stylesheet hrefs. * * String form is deprecated, with support removed in SDK 60 */ css: (CssAsset | string)[]; /** * External stylesheets from legacy manifests. * @deprecated To be removed in SDK 60 */ externalCss?: ExternalCssInfo[]; js: string[]; /** Public href of a favicon generated from `web.favicon` in the app config. */ favicon?: string; } /** * A single external stylesheet `` (e.g. from `@import url(https://...)`). * * @deprecated To be removed in SDK 60 */ export interface ExternalCssInfo { href: string; /** Media query baked into the `` tag, when present. */ media?: string; } export declare function normalizeCssAssets(assets?: AssetInfo): CssAsset[]; /** * Rendering configuration. Discriminated union supporting multiple rendering modes. */ export type RenderingConfiguration = RenderingConfigurationForSSR; /** * Configuration for server-side rendering (SSR). HTML is rendered at runtime on each request. */ export interface RenderingConfigurationForSSR { mode: 'ssr'; /** Path to the SSR render module, typically `_expo/server/render.js` */ file: string; } export interface MiddlewareInfo { /** * Path to the module that contains the middleware function as a default export. * * @example _expo/functions/+middleware.js */ file: string; } export interface RouteInfo { file: string; page: string; /** * Regex for matching a path against the route. * The regex is normalized for named matchers so keys must be looked up against the `routeKeys` object to collect the original route param names. * Regex matching alone cannot accurately route to a file, the order in which routes are matched is equally important to ensure correct priority. */ namedRegex: TRegex; /** * Keys are route param names that have been normalized for a regex named-matcher, values are the original route param names. */ routeKeys: Record; /** Indicates that the route was generated and does not map to any file in the project's routes directory. */ generated?: boolean; /** Indicates that this is a redirect that should use 301 instead of 307 */ permanent?: boolean; /** If a redirect, which methods are allowed. Undefined represents all methods */ methods?: string[]; /** Path to the loader module for this route, typically `_expo/loaders/[ROUTE].js`. When present, the loader should be executed before rendering. */ loader?: string; /** Per-route async chunk assets. Merged with top-level `assets` at serve time. */ assets?: AssetInfo; } /** * A per-path header rule, applied to matching page responses only. * * For scalar headers, the order is headers already on the response (set by * `expo-server` or declared by the route itself), then matching rules, then * global `headers`. When multiple rules match a path, the rule declared last * in the `pageHeaders` array takes precedence. * * For array headers, always append. Values from `headers` come first, * then `pageHeaders`. */ export interface PageHeaderInfo { /** * Regex for matching the requested path against this rule. */ namedRegex: TRegex; /** * Headers to apply to matching responses. Scalar values are set unless the response already * carries the header; array values always append. */ headers: Record; } export interface RoutesManifest { /** Public server origin configured in the Expo Router config plugin. */ origin?: string; /** * Middleware function that runs before any route matching. * Only allowed at the root level and requires web.output: "server". */ middleware?: MiddlewareInfo; /** * Headers to be applied to all responses from the server. */ headers?: Record; /** * Headers to be applied to path-specific responses from the server. */ pageHeaders?: PageHeaderInfo[]; /** * Routes that are matched after HTML routes and invoke WinterCG-compliant functions. */ apiRoutes: RouteInfo[]; /** * Routes that return static HTML files for a given path. * These are only matched against requests with method `GET` and `HEAD`. */ htmlRoutes: RouteInfo[]; /** * List of routes that are matched last and return with status code 404. */ notFoundRoutes: RouteInfo[]; /** * List of routes that match second. Returns 301 and redirects to another path. */ redirects: RouteInfo[]; /** * Rewrites. After middleware has processed and regular routing resumes, these occur first. */ rewrites: RouteInfo[]; /** * CSS/JS assets. Used for client hydration in SSR mode. */ assets?: AssetInfo; /** * Rendering configuration. Determines how HTML is generated. * When present, HTML routes are rendered at runtime instead of being served from pre-rendered files. */ rendering?: RenderingConfiguration; /** * Set to `development` when the server was exported with `expo export --dev`. */ mode?: 'development'; } export type RawManifest = RoutesManifest; export type Manifest = RoutesManifest; export type Route = RouteInfo; /** The route the server matched for a request. */ export interface MatchedRoute { file: string; page: string; /** True for generated routes, such as the sitemap. */ generated?: boolean; } /** * Options of the legacy `getStaticContent()` renderer. * * @deprecated Use {@link GetStreamingContentOptions}. */ export interface GetStaticContentOptions { loader?: { data?: unknown; key: string; }; request?: Request; /** The route the server matched for the location. */ route: MatchedRoute; /** The params the server captured for `route`. */ params?: Record; assets?: AssetInfo; } /** * @type {import('@expo/router-server/src/server/renderStreamingContent').GetStreamingContentOptions} */ export interface GetStreamingContentOptions { loader?: { data?: unknown; key: string; }; metadata?: { headNodes: ReactNode[]; } | null; request?: Request; /** The route the server matched for the location. */ route: MatchedRoute; /** The params the server captured for `route`. */ params?: Record; assets?: AssetInfo; output?: 'static' | 'server'; hydrate?: boolean; }