import type { HandlerContext } from "../../handlers/types.js"; import { type RendererAdapter } from "../../shared/renderer-factory.js"; import type { SSRFailureOutcome } from "../../../rendering/ssr-outcome.js"; import type { CacheRepository } from "../../../repositories/types.js"; import type { DependencyPinningSourceInput } from "../../../transforms/esm/package-registry.js"; import type { ApplicationIdentity } from "../../../security/application-auth/types.js"; import type { ResponseCookie } from "../../../data/types.js"; /** * Provides a renderer for a given handler context. * Extracted to allow dependency injection in tests. */ export interface RendererProvider { getRenderer(ctx: HandlerContext): Promise; } /** * Minimal interface for SSRService consumers (e.g., SSRHandler). * Allows dependency injection and mocking in tests. */ export interface SSRServiceLike { checkMemoryPressure(): MemoryStatus; renderPage(ctx: HandlerContext, options: SSRRenderOptions): Promise; createMemoryPressureResult(slug: string): SSRRenderResult; } export interface SSRRenderResult { status: number; html?: string; /** * Marks a complete HTML document produced solely by framework-owned error * templates. Application render output must leave this unset. */ htmlProvenance?: "framework"; stream?: ReadableStream; isStreaming: boolean; etag?: string; cacheStrategy: "no-cache" | "short"; /** * How the render ended, when it did not end in a page. * * Absent on success. Carried whole rather than flattened into status-plus- * flags so callers discriminate on `kind` instead of reconstructing the * decision the SSR Outcome module already made. */ failure?: SSRFailureOutcome; slug: string; /** Dependency snapshot identity rendered into this document. */ dependencyPinningCacheKey?: string; /** Validated application headers appended after framework-owned headers. */ headers?: Record; /** Distinct cookies emitted as separate Set-Cookie response fields. */ cookies?: ResponseCookie[]; } export interface SSRRenderOptions { request: Request; url: URL; slug: string; nonce: string; studioEmbed: boolean; projectId?: string; pageId?: string; noHmr: boolean; forceProductionScripts?: boolean; useNoCache: boolean; /** Immutable dependency snapshot selected at the HTTP request boundary. */ dependencyPinningCacheKey?: string; /** Immutable package map paired with dependencyPinningCacheKey. */ dependencyPinningDependencies?: Readonly>; /** Exact package source namespace paired with the immutable snapshot. */ dependencyPinningSource?: DependencyPinningSourceInput; /** Verified application identity admitted by the host-owned auth boundary. */ applicationIdentity?: ApplicationIdentity | null; } export interface MemoryStatus { shouldReject: boolean; heapUsedMB: number; heapLimitMB: number; heapUsedPercent: number; } export declare class SSRService implements SSRServiceLike { private readonly cacheRepo?; private readonly rendererProvider; constructor(options?: { cacheRepo?: CacheRepository; rendererProvider?: RendererProvider; }); checkMemoryPressure(): MemoryStatus; getRenderer(ctx: HandlerContext): Promise; renderPage(ctx: HandlerContext, options: SSRRenderOptions): Promise; private handleRenderError; createMemoryPressureResult(slug: string): SSRRenderResult; } //# sourceMappingURL=ssr.service.d.ts.map