import { ad as ReadonlyMiddlewareStore, ae as FarmMiddlewareConfig, af as MiddlewareModule, ag as MiddlewareConfig, ah as MiddlewareContext } from './client-plugins-IR4yJ6w3.js'; import { R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.js'; import { R as ResolvedFarmServerConfig } from './workflows-BantWytQ.js'; /** * Server-side middleware utilities for accessing middleware data in pages */ type MiddlewareStoreInput = Record | Map; /** * Internal: Run code with middleware data available * This is called by the server renderer */ declare function _runWithMiddlewareData(data: MiddlewareStoreInput, fn: () => T | Promise): Promise; /** Internal: Run code with server-only middleware context available. */ declare function _runWithMiddlewareContext(context: MiddlewareStoreInput, fn: () => T | Promise): Promise; /** * Get middleware data in a server component * No props needed - uses global storage! * * @example * ```tsx * import { getMiddlewareData } from 'farm/middleware'; * * export default function Page() { * const data = getMiddlewareData(); // ← No props needed! * const user = data.get('user'); * const demoInfo = data.get('demoInfo'); * * return
Welcome {user?.name}
; * } * ``` */ declare function getMiddlewareData = Record>(): Map; /** * Get a specific value from middleware data (synchronous) * Uses AsyncLocalStorage for request scoping - no props needed. * * @example * ```tsx * import { getMiddlewareValue } from 'farm/middleware'; * * export default function Page() { * const user = getMiddlewareValue('user'); // ← No props needed! * const stats = getMiddlewareValue('dashboardStats'); * * return
Welcome {user?.name}
; * } * ``` */ declare function getMiddlewareValue(key: string): T | undefined; /** * Read server-only values set by route middleware for the current request. * The returned store is available to the matched page, layouts, and nested * Server Components, but is never added to hydration props. */ declare function getMiddlewareContext = Record>(): ReadonlyMiddlewareStore; interface ProductionMiddlewareModuleEntry { path: string; filePath?: string; module: MiddlewareModule | Record; } interface ProductionMiddlewareRunnerOptions { config?: FarmMiddlewareConfig | null; modules?: ProductionMiddlewareModuleEntry[]; i18n?: ResolvedFarmI18nConfig; server?: Pick; } interface ProductionMiddlewareResult { request: Request; response: Response | null; data: Map; context: Map; headers: Headers; handled: boolean; } /** * Decide whether a middleware entry's `export const config` applies to a path. * * Exported so the standalone dev plugin matches exactly what the production * runner does instead of maintaining a parallel implementation. */ declare function matchesMiddlewareConfig(pathname: string, config: MiddlewareConfig, ctx: MiddlewareContext): { matched: boolean; params?: Record; }; declare function createProductionMiddlewareRunner(options?: ProductionMiddlewareRunnerOptions): (request: Request) => Promise; declare function applyProductionMiddlewareHeaders(response: Response, middlewareHeaders?: Headers | null): Response; export { _runWithMiddlewareContext as _, applyProductionMiddlewareHeaders as a, _runWithMiddlewareData as b, createProductionMiddlewareRunner as c, getMiddlewareData as d, getMiddlewareValue as e, getMiddlewareContext as g, matchesMiddlewareConfig as m };