import type { EcoPagesAppConfig, IHmrManager } from '../../../types/internal-types.js'; import type { EcoBuildPlugin } from '../../../build/contracts/build-types.js'; import type { StaticRoute } from '../../../types/public-types.js'; import type { RouteRegistry } from '../../../router/server/route-registry.js'; import type { StaticSiteGenerator } from '../../../static-site-generator/static-site-generator.js'; import type { StaticGenerationRendererResolver } from '../../../route-renderer/route-renderer.js'; export interface StaticBuildOptions { baseUrl?: string; force?: boolean; } export interface ServeOptions { hostname?: string; port?: number | string; } export interface ServerStaticBuilderParams { appConfig: EcoPagesAppConfig; staticSiteGenerator: StaticSiteGenerator; serveOptions: ServeOptions; runtimeOrigin: string; /** * Whether the app requires a server entry bundle for production use. * When `true`, the build step bundles the server entry file for `ecopages start`. * Defaults to `false` (static-only build, no server needed). */ needsServerBundle?: boolean; logger?: ServerStaticBuilderLogger; entryFile?: string; hmrManager?: IHmrManager; onRuntimePlugin?: (plugin: EcoBuildPlugin) => void; } /** * Minimal logger dependency used by the static builder. */ export interface ServerStaticBuilderLogger { warn(message: string, detail?: string): unknown; info(message: string): unknown; debug(message: string): unknown; error(message: string): unknown; } /** * Handles static site generation. */ export declare class ServerStaticBuilder { private readonly appConfig; private readonly staticSiteGenerator; private readonly serveOptions; private readonly runtimeOrigin; private readonly needsServerBundle; private readonly logger; private readonly entryFile; private readonly hmrManager?; private readonly onRuntimePlugin?; constructor({ appConfig, staticSiteGenerator, serveOptions, runtimeOrigin, needsServerBundle, logger, entryFile, hmrManager, onRuntimePlugin, }: ServerStaticBuilderParams); private prepareExportDirectory; private refreshRuntimeAssets; /** * Bundles the server entry file for production use. * * @remarks * Only invoked when the app requires a runtime server (API handlers, * websocket handlers, etc.). Static-only apps skip this step entirely. * Incremental builds may skip Rolldown when the `.eco/.server-entry` * cache is still valid. * * Package imports remain external so native addons and runtime-owned * dependencies continue to load through the app's installed * `node_modules` tree. Only the app entry graph is bundled. * * Throws if the build adapter is unavailable, is owned by a host * runtime, or bundling fails. * * @throws If the build adapter is unavailable, is host-owned, or bundling fails. */ private bundleServerEntry; /** * Generates a static build of the site for deployment. * @param dependencies.router - The initialized router * @param dependencies.routeRendererFactory - The route renderer factory * @param dependencies.staticRoutes - Explicit static routes registered via app.static() */ build(options: StaticBuildOptions | undefined, dependencies: { router: RouteRegistry; routeRendererFactory: StaticGenerationRendererResolver; staticRoutes?: StaticRoute[]; }): Promise; }